diff options
author | 2019-06-06 20:16:07 -0700 | |
---|---|---|
committer | 2019-06-07 23:05:24 +0000 | |
commit | 93adcb53c77f4f04dfebd30b94e8ea9936aa8abb (patch) | |
tree | bdf638b78c045eed106ace99fbdc64506712d8ea | |
parent | 01f2e3a488fa06d98e2efbaf3ea8066d8457f216 (diff) |
ART: Remove some compile-time info points
Remove no longer needed compile-time info points in the verifier. Only
check-casts are still reliant on support for elision.
This reduces the number of pre-populated register lines in a large
app by 70%, and the number of instructions executed during verification
by about 2%.
Bug: 110852609
Test: m test-art-host
Change-Id: Iefa8253749b1a2750f57360e08ddfb502d0478b1
-rw-r--r-- | compiler/dex/verified_method.cc | 1 | ||||
-rw-r--r-- | runtime/verifier/instruction_flags.h | 5 | ||||
-rw-r--r-- | runtime/verifier/method_verifier.cc | 30 |
3 files changed, 11 insertions, 25 deletions
diff --git a/compiler/dex/verified_method.cc b/compiler/dex/verified_method.cc index 54f216a64d..172ec6b102 100644 --- a/compiler/dex/verified_method.cc +++ b/compiler/dex/verified_method.cc @@ -76,6 +76,7 @@ void VerifiedMethod::GenerateSafeCastSet(verifier::MethodVerifier* method_verifi continue; } const verifier::RegisterLine* line = method_verifier->GetRegLine(dex_pc); + DCHECK(line != nullptr) << "Did not have line for dex pc 0x" << std::hex << dex_pc; const verifier::RegType& reg_type(line->GetRegisterType(method_verifier, inst.VRegA_21c())); const verifier::RegType& cast_type = diff --git a/runtime/verifier/instruction_flags.h b/runtime/verifier/instruction_flags.h index e5e71a4d07..6cd2865f25 100644 --- a/runtime/verifier/instruction_flags.h +++ b/runtime/verifier/instruction_flags.h @@ -102,11 +102,6 @@ class InstructionFlags final { return (flags_ & (1 << kReturn)) != 0; } - void SetCompileTimeInfoPointAndReturn() { - SetCompileTimeInfoPoint(); - SetReturn(); - } - std::string ToString() const; private: diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index e838e3a861..ee91efaa03 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -97,8 +97,6 @@ void PcToRegisterLineTable::Init(RegisterTrackingMode mode, case kTrackRegsBranches: interesting = flags[i].IsBranchTarget(); break; - default: - break; } if (interesting) { register_lines_[i].reset(RegisterLine::Create(registers_size, allocator, reg_types)); @@ -1031,31 +1029,20 @@ bool MethodVerifier<kVerifierDebug>::ScanTryCatchBlocks() { template <bool kVerifierDebug> template <bool kAllowRuntimeOnlyInstructions> bool MethodVerifier<kVerifierDebug>::VerifyInstructions() { - /* Flag the start of the method as a branch target, and a GC point due to stack overflow errors */ + // Flag the start of the method as a branch target. GetModifiableInstructionFlags(0).SetBranchTarget(); - GetModifiableInstructionFlags(0).SetCompileTimeInfoPoint(); for (const DexInstructionPcPair& inst : code_item_accessor_) { const uint32_t dex_pc = inst.DexPc(); if (!VerifyInstruction<kAllowRuntimeOnlyInstructions>(&inst.Inst(), dex_pc)) { DCHECK_NE(failures_.size(), 0U); return false; } - /* Flag instructions that are garbage collection points */ - // All invoke points are marked as "Throw" points already. - // We are relying on this to also count all the invokes as interesting. - if (inst->IsBranch()) { - GetModifiableInstructionFlags(dex_pc).SetCompileTimeInfoPoint(); - // The compiler also needs safepoints for fall-through to loop heads. - // Such a loop head must be a target of a branch. - int32_t offset = 0; - bool cond, self_ok; - bool target_ok = GetBranchOffset(dex_pc, &offset, &cond, &self_ok); - DCHECK(target_ok); - GetModifiableInstructionFlags(dex_pc + offset).SetCompileTimeInfoPoint(); - } else if (inst->IsSwitch() || inst->IsThrow()) { + // Flag some interesting instructions. + if (inst->IsReturn()) { + GetModifiableInstructionFlags(dex_pc).SetReturn(); + } else if (inst->Opcode() == Instruction::CHECK_CAST) { + // The dex-to-dex compiler wants type information to elide check-casts. GetModifiableInstructionFlags(dex_pc).SetCompileTimeInfoPoint(); - } else if (inst->IsReturn()) { - GetModifiableInstructionFlags(dex_pc).SetCompileTimeInfoPointAndReturn(); } } return true; @@ -1588,7 +1575,10 @@ bool MethodVerifier<kVerifierDebug>::VerifyCodeFlow() { const uint16_t registers_size = code_item_accessor_.RegistersSize(); /* Create and initialize table holding register status */ - reg_table_.Init(fill_register_lines_ ? kTrackRegsAll : kTrackCompilerInterestPoints, + RegisterTrackingMode base_mode = Runtime::Current()->IsAotCompiler() + ? kTrackCompilerInterestPoints + : kTrackRegsBranches; + reg_table_.Init(fill_register_lines_ ? kTrackRegsAll : base_mode, insn_flags_.get(), code_item_accessor_.InsnsSizeInCodeUnits(), registers_size, |