diff options
author | 2017-05-15 10:17:30 -0700 | |
---|---|---|
committer | 2017-05-15 10:57:33 -0700 | |
commit | e05cc662505e13f0c29e777bd99b7f49db9c670b (patch) | |
tree | fa094ed3b9e8340fc1bf48538b49be343e5c66c7 | |
parent | 6fb693a39b263af3e62b97f8d9f2c2289cab3c1a (diff) |
ART: Add experimental constexpr
Add a constexpr flag to bypass a branch in the verifier when there
are no experimental dex instructions. Guarantee the value with
static_asserts.
Bug: 10921004
Test: m test-art-host
Change-Id: Ib77b6142c4d2debe4b4d4fec60c02d92b1e7349f
-rw-r--r-- | runtime/dex_instruction.cc | 8 | ||||
-rw-r--r-- | runtime/dex_instruction.h | 2 | ||||
-rw-r--r-- | runtime/verifier/method_verifier.cc | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/runtime/dex_instruction.cc b/runtime/dex_instruction.cc index 9f34c12d9a..7dc62ed4ec 100644 --- a/runtime/dex_instruction.cc +++ b/runtime/dex_instruction.cc @@ -537,6 +537,14 @@ struct InstructionStaticAsserts : private Instruction { DEX_INSTRUCTION_LIST(VAR_ARGS_RANGE_CHECK) #undef DEX_INSTRUCTION_LIST #undef VAR_ARGS_RANGE_CHECK + + #define EXPERIMENTAL_CHECK(o, c, pname, f, i, a, v) \ + static_assert(kHaveExperimentalInstructions || (((a) & kExperimental) == 0), \ + "Unexpected experimental instruction."); + #include "dex_instruction_list.h" + DEX_INSTRUCTION_LIST(EXPERIMENTAL_CHECK) + #undef DEX_INSTRUCTION_LIST + #undef EXPERIMENTAL_CHECK }; std::ostream& operator<<(std::ostream& os, const Instruction::Code& code) { diff --git a/runtime/dex_instruction.h b/runtime/dex_instruction.h index d269110570..6b9ec7d2c2 100644 --- a/runtime/dex_instruction.h +++ b/runtime/dex_instruction.h @@ -196,6 +196,8 @@ class Instruction { static constexpr uint32_t kMaxVarArgRegs = 5; + static constexpr bool kHaveExperimentalInstructions = false; + // Returns the size (in 2 byte code units) of this instruction. size_t SizeInCodeUnits() const { int result = kInstructionSizeInCodeUnits[Opcode()]; diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index acc918d326..a77ba6a7b2 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -1139,7 +1139,7 @@ bool MethodVerifier::VerifyInstructions() { } bool MethodVerifier::VerifyInstruction(const Instruction* inst, uint32_t code_offset) { - if (UNLIKELY(inst->IsExperimental())) { + if (Instruction::kHaveExperimentalInstructions && UNLIKELY(inst->IsExperimental())) { // Experimental instructions don't yet have verifier support implementation. // While it is possible to use them by themselves, when we try to use stable instructions // with a virtual register that was created by an experimental instruction, |