Verifier clean up.

This is the first part in trying to move to a more rigorous mode of
asserting the validity of garbage collection maps.
In the bring over of the verifier from Dalvik a large class had been
created where all of the Dalvik/Dex functions were static methods of
that class. This rewrite introduces 3 key classes, Verifier that
orchestrates the verification of a method, RegisterLine which describes
the types associated with registers for a particular PC and RegType
which describes the current type of a register within a line. The
functionality is brought over from Dalvik but cleaned up to not do
things like goto. Failing within the verifier is also cleaned up. By
virtue of having stateful objects the interfaces between different
aspects of the verifier are greatly simplified.
To save space, RegTypes are cached upto a maximum possible 2^16, and
given an Id. As the number of RegTypes is typically small this means
that we have a full OO implementation but at a lower space cost than the
current convention that uses botched together enum values requiring
32bits of storage in a RegisterLine rather than 16bits (ie half the
space requirement per register in a register line). To make use of
this space more rigorous monitor verification is brought back, and
ultimately I think we can work around bug 3215458 with richer RegTypes
that are aware of literal objects.
The code removes short cuts that had been added to Dalvik's verifier and
appear illegitimate, it also fixes a large number of bugs in the
description of the verifier.
Where possible the spaghetti of code is replaced with straight line
if-then-elsif.. code that clearly follows the ordering semantics of the
specification. The code is also aiming toward having a more type
rigorous description of the verification process, and when this isn't
possible following the description convention of the specification.

Change-Id: Id25b742018a2ad5ea95687973cca610d7e19513c
diff --git a/src/dex_instruction.h b/src/dex_instruction.h
index 2c1a397..36ea295 100644
--- a/src/dex_instruction.h
+++ b/src/dex_instruction.h
@@ -9,6 +9,8 @@
 
 namespace art {
 
+class DexFile;
+
 class Instruction {
  public:
   // NOP-encoded switch-statement signatures.
@@ -108,8 +110,8 @@
   // 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;
 
-  // Returns the size in bytes of this instruction.
-  size_t Size() const;
+  // Returns the size in 2 byte code units, for this instruction.
+  size_t SizeInCodeUnits() const;
 
   // Returns a pointer to the next instruction in the stream.
   const Instruction* Next() const;
@@ -123,7 +125,7 @@
   Code Opcode() const;
 
   // Reads an instruction out of the stream at the specified address.
-  static const Instruction* At(const byte* code) {
+  static const Instruction* At(const uint16_t* code) {
     CHECK(code != NULL);
     return reinterpret_cast<const Instruction*>(code);
   }
@@ -187,6 +189,12 @@
              kVerifySwitchTargets | kVerifyVarArg | kVerifyVarArgRange | kVerifyError));
   }
 
+  // Dump code_units worth of this instruction, padding to code_units for shorter instructions
+  void DumpHex(std::ostream& os, size_t code_units) const;
+
+  // Dump decoded version of instruction
+  void Dump(std::ostream& os, const DexFile*) const;
+
  private:
   static const char* const kInstructionNames[];
   static InstructionFormat const kInstructionFormats[];
@@ -194,6 +202,7 @@
   static int const kInstructionVerifyFlags[];
   DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction);
 };
+std::ostream& operator<<(std::ostream& os, const Instruction& rhs);
 
 }  // namespace art