From a51a0b0300268b605e3ad71b0e87ff394032c5e7 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 21 May 2014 12:08:39 +0100 Subject: Method inlining across dex files in boot image. Fix LoadCodeAddress() and LoadMethodAddress() to use the dex file in addition to the method index to uniquely identify the literal. With that fix in place, when we have both the direct code and the direct method, we can safely pass the actual target method id instead of the method id from the same dex file in the method lowering info. This was already done for calls from apps into boot image (and thus there was a bug with a tiny risk of the wrong literal being used) and now we also do that for calls within the boot image. The latter allows the inlining pass to inline many more methods than before in the boot image. Bug: 15021903 Change-Id: Ic765ce9809b43ef07e7db32b8e3fbc9acb09147f --- compiler/driver/compiler_driver.cc | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index eb62f1b577..b8c33a07e0 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -1152,28 +1152,22 @@ void CompilerDriver::GetCodeAndMethodForDirectCall(InvokeType* type, InvokeType *type = sharp_type; } } else { - if (compiling_boot) { + bool method_in_image = compiling_boot || + Runtime::Current()->GetHeap()->FindSpaceFromObject(method, false)->IsImageSpace(); + if (method_in_image) { + CHECK(!method->IsAbstract()); *type = sharp_type; - *direct_method = -1; - *direct_code = -1; + *direct_method = compiling_boot ? -1 : reinterpret_cast(method); + *direct_code = compiling_boot ? -1 : compiler_->GetEntryPointOf(method); + target_method->dex_file = method->GetDeclaringClass()->GetDexCache()->GetDexFile(); + target_method->dex_method_index = method->GetDexMethodIndex(); + } else if (!must_use_direct_pointers) { + // Set the code and rely on the dex cache for the method. + *type = sharp_type; + *direct_code = compiler_->GetEntryPointOf(method); } else { - bool method_in_image = - Runtime::Current()->GetHeap()->FindSpaceFromObject(method, false)->IsImageSpace(); - if (method_in_image) { - CHECK(!method->IsAbstract()); - *type = sharp_type; - *direct_method = reinterpret_cast(method); - *direct_code = compiler_->GetEntryPointOf(method); - target_method->dex_file = method->GetDeclaringClass()->GetDexCache()->GetDexFile(); - target_method->dex_method_index = method->GetDexMethodIndex(); - } else if (!must_use_direct_pointers) { - // Set the code and rely on the dex cache for the method. - *type = sharp_type; - *direct_code = compiler_->GetEntryPointOf(method); - } else { - // Direct pointers were required but none were available. - VLOG(compiler) << "Dex cache devirtualization failed for: " << PrettyMethod(method); - } + // Direct pointers were required but none were available. + VLOG(compiler) << "Dex cache devirtualization failed for: " << PrettyMethod(method); } } } -- cgit v1.2.3-59-g8ed1b