diff options
author | 2016-01-14 18:43:36 +0000 | |
---|---|---|
committer | 2016-01-14 18:43:36 +0000 | |
commit | 7b4199a5fa9f151fbf3af2a34f26d04215a1016c (patch) | |
tree | 111493b5fee26087dcc8abc1a1f56a140d549c8d /compiler/dex/quick/quick_compiler.cc | |
parent | 15db4dcfcc17dfe6c41d3c7b26355ccfa2504f4e (diff) | |
parent | 705ad49f353d3f90d8b63625aca2c2035bacdbef (diff) |
Merge "Support directly invoking interface default methods"
Diffstat (limited to 'compiler/dex/quick/quick_compiler.cc')
-rw-r--r-- | compiler/dex/quick/quick_compiler.cc | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/compiler/dex/quick/quick_compiler.cc b/compiler/dex/quick/quick_compiler.cc index 3260a7a050..ebc9a2c9ea 100644 --- a/compiler/dex/quick/quick_compiler.cc +++ b/compiler/dex/quick/quick_compiler.cc @@ -520,7 +520,12 @@ static bool CanCompileShorty(const char* shorty, InstructionSet instruction_set) // In the rare cases we compile experimental opcodes, the runtime has an option to enable it, // which will force scanning for any unsupported opcodes. static bool SkipScanningUnsupportedOpcodes(InstructionSet instruction_set) { - if (UNLIKELY(kUnsupportedOpcodesSize[instruction_set] == 0U)) { + Runtime* runtime = Runtime::Current(); + if (UNLIKELY(runtime->AreExperimentalFlagsEnabled(ExperimentalFlags::kDefaultMethods))) { + // Always need to scan opcodes if we have default methods since invoke-super for interface + // methods is never going to be supported in the quick compiler. + return false; + } else if (UNLIKELY(kUnsupportedOpcodesSize[instruction_set] == 0U)) { // All opcodes are supported no matter what. Usually not the case // since experimental opcodes are not implemented in the quick compiler. return true; @@ -538,8 +543,28 @@ static bool SkipScanningUnsupportedOpcodes(InstructionSet instruction_set) { } } +bool QuickCompiler::CanCompileInstruction(const MIR* mir, + const DexFile& dex_file) const { + switch (mir->dalvikInsn.opcode) { + // Quick compiler won't support new instruction semantics to invoke-super into an interface + // method + case Instruction::INVOKE_SUPER: // Fall-through + case Instruction::INVOKE_SUPER_RANGE: { + DCHECK(mir->dalvikInsn.IsInvoke()); + uint32_t invoke_method_idx = mir->dalvikInsn.vB; + const DexFile::MethodId& method_id = dex_file.GetMethodId(invoke_method_idx); + const DexFile::ClassDef* class_def = dex_file.FindClassDef(method_id.class_idx_); + // False if we are an interface i.e. !(java_access_flags & kAccInterface) + return class_def != nullptr && ((class_def->GetJavaAccessFlags() & kAccInterface) == 0); + } + default: + return true; + } +} + // Skip the method that we do not support currently. -bool QuickCompiler::CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, +bool QuickCompiler::CanCompileMethod(uint32_t method_idx, + const DexFile& dex_file, CompilationUnit* cu) const { // This is a limitation in mir_graph. See MirGraph::SetNumSSARegs. if (cu->mir_graph->GetNumOfCodeAndTempVRs() > kMaxAllowedDalvikRegisters) { @@ -580,6 +605,9 @@ bool QuickCompiler::CanCompileMethod(uint32_t method_idx, const DexFile& dex_fil << MIRGraph::extended_mir_op_names_[opcode - kMirOpFirst]; } return false; + } else if (!CanCompileInstruction(mir, dex_file)) { + VLOG(compiler) << "Cannot compile dalvik opcode : " << mir->dalvikInsn.opcode; + return false; } // Check if it invokes a prototype that we cannot support. if (std::find(kInvokeOpcodes, kInvokeOpcodes + arraysize(kInvokeOpcodes), opcode) |