summaryrefslogtreecommitdiff
path: root/compiler/optimizing
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing')
-rw-r--r--compiler/optimizing/sharpening.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc
index 649496478a..a128079cdb 100644
--- a/compiler/optimizing/sharpening.cc
+++ b/compiler/optimizing/sharpening.cc
@@ -20,6 +20,7 @@
#include "utils/dex_cache_arrays_layout-inl.h"
#include "driver/compiler_driver.h"
#include "nodes.h"
+#include "runtime.h"
namespace art {
@@ -78,7 +79,13 @@ void HSharpening::ProcessInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) {
method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kRecursive;
code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallSelf;
} else {
+ bool use_pc_relative_instructions =
+ ((direct_method == 0u || direct_code == static_cast<uintptr_t>(-1))) &&
+ ContainsElement(compiler_driver_->GetDexFilesForOatFile(), target_method.dex_file);
if (direct_method != 0u) { // Should we use a direct pointer to the method?
+ // Note: For JIT, kDirectAddressWithFixup doesn't make sense at all and while
+ // kDirectAddress would be fine for image methods, we don't support it at the moment.
+ DCHECK(!Runtime::Current()->UseJit());
if (direct_method != static_cast<uintptr_t>(-1)) { // Is the method pointer known now?
method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kDirectAddress;
method_load_data = direct_method;
@@ -87,24 +94,25 @@ void HSharpening::ProcessInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke) {
}
} else { // Use dex cache.
DCHECK_EQ(target_method.dex_file, &graph_->GetDexFile());
- DexCacheArraysLayout layout =
- compiler_driver_->GetDexCacheArraysLayout(target_method.dex_file);
- if (layout.Valid()) { // Can we use PC-relative access to the dex cache arrays?
+ if (use_pc_relative_instructions) { // Can we use PC-relative access to the dex cache arrays?
+ DCHECK(!Runtime::Current()->UseJit());
method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kDexCachePcRelative;
+ DexCacheArraysLayout layout(GetInstructionSetPointerSize(codegen_->GetInstructionSet()),
+ &graph_->GetDexFile());
method_load_data = layout.MethodOffset(target_method.dex_method_index);
} else { // We must go through the ArtMethod's pointer to resolved methods.
method_load_kind = HInvokeStaticOrDirect::MethodLoadKind::kDexCacheViaMethod;
}
}
if (direct_code != 0u) { // Should we use a direct pointer to the code?
+ // Note: For JIT, kCallPCRelative and kCallDirectWithFixup don't make sense at all and
+ // while kCallDirect would be fine for image methods, we don't support it at the moment.
+ DCHECK(!Runtime::Current()->UseJit());
if (direct_code != static_cast<uintptr_t>(-1)) { // Is the code pointer known now?
code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallDirect;
direct_code_ptr = direct_code;
- } else if (compiler_driver_->IsImage() ||
- target_method.dex_file == &graph_->GetDexFile()) {
+ } else if (use_pc_relative_instructions) {
// Use PC-relative calls for invokes within a multi-dex oat file.
- // TODO: Recognize when the target dex file is within the current oat file for
- // app compilation. At the moment we recognize only the boot image as multi-dex.
code_ptr_location = HInvokeStaticOrDirect::CodePtrLocation::kCallPCRelative;
} else { // The direct pointer will be known at link time.
// NOTE: This is used for app->boot calls when compiling an app against