From 590fee9e8972f872301c2d16a575d579ee564bee Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Fri, 13 Sep 2013 13:46:47 -0700 Subject: Compacting collector. The compacting collector is currently similar to semispace. It works by copying objects back and forth between two bump pointer spaces. There are types of objects which are "non-movable" due to current runtime limitations. These are Classes, Methods, and Fields. Bump pointer spaces are a new type of continuous alloc space which have no lock in the allocation code path. When you allocate from these it uses atomic operations to increase an index. Traversing the objects in the bump pointer space relies on Object::SizeOf matching the allocated size exactly. Runtime changes: JNI::GetArrayElements returns copies objects if you attempt to get the backing data of a movable array. For GetArrayElementsCritical, we return direct backing storage for any types of arrays, but temporarily disable the GC until the critical region is completed. Added a new runtime call called VisitObjects, this is used in place of the old pattern which was flushing the allocation stack and walking the bitmaps. Changed image writer to be compaction safe and use object monitor word for forwarding addresses. Added a bunch of added SIRTs to ClassLinker, MethodLinker, etc.. TODO: Enable switching allocators, compacting on background, etc.. Bug: 8981901 Change-Id: I3c886fd322a6eef2b99388d19a765042ec26ab99 --- runtime/jni_internal_test.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'runtime/jni_internal_test.cc') diff --git a/runtime/jni_internal_test.cc b/runtime/jni_internal_test.cc index c389580ebf..26b18364cf 100644 --- a/runtime/jni_internal_test.cc +++ b/runtime/jni_internal_test.cc @@ -86,19 +86,19 @@ class JniInternalTest : public CommonTest { const char* class_name = is_static ? "StaticLeafMethods" : "NonStaticLeafMethods"; jobject jclass_loader(LoadDex(class_name)); Thread* self = Thread::Current(); + SirtRef null_class_loader(self, nullptr); SirtRef class_loader(self, ScopedObjectAccessUnchecked(self).Decode(jclass_loader)); if (is_static) { - CompileDirectMethod(class_loader.get(), class_name, method_name, method_signature); + CompileDirectMethod(class_loader, class_name, method_name, method_signature); } else { - CompileVirtualMethod(NULL, "java.lang.Class", "isFinalizable", "()Z"); - CompileDirectMethod(NULL, "java.lang.Object", "", "()V"); - CompileVirtualMethod(class_loader.get(), class_name, method_name, method_signature); + CompileVirtualMethod(null_class_loader, "java.lang.Class", "isFinalizable", "()Z"); + CompileDirectMethod(null_class_loader, "java.lang.Object", "", "()V"); + CompileVirtualMethod(class_loader, class_name, method_name, method_signature); } - mirror::Class* c = class_linker_->FindClass(DotToDescriptor(class_name).c_str(), - class_loader.get()); + mirror::Class* c = class_linker_->FindClass(DotToDescriptor(class_name).c_str(), class_loader); CHECK(c != NULL); method = is_static ? c->FindDirectMethod(method_name, method_signature) @@ -1081,7 +1081,6 @@ TEST_F(JniInternalTest, RegisterNatives) { EXPECT_EQ(memcmp(&src_buf[0], xs, size * sizeof(scalar_type)), 0) \ << # get_elements_fn " not equal"; \ env_->release_elements_fn(a, xs, 0); \ - EXPECT_EQ(reinterpret_cast(v), reinterpret_cast(xs)) TEST_F(JniInternalTest, BooleanArrays) { EXPECT_PRIMITIVE_ARRAY(NewBooleanArray, GetBooleanArrayRegion, SetBooleanArrayRegion, @@ -1337,7 +1336,7 @@ TEST_F(JniInternalTest, GetStringChars_ReleaseStringChars) { jboolean is_copy = JNI_FALSE; chars = env_->GetStringChars(s, &is_copy); - EXPECT_EQ(JNI_FALSE, is_copy); + EXPECT_EQ(JNI_TRUE, is_copy); EXPECT_EQ(expected[0], chars[0]); EXPECT_EQ(expected[1], chars[1]); EXPECT_EQ(expected[2], chars[2]); @@ -1361,7 +1360,8 @@ TEST_F(JniInternalTest, GetStringCritical_ReleaseStringCritical) { jboolean is_copy = JNI_FALSE; chars = env_->GetStringCritical(s, &is_copy); - EXPECT_EQ(JNI_FALSE, is_copy); + // TODO: Fix GetStringCritical to use the same mechanism as GetPrimitiveArrayElementsCritical. + EXPECT_EQ(JNI_TRUE, is_copy); EXPECT_EQ(expected[0], chars[0]); EXPECT_EQ(expected[1], chars[1]); EXPECT_EQ(expected[2], chars[2]); @@ -1669,9 +1669,9 @@ TEST_F(JniInternalTest, StaticMainMethod) { jobject jclass_loader = LoadDex("Main"); SirtRef class_loader(soa.Self(), soa.Decode(jclass_loader)); - CompileDirectMethod(class_loader.get(), "Main", "main", "([Ljava/lang/String;)V"); + CompileDirectMethod(class_loader, "Main", "main", "([Ljava/lang/String;)V"); - mirror::Class* klass = class_linker_->FindClass("LMain;", class_loader.get()); + mirror::Class* klass = class_linker_->FindClass("LMain;", class_loader); ASSERT_TRUE(klass != NULL); mirror::ArtMethod* method = klass->FindDirectMethod("main", "([Ljava/lang/String;)V"); -- cgit v1.2.3