OSDN Git Service

Fix stack scanning bugs: Add PC OFFSET before retrieving Registermap.
authorShih-wei Liao <sliao@google.com>
Wed, 28 Sep 2011 04:33:19 +0000 (21:33 -0700)
committerShih-wei Liao <sliao@google.com>
Wed, 28 Sep 2011 22:47:56 +0000 (15:47 -0700)
GC passes for the MemUsage of 5 MB * 100.
Note that RegisterMap is uncompressed. Also add new GC test.

Change-Id: I7a7afc845d4582f8f2f3ba95e4716266ec46c635

build/Android.oattest.mk
src/dex_verifier.cc
src/thread.cc
test/MemUsage/MemUsage.java

index 1957971..fe26a9b 100644 (file)
@@ -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,))
 
 ########################################################################
index 8577dcc..2908d58 100644 (file)
@@ -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;
 }
 
index c92eae4..dc08799 100644 (file)
@@ -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_);
+          }
         }
       }
     }
index 4cc4159..710031b 100644 (file)
@@ -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";
       }
     }
   }