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
diff --git a/build/Android.oattest.mk b/build/Android.oattest.mk
index 1957971..fe26a9b 100644
--- a/build/Android.oattest.mk
+++ b/build/Android.oattest.mk
@@ -81,7 +81,6 @@
# $(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 8577dcc..2908d58 100644
--- a/src/dex_verifier.cc
+++ b/src/dex_verifier.cc
@@ -5242,6 +5242,7 @@
#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 @@
delete map;
map = compress_map;
}
-
+#endif
return map;
}
diff --git a/src/thread.cc b/src/thread.cc
index c92eae4..dc08799 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -1584,6 +1584,9 @@
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 @@
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 @@
} 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 4cc4159..710031b 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";
}
}
}