summaryrefslogtreecommitdiff
path: root/src/compiler_test.cc
diff options
context:
space:
mode:
author Ian Rogers <irogers@google.com> 2012-07-19 15:28:27 -0700
committer Ian Rogers <irogers@google.com> 2012-08-14 10:45:52 -0700
commit00f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abac (patch)
tree6a2172ece15c4699e6c2a67ce76f019db0a9a21d /src/compiler_test.cc
parent634ea28f78c4a138e6a1de54eae8696095422415 (diff)
Global lock levels.
Introduce the notion of the mutators/GC being a shared-exclusive (aka reader-writer) lock. Introduce globally ordered locks, analysable by annotalysis, statically at compile time. Add locking attributes to methods. More subtly, remove the heap_lock_ and split between various locks that are held for smaller periods (where work doesn't get blocked). Remove buggy Dalvik style thread transitions. Make GC use CMS in all cases when concurrent is enabled. Fix bug where suspend counts rather than debug suspend counts were sent to JDWP. Move the PathClassLoader to WellKnownClasses. In debugger refactor calls to send request and possibly suspend. Break apart different VmWait thread states. Move identity hash code to a shared method. Change-Id: Icdbfc3ce3fcccd14341860ac7305d8e97b51f5c6
Diffstat (limited to 'src/compiler_test.cc')
-rw-r--r--src/compiler_test.cc39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/compiler_test.cc b/src/compiler_test.cc
index 088726fff5..0c53bb9981 100644
--- a/src/compiler_test.cc
+++ b/src/compiler_test.cc
@@ -31,14 +31,16 @@ namespace art {
class CompilerTest : public CommonTest {
protected:
- void CompileAll(ClassLoader* class_loader) {
+ void CompileAll(jobject class_loader) LOCKS_EXCLUDED(GlobalSynchronization::mutator_lock_) {
compiler_->CompileAll(class_loader, Runtime::Current()->GetCompileTimeClassPath(class_loader));
MakeAllExecutable(class_loader);
}
- void EnsureCompiled(ClassLoader* class_loader, const char* class_name, const char* method,
- const char* signature, bool is_virtual) {
+ void EnsureCompiled(jobject class_loader, const char* class_name, const char* method,
+ const char* signature, bool is_virtual)
+ LOCKS_EXCLUDED(GlobalSynchronization::mutator_lock_) {
CompileAll(class_loader);
+ Thread::Current()->TransitionFromSuspendedToRunnable();
runtime_->Start();
env_ = Thread::Current()->GetJniEnv();
class_ = env_->FindClass(class_name);
@@ -51,7 +53,7 @@ class CompilerTest : public CommonTest {
CHECK(mid_ != NULL) << "Method not found: " << class_name << "." << method << signature;
}
- void MakeAllExecutable(ClassLoader* class_loader) {
+ void MakeAllExecutable(jobject class_loader) {
const std::vector<const DexFile*>& class_path
= Runtime::Current()->GetCompileTimeClassPath(class_loader);
for (size_t i = 0; i != class_path.size(); ++i) {
@@ -61,12 +63,13 @@ class CompilerTest : public CommonTest {
}
}
- void MakeDexFileExecutable(ClassLoader* class_loader, const DexFile& dex_file) {
+ void MakeDexFileExecutable(jobject class_loader, const DexFile& dex_file) {
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
for (size_t i = 0; i < dex_file.NumClassDefs(); i++) {
const DexFile::ClassDef& class_def = dex_file.GetClassDef(i);
const char* descriptor = dex_file.GetClassDescriptor(class_def);
- Class* c = class_linker->FindClass(descriptor, class_loader);
+ ScopedObjectAccess soa(Thread::Current());
+ Class* c = class_linker->FindClass(descriptor, soa.Decode<ClassLoader*>(class_loader));
CHECK(c != NULL);
for (size_t i = 0; i < c->NumDirectMethods(); i++) {
MakeExecutable(c->GetDirectMethod(i));
@@ -87,6 +90,7 @@ TEST_F(CompilerTest, DISABLED_LARGE_CompileDexLibCore) {
CompileAll(NULL);
// All libcore references should resolve
+ ScopedObjectAccess soa(Thread::Current());
const DexFile* dex = java_lang_dex_file_;
DexCache* dex_cache = class_linker_->FindDexCache(*dex);
EXPECT_EQ(dex->NumStringIds(), dex_cache->NumStrings());
@@ -125,12 +129,15 @@ TEST_F(CompilerTest, DISABLED_LARGE_CompileDexLibCore) {
}
TEST_F(CompilerTest, AbstractMethodErrorStub) {
- CompileVirtualMethod(NULL, "java.lang.Class", "isFinalizable", "()Z");
- CompileDirectMethod(NULL, "java.lang.Object", "<init>", "()V");
-
- SirtRef<ClassLoader> class_loader(LoadDex("AbstractMethod"));
- ASSERT_TRUE(class_loader.get() != NULL);
- EnsureCompiled(class_loader.get(), "AbstractClass", "foo", "()V", true);
+ jobject class_loader;
+ {
+ ScopedObjectAccess soa(Thread::Current());
+ CompileVirtualMethod(NULL, "java.lang.Class", "isFinalizable", "()Z");
+ CompileDirectMethod(NULL, "java.lang.Object", "<init>", "()V");
+ class_loader = LoadDex("AbstractMethod");
+ }
+ ASSERT_TRUE(class_loader != NULL);
+ EnsureCompiled(class_loader, "AbstractClass", "foo", "()V", true);
// Create a jobj_ of ConcreteClass, NOT AbstractClass.
jclass c_class = env_->FindClass("ConcreteClass");
@@ -138,11 +145,13 @@ TEST_F(CompilerTest, AbstractMethodErrorStub) {
jobject jobj_ = env_->NewObject(c_class, constructor);
ASSERT_TRUE(jobj_ != NULL);
- Class* jlame = class_linker_->FindClass("Ljava/lang/AbstractMethodError;", class_loader.get());
// Force non-virtual call to AbstractClass foo, will throw AbstractMethodError exception.
env_->CallNonvirtualVoidMethod(jobj_, class_, mid_);
- EXPECT_TRUE(Thread::Current()->IsExceptionPending());
- EXPECT_TRUE(Thread::Current()->GetException()->InstanceOf(jlame));
+ EXPECT_EQ(env_->ExceptionCheck(), JNI_TRUE);
+ jthrowable exception = env_->ExceptionOccurred();
+ env_->ExceptionClear();
+ jclass jlame = env_->FindClass("java/lang/AbstractMethodError");
+ EXPECT_TRUE(env_->IsInstanceOf(exception, jlame));
Thread::Current()->ClearException();
}