summaryrefslogtreecommitdiffstats
path: root/compiler/jni/jni_compiler_test.cc
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-01-06 12:55:46 -0800
committerIan Rogers <irogers@google.com>2014-02-06 23:20:27 -0800
commitef7d42fca18c16fbaf103822ad16f23246e2905d (patch)
treec67eea52a349c2ea7f2c3bdda8e73933c05531a8 /compiler/jni/jni_compiler_test.cc
parent822115a225185d2896607eb08d70ce5c7099adef (diff)
downloadandroid_art-ef7d42fca18c16fbaf103822ad16f23246e2905d.tar.gz
android_art-ef7d42fca18c16fbaf103822ad16f23246e2905d.tar.bz2
android_art-ef7d42fca18c16fbaf103822ad16f23246e2905d.zip
Object model changes to support 64bit.
Modify mirror objects so that references between them use an ObjectReference value type rather than an Object* so that functionality to compress larger references can be captured in the ObjectRefererence implementation. ObjectReferences are 32bit and all other aspects of object layout remain as they are currently. Expand fields in objects holding pointers so they can hold 64bit pointers. Its expected the size of these will come down by improving where we hold compiler meta-data. Stub out x86_64 architecture specific runtime implementation. Modify OutputStream so that reads and writes are of unsigned quantities. Make the use of portable or quick code more explicit. Templatize AtomicInteger to support more than just int32_t as a type. Add missing, and fix issues relating to, missing annotalysis information on the mutator lock. Refactor and share implementations for array copy between System and uses elsewhere in the runtime. Fix numerous 64bit build issues. Change-Id: I1a5694c251a42c9eff71084dfdd4b51fff716822
Diffstat (limited to 'compiler/jni/jni_compiler_test.cc')
-rw-r--r--compiler/jni/jni_compiler_test.cc47
1 files changed, 30 insertions, 17 deletions
diff --git a/compiler/jni/jni_compiler_test.cc b/compiler/jni/jni_compiler_test.cc
index 1c8714a6c3..c77d319330 100644
--- a/compiler/jni/jni_compiler_test.cc
+++ b/compiler/jni/jni_compiler_test.cc
@@ -58,11 +58,14 @@ class JniCompilerTest : public CommonTest {
method = c->FindVirtualMethod(method_name, method_sig);
}
ASSERT_TRUE(method != NULL) << method_name << " " << method_sig;
- if (method->GetEntryPointFromCompiledCode() != NULL) {
- return;
+ if (method->GetEntryPointFromQuickCompiledCode() == nullptr) {
+ ASSERT_TRUE(method->GetEntryPointFromPortableCompiledCode() == nullptr);
+ CompileMethod(method);
+ ASSERT_TRUE(method->GetEntryPointFromQuickCompiledCode() != nullptr)
+ << method_name << " " << method_sig;
+ ASSERT_TRUE(method->GetEntryPointFromPortableCompiledCode() != nullptr)
+ << method_name << " " << method_sig;
}
- CompileMethod(method);
- ASSERT_TRUE(method->GetEntryPointFromCompiledCode() != NULL) << method_name << " " << method_sig;
}
void SetUpForTest(bool direct, const char* method_name, const char* method_sig,
@@ -122,19 +125,19 @@ jobject JniCompilerTest::class_loader_;
int gJava_MyClassNatives_foo_calls = 0;
void Java_MyClassNatives_foo(JNIEnv* env, jobject thisObj) {
// 1 = thisObj
- EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
EXPECT_EQ(kNative, Thread::Current()->GetState());
Locks::mutator_lock_->AssertNotHeld(Thread::Current());
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
EXPECT_TRUE(thisObj != NULL);
EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_));
gJava_MyClassNatives_foo_calls++;
+ ScopedObjectAccess soa(Thread::Current());
+ EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
}
TEST_F(JniCompilerTest, CompileAndRunNoArgMethod) {
TEST_DISABLED_FOR_PORTABLE();
- SetUpForTest(false, "foo", "()V",
- reinterpret_cast<void*>(&Java_MyClassNatives_foo));
+ SetUpForTest(false, "foo", "()V", reinterpret_cast<void*>(&Java_MyClassNatives_foo));
EXPECT_EQ(0, gJava_MyClassNatives_foo_calls);
env_->CallNonvirtualVoidMethod(jobj_, jklass_, jmethod_);
@@ -178,12 +181,13 @@ TEST_F(JniCompilerTest, CompileAndRunStaticIntMethodThroughStub) {
int gJava_MyClassNatives_fooI_calls = 0;
jint Java_MyClassNatives_fooI(JNIEnv* env, jobject thisObj, jint x) {
// 1 = thisObj
- EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
EXPECT_EQ(kNative, Thread::Current()->GetState());
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
EXPECT_TRUE(thisObj != NULL);
EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_));
gJava_MyClassNatives_fooI_calls++;
+ ScopedObjectAccess soa(Thread::Current());
+ EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
return x;
}
@@ -204,12 +208,13 @@ TEST_F(JniCompilerTest, CompileAndRunIntMethod) {
int gJava_MyClassNatives_fooII_calls = 0;
jint Java_MyClassNatives_fooII(JNIEnv* env, jobject thisObj, jint x, jint y) {
// 1 = thisObj
- EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
EXPECT_EQ(kNative, Thread::Current()->GetState());
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
EXPECT_TRUE(thisObj != NULL);
EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_));
gJava_MyClassNatives_fooII_calls++;
+ ScopedObjectAccess soa(Thread::Current());
+ EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
return x - y; // non-commutative operator
}
@@ -231,12 +236,13 @@ TEST_F(JniCompilerTest, CompileAndRunIntIntMethod) {
int gJava_MyClassNatives_fooJJ_calls = 0;
jlong Java_MyClassNatives_fooJJ(JNIEnv* env, jobject thisObj, jlong x, jlong y) {
// 1 = thisObj
- EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
EXPECT_EQ(kNative, Thread::Current()->GetState());
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
EXPECT_TRUE(thisObj != NULL);
EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_));
gJava_MyClassNatives_fooJJ_calls++;
+ ScopedObjectAccess soa(Thread::Current());
+ EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
return x - y; // non-commutative operator
}
@@ -259,12 +265,13 @@ TEST_F(JniCompilerTest, CompileAndRunLongLongMethod) {
int gJava_MyClassNatives_fooDD_calls = 0;
jdouble Java_MyClassNatives_fooDD(JNIEnv* env, jobject thisObj, jdouble x, jdouble y) {
// 1 = thisObj
- EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
EXPECT_EQ(kNative, Thread::Current()->GetState());
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
EXPECT_TRUE(thisObj != NULL);
EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_));
gJava_MyClassNatives_fooDD_calls++;
+ ScopedObjectAccess soa(Thread::Current());
+ EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
return x - y; // non-commutative operator
}
@@ -288,12 +295,13 @@ TEST_F(JniCompilerTest, CompileAndRunDoubleDoubleMethod) {
int gJava_MyClassNatives_fooJJ_synchronized_calls = 0;
jlong Java_MyClassNatives_fooJJ_synchronized(JNIEnv* env, jobject thisObj, jlong x, jlong y) {
// 1 = thisObj
- EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
EXPECT_EQ(kNative, Thread::Current()->GetState());
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
EXPECT_TRUE(thisObj != NULL);
EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_));
gJava_MyClassNatives_fooJJ_synchronized_calls++;
+ ScopedObjectAccess soa(Thread::Current());
+ EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
return x | y;
}
@@ -314,12 +322,13 @@ int gJava_MyClassNatives_fooIOO_calls = 0;
jobject Java_MyClassNatives_fooIOO(JNIEnv* env, jobject thisObj, jint x, jobject y,
jobject z) {
// 3 = this + y + z
- EXPECT_EQ(3U, Thread::Current()->NumStackReferences());
EXPECT_EQ(kNative, Thread::Current()->GetState());
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
EXPECT_TRUE(thisObj != NULL);
EXPECT_TRUE(env->IsInstanceOf(thisObj, JniCompilerTest::jklass_));
gJava_MyClassNatives_fooIOO_calls++;
+ ScopedObjectAccess soa(Thread::Current());
+ EXPECT_EQ(3U, Thread::Current()->NumStackReferences());
switch (x) {
case 1:
return y;
@@ -365,12 +374,13 @@ TEST_F(JniCompilerTest, CompileAndRunIntObjectObjectMethod) {
int gJava_MyClassNatives_fooSII_calls = 0;
jint Java_MyClassNatives_fooSII(JNIEnv* env, jclass klass, jint x, jint y) {
// 1 = klass
- EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
EXPECT_EQ(kNative, Thread::Current()->GetState());
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
EXPECT_TRUE(klass != NULL);
EXPECT_TRUE(env->IsInstanceOf(JniCompilerTest::jobj_, klass));
gJava_MyClassNatives_fooSII_calls++;
+ ScopedObjectAccess soa(Thread::Current());
+ EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
return x + y;
}
@@ -388,12 +398,13 @@ TEST_F(JniCompilerTest, CompileAndRunStaticIntIntMethod) {
int gJava_MyClassNatives_fooSDD_calls = 0;
jdouble Java_MyClassNatives_fooSDD(JNIEnv* env, jclass klass, jdouble x, jdouble y) {
// 1 = klass
- EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
EXPECT_EQ(kNative, Thread::Current()->GetState());
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
EXPECT_TRUE(klass != NULL);
EXPECT_TRUE(env->IsInstanceOf(JniCompilerTest::jobj_, klass));
gJava_MyClassNatives_fooSDD_calls++;
+ ScopedObjectAccess soa(Thread::Current());
+ EXPECT_EQ(1U, Thread::Current()->NumStackReferences());
return x - y; // non-commutative operator
}
@@ -417,12 +428,13 @@ int gJava_MyClassNatives_fooSIOO_calls = 0;
jobject Java_MyClassNatives_fooSIOO(JNIEnv* env, jclass klass, jint x, jobject y,
jobject z) {
// 3 = klass + y + z
- EXPECT_EQ(3U, Thread::Current()->NumStackReferences());
EXPECT_EQ(kNative, Thread::Current()->GetState());
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
EXPECT_TRUE(klass != NULL);
EXPECT_TRUE(env->IsInstanceOf(JniCompilerTest::jobj_, klass));
gJava_MyClassNatives_fooSIOO_calls++;
+ ScopedObjectAccess soa(Thread::Current());
+ EXPECT_EQ(3U, Thread::Current()->NumStackReferences());
switch (x) {
case 1:
return y;
@@ -469,12 +481,13 @@ TEST_F(JniCompilerTest, CompileAndRunStaticIntObjectObjectMethod) {
int gJava_MyClassNatives_fooSSIOO_calls = 0;
jobject Java_MyClassNatives_fooSSIOO(JNIEnv* env, jclass klass, jint x, jobject y, jobject z) {
// 3 = klass + y + z
- EXPECT_EQ(3U, Thread::Current()->NumStackReferences());
EXPECT_EQ(kNative, Thread::Current()->GetState());
EXPECT_EQ(Thread::Current()->GetJniEnv(), env);
EXPECT_TRUE(klass != NULL);
EXPECT_TRUE(env->IsInstanceOf(JniCompilerTest::jobj_, klass));
gJava_MyClassNatives_fooSSIOO_calls++;
+ ScopedObjectAccess soa(Thread::Current());
+ EXPECT_EQ(3U, Thread::Current()->NumStackReferences());
switch (x) {
case 1:
return y;