Various improvements to interpreter.
- Created separate Next_xxx methods to get the next instruction to
avoid having to look up the size based on the opcode.
- Moved exception handling to after throwing instructions only.
- Added a test of all thread flags before checking for suspend during
the interpreter execute loop.
- Made it unlikely that instrumentation has dex pc listeners for
DexPcMovedEvent.
Change-Id: I88afc98cf42f2e36c747582df8e74669d24ef864
diff --git a/src/dex_instruction.h b/src/dex_instruction.h
index 45c93ef..218acb6 100644
--- a/src/dex_instruction.h
+++ b/src/dex_instruction.h
@@ -169,6 +169,33 @@
return reinterpret_cast<const Instruction*>(ptr + current_size_in_bytes);
}
+ // Returns a pointer to the instruction after this 1xx instruction in the stream.
+ const Instruction* Next_1xx() const {
+ DCHECK(FormatOf(Opcode()) >= k10x && FormatOf(Opcode()) <= k10t);
+ size_t current_size_in_bytes = 1 * sizeof(uint16_t);
+ const uint8_t* ptr = reinterpret_cast<const uint8_t*>(this);
+ return reinterpret_cast<const Instruction*>(ptr + current_size_in_bytes);
+ }
+
+ // Returns a pointer to the instruction after this 2xx instruction in the stream.
+ const Instruction* Next_2xx() const {
+ DCHECK(FormatOf(Opcode()) >= k20t && FormatOf(Opcode()) <= k22c);
+ size_t current_size_in_bytes = 2 * sizeof(uint16_t);
+ const uint8_t* ptr = reinterpret_cast<const uint8_t*>(this);
+ return reinterpret_cast<const Instruction*>(ptr + current_size_in_bytes);
+ }
+
+ // Returns a pointer to the instruction after this 3xx instruction in the stream.
+ const Instruction* Next_3xx() const {
+ DCHECK(FormatOf(Opcode()) >= k32x && FormatOf(Opcode()) <= k3rc);
+ size_t current_size_in_bytes = 3 * sizeof(uint16_t);
+ const uint8_t* ptr = reinterpret_cast<const uint8_t*>(this);
+ return reinterpret_cast<const Instruction*>(ptr + current_size_in_bytes);
+ }
+
+ // Returns a pointer to the instruction after this 51l instruction in the stream.
+ const Instruction* Next_51l() const;
+
// Returns the name of this instruction's opcode.
const char* Name() const {
return Instruction::Name(Opcode());