diff options
| author | 2011-09-27 21:33:19 -0700 | |
|---|---|---|
| committer | 2011-09-28 15:47:56 -0700 | |
| commit | 4f894e385e8ac018f078be75fea0a45696626b15 (patch) | |
| tree | ce10f5891f700c6535091984c251730e8e50d02c | |
| parent | d1422f81bf9b35cb2aad3fb5615d3f5209014709 (diff) | |
Fix stack scanning bugs: Add PC OFFSET before retrieving Registermap.
GC passes for the MemUsage of 5 MB * 100.
Note that RegisterMap is uncompressed. Also add new GC test.
Change-Id: I7a7afc845d4582f8f2f3ba95e4716266ec46c635
| -rw-r--r-- | build/Android.oattest.mk | 3 | ||||
| -rw-r--r-- | src/dex_verifier.cc | 3 | ||||
| -rw-r--r-- | src/thread.cc | 16 | ||||
| -rw-r--r-- | test/MemUsage/MemUsage.java | 18 |
4 files changed, 23 insertions, 17 deletions
diff --git a/build/Android.oattest.mk b/build/Android.oattest.mk index 1957971f41..fe26a9bbeb 100644 --- a/build/Android.oattest.mk +++ b/build/Android.oattest.mk @@ -81,7 +81,6 @@ $(eval $(call declare-test-test-target,SystemMethods,)) # $(eval $(call declare-test-test-target,StackWalk,)) # $(eval $(call declare-test-test-target,StackWalk2,)) -# TODO: Re-enable this when RegisterMap is working for thread run. -# $(eval $(call declare-test-test-target,MemUsage,)) + $(eval $(call declare-test-test-target,MemUsage,)) ######################################################################## diff --git a/src/dex_verifier.cc b/src/dex_verifier.cc index 8577dccd9d..2908d580f3 100644 --- a/src/dex_verifier.cc +++ b/src/dex_verifier.cc @@ -5242,6 +5242,7 @@ DexVerifier::RegisterMap* DexVerifier::GenerateRegisterMapV(VerifierData* vdata) #endif /* Try to compress the map. */ +#if 0 RegisterMap* compress_map = CompressMapDifferential(map); if (compress_map != NULL) { // TODO: Remove this check when it's really running... @@ -5270,7 +5271,7 @@ DexVerifier::RegisterMap* DexVerifier::GenerateRegisterMapV(VerifierData* vdata) delete map; map = compress_map; } - +#endif return map; } diff --git a/src/thread.cc b/src/thread.cc index c92eae44a9..dc08799f22 100644 --- a/src/thread.cc +++ b/src/thread.cc @@ -1584,6 +1584,9 @@ bool Thread::IsDaemon() { return gThread_daemon->GetBoolean(peer_); } +// blx is 2-byte in Thumb2. Need to offset PC back to a call site. +static const int kThumb2InstSize = 2; + class ReferenceMapVisitor : public Thread::StackVisitor { public: ReferenceMapVisitor(Context* context, Heap::RootVisitor* root_visitor, void* arg) : @@ -1592,13 +1595,18 @@ class ReferenceMapVisitor : public Thread::StackVisitor { void VisitFrame(const Frame& frame, uintptr_t pc) { Method* m = frame.GetMethod(); - LOG(INFO) << "Visiting stack roots in " << PrettyMethod(m, false); // Process register map (which native and callee save methods don't have) if (!m->IsNative() && !m->IsPhony()) { UniquePtr<art::DexVerifier::RegisterMap> map(art::DexVerifier::GetExpandedRegisterMap(m)); - const uint8_t* reg_bitmap = art::DexVerifier::RegisterMapGetLine(map.get(), m->ToDexPC(pc)); + const uint8_t* reg_bitmap = art::DexVerifier::RegisterMapGetLine( + map.get(), + m->ToDexPC(pc -kThumb2InstSize)); + + LOG(INFO) << "Visiting stack roots in " << PrettyMethod(m, false) + << "@ PC: " << m->ToDexPC(pc - kThumb2InstSize); + CHECK(reg_bitmap != NULL); ShortArray* vmap = m->GetVMapTable(); // For all dex registers @@ -1632,7 +1640,9 @@ class ReferenceMapVisitor : public Thread::StackVisitor { } else { ref = reinterpret_cast<Object*>(frame.GetVReg(m ,reg)); } - root_visitor_(ref, arg_); + if (ref != NULL) { + root_visitor_(ref, arg_); + } } } } diff --git a/test/MemUsage/MemUsage.java b/test/MemUsage/MemUsage.java index 4cc4159cdc..710031bb20 100644 --- a/test/MemUsage/MemUsage.java +++ b/test/MemUsage/MemUsage.java @@ -1,18 +1,14 @@ - public class MemUsage { - public static final int NUM_1D_ARRAYS = 1000; - public static final int INCREMENT = 300; + public static final int ROUNDS = 8; + public static final int SIZE = 2000; public static void main(String [] args) { - int sz = 1000; - double[][] RelocationArray = new double[NUM_1D_ARRAYS][]; - while (true) { - for (int i = 0; i < NUM_1D_ARRAYS; i++) { - RelocationArray[i] = new double[sz]; - if (sz + INCREMENT > 0) { - sz += INCREMENT; - } + String s; + for (int j = 0; j < ROUNDS; j++) { + s = ""; + for (int i = 0; i < SIZE; i++) { + s += "x"; } } } |