summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2016-05-23 15:32:42 +0100
committer Vladimir Marko <vmarko@google.com> 2016-05-24 17:33:07 +0100
commitf6d1e0f6196cb3669dfb4eed8ceef679b0588c0f (patch)
treefa9ade37af2b3c5736aa3431e393be348f21532c
parent84f00fe695a7a78551d7f2e8d7bc2bed1ce86a67 (diff)
Compile JNI stubs for verify-profile and interpret-only.
This is the intended behavior to have a good JNI transition performance. Bug: 28902384 (cherry picked from commit 8c185bf0c6f18a5349bc87a7e3751ba06d90f461) Change-Id: I52767909b916ada3c619206c8838b85bff5ac316
-rw-r--r--compiler/dex/verification_results.cc2
-rw-r--r--compiler/driver/compiler_driver.cc4
-rw-r--r--compiler/driver/compiler_options.h8
-rw-r--r--dex2oat/dex2oat.cc19
-rw-r--r--runtime/compiler_filter.cc21
-rw-r--r--runtime/compiler_filter.h16
-rw-r--r--runtime/oat_file_assistant.cc4
-rw-r--r--runtime/oat_file_assistant_test.cc2
-rw-r--r--test/117-nopatchoat/nopatchoat.cc2
9 files changed, 43 insertions, 35 deletions
diff --git a/compiler/dex/verification_results.cc b/compiler/dex/verification_results.cc
index 606302bd78..03c94a45e3 100644
--- a/compiler/dex/verification_results.cc
+++ b/compiler/dex/verification_results.cc
@@ -104,7 +104,7 @@ bool VerificationResults::IsClassRejected(ClassReference ref) {
bool VerificationResults::IsCandidateForCompilation(MethodReference&,
const uint32_t access_flags) {
- if (!compiler_options_->IsCompilationEnabled()) {
+ if (!compiler_options_->IsBytecodeCompilationEnabled()) {
return false;
}
// Don't compile class initializers unless kEverything.
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 1ab1d31f09..d20f51001c 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -553,8 +553,8 @@ static void CompileMethod(Thread* self,
MethodReference method_ref(&dex_file, method_idx);
if ((access_flags & kAccNative) != 0) {
- // Are we interpreting only and have support for generic JNI down calls?
- if (!driver->GetCompilerOptions().IsCompilationEnabled() &&
+ // Are we extracting only and have support for generic JNI down calls?
+ if (!driver->GetCompilerOptions().IsJniCompilationEnabled() &&
InstructionSetHasGenericJniStub(driver->GetInstructionSet())) {
// Leaving this empty will trigger the generic JNI version
} else {
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h
index 6bbd3c5a19..60b700ad91 100644
--- a/compiler/driver/compiler_options.h
+++ b/compiler/driver/compiler_options.h
@@ -88,8 +88,12 @@ class CompilerOptions FINAL {
return compiler_filter_ == CompilerFilter::kVerifyAtRuntime;
}
- bool IsCompilationEnabled() const {
- return CompilerFilter::IsCompilationEnabled(compiler_filter_);
+ bool IsBytecodeCompilationEnabled() const {
+ return CompilerFilter::IsBytecodeCompilationEnabled(compiler_filter_);
+ }
+
+ bool IsJniCompilationEnabled() const {
+ return CompilerFilter::IsJniCompilationEnabled(compiler_filter_);
}
bool IsVerificationEnabled() const {
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index cb274dcc09..9f6f4530c7 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1450,25 +1450,6 @@ class Dex2Oat FINAL {
class_linker->RegisterDexFile(*dex_file, Runtime::Current()->GetLinearAlloc())));
}
- /*
- * If we're not in interpret-only or verify-none or verify-at-runtime or verify-profile mode,
- * go ahead and compile small applications. Don't bother to check if we're doing the image.
- */
- if (!IsBootImage() &&
- compiler_options_->IsCompilationEnabled() &&
- compiler_kind_ == Compiler::kQuick) {
- size_t num_methods = 0;
- for (size_t i = 0; i != dex_files_.size(); ++i) {
- const DexFile* dex_file = dex_files_[i];
- CHECK(dex_file != nullptr);
- num_methods += dex_file->NumMethodIds();
- }
- if (num_methods <= compiler_options_->GetNumDexMethodsThreshold()) {
- compiler_options_->SetCompilerFilter(CompilerFilter::kSpeed);
- VLOG(compiler) << "Below method threshold, compiling anyways";
- }
- }
-
return true;
}
diff --git a/runtime/compiler_filter.cc b/runtime/compiler_filter.cc
index d617caf78c..dc197c1066 100644
--- a/runtime/compiler_filter.cc
+++ b/runtime/compiler_filter.cc
@@ -20,7 +20,7 @@
namespace art {
-bool CompilerFilter::IsCompilationEnabled(Filter filter) {
+bool CompilerFilter::IsBytecodeCompilationEnabled(Filter filter) {
switch (filter) {
case CompilerFilter::kVerifyNone:
case CompilerFilter::kVerifyAtRuntime:
@@ -39,6 +39,25 @@ bool CompilerFilter::IsCompilationEnabled(Filter filter) {
UNREACHABLE();
}
+bool CompilerFilter::IsJniCompilationEnabled(Filter filter) {
+ switch (filter) {
+ case CompilerFilter::kVerifyNone:
+ case CompilerFilter::kVerifyAtRuntime: return false;
+
+ case CompilerFilter::kVerifyProfile:
+ case CompilerFilter::kInterpretOnly:
+ case CompilerFilter::kSpaceProfile:
+ case CompilerFilter::kSpace:
+ case CompilerFilter::kBalanced:
+ case CompilerFilter::kTime:
+ case CompilerFilter::kSpeedProfile:
+ case CompilerFilter::kSpeed:
+ case CompilerFilter::kEverythingProfile:
+ case CompilerFilter::kEverything: return true;
+ }
+ UNREACHABLE();
+}
+
bool CompilerFilter::IsVerificationEnabled(Filter filter) {
switch (filter) {
case CompilerFilter::kVerifyNone:
diff --git a/runtime/compiler_filter.h b/runtime/compiler_filter.h
index e8d74dd9e8..37631cc6d2 100644
--- a/runtime/compiler_filter.h
+++ b/runtime/compiler_filter.h
@@ -30,10 +30,10 @@ class CompilerFilter FINAL {
// Note: Order here matters. Later filter choices are considered "as good
// as" earlier filter choices.
enum Filter {
- kVerifyNone, // Skip verification and compile nothing except JNI stubs.
- kVerifyAtRuntime, // Only compile JNI stubs and verify at runtime.
- kVerifyProfile, // Verify only the classes in the profile.
- kInterpretOnly, // Verify, and compile only JNI stubs.
+ kVerifyNone, // Skip verification but mark all classes as verified anyway.
+ kVerifyAtRuntime, // Delay verication to runtime, do not compile anything.
+ kVerifyProfile, // Verify only the classes in the profile, compile only JNI stubs.
+ kInterpretOnly, // Verify everything, compile only JNI stubs.
kTime, // Compile methods, but minimize compilation time.
kSpaceProfile, // Maximize space savings based on profile.
kSpace, // Maximize space savings.
@@ -47,8 +47,12 @@ class CompilerFilter FINAL {
static const Filter kDefaultCompilerFilter = kSpeed;
// Returns true if an oat file with this compiler filter contains
- // compiled executable code.
- static bool IsCompilationEnabled(Filter filter);
+ // compiled executable code for bytecode.
+ static bool IsBytecodeCompilationEnabled(Filter filter);
+
+ // Returns true if an oat file with this compiler filter contains
+ // compiled executable code for JNI methods.
+ static bool IsJniCompilationEnabled(Filter filter);
// Returns true if this compiler filter requires running verification.
static bool IsVerificationEnabled(Filter filter);
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index fba10ca014..64b40b71b6 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -153,7 +153,7 @@ bool OatFileAssistant::OdexFileCompilerFilterIsOkay(CompilerFilter::Filter targe
}
OatFileAssistant::DexOptNeeded OatFileAssistant::GetDexOptNeeded(CompilerFilter::Filter target) {
- bool compilation_desired = CompilerFilter::IsCompilationEnabled(target);
+ bool compilation_desired = CompilerFilter::IsBytecodeCompilationEnabled(target);
// See if the oat file is in good shape as is.
bool oat_okay = OatFileCompilerFilterIsOkay(target);
@@ -600,7 +600,7 @@ bool OatFileAssistant::GivenOatFileIsUpToDate(const OatFile& file) {
CompilerFilter::Filter current_compiler_filter = file.GetCompilerFilter();
- if (CompilerFilter::IsCompilationEnabled(current_compiler_filter)) {
+ if (CompilerFilter::IsBytecodeCompilationEnabled(current_compiler_filter)) {
if (!file.IsPic()) {
const ImageInfo* image_info = GetImageInfo();
if (image_info == nullptr) {
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index 15a1aa4d10..c79a9a67b3 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -233,7 +233,7 @@ class OatFileAssistantTest : public CommonRuntimeTest {
EXPECT_TRUE(odex_file->HasPatchInfo());
EXPECT_EQ(filter, odex_file->GetCompilerFilter());
- if (CompilerFilter::IsCompilationEnabled(filter)) {
+ if (CompilerFilter::IsBytecodeCompilationEnabled(filter)) {
const std::vector<gc::space::ImageSpace*> image_spaces =
runtime->GetHeap()->GetBootImageSpaces();
ASSERT_TRUE(!image_spaces.empty() && image_spaces[0] != nullptr);
diff --git a/test/117-nopatchoat/nopatchoat.cc b/test/117-nopatchoat/nopatchoat.cc
index 0dab4007a7..c6a2e9a5a8 100644
--- a/test/117-nopatchoat/nopatchoat.cc
+++ b/test/117-nopatchoat/nopatchoat.cc
@@ -55,7 +55,7 @@ class NoPatchoatTest {
const OatFile* oat_file = oat_dex_file->GetOatFile();
return !oat_file->IsPic()
- && CompilerFilter::IsCompilationEnabled(oat_file->GetCompilerFilter());
+ && CompilerFilter::IsBytecodeCompilationEnabled(oat_file->GetCompilerFilter());
}
};