summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2013-09-06 14:52:10 +0200
committerSebastien Hertz <shertz@google.com>2013-09-06 14:52:10 +0200
commit1e54d68ce8e77dfe63340275d11a072c5184c89a (patch)
tree08454be7d08352d228e6a6078d53226d6fb92880
parentc8c4e2a4edfdafb18047b2392a8f72ae93119bc2 (diff)
downloadart-1e54d68ce8e77dfe63340275d11a072c5184c89a.zip
art-1e54d68ce8e77dfe63340275d11a072c5184c89a.tar.gz
art-1e54d68ce8e77dfe63340275d11a072c5184c89a.tar.bz2
Disable devirtualization detection in DEX-to-DEX compiler.
This CL allows the DEX-to-DEX compiler to disable devirtualization detection. This allows to quicken invoke-virtual/range instructions that used to be eligible for devirtualization. Bug: 10632943 Change-Id: I6c9f4d3249cf42b47f004be5825b3186fa83501e
-rw-r--r--compiler/dex/dex_to_dex_compiler.cc5
-rw-r--r--compiler/dex/mir_dataflow.cc2
-rw-r--r--compiler/dex/quick/gen_invoke.cc2
-rw-r--r--compiler/driver/compiler_driver.cc10
-rw-r--r--compiler/driver/compiler_driver.h3
-rw-r--r--compiler/llvm/gbc_expander.cc2
6 files changed, 13 insertions, 11 deletions
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index a0e2c1e..2a4d3d5 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -298,11 +298,12 @@ void DexCompiler::CompileInvokeVirtual(Instruction* inst,
int vtable_idx;
uintptr_t direct_code;
uintptr_t direct_method;
+ // TODO: support devirtualization.
+ const bool kEnableDevirtualization = false;
bool fast_path = driver_.ComputeInvokeInfo(&unit_, dex_pc, invoke_type,
target_method, vtable_idx,
direct_code, direct_method,
- false);
- // TODO: support devirtualization.
+ false, kEnableDevirtualization);
if (fast_path && original_invoke_type == invoke_type) {
if (vtable_idx >= 0 && IsUint(16, vtable_idx)) {
VLOG(compiler) << "Quickening " << Instruction::Name(inst->Opcode())
diff --git a/compiler/dex/mir_dataflow.cc b/compiler/dex/mir_dataflow.cc
index 3a73717..42ca5dc 100644
--- a/compiler/dex/mir_dataflow.cc
+++ b/compiler/dex/mir_dataflow.cc
@@ -1224,7 +1224,7 @@ bool MIRGraph::InvokeUsesMethodStar(MIR* mir) {
type, target_method,
vtable_idx,
direct_code, direct_method,
- false) &&
+ false, true) &&
!(cu_->enable_debug & (1 << kDebugSlowInvokePath));
return (((type == kDirect) || (type == kStatic)) &&
fast_path && ((direct_code == 0) || (direct_method == 0)));
diff --git a/compiler/dex/quick/gen_invoke.cc b/compiler/dex/quick/gen_invoke.cc
index 073b550..a4ab15d 100644
--- a/compiler/dex/quick/gen_invoke.cc
+++ b/compiler/dex/quick/gen_invoke.cc
@@ -1359,7 +1359,7 @@ void Mir2Lir::GenInvoke(CallInfo* info) {
info->type, target_method,
vtable_idx,
direct_code, direct_method,
- true) && !SLOW_INVOKE_PATH;
+ true, true) && !SLOW_INVOKE_PATH;
if (info->type == kInterface) {
if (fast_path) {
p_null_ck = &null_ck;
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 634d3bc..1468b87 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -1099,7 +1099,7 @@ bool CompilerDriver::ComputeInvokeInfo(const DexCompilationUnit* mUnit, const ui
MethodReference& target_method,
int& vtable_idx,
uintptr_t& direct_code, uintptr_t& direct_method,
- bool update_stats) {
+ bool update_stats, bool enable_devirtualization) {
ScopedObjectAccess soa(Thread::Current());
vtable_idx = -1;
direct_code = 0;
@@ -1130,7 +1130,7 @@ bool CompilerDriver::ComputeInvokeInfo(const DexCompilationUnit* mUnit, const ui
}
if (referrer_class->CanAccess(methods_class) &&
referrer_class->CanAccessMember(methods_class, resolved_method->GetAccessFlags())) {
- const bool kEnableFinalBasedSharpening = true;
+ const bool enableFinalBasedSharpening = enable_devirtualization;
// Sharpen a virtual call into a direct call when the target is known not to have been
// overridden (ie is final).
bool can_sharpen_virtual_based_on_type =
@@ -1142,7 +1142,7 @@ bool CompilerDriver::ComputeInvokeInfo(const DexCompilationUnit* mUnit, const ui
resolved_method->GetMethodIndex() < methods_class->GetVTable()->GetLength() &&
(methods_class->GetVTable()->Get(resolved_method->GetMethodIndex()) == resolved_method);
- if (kEnableFinalBasedSharpening && (can_sharpen_virtual_based_on_type ||
+ if (enableFinalBasedSharpening && (can_sharpen_virtual_based_on_type ||
can_sharpen_super_based_on_type)) {
// Sharpen a virtual call into a direct call. The method_idx is into referrer's
// dex cache, check that this resolved method is where we expect it.
@@ -1157,8 +1157,8 @@ bool CompilerDriver::ComputeInvokeInfo(const DexCompilationUnit* mUnit, const ui
invoke_type = kDirect;
return true;
}
- const bool kEnableVerifierBasedSharpening = true;
- if (kEnableVerifierBasedSharpening && (invoke_type == kVirtual ||
+ const bool enableVerifierBasedSharpening = enable_devirtualization;
+ if (enableVerifierBasedSharpening && (invoke_type == kVirtual ||
invoke_type == kInterface)) {
// Did the verifier record a more precise invoke target based on its type information?
const MethodReference caller_method(mUnit->GetDexFile(), mUnit->GetDexMethodIndex());
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index fa1b8f9..c324590 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -183,7 +183,8 @@ class CompilerDriver {
// index.
bool ComputeInvokeInfo(const DexCompilationUnit* mUnit, const uint32_t dex_pc,
InvokeType& type, MethodReference& target_method, int& vtable_idx,
- uintptr_t& direct_code, uintptr_t& direct_method, bool update_stats)
+ uintptr_t& direct_code, uintptr_t& direct_method, bool update_stats,
+ bool enable_devirtualization)
LOCKS_EXCLUDED(Locks::mutator_lock_);
bool IsSafeCast(const MethodReference& mr, uint32_t dex_pc);
diff --git a/compiler/llvm/gbc_expander.cc b/compiler/llvm/gbc_expander.cc
index 4f6fa0a..19c8049 100644
--- a/compiler/llvm/gbc_expander.cc
+++ b/compiler/llvm/gbc_expander.cc
@@ -849,7 +849,7 @@ llvm::Value* GBCExpanderPass::EmitInvoke(llvm::CallInst& call_inst) {
invoke_type, target_method,
vtable_idx,
direct_code, direct_method,
- true);
+ true, true);
// Load the method object
llvm::Value* callee_method_object_addr = NULL;