Another round of scary indirect ref changes.

This change adds a not-really-working implementation to Jni.c, with
various changes #ifdefed throughout the code.  The ifdef is currently
disabled, so the old behavior should continue.  Eventually the old
version will be stripped out and the ifdefs removed.

This renames the stack's "localRefTop" field, which nudged a bunch of
code.  The name wasn't really right before (it's the *bottom* of the
local references), and it's even less right now.  This and one other
mterp-visible constant were changed, which caused some ripples through
mterp and the JIT, but the ifdeffing was limited to one in
asm-constants.h (and the constant is the same both ways, so toggling the
ifdef won't require rebuilding asm sources).

Some comments and arg names in ReferenceTable were updated for the
correct orientation of bottom vs. top.

Some adjustments were made to the JNI code, e.g. dvmCallMethod now needs
to understand if it needs to convert reference arguments from
local/global refs to pointers (it's called from various places
throughout the VM).
diff --git a/vm/Thread.c b/vm/Thread.c
index 3f63132..6a1e9aa 100644
--- a/vm/Thread.c
+++ b/vm/Thread.c
@@ -980,15 +980,22 @@
     /*
      * Initialize our reference tracking tables.
      *
-     * The JNI local ref table *must* be fixed-size because we keep pointers
-     * into the table in our stack frames.
-     *
      * Most threads won't use jniMonitorRefTable, so we clear out the
      * structure but don't call the init function (which allocs storage).
      */
+#ifdef USE_INDIRECT_REF
+    if (!dvmInitIndirectRefTable(&thread->jniLocalRefTable,
+            kJniLocalRefMin, kJniLocalRefMax, kIndirectKindLocal))
+        return false;
+#else
+    /*
+     * The JNI local ref table *must* be fixed-size because we keep pointers
+     * into the table in our stack frames.
+     */
     if (!dvmInitReferenceTable(&thread->jniLocalRefTable,
             kJniLocalRefMax, kJniLocalRefMax))
         return false;
+#endif
     if (!dvmInitReferenceTable(&thread->internalLocalRefTable,
             kInternalRefDefault, kInternalRefMax))
         return false;
@@ -1042,7 +1049,11 @@
 #endif
     }
 
+#ifdef USE_INDIRECT_REF
+    dvmClearIndirectRefTable(&thread->jniLocalRefTable);
+#else
     dvmClearReferenceTable(&thread->jniLocalRefTable);
+#endif
     dvmClearReferenceTable(&thread->internalLocalRefTable);
     if (&thread->jniMonitorRefTable.table != NULL)
         dvmClearReferenceTable(&thread->jniMonitorRefTable);
@@ -3742,6 +3753,20 @@
     }
 }
 
+static void gcScanIndirectRefTable(IndirectRefTable* pRefTable)
+{
+    Object** op = pRefTable->table;
+    int numEntries = dvmIndirectRefTableEntries(pRefTable);
+    int i;
+
+    for (i = 0; i < numEntries; i++) {
+        Object* obj = *op;
+        if (obj != NULL)
+            dvmMarkObjectNonNull(obj);
+        op++;
+    }
+}
+
 /*
  * Scan a Thread and mark any objects it references.
  */
@@ -3772,7 +3797,11 @@
 
     HPROF_SET_GC_SCAN_STATE(HPROF_ROOT_JNI_LOCAL, thread->threadId);
 
+#ifdef USE_INDIRECT_REF
+    gcScanIndirectRefTable(&thread->jniLocalRefTable);
+#else
     gcScanReferenceTable(&thread->jniLocalRefTable);
+#endif
 
     if (thread->jniMonitorRefTable.table != NULL) {
         HPROF_SET_GC_SCAN_STATE(HPROF_ROOT_JNI_MONITOR, thread->threadId);