summaryrefslogtreecommitdiff
path: root/compiler/optimizing/sharpening.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2019-06-19 10:00:00 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2019-06-26 12:24:15 +0000
commit05f87217ddc9b4b9186710c0135b918f456c5aef (patch)
tree6e7bc0d2a3d8faa94c303d7d753319f3850fadcd /compiler/optimizing/sharpening.cc
parent8d335b61d637fa9b040eb9d559dbac98067467f1 (diff)
Make the JIT zygote memory shared.
Test: boots Bug: 119800099 Change-Id: I75ff8a58eea4de5cb833139641b4e15b8394d9b1
Diffstat (limited to 'compiler/optimizing/sharpening.cc')
-rw-r--r--compiler/optimizing/sharpening.cc41
1 files changed, 33 insertions, 8 deletions
diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc
index 8637db13ad..3e22edc773 100644
--- a/compiler/optimizing/sharpening.cc
+++ b/compiler/optimizing/sharpening.cc
@@ -19,6 +19,7 @@
#include "art_method-inl.h"
#include "base/casts.h"
#include "base/enums.h"
+#include "base/logging.h"
#include "class_linker.h"
#include "code_generator.h"
#include "driver/compiler_options.h"
@@ -26,6 +27,7 @@
#include "gc/heap.h"
#include "gc/space/image_space.h"
#include "handle_scope-inl.h"
+#include "jit/jit.h"
#include "mirror/dex_cache.h"
#include "mirror/string.h"
#include "nodes.h"
@@ -98,11 +100,17 @@ HInvokeStaticOrDirect::DispatchInfo HSharpening::SharpenInvokeStaticOrDirect(
}
code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod;
} else if (Runtime::Current()->UseJitCompilation()) {
- // JIT or on-device AOT compilation referencing a boot image method.
- // Use the method address directly.
- method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kJitDirectAddress;
- method_load_data = reinterpret_cast<uintptr_t>(callee);
- code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod;
+ if (Runtime::Current()->GetJit()->CanEncodeMethod(
+ callee,
+ codegen->GetGraph()->IsCompilingForSharedJitCode())) {
+ method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kJitDirectAddress;
+ method_load_data = reinterpret_cast<uintptr_t>(callee);
+ code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod;
+ } else {
+ // Do not sharpen.
+ method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kRuntimeCall;
+ code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallArtMethod;
+ }
} else if (IsInBootImage(callee)) {
// Use PC-relative access to the .data.bimg.rel.ro methods array.
method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kBootImageRelRo;
@@ -175,7 +183,16 @@ HLoadClass::LoadKind HSharpening::ComputeLoadClassKind(
if (is_in_boot_image) {
desired_load_kind = HLoadClass::LoadKind::kJitBootImageAddress;
} else if (klass != nullptr) {
- desired_load_kind = HLoadClass::LoadKind::kJitTableAddress;
+ if (runtime->GetJit()->CanEncodeClass(
+ klass.Get(),
+ codegen->GetGraph()->IsCompilingForSharedJitCode())) {
+ desired_load_kind = HLoadClass::LoadKind::kJitTableAddress;
+ } else {
+ // Shared JIT code cannot encode a literal that the GC can move.
+ VLOG(jit) << "Unable to encode in shared region class literal: "
+ << klass->PrettyClass();
+ desired_load_kind = HLoadClass::LoadKind::kRuntimeCall;
+ }
} else {
// Class not loaded yet. This happens when the dex code requesting
// this `HLoadClass` hasn't been executed in the interpreter.
@@ -331,10 +348,18 @@ void HSharpening::ProcessLoadString(
DCHECK(!codegen->GetCompilerOptions().GetCompilePic());
string = class_linker->LookupString(string_index, dex_cache.Get());
if (string != nullptr) {
- if (runtime->GetHeap()->ObjectIsInBootImageSpace(string)) {
+ gc::Heap* heap = runtime->GetHeap();
+ if (heap->ObjectIsInBootImageSpace(string)) {
desired_load_kind = HLoadString::LoadKind::kJitBootImageAddress;
- } else {
+ } else if (runtime->GetJit()->CanEncodeString(
+ string,
+ codegen->GetGraph()->IsCompilingForSharedJitCode())) {
desired_load_kind = HLoadString::LoadKind::kJitTableAddress;
+ } else {
+ // Shared JIT code cannot encode a literal that the GC can move.
+ VLOG(jit) << "Unable to encode in shared region string literal: "
+ << string->ToModifiedUtf8();
+ desired_load_kind = HLoadString::LoadKind::kRuntimeCall;
}
} else {
desired_load_kind = HLoadString::LoadKind::kRuntimeCall;