summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler/common_compiler_test.cc2
-rw-r--r--compiler/dex/quick_compiler_callbacks.h4
-rw-r--r--compiler/jit/jit_compiler.cc2
-rw-r--r--compiler/oat_test.cc2
-rw-r--r--dex2oat/dex2oat.cc9
-rw-r--r--runtime/compiler_callbacks.h37
-rw-r--r--runtime/jni_internal.cc2
-rw-r--r--runtime/mirror/art_field.cc2
-rw-r--r--runtime/noop_compiler_callbacks.h2
-rw-r--r--runtime/runtime.cc10
-rw-r--r--runtime/runtime.h13
11 files changed, 52 insertions, 33 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index d506cc21e9..257406a622 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -179,7 +179,7 @@ void CommonCompilerTest::SetUpRuntimeOptions(RuntimeOptions* options) {
method_inliner_map_.reset(new DexFileToMethodInlinerMap);
callbacks_.reset(new QuickCompilerCallbacks(verification_results_.get(),
method_inliner_map_.get(),
- false));
+ CompilerCallbacks::CallbackMode::kCompileApp));
options->push_back(std::make_pair("compilercallbacks", callbacks_.get()));
}
diff --git a/compiler/dex/quick_compiler_callbacks.h b/compiler/dex/quick_compiler_callbacks.h
index 56706e3e35..d692d26229 100644
--- a/compiler/dex/quick_compiler_callbacks.h
+++ b/compiler/dex/quick_compiler_callbacks.h
@@ -28,8 +28,8 @@ class QuickCompilerCallbacks FINAL : public CompilerCallbacks {
public:
QuickCompilerCallbacks(VerificationResults* verification_results,
DexFileToMethodInlinerMap* method_inliner_map,
- bool boot_image)
- : CompilerCallbacks(boot_image), verification_results_(verification_results),
+ CompilerCallbacks::CallbackMode mode)
+ : CompilerCallbacks(mode), verification_results_(verification_results),
method_inliner_map_(method_inliner_map) {
CHECK(verification_results != nullptr);
CHECK(method_inliner_map != nullptr);
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index d034736f95..df5d5cca3b 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -90,7 +90,7 @@ JitCompiler::JitCompiler() : total_time_(0) {
method_inliner_map_.reset(new DexFileToMethodInlinerMap);
callbacks_.reset(new QuickCompilerCallbacks(verification_results_.get(),
method_inliner_map_.get(),
- false));
+ CompilerCallbacks::CallbackMode::kCompileApp));
compiler_driver_.reset(new CompilerDriver(
compiler_options_.get(), verification_results_.get(), method_inliner_map_.get(),
Compiler::kQuick, instruction_set, instruction_set_features_.get(), false,
diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc
index 440c1b634c..d59ad6c32f 100644
--- a/compiler/oat_test.cc
+++ b/compiler/oat_test.cc
@@ -87,7 +87,7 @@ TEST_F(OatTest, WriteRead) {
method_inliner_map_.reset(new DexFileToMethodInlinerMap);
callbacks_.reset(new QuickCompilerCallbacks(verification_results_.get(),
method_inliner_map_.get(),
- false));
+ CompilerCallbacks::CallbackMode::kCompileApp));
timer_.reset(new CumulativeLogger("Compilation times"));
compiler_driver_.reset(new CompilerDriver(compiler_options_.get(),
verification_results_.get(),
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index f1cd30a4f7..2e1b7aef04 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1053,9 +1053,12 @@ class Dex2Oat FINAL {
}
verification_results_.reset(new VerificationResults(compiler_options_.get()));
- callbacks_.reset(new QuickCompilerCallbacks(verification_results_.get(),
- &method_inliner_map_,
- image_));
+ callbacks_.reset(new QuickCompilerCallbacks(
+ verification_results_.get(),
+ &method_inliner_map_,
+ image_ ?
+ CompilerCallbacks::CallbackMode::kCompileBootImage :
+ CompilerCallbacks::CallbackMode::kCompileApp));
runtime_options.push_back(std::make_pair("compilercallbacks", callbacks_.get()));
runtime_options.push_back(
std::make_pair("imageinstructionset", GetInstructionSetString(instruction_set_)));
diff --git a/runtime/compiler_callbacks.h b/runtime/compiler_callbacks.h
index 3fabe3ed44..b296e39c5e 100644
--- a/runtime/compiler_callbacks.h
+++ b/runtime/compiler_callbacks.h
@@ -29,27 +29,32 @@ class MethodVerifier;
} // namespace verifier
class CompilerCallbacks {
- public:
- virtual ~CompilerCallbacks() { }
+ public:
+ enum class CallbackMode { // private
+ kCompileBootImage,
+ kCompileApp
+ };
- virtual bool MethodVerified(verifier::MethodVerifier* verifier)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0;
- virtual void ClassRejected(ClassReference ref) = 0;
+ virtual ~CompilerCallbacks() { }
- // Return true if we should attempt to relocate to a random base address if we have not already
- // done so. Return false if relocating in this way would be problematic.
- virtual bool IsRelocationPossible() = 0;
+ virtual bool MethodVerified(verifier::MethodVerifier* verifier)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0;
+ virtual void ClassRejected(ClassReference ref) = 0;
- bool IsBootImage() {
- return boot_image_;
- }
+ // Return true if we should attempt to relocate to a random base address if we have not already
+ // done so. Return false if relocating in this way would be problematic.
+ virtual bool IsRelocationPossible() = 0;
- protected:
- explicit CompilerCallbacks(bool boot_image) : boot_image_(boot_image) { }
+ bool IsBootImage() {
+ return mode_ == CallbackMode::kCompileBootImage;
+ }
- private:
- // Whether the compiler is creating a boot image.
- const bool boot_image_;
+ protected:
+ explicit CompilerCallbacks(CallbackMode mode) : mode_(mode) { }
+
+ private:
+ // Whether the compiler is creating a boot image.
+ const CallbackMode mode_;
};
} // namespace art
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index 566b097a6e..9a71ba4ca7 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -167,7 +167,7 @@ static mirror::ClassLoader* GetClassLoader(const ScopedObjectAccess& soa)
// If so, CommonCompilerTest should have marked the runtime as a compiler not compiling an
// image.
CHECK(Runtime::Current()->IsAotCompiler());
- CHECK(!Runtime::Current()->GetCompilerCallbacks()->IsBootImage());
+ CHECK(!Runtime::Current()->IsCompilingBootImage());
return class_loader;
}
// Use the BOOTCLASSPATH.
diff --git a/runtime/mirror/art_field.cc b/runtime/mirror/art_field.cc
index 5d543a178c..4c36753724 100644
--- a/runtime/mirror/art_field.cc
+++ b/runtime/mirror/art_field.cc
@@ -45,7 +45,7 @@ void ArtField::ResetClass() {
void ArtField::SetOffset(MemberOffset num_bytes) {
DCHECK(GetDeclaringClass()->IsLoaded() || GetDeclaringClass()->IsErroneous());
if (kIsDebugBuild && Runtime::Current()->IsAotCompiler() &&
- Runtime::Current()->GetCompilerCallbacks()->IsBootImage()) {
+ Runtime::Current()->IsCompilingBootImage()) {
Primitive::Type type = GetTypeAsPrimitiveType();
if (type == Primitive::kPrimDouble || type == Primitive::kPrimLong) {
DCHECK_ALIGNED(num_bytes.Uint32Value(), 8);
diff --git a/runtime/noop_compiler_callbacks.h b/runtime/noop_compiler_callbacks.h
index a40659e66c..1cbf2bbda4 100644
--- a/runtime/noop_compiler_callbacks.h
+++ b/runtime/noop_compiler_callbacks.h
@@ -23,7 +23,7 @@ namespace art {
class NoopCompilerCallbacks FINAL : public CompilerCallbacks {
public:
- NoopCompilerCallbacks() : CompilerCallbacks(false) {}
+ NoopCompilerCallbacks() : CompilerCallbacks(CompilerCallbacks::CallbackMode::kCompileApp) {}
~NoopCompilerCallbacks() {}
bool MethodVerified(verifier::MethodVerifier* verifier ATTRIBUTE_UNUSED) OVERRIDE {
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index ffe3dc6fc9..c462153ed3 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -50,9 +50,11 @@
#include "arch/x86_64/registers_x86_64.h"
#include "asm_support.h"
#include "atomic.h"
+#include "base/arena_allocator.h"
#include "base/dumpable.h"
#include "base/unix_file/fd_file.h"
#include "class_linker.h"
+#include "compiler_callbacks.h"
#include "debugger.h"
#include "elf_file.h"
#include "entrypoints/runtime_asm_entrypoints.h"
@@ -1653,4 +1655,12 @@ void Runtime::CreateJit() {
}
}
+bool Runtime::CanRelocate() const {
+ return !IsAotCompiler() || compiler_callbacks_->IsRelocationPossible();
+}
+
+bool Runtime::IsCompilingBootImage() const {
+ return IsCompiler() && compiler_callbacks_->IsBootImage();
+}
+
} // namespace art
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 7181097563..085335fd3c 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -27,10 +27,7 @@
#include <vector>
#include "arch/instruction_set.h"
-#include "base/allocator.h"
-#include "base/arena_allocator.h"
#include "base/macros.h"
-#include "compiler_callbacks.h"
#include "gc_root.h"
#include "instrumentation.h"
#include "jobject_comparator.h"
@@ -43,6 +40,9 @@
namespace art {
+class ArenaPool;
+class CompilerCallbacks;
+
namespace gc {
class Heap;
namespace collector {
@@ -112,9 +112,10 @@ class Runtime {
return compiler_callbacks_ != nullptr;
}
- bool CanRelocate() const {
- return !IsAotCompiler() || compiler_callbacks_->IsRelocationPossible();
- }
+ // If a compiler, are we compiling a boot image?
+ bool IsCompilingBootImage() const;
+
+ bool CanRelocate() const;
bool ShouldRelocate() const {
return must_relocate_ && CanRelocate();