Save/restore local table state on down calls.

Also add unit test.

Change-Id: Ia1dc54eaac20c4bbb1ca3d9ac2933d6ab0241261
diff --git a/src/indirect_reference_table.h b/src/indirect_reference_table.h
index a53983f..5595ae7 100644
--- a/src/indirect_reference_table.h
+++ b/src/indirect_reference_table.h
@@ -297,7 +297,7 @@
    * so may be larger than the actual number of "live" entries.
    */
   size_t Capacity() const {
-    return segmentState.parts.topIndex;
+    return segment_state_.parts.topIndex;
   }
 
   iterator begin() {
@@ -310,6 +310,9 @@
 
   void VisitRoots(Heap::RootVisitor* visitor, void* arg);
 
+  static Offset SegmentStateOffset() {
+    return Offset(OFFSETOF_MEMBER(IndirectReferenceTable, segment_state_));
+  }
  private:
   /*
    * Extract the table index from an indirect reference.
@@ -348,8 +351,8 @@
   bool GetChecked(IndirectRef) const;
   bool CheckEntry(const char*, IndirectRef, int) const;
 
-  /* semi-public - read/write by interpreter in native call handler */
-  IRTSegmentState segmentState;
+  /* semi-public - read/write by jni down calls */
+  IRTSegmentState segment_state_;
 
   /* bottom of the stack */
   const Object** table_;