summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler.cc16
-rw-r--r--src/compiler.h5
-rw-r--r--src/compiler/Frontend.cc21
-rw-r--r--src/compiler_test.cc424
-rw-r--r--src/jni_internal.cc10
-rw-r--r--src/thread.h6
6 files changed, 118 insertions, 364 deletions
diff --git a/src/compiler.cc b/src/compiler.cc
index a623d20d50..52babf7fa0 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -12,14 +12,15 @@ extern bool oatCompileMethod(art::Method*, art::InstructionSet);
namespace art {
// TODO need to specify target
-void Compiler::Compile(std::vector<const DexFile*> class_path) {
- ClassLoader* class_loader = PathClassLoader::Alloc(class_path);
+const ClassLoader* Compiler::Compile(std::vector<const DexFile*> class_path) {
+ const ClassLoader* class_loader = PathClassLoader::Alloc(class_path);
Resolve(class_loader);
for (size_t i = 0; i != class_path.size(); ++i) {
const DexFile* dex_file = class_path[i];
CHECK(dex_file != NULL);
CompileDexFile(class_loader, *dex_file);
}
+ return class_loader;
}
void Compiler::Resolve(const ClassLoader* class_loader) {
@@ -77,20 +78,19 @@ void Compiler::CompileClass(Class* klass) {
}
void Compiler::CompileMethod(Method* method) {
- // TODO remove this as various compilers come on line
- if (true) {
- return;
- }
if (method->IsNative()) {
+ // TODO note code will be unmapped when JniCompiler goes out of scope
Assembler jni_asm;
JniCompiler jni_compiler;
jni_compiler.Compile(&jni_asm, method);
} else if (method->IsAbstract()) {
- // TODO setup precanned code to throw something like AbstractMethodError
+ // TODO: This might be also noted in the ClassLinker.
+ // Probably makes more sense to do here?
+ UNIMPLEMENTED(FATAL) << "compile stub to throw AbstractMethodError";
} else {
oatCompileMethod(method, kThumb2);
}
- CHECK(method->HasCode());
+ // CHECK(method->HasCode()); // TODO: enable this check ASAP
}
} // namespace art
diff --git a/src/compiler.h b/src/compiler.h
index 1e5da6bb79..e779646a22 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -10,7 +10,10 @@ namespace art {
class Compiler {
public:
- void Compile(std::vector<const DexFile*> class_path);
+ // Compile the DexFiles on a classpath. Returns a ClassLoader for
+ // the path used by the classes that were compiled. This ClassLoader
+ // can be used with FindClass to lookup a compiled class by name.
+ const ClassLoader* Compile(std::vector<const DexFile*> class_path);
private:
// Attempt to resolve all type, methods, fields, and strings
diff --git a/src/compiler/Frontend.cc b/src/compiler/Frontend.cc
index 8a3d8b239d..1775375e71 100644
--- a/src/compiler/Frontend.cc
+++ b/src/compiler/Frontend.cc
@@ -697,14 +697,21 @@ static void processCanThrow(CompilationUnit* cUnit, BasicBlock* curBlock,
*/
bool oatCompileMethod(Method* method, art::InstructionSet insnSet)
{
- if ((method->GetName()->ToModifiedUtf8().find("init>") !=
- std::string::npos) ||
- (method->GetName()->ToModifiedUtf8().find("foo") !=
- std::string::npos)) {
- LOG(INFO) << "not compiling " << PrettyMethod(method, false);
+ if (!method->IsStatic() ||
+ (method->GetName()->ToModifiedUtf8().find("foo") != std::string::npos) ||
+ (method->GetName()->ToModifiedUtf8().find("init>") != std::string::npos) ||
+ (method->GetName()->ToModifiedUtf8().find("intOperTest") != std::string::npos) ||
+ (method->GetName()->ToModifiedUtf8().find("intShiftTest") != std::string::npos) ||
+ (method->GetName()->ToModifiedUtf8().find("lit16Test") != std::string::npos) ||
+ (method->GetName()->ToModifiedUtf8().find("lit8Test") != std::string::npos) ||
+ (method->GetName()->ToModifiedUtf8().find("longOperTest") != std::string::npos) ||
+ (method->GetName()->ToModifiedUtf8().find("longShiftTest") != std::string::npos) ||
+ (method->GetName()->ToModifiedUtf8().find("shiftTest1") != std::string::npos) ||
+ (method->GetName()->ToModifiedUtf8().find("main") != std::string::npos)) {
+ LOG(INFO) << "not compiling " << PrettyMethod(method, true);
return false;
} else {
- LOG(INFO) << "Compiling " << PrettyMethod(method, false);
+ LOG(INFO) << "Compiling " << PrettyMethod(method, true);
}
CompilationUnit cUnit;
@@ -906,7 +913,7 @@ bool oatCompileMethod(Method* method, art::InstructionSet insnSet)
oatDumpCFG(&cUnit, "/sdcard/cfg/");
#endif
- return false;
+ return true;
}
void oatInit(void)
diff --git a/src/compiler_test.cc b/src/compiler_test.cc
index 4692f82260..b112eef946 100644
--- a/src/compiler_test.cc
+++ b/src/compiler_test.cc
@@ -12,14 +12,46 @@
#include <stdint.h>
#include <stdio.h>
-#include "gtest/gtest.h"
namespace art {
class CompilerTest : public CommonTest {
+ protected:
+ void CompileDex(const char* base64_dex, const char* base64_name) {
+ dex_file_.reset(OpenDexFileBase64(base64_dex, base64_name));
+ class_linker_->RegisterDexFile(*dex_file_.get());
+ std::vector<const DexFile*> class_path;
+ class_path.push_back(dex_file_.get());
+ Compiler compiler;
+ const ClassLoader* class_loader = compiler.Compile(class_path);
+ Thread::Current()->SetClassLoaderOverride(class_loader);
+ }
+
+ void AssertStaticIntMethod(const char* klass, const char* method, const char* signature,
+ jint expected, ...) {
+ JNIEnv* env = Thread::Current()->GetJniEnv();
+ jclass c = env->FindClass(klass);
+ CHECK(c != NULL);
+ jmethodID m = env->GetStaticMethodID(c, method, signature);
+ CHECK(m != NULL);
+#if defined(__arm__)
+ va_list args;
+ va_start(args, expected);
+ jint result = env->CallStaticIntMethodV(c, m, args);
+ va_end(args);
+ LOG(INFO) << klass << "." << method << "(...) result is " << result;
+ EXPECT_EQ(expected, result);
+#endif // __arm__
+ }
+ private:
+ scoped_ptr<DexFile> dex_file_;
};
-TEST_F(CompilerTest, CompileLibCore) {
+TEST_F(CompilerTest, CompileDexLibCore) {
+ // TODO renenable when compiler can handle libcore
+ if (true) {
+ return;
+ }
Compiler compiler;
compiler.Compile(boot_class_path_);
@@ -51,409 +83,127 @@ TEST_F(CompilerTest, CompileLibCore) {
}
-
-#if defined(__arm__)
TEST_F(CompilerTest, BasicCodegen) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kFibonacciDex,
- "kFibonacciDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("Fibonacci");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "fibonacci", "(I)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, 10);
- LOG(INFO) << "Fibonacci[10] is " << result;
-
- ASSERT_EQ(55, result);
+ CompileDex(kFibonacciDex, "kFibonacciDex");
+ AssertStaticIntMethod("Fibonacci", "fibonacci", "(I)I", 55,
+ 10);
}
TEST_F(CompilerTest, UnopTest) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "unopTest", "(I)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, 38);
- LOG(INFO) << "unopTest(38) == " << result;
-
- ASSERT_EQ(37, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "unopTest", "(I)I", 37,
+ 38);
}
#if 0 // Does filled array - needs load-time class resolution
TEST_F(CompilerTest, ShiftTest1) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "shiftTest1", "()I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m);
-
- ASSERT_EQ(0, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "shiftTest1", "()I", 0);
}
#endif
TEST_F(CompilerTest, ShiftTest2) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "shiftTest2", "()I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m);
-
- ASSERT_EQ(0, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "shiftTest2", "()I", 0);
}
TEST_F(CompilerTest, UnsignedShiftTest) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "unsignedShiftTest", "()I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m);
-
- ASSERT_EQ(0, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "unsignedShiftTest", "()I", 0);
}
#if 0 // Fail subtest #3, long to int conversion w/ truncation.
TEST_F(CompilerTest, ConvTest) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "convTest", "()I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m);
-
- ASSERT_EQ(0, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "convTest", "()I", 0);
}
#endif
TEST_F(CompilerTest, CharSubTest) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "charSubTest", "()I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m);
-
- ASSERT_EQ(0, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "charSubTest", "()I", 0);
}
#if 0 // Needs array allocation & r9 to be set up with Thread*
TEST_F(CompilerTest, IntOperTest) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "intOperTest", "(II)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, 70000, -3);
-
- ASSERT_EQ(0, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "intOperTest", "(II)I", 0,
+ 70000, -3);
}
#endif
#if 0 // Needs array allocation & r9 to be set up with Thread*
TEST_F(CompilerTest, Lit16Test) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "lit16Test", "(I)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, 77777);
-
- ASSERT_EQ(0, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "lit16Test", "(I)I", 0,
+ 77777);
}
#endif
#if 0 // Needs array allocation & r9 to be set up with Thread*
TEST_F(CompilerTest, Lit8Test) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "lit8Test", "(I)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, -55555);
-
- ASSERT_EQ(0, result);
-}
-#endif
-
-#if 0 // Needs array allocation & r9 to be set up with Thread*
-TEST_F(CompilerTest, Lit8Test) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "lit8Test", "(I)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, -55555);
-
- ASSERT_EQ(0, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "lit8Test", "(I)I", 0,
+ -55555);
}
#endif
#if 0 // Needs array allocation & r9 to be set up with Thread*
TEST_F(CompilerTest, IntShiftTest) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "intShiftTest", "(II)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, 0xff00aa01, 8);
-
- ASSERT_EQ(0, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "intShiftTest", "(II)I", 0,
+ 0xff00aa01, 8);
}
#endif
#if 0 // Needs array allocation & r9 to be set up with Thread*
TEST_F(CompilerTest, LongOperTest) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "longOperTest", "(LL)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, 70000000000L, 3);
-
- ASSERT_EQ(0, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "longOperTest", "(JJ)I", 0,
+ 70000000000LL, 3);
}
#endif
#if 0 // Needs array allocation & r9 to be set up with Thread*
TEST_F(CompilerTest, LongShiftTest) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "longShiftTest", "(LL)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, 0xd5aa96deff00aa01, 8);
-
- ASSERT_EQ(0, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "longShiftTest", "(JJ)I", 0,
+ 0xd5aa96deff00aa01LL, 8);
}
#endif
TEST_F(CompilerTest, SwitchTest1) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "switchTest", "(I)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, 1);
-
- ASSERT_EQ(1234, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "switchTest", "(I)I", 1234,
+ 1);
}
TEST_F(CompilerTest, IntCompare) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "testIntCompare", "(IIII)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, -5, 4, 4, 0);
-
- ASSERT_EQ(1111, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "testIntCompare", "(IIII)I", 1111,
+ -5, 4, 4, 0);
}
TEST_F(CompilerTest, LongCompare) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "testLongCompare", "(JJJJ)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, -5LL, -4294967287LL, 4LL, 8LL);
-
- ASSERT_EQ(2222, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "testLongCompare", "(JJJJ)I", 2222,
+ -5LL, -4294967287LL, 4LL, 8LL);
}
+#if 0
TEST_F(CompilerTest, FloatCompare) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "testFloatCompare", "(FFFF)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, -5.0f, 4.0f, 4.0f,
- (1.0f/0.0f) / (1.0f/0.0f));
-
- ASSERT_EQ(3333, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "testFloatCompare", "(FFFF)I", 3333
+ -5.0f, 4.0f, 4.0f,
+ (1.0f/0.0f) / (1.0f/0.0f));
}
+#endif
TEST_F(CompilerTest, DoubleCompare) {
- scoped_ptr<DexFile> dex_file(OpenDexFileBase64(kIntMathDex,
- "kIntMathDex"));
- PathClassLoader* class_loader = AllocPathClassLoader(dex_file.get());
-
- Thread::Current()->SetClassLoaderOverride(class_loader);
-
- JNIEnv* env = Thread::Current()->GetJniEnv();
-
- jclass c = env->FindClass("IntMath");
- ASSERT_TRUE(c != NULL);
-
- jmethodID m = env->GetStaticMethodID(c, "testDoubleCompare", "(DDDD)I");
- ASSERT_TRUE(m != NULL);
-
- jint result = env->CallStaticIntMethod(c, m, -5.0, 4.0, 4.0,
- (1.0/0.0) / (1.0/0.0));
-
- ASSERT_EQ(4444, result);
+ CompileDex(kIntMathDex, "kIntMathDex");
+ AssertStaticIntMethod("IntMath", "testDoubleCompare", "(DDDD)I", 4444,
+ -5.0, 4.0, 4.0,
+ (1.0/0.0) / (1.0/0.0));
}
-#endif // Arm
} // namespace art
diff --git a/src/jni_internal.cc b/src/jni_internal.cc
index 8485cede23..1746cc3d0d 100644
--- a/src/jni_internal.cc
+++ b/src/jni_internal.cc
@@ -21,8 +21,6 @@
#include "stringpiece.h"
#include "thread.h"
-extern bool oatCompileMethod(art::Method*, art::InstructionSet);
-
namespace art {
// This is private API, but with two different implementations: ARM and x86.
@@ -264,10 +262,6 @@ JValue InvokeWithArgArray(ScopedJniThreadState& ts, Object* receiver,
const Method::InvokeStub* stub = method->GetInvokeStub();
CHECK(stub != NULL);
- // Compile...
- // TODO: not here!
- oatCompileMethod(method, kThumb2);
-
JValue result;
if (method->HasCode()) {
(*stub)(method, receiver, self, args, &result);
@@ -686,7 +680,7 @@ class JNI {
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
std::string descriptor(NormalizeJniClassDescriptor(name));
// TODO: need to get the appropriate ClassLoader.
- ClassLoader* cl = ts.Self()->GetClassLoaderOverride();
+ const ClassLoader* cl = ts.Self()->GetClassLoaderOverride();
Class* c = class_linker->FindClass(descriptor, cl);
return AddLocalReference<jclass>(ts, c);
}
@@ -2826,7 +2820,7 @@ bool JavaVMExt::LoadNativeLibrary(const std::string& path, ClassLoader* class_lo
// the comments in the JNI FindClass function.)
typedef int (*JNI_OnLoadFn)(JavaVM*, void*);
JNI_OnLoadFn jni_on_load = reinterpret_cast<JNI_OnLoadFn>(sym);
- ClassLoader* old_class_loader = self->GetClassLoaderOverride();
+ const ClassLoader* old_class_loader = self->GetClassLoaderOverride();
self->SetClassLoaderOverride(class_loader);
old_state = self->GetState();
diff --git a/src/thread.h b/src/thread.h
index 820e2aad41..7609b40f1f 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -377,11 +377,11 @@ class Thread {
top_of_managed_stack_.SetSP( reinterpret_cast<const Method**>(record.last_top_of_managed_stack) );
}
- ClassLoader* GetClassLoaderOverride() {
+ const ClassLoader* GetClassLoaderOverride() {
return class_loader_override_;
}
- void SetClassLoaderOverride(ClassLoader* class_loader_override) {
+ void SetClassLoaderOverride(const ClassLoader* class_loader_override) {
class_loader_override_ = class_loader_override;
}
@@ -450,7 +450,7 @@ class Thread {
// Needed to get the right ClassLoader in JNI_OnLoad, but also
// useful for testing.
- ClassLoader* class_loader_override_;
+ const ClassLoader* class_loader_override_;
// The memory mapping of the stack for non-attached threads.
scoped_ptr<MemMap> stack_;