diff options
author | 2019-02-20 11:27:52 +0000 | |
---|---|---|
committer | 2019-02-20 12:03:00 +0000 | |
commit | 2b076df33e508c04657427e4bd961d19f964e0ed (patch) | |
tree | 37c77f1f86400bf52b9f49cff9f40ba2de9122fe | |
parent | 038924b75f06b91c2a7e944196ca11f118ce182f (diff) |
Make jni_internal_test a CommonRuntimeTest.
Also clean up proxy_test and reflection_test.
Test: m test-art-host-gtest
Change-Id: I7530855a40d7b9f7214ea7a069508ae1361b2b42
-rw-r--r-- | runtime/Android.bp | 4 | ||||
-rw-r--r-- | runtime/common_runtime_test.cc | 7 | ||||
-rw-r--r-- | runtime/common_runtime_test.h | 3 | ||||
-rw-r--r-- | runtime/jni/jni_internal_test.cc | 23 | ||||
-rw-r--r-- | runtime/proxy_test.cc | 2 | ||||
-rw-r--r-- | runtime/reflection_test.cc | 42 |
6 files changed, 45 insertions, 36 deletions
diff --git a/runtime/Android.bp b/runtime/Android.bp index a08ba707c9..2170e95e63 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -618,6 +618,7 @@ art_cc_test { "jdwp/jdwp_options_test.cc", "jit/profiling_info_test.cc", "jni/java_vm_ext_test.cc", + "jni/jni_internal_test.cc", "method_handles_test.cc", "mirror/dex_cache_test.cc", "mirror/method_type_test.cc", @@ -629,6 +630,7 @@ art_cc_test { "oat_file_assistant_test.cc", "parsed_options_test.cc", "prebuilt_tools_test.cc", + "proxy_test.cc", "reference_table_test.cc", "runtime_callbacks_test.cc", "subtype_check_info_test.cc", @@ -656,8 +658,6 @@ art_cc_test { "art_gtest_defaults", ], srcs: [ - "jni/jni_internal_test.cc", - "proxy_test.cc", "reflection_test.cc", ], shared_libs: [ diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc index a20baa0dc4..ca410d9ba9 100644 --- a/runtime/common_runtime_test.cc +++ b/runtime/common_runtime_test.cc @@ -385,6 +385,13 @@ void CommonRuntimeTestImpl::SetUpRuntimeOptionsForFillHeap(RuntimeOptions *optio } } +void CommonRuntimeTestImpl::MakeInterpreted(ObjPtr<mirror::Class> klass) { + PointerSize pointer_size = class_linker_->GetImagePointerSize(); + for (ArtMethod& method : klass->GetMethods(pointer_size)) { + class_linker_->SetEntryPointsToInterpreter(&method); + } +} + bool CommonRuntimeTestImpl::StartDex2OatCommandLine(/*out*/std::vector<std::string>* argv, /*out*/std::string* error_msg) { DCHECK(argv != nullptr); diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h index d7f6127ccb..ab90fc5444 100644 --- a/runtime/common_runtime_test.h +++ b/runtime/common_runtime_test.h @@ -97,6 +97,9 @@ class CommonRuntimeTestImpl : public CommonArtTestImpl { return true; } + void MakeInterpreted(ObjPtr<mirror::Class> klass) + REQUIRES_SHARED(Locks::mutator_lock_); + static bool StartDex2OatCommandLine(/*out*/std::vector<std::string>* argv, /*out*/std::string* error_msg); diff --git a/runtime/jni/jni_internal_test.cc b/runtime/jni/jni_internal_test.cc index 57346b7f78..a4b3801de7 100644 --- a/runtime/jni/jni_internal_test.cc +++ b/runtime/jni/jni_internal_test.cc @@ -19,7 +19,7 @@ #include "android-base/stringprintf.h" #include "art_method-inl.h" -#include "common_compiler_test.h" +#include "common_runtime_test.h" #include "indirect_reference_table.h" #include "java_vm_ext.h" #include "jni_env_ext.h" @@ -31,11 +31,10 @@ namespace art { using android::base::StringPrintf; -// TODO: Convert to CommonRuntimeTest. Currently MakeExecutable is used. -class JniInternalTest : public CommonCompilerTest { +class JniInternalTest : public CommonRuntimeTest { protected: void SetUp() override { - CommonCompilerTest::SetUp(); + CommonRuntimeTest::SetUp(); vm_ = Runtime::Current()->GetJavaVM(); @@ -86,7 +85,7 @@ class JniInternalTest : public CommonCompilerTest { void TearDown() override { CleanUpJniEnv(); - CommonCompilerTest::TearDown(); + CommonRuntimeTest::TearDown(); } jclass GetPrimitiveClass(char descriptor) { @@ -2265,13 +2264,13 @@ TEST_F(JniInternalTest, NewDirectBuffer_GetDirectBufferAddress_GetDirectBufferCa // Start runtime. Thread* self = Thread::Current(); self->TransitionFromSuspendedToRunnable(); - MakeExecutable(nullptr, "java.lang.Class"); - MakeExecutable(nullptr, "java.lang.Object"); - MakeExecutable(nullptr, "java.nio.DirectByteBuffer"); - MakeExecutable(nullptr, "java.nio.Bits"); - MakeExecutable(nullptr, "java.nio.MappedByteBuffer"); - MakeExecutable(nullptr, "java.nio.ByteBuffer"); - MakeExecutable(nullptr, "java.nio.Buffer"); + MakeInterpreted(class_linker_->FindSystemClass(self, "Ljava/lang/Class;")); + MakeInterpreted(class_linker_->FindSystemClass(self, "Ljava/lang/Object;")); + MakeInterpreted(class_linker_->FindSystemClass(self, "Ljava/nio/DirectByteBuffer;")); + MakeInterpreted(class_linker_->FindSystemClass(self, "Ljava/nio/Bits;")); + MakeInterpreted(class_linker_->FindSystemClass(self, "Ljava/nio/MappedByteBuffer;")); + MakeInterpreted(class_linker_->FindSystemClass(self, "Ljava/nio/ByteBuffer;")); + MakeInterpreted(class_linker_->FindSystemClass(self, "Ljava/nio/Buffer;")); // TODO: we only load a dex file here as starting the runtime relies upon it. const char* class_name = "StaticLeafMethods"; LoadDex(class_name); diff --git a/runtime/proxy_test.cc b/runtime/proxy_test.cc index f1e485b951..b78855fd3d 100644 --- a/runtime/proxy_test.cc +++ b/runtime/proxy_test.cc @@ -19,7 +19,7 @@ #include "art_field-inl.h" #include "base/enums.h" -#include "common_compiler_test.h" +#include "common_runtime_test.h" #include "mirror/field-inl.h" #include "proxy_test.h" #include "scoped_thread_state_change-inl.h" diff --git a/runtime/reflection_test.cc b/runtime/reflection_test.cc index 9fab7fbb90..8a7685578e 100644 --- a/runtime/reflection_test.cc +++ b/runtime/reflection_test.cc @@ -31,7 +31,7 @@ namespace art { -// TODO: Convert to CommonRuntimeTest. Currently MakeExecutable is used. +// TODO: Convert to CommonRuntimeTest. Currently CompileDirectMethod is used in one test. class ReflectionTest : public CommonCompilerTest { protected: void SetUp() override { @@ -86,11 +86,11 @@ class ReflectionTest : public CommonCompilerTest { return soa.AddLocalReference<jclass>(c); } - void ReflectionTestMakeExecutable(ArtMethod** method, - ObjPtr<mirror::Object>* receiver, - bool is_static, - const char* method_name, - const char* method_signature) + void ReflectionTestMakeInterpreted(ArtMethod** method, + ObjPtr<mirror::Object>* receiver, + bool is_static, + const char* method_name, + const char* method_signature) REQUIRES_SHARED(Locks::mutator_lock_) { const char* class_name = is_static ? "StaticLeafMethods" : "NonStaticLeafMethods"; jobject jclass_loader(LoadDex(class_name)); @@ -100,15 +100,15 @@ class ReflectionTest : public CommonCompilerTest { hs.NewHandle( ScopedObjectAccessUnchecked(self).Decode<mirror::ClassLoader>(jclass_loader))); if (!is_static) { - MakeExecutable(nullptr, "java.lang.Class"); - MakeExecutable(nullptr, "java.lang.Object"); + MakeInterpreted(class_linker_->FindSystemClass(self, "Ljava/lang/Class;")); + MakeInterpreted(class_linker_->FindSystemClass(self, "Ljava/lang/Object;")); } - MakeExecutable(class_loader.Get(), class_name); ObjPtr<mirror::Class> c = class_linker_->FindClass(self, DotToDescriptor(class_name).c_str(), class_loader); CHECK(c != nullptr); + MakeInterpreted(c); *method = c->FindClassMethod(method_name, method_signature, kRuntimePointerSize); CHECK(*method != nullptr); @@ -138,7 +138,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "nop", "()V"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "nop", "()V"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); InvokeWithJValues(soa, receiver_ref.get(), jni::EncodeArtMethod(method), nullptr); } @@ -147,7 +147,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "identity", "(B)B"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "identity", "(B)B"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jvalue args[1]; @@ -173,7 +173,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "identity", "(I)I"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "identity", "(I)I"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jvalue args[1]; @@ -198,7 +198,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "identity", "(D)D"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "identity", "(D)D"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jvalue args[1]; @@ -223,7 +223,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(II)I"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "sum", "(II)I"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jvalue args[2]; @@ -252,7 +252,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(III)I"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "sum", "(III)I"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jvalue args[3]; @@ -291,7 +291,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(IIII)I"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "sum", "(IIII)I"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jvalue args[4]; @@ -335,7 +335,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(IIIII)I"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "sum", "(IIIII)I"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jvalue args[5]; @@ -384,7 +384,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(DD)D"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "sum", "(DD)D"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jvalue args[2]; @@ -418,7 +418,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(DDD)D"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "sum", "(DDD)D"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jvalue args[3]; @@ -445,7 +445,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(DDDD)D"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "sum", "(DDDD)D"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jvalue args[4]; @@ -475,7 +475,7 @@ class ReflectionTest : public CommonCompilerTest { ScopedObjectAccess soa(env_); ArtMethod* method; ObjPtr<mirror::Object> receiver; - ReflectionTestMakeExecutable(&method, &receiver, is_static, "sum", "(DDDDD)D"); + ReflectionTestMakeInterpreted(&method, &receiver, is_static, "sum", "(DDDDD)D"); ScopedLocalRef<jobject> receiver_ref(soa.Env(), soa.AddLocalReference<jobject>(receiver)); jvalue args[5]; |