Generate code for loops formed with the new builder

Adapt the existing counted loop analysis and range/null check
elimination code to work with the new loop building heuristics.
Cleaned up the old ad-hoc loop builder.

Suspend polling is enabled by default for loops. The backward chaining
cell will be used in self-verification and profiling mode.

If the loop includes accesses to resolved fields/classes, abort code
generation for now and revert to the basic acyclic trace. Added
tests/090-loop-formation to make sure the JIT won't choke on such
instructions.

Change-Id: Idbc57df0a745be3b692f68c1acb6d4861c537f75
diff --git a/vm/compiler/CompilerIR.h b/vm/compiler/CompilerIR.h
index 7b9987b..bdb69ce 100644
--- a/vm/compiler/CompilerIR.h
+++ b/vm/compiler/CompilerIR.h
@@ -54,11 +54,9 @@
     kChainingCellGap,
     /* Don't insert new fields between Gap and Last */
     kChainingCellLast = kChainingCellGap + 1,
-    kMethodEntryBlock,
-    kTraceEntryBlock,
+    kEntryBlock,
     kDalvikByteCode,
-    kTraceExitBlock,
-    kMethodExitBlock,
+    kExitBlock,
     kPCReconstruction,
     kExceptionHandling,
     kCatchEntry,
@@ -255,12 +253,13 @@
      */
     const u2 *switchOverflowPad;
 
-    /* New fields only for method-based compilation */
     JitMode jitMode;
     int numReachableBlocks;
     int numDalvikRegisters;             // method->registersSize + inlined
     BasicBlock *entryBlock;
     BasicBlock *exitBlock;
+    BasicBlock *puntBlock;              // punting to interp for exceptions
+    BasicBlock *backChainBlock;         // for loop-trace
     BasicBlock *curBlock;
     BasicBlock *nextCodegenBlock;       // for extended trace codegen
     GrowableList dfsOrder;
@@ -272,6 +271,7 @@
     BitVector *tempSSARegisterV;        // numSSARegs
     bool printSSANames;
     void *blockLabelList;
+    bool quitLoopMode;                  // cold path/complex bytecode
 } CompilationUnit;
 
 #if defined(WITH_SELF_VERIFICATION)