diff options
author | 2024-09-03 10:40:35 +0100 | |
---|---|---|
committer | 2024-09-27 14:32:21 +0000 | |
commit | 871b53457d80d87c548998882626f62b506b25a8 (patch) | |
tree | 6a8f92e92610aed1db4a2b3810acc37d58300f62 | |
parent | d53f0ae0e7a045c29a3e270504ef8b82bf0581b9 (diff) |
Turn kNumPackedOpcodes enum into constexpr
And do cleanups related to it.
Change-Id: Ie24219984139eb9964fce1119f97b4d4e338dd55
-rw-r--r-- | libdexfile/dex/dex_instruction.h | 5 | ||||
-rw-r--r-- | runtime/interpreter/mterp/nterp.cc | 5 |
2 files changed, 5 insertions, 5 deletions
diff --git a/libdexfile/dex/dex_instruction.h b/libdexfile/dex/dex_instruction.h index ff6fcf7bd4..f6950af9a0 100644 --- a/libdexfile/dex/dex_instruction.h +++ b/libdexfile/dex/dex_instruction.h @@ -29,9 +29,8 @@ namespace art { class DexFile; -enum { - kNumPackedOpcodes = 0x100 -}; +// The number of Dalvik opcodes. +static constexpr size_t kNumPackedOpcodes = 0x100; class Instruction { public: diff --git a/runtime/interpreter/mterp/nterp.cc b/runtime/interpreter/mterp/nterp.cc index a3e72725ce..9f627186bf 100644 --- a/runtime/interpreter/mterp/nterp.cc +++ b/runtime/interpreter/mterp/nterp.cc @@ -106,10 +106,11 @@ void CheckNterpAsmConstants() { * which one did, but if any one is too big the total size will * overflow. */ - const int width = kNterpHandlerSize; + constexpr size_t width = kNterpHandlerSize; ptrdiff_t interp_size = reinterpret_cast<uintptr_t>(artNterpAsmInstructionEnd) - reinterpret_cast<uintptr_t>(artNterpAsmInstructionStart); - if ((interp_size == 0) || (interp_size != (art::kNumPackedOpcodes * width))) { + static_assert(kNumPackedOpcodes * width != 0); + if (interp_size != kNumPackedOpcodes * width) { LOG(FATAL) << "ERROR: unexpected asm interp size " << interp_size << "(did an instruction handler exceed " << width << " bytes?)"; } |