Added second pass which does code flow checking to verifier.
Ran this through libcore and it finds no errors, but I still need to
create tests to make sure it catches errors when it should. Also, it's
still missing 2 pieces, replacement of failing opcodes and generation of
the register map.
Change-Id: I0f4c4c20751b5b030ca44c23e1d1c2e133404e0c
diff --git a/src/dex_instruction.h b/src/dex_instruction.h
index 8cf645d..3934d7d 100644
--- a/src/dex_instruction.h
+++ b/src/dex_instruction.h
@@ -87,6 +87,23 @@
kVerifyError = 0x80000,
};
+ /*
+ * Holds the contents of a decoded instruction.
+ */
+ struct DecodedInstruction {
+ uint32_t vA_;
+ uint32_t vB_;
+ uint64_t vB_wide_; /* for kFmt51l */
+ uint32_t vC_;
+ uint32_t arg_[5]; /* vC/D/E/F/G in invoke or filled-new-array */
+ Code opcode_;
+
+ DecodedInstruction(const Instruction* inst) {
+ inst->Decode(vA_, vB_, vB_wide_, vC_, arg_);
+ opcode_ = inst->Opcode();
+ }
+ };
+
// Decodes this instruction, populating its arguments.
void Decode(uint32_t &vA, uint32_t &vB, uint64_t &vB_wide, uint32_t &vC, uint32_t arg[]) const;
@@ -115,6 +132,11 @@
return kInstructionFormats[Opcode()];
}
+ // Returns the flags for the current instruction.
+ int Flag() const {
+ return kInstructionFlags[Opcode()];
+ }
+
// Returns true if this instruction is a branch.
bool IsBranch() const {
return (kInstructionFlags[Opcode()] & kBranch) != 0;