harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r587522 - in /harmony/enhanced/drlvm/trunk/vm/interpreter/src: interp_defs.h interp_exports.cpp interp_native_em64t.cpp interp_native_ia32.cpp interp_native_ipf.cpp interp_stack_trace.cpp interpreter.cpp interpreter_ti.cpp
Date Tue, 23 Oct 2007 14:41:38 GMT
Author: gshimansky
Date: Tue Oct 23 07:41:36 2007
New Revision: 587522

URL: http://svn.apache.org/viewvc?rev=587522&view=rev
Log:
Applied patch from HARMONY-4922
[drlvm][interpreter] Interpreter should be runtime switchable wrt compressed references


Modified:
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_defs.h
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_exports.cpp
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_em64t.cpp
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ipf.cpp
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_stack_trace.cpp
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_defs.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_defs.h?rev=587522&r1=587521&r2=587522&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_defs.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_defs.h Tue Oct 23 07:41:36 2007
@@ -79,7 +79,10 @@
 
 /** \def ASSERT_OBJECT(a)
   * \brief Checks the object.*/
-#define ASSERT_OBJECT(a) assert((a == 0) || ((*((a)->vt()->clss->get_class_handle()))->vt()->clss == VM_Global_State::loader_env->JavaLangClass_Class))
+#define ASSERT_OBJECT(a)                                       \
+    assert((a == 0) ||                                         \
+    ( (*((a)->vt()->clss->get_class_handle()))->vt()->clss ==  \
+            VM_Global_State::loader_env->JavaLangClass_Class))
 
 #ifndef INTERPRETER_USE_MALLOC_ALLOCATION
 /** \def ALLOC_FRAME(sz)
@@ -94,72 +97,74 @@
 #define FREE_FRAME(ptr) m_free(ptr)
 #endif
 
-/***** Compressed pointers on *****/
-#if defined _IPF_ || defined _EM64T_
-#define COMPRESS_MODE
+#if POINTER64
+#   define COMPACT_FIELDS
+#   define uword uint64
+#   define word int64
+#else
+#   define uword uint32
+#   define word int32
 #endif
 
-#if defined _IPF_ || defined _EM64T_
-#  define COMPACT_FIELDS
-#  define uword uint64
-#  define word int64
-#  ifdef COMPRESS_MODE
-#    define CREF COMPRESSED_REFERENCE
-#    define PTR32
-#  else
-#    define CREF ManagedObject*
-#  endif
+#if defined(POINTER64) && defined(REFS_USE_COMPRESSED)
+#define REF32                // Use compressed references
+typedef COMPRESSED_REFERENCE REF;
 #else
-// no define for: COMPACT_FIELDS
-/** The unsigned <code>int</code> value */
-#    define uword uint32
-/** The signed <code>int</code> value */
-#    define word int32
-/** The compressed reference */
-#    define CREF uint32
-#    define PTR32
+typedef ManagedObject* REF;  // Use uncompressed references
 #endif
 
-#ifdef COMPRESS_MODE
-/** \def COMPRESS_REF(ref)
-  * \brief Calls <code>compress_reference(ref)</code>.*/
-#define COMPRESS_REF(ref) compress_reference(ref)
-/** \def UNCOMPRESS_REF(cref)
-  * \brief Calls <code>uncompress_compressed_reference(cref)</code>.*/
-#define UNCOMPRESS_REF(cref) uncompress_compressed_reference(cref)
+#if defined(REF32) || !defined(POINTER64)
+#define VAL32 // Value is 32-bit
+#endif
 
-#else /* ! COMPRESS_MODE */
 
-/**
- * The fake compressed reference.
- * 
- * @param[in] obj - the object to compress
- * @return The compressed reference.
- */
-static inline CREF
-fake_compress_reference(ManagedObject *obj) {
-    return (CREF) obj;
-}
+// Create uncompressed value
+#define MAKEREFVAL(_val_)   (*((ManagedObject**)(&(_val_))))
+// Create compressed value
+#define MAKECRVAL(_val_)    (*((COMPRESSED_REFERENCE*)(&(_val_))))
+
+// Macros to compress/uncompress references in fiels and arrays
+// Note: VM references are references in heap and fields and arrays
+//       interpreter references are references in method stack and local vars
+#if defined(REFS_USE_COMPRESSED)
+// Both VM and interpreter references are compressed
+#define STORE_UREF_BY_ADDR(_addr_, _val_)                                    \
+    *((COMPRESSED_REFERENCE*)(_addr_)) = compress_reference(_val_)
+#define UNCOMPRESS_REF(cref) (uncompress_compressed_reference(MAKECRVAL(cref)))
+//----------------------
+#elif defined(REFS_USE_UNCOMPRESSED)
+// Both VM and interpreter references are uncompressed
+#define STORE_UREF_BY_ADDR(_addr_, _val_)                                    \
+    *((ManagedObject**)(_addr_)) = (ManagedObject*)(_val_)
+#define UNCOMPRESS_REF(cref) ((ManagedObject*)(cref))
+//----------------------
+#else // for REFS_USE_RUNTIME_SWITCH
+// interpreter refs are uncompressed; VM refs can be either
+#define STORE_UREF_BY_ADDR(_addr_, _val_)                                   \
+    if (REFS_IS_COMPRESSED_MODE) {                                          \
+        *((COMPRESSED_REFERENCE*)(_addr_)) = compress_reference(_val_);     \
+    } else {                                                                \
+        *((ManagedObject**)(_addr_)) = (ManagedObject*)(_val_);             \
+    }
+#define UNCOMPRESS_REF(cref)    ( REFS_IS_COMPRESSED_MODE ?                 \
+            (uncompress_compressed_reference(MAKECRVAL(cref))) :            \
+            (MAKEREFVAL(cref)))
+//----------------------
+#endif
 
-/**
- * Uncompresses the compressed reference.
- * 
- * @param[in] compressed_ref - the compressed reference
- * @return The uncompressed reference.
- */
-static inline ManagedObject*
-fake_uncompress_compressed_reference(CREF compressed_ref) {
-    return (ManagedObject*) compressed_ref;
-}
+// Macros for compressing/uncompressing referenceses in interpreter's
+// method stack and local vars
+#ifdef REF32
+#define COMPRESS_INTERP(ref)    (compress_reference(ref))
+#define UNCOMPRESS_INTERP(cref) (uncompress_compressed_reference(cref))
+#define REF_NULL                (MANAGED_NULL)
+#else // REF32
+#define COMPRESS_INTERP(ref)    ((ManagedObject*)(ref))
+#define UNCOMPRESS_INTERP(cref) ((ManagedObject*)(cref))
+#define REF_NULL                0
+#endif // REF32
 
-/** \def COMPRESS_REF(ref)
-  * \brief Calls <code>fake_compress_reference(ref)</code>.*/
-#define COMPRESS_REF(ref) fake_compress_reference(ref)
-/** \def UNCOMPRESS_REF(cref)
-  * \brief Calls <code>fake_uncompress_compressed_reference(cref)</code>.*/
-#define UNCOMPRESS_REF(cref) fake_uncompress_compressed_reference(cref)
 
-#endif
 
 /** Defines byte ordering in Value2 in different situations.*/
 
@@ -197,13 +202,13 @@
     int32 i;
 /** The float value.*/
     float f;
-/** The compressed reference.*/
-    CREF cr;
+///** Compressed/uncompressed reference.*/
+    REF ref;
 };
 
 /** Holds 64-bit values */
 union Value2 {
-#ifdef PTR32
+#ifdef VAL32
 /** Two 32-bit values */
     Value v[2];
 #else
@@ -215,6 +220,8 @@
     uint64 u64;
 /** The double value */
     double d;
+/** The reference */
+    ManagedObject* ref;
 };
 
 /** The local variable types.*/
@@ -361,7 +368,7 @@
 /** The storage for local variables of the executed Java method.*/
 class Locals {
     // local variable value
-    Value *var;
+    Value *vars;
     // references to the local variable type
     uint8 *refs;
     // locals size
@@ -689,8 +696,8 @@
 
 void
 Locals::init(void *ptr, uint32 size) {
-    var = (Value*) ptr;
-    refs = (uint8*)(var + size);
+    vars = (Value*) ptr;
+    refs = (uint8*)(vars + size);
     varNum = size;
     for(uint32 i = 0; i < varNum; i++) refs[i] = 0;
 }
@@ -703,12 +710,12 @@
 Value&
 Locals::operator () (uint32 id) {
     assert(id < varNum);
-    return var[id];
+    return vars[id];
 }
 
 void
 Locals::setLong(int idx, Value2 val) {
-#ifdef PTR32
+#ifdef VAL32
     operator() (idx+l0) = val.v[a0];
     operator() (idx+l1) = val.v[a1];
 #else
@@ -719,7 +726,7 @@
 Value2
 Locals::getLong(int idx) {
     Value2 val;
-#ifdef PTR32
+#ifdef VAL32
     val.v[a0] = operator() (idx+l0);
     val.v[a1] = operator() (idx+l1);
 #else
@@ -754,7 +761,7 @@
 
 void
 Stack::setLong(int idx, Value2 val) {
-#ifdef PTR32
+#ifdef VAL32
     pick(idx + s0) = val.v[a0];
     pick(idx + s1) = val.v[a1];
 #else
@@ -765,7 +772,7 @@
 Value2
 Stack::getLong(int idx) {
     Value2 val;
-#ifdef PTR32
+#ifdef VAL32
     val.v[a0] = pick(idx + s0);
     val.v[a1] = pick(idx + s1);
 #else

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_exports.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_exports.cpp?rev=587522&r1=587521&r2=587522&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_exports.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_exports.cpp Tue Oct 23 07:41:36 2007
@@ -141,10 +141,10 @@
 }
 
 EXPORT Boolean JIT_supports_compressed_references(JIT_Handle UNREF jh) {
-#if defined _IPF_ || defined _EM64T_
-    return true;
-#else
+#ifdef REFS_USE_UNCOMPRESSED
     return false;
+#else
+    return true;
 #endif
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_em64t.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_em64t.cpp?rev=587522&r1=587521&r2=587522&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_em64t.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_em64t.cpp Tue Oct 23 07:41:36 2007
@@ -326,17 +326,17 @@
             case JAVA_TYPE_ARRAY:
                 {
                     ASSERT_TAGS(prevFrame.stack.ref(pos));
-                    CREF& cr = prevFrame.stack.pick(pos--).cr;
-                    ASSERT_OBJECT(UNCOMPRESS_REF(cr));
-                    if (cr == 0) {
+                    REF& ref = prevFrame.stack.pick(pos--).ref;
+                    ASSERT_OBJECT(UNCOMPRESS_INTERP(ref));
+                    if (ref == 0) {
                         arg = 0;
                     } else {
-#ifdef COMPRESS_MODE
+#ifdef REF32
                         ObjectHandle new_handle = oh_allocate_local_handle();
-                        new_handle->object = UNCOMPRESS_REF(cr);
+                        new_handle->object = UNCOMPRESS_INTERP(ref);
                         arg = (uword) new_handle;
 #else
-                        arg = (uword) &cr;
+                        arg = (uword) &ref;
 #endif
                     }
                     if (n_ints != MAX_REG_INTS) {
@@ -459,9 +459,9 @@
                         << method->get_descriptor()->bytes <<
                         "\nVM WARNING: Not allowed, return NULL (0) instead\n");
                     }
-                    prevFrame.stack.pick().cr = COMPRESS_REF(*ref);
+                    prevFrame.stack.pick().ref = COMPRESS_INTERP(*ref);
                 } else {
-                    prevFrame.stack.pick().cr = 0;
+                    prevFrame.stack.pick().ref = 0;
                 }
                 prevFrame.stack.ref() = FLAG_OBJECT;
             }
@@ -615,17 +615,17 @@
             case JAVA_TYPE_ARRAY:
                 {
                     ASSERT_TAGS(prevFrame.stack.ref(pos));
-                    CREF& cr = prevFrame.stack.pick(pos--).cr;
-                    ASSERT_OBJECT(UNCOMPRESS_REF(cr));
-                    if (cr == 0) {
+                    REF& ref = prevFrame.stack.pick(pos--).ref;
+                    ASSERT_OBJECT(UNCOMPRESS_INTERP(ref));
+                    if (ref == 0) {
                         arg = 0;
                     } else {
-#ifdef COMPRESS_MODE
+#ifdef REF32
                         ObjectHandle new_handle = oh_allocate_local_handle();
-                        new_handle->object = UNCOMPRESS_REF(cr);
+                        new_handle->object = UNCOMPRESS_INTERP(ref);
                         arg = (uword) new_handle;
 #else
-                        arg = (uword) &cr;
+                        arg = (uword) &ref;
 #endif
                     }
                     if (n_ints != MAX_REG_INTS) {
@@ -745,9 +745,9 @@
                         << method->get_descriptor()->bytes <<
                         "\nVM WARNING: Not allowed, return NULL (0) instead\n");
                     }
-                    prevFrame.stack.pick().cr = COMPRESS_REF(*ref);
+                    prevFrame.stack.pick().ref = COMPRESS_INTERP(*ref);
                 } else {
-                    prevFrame.stack.pick().cr = 0;
+                    prevFrame.stack.pick().ref = 0;
                 }
                 prevFrame.stack.ref() = FLAG_OBJECT;
             }

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ia32.cpp?rev=587522&r1=587521&r2=587522&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ia32.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ia32.cpp Tue Oct 23 07:41:36 2007
@@ -290,18 +290,12 @@
             case JAVA_TYPE_ARRAY:
                 {
                     ASSERT_TAGS(prevFrame.stack.ref(pos));
-                    CREF& cr = prevFrame.stack.pick(pos--).cr;
-                    ASSERT_OBJECT(UNCOMPRESS_REF(cr));
-                    if (cr == 0) {
+                    REF& ref = prevFrame.stack.pick(pos--).ref;
+                    ASSERT_OBJECT(ref);
+                    if (ref == 0) {
                         args[argId++] = 0;
                     } else {
-#ifdef COMPRESS_MODE
-                        ObjectHandle new_handle = oh_allocate_local_handle();
-                        new_handle->object = UNCOMPRESS_REF(cr);
-                        args[argId++] = (uword) new_handle;
-#else
-                        args[argId++] = (uword) &cr;
-#endif
+                        args[argId++] = (uword) &ref;
                     }
                     while(*mtype == '[') mtype++;
                     if (*mtype == 'L')
@@ -381,9 +375,9 @@
                         << method->get_descriptor()->bytes <<
                         "\nVM WARNING: Not allowed, return NULL (0) instead\n");
                     }
-                    prevFrame.stack.pick().cr = COMPRESS_REF(*ref);
+                    prevFrame.stack.pick().ref = *ref;
                 } else {
-                    prevFrame.stack.pick().cr = 0;
+                    prevFrame.stack.pick().ref = 0;
                 }
                 prevFrame.stack.ref() = FLAG_OBJECT;
             }
@@ -527,18 +521,12 @@
             case JAVA_TYPE_ARRAY:
                 {
                     ASSERT_TAGS(prevFrame.stack.ref(pos));
-                    CREF& cr = prevFrame.stack.pick(pos--).cr;
-                    ASSERT_OBJECT(UNCOMPRESS_REF(cr));
-                    if (cr == 0) {
+                    REF& ref = prevFrame.stack.pick(pos--).ref;
+                    ASSERT_OBJECT(ref);
+                    if (ref == 0) {
                         args[argId++] = 0;
                     } else {
-#ifdef COMPRESS_MODE
-                        ObjectHandle new_handle = oh_allocate_local_handle();
-                        new_handle->object = UNCOMPRESS_REF(cr);
-                        args[argId++] = (uword) new_handle;
-#else
-                        args[argId++] = (uword) &cr;
-#endif
+                        args[argId++] = (uword) &ref;
                     }
                     while(*mtype == '[') mtype++;
                     if (*mtype == 'L')
@@ -619,9 +607,9 @@
                         << method->get_descriptor()->bytes <<
                         "\nVM WARNING: Not allowed, return NULL (0) instead\n");
                     }
-                    prevFrame.stack.pick().cr = COMPRESS_REF(*ref);
+                    prevFrame.stack.pick().ref = *ref;
                 } else {
-                    prevFrame.stack.pick().cr = 0;
+                    prevFrame.stack.pick().ref = 0;
                 }
                 prevFrame.stack.ref() = FLAG_OBJECT;
             }

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ipf.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ipf.cpp?rev=587522&r1=587521&r2=587522&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ipf.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ipf.cpp Tue Oct 23 07:41:36 2007
@@ -309,17 +309,17 @@
             case JAVA_TYPE_ARRAY:
                 {
                     ASSERT_TAGS(prevFrame.stack.ref(pos));
-                    CREF& cr = prevFrame.stack.pick(pos--).cr;
-                    ASSERT_OBJECT(UNCOMPRESS_REF(cr));
-                    if (cr == 0) {
+                    REF& ref = prevFrame.stack.pick(pos--).ref;
+                    ASSERT_OBJECT(UNCOMPRESS_INTERP(ref));
+                    if (ref == 0) {
                         args[argId++] = 0;
                     } else {
-#ifdef COMPRESS_MODE
+#ifdef REF32
                         ObjectHandle new_handle = oh_allocate_local_handle();
-                        new_handle->object = UNCOMPRESS_REF(cr);
+                        new_handle->object = UNCOMPRESS_INTERP(ref);
                         args[argId++] = (uword) new_handle;
 #else
-                        args[argId++] = (uword) &cr;
+                        args[argId++] = (uword) &ref;
 #endif
                     }
                     while(*mtype == '[') mtype++;
@@ -414,7 +414,7 @@
                 hythread_suspend_disable();
                 prevFrame.stack.popClearRef(sz);
 
-                CREF cr;
+                REF stack_ref;
                 prevFrame.stack.push();
                 if (ref != 0) {
                     ASSERT_OBJECT(*ref);
@@ -428,14 +428,14 @@
                         "\nVM WARNING: Not allowed, return NULL (0) instead\n");
                     }
                     if (*ref) {
-                        cr = COMPRESS_REF(*ref);
+                        stack_ref = COMPRESS_INTERP(*ref);
                     } else {
-                        cr = 0;
+                        stack_ref = 0;
                     }
                 } else {
-                    cr = 0;
+                    stack_ref = 0;
                 }
-                prevFrame.stack.pick().cr = cr;
+                prevFrame.stack.pick().ref = stack_ref;
                 prevFrame.stack.ref() = FLAG_OBJECT;
             }
             break;
@@ -583,17 +583,17 @@
             case JAVA_TYPE_ARRAY:
                 {
                     ASSERT_TAGS(prevFrame.stack.ref(pos));
-                    CREF& cr = prevFrame.stack.pick(pos--).cr;
-                    ASSERT_OBJECT(UNCOMPRESS_REF(cr));
-                    if (cr == 0) {
+                    REF& ref = prevFrame.stack.pick(pos--).ref;
+                    ASSERT_OBJECT(UNCOMPRESS_INTERP(ref));
+                    if (ref == 0) {
                         args[argId++] = 0;
                     } else {
-#ifdef COMPRESS_MODE
+#ifdef REF32
                         ObjectHandle new_handle = oh_allocate_local_handle();
-                        new_handle->object = UNCOMPRESS_REF(cr);
+                        new_handle->object = UNCOMPRESS_INTERP(ref);
                         args[argId++] = (uword) new_handle;
 #else
-                        args[argId++] = (uword) &cr;
+                        args[argId++] = (uword) &ref;
 #endif
                     }
                     while(*mtype == '[') mtype++;
@@ -688,7 +688,7 @@
                 hythread_suspend_disable();
                 prevFrame.stack.popClearRef(sz);
 
-                CREF cr;
+                REF stack_ref;
                 prevFrame.stack.push();
                 if (ref != 0) {
                     ASSERT_OBJECT(*ref);
@@ -703,14 +703,14 @@
 
                     }
                     if (*ref) {
-                        cr = COMPRESS_REF(*ref);
+                        stack_ref = COMPRESS_INTERP(*ref);
                     } else {
-                        cr = 0;
+                        stack_ref = 0;
                     }
                 } else {
-                    cr = 0;
+                    stack_ref = 0;
                 }
-                prevFrame.stack.pick().cr = cr;
+                prevFrame.stack.pick().ref = stack_ref;
                 prevFrame.stack.ref() = FLAG_OBJECT;
             }
             break;

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_stack_trace.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_stack_trace.cpp?rev=587522&r1=587521&r2=587522&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_stack_trace.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_stack_trace.cpp Tue Oct 23 07:41:36 2007
@@ -152,13 +152,14 @@
     interp_si_free(si);
 }
 
-#ifdef COMPRESS_MODE
+
+#if defined(REF32) // Compressed references; cref is COMPRESSED_REFERENCE
 #define vm_enumerate(cref,f) vm_enumerate_compressed_root_reference(cref,f)
-#else
-static inline void** m2v(CREF* obj) {
+#else // Uncompressed or runtime switchable; ref us uncompressed
+static inline void** m2v(REF* obj) {
     return (void**)obj;
 }
-#define vm_enumerate(cref,f) vm_enumerate_root_reference(m2v(cref),f)
+#define vm_enumerate(ref,f) vm_enumerate_root_reference(m2v(ref),f)
 #endif
 
 void
@@ -201,13 +202,13 @@
             for(i = 0; i <= si->stack.index; i++) {
                 if (si->stack.refs[i] == FLAG_OBJECT) {
                     DEBUG_GC("  Stack[" << i << "] ");
-                    CREF* cref = &si->stack.data[i].cr;
-                    ManagedObject *obj = UNCOMPRESS_REF(*cref);
+                    REF* ref = &si->stack.data[i].ref;
+                    ManagedObject *obj = UNCOMPRESS_INTERP(*ref);
                     if (obj == 0) {
                         DEBUG_GC("NULL");
                     } else {
                         DEBUG_GC(obj->vt()->clss->get_name()->bytes << endl);
-                        vm_enumerate(cref, FALSE);
+                        vm_enumerate(ref, FALSE); // CHECK!!! can we enumerate uncompressed ref in compressed mode
                     }
                 }
             }
@@ -217,13 +218,13 @@
             for(j = 0; j < si->locals.varNum; j++) {
                 if (si->locals.refs[j] == FLAG_OBJECT) {
                     DEBUG_GC("  Locals[" << j << "] ");
-                    CREF* cref = &si->locals.var[j].cr;
-                    ManagedObject *obj = UNCOMPRESS_REF(*cref);
+                    REF* ref = &si->locals.vars[j].ref;
+                    ManagedObject *obj = UNCOMPRESS_INTERP(*ref);
                     if (obj == 0) {
                         DEBUG_GC("NULL\n");
                     } else {
                         DEBUG_GC(obj->vt()->clss->get_name()->bytes << endl);
-                        vm_enumerate(cref, FALSE);
+                        vm_enumerate(ref, FALSE); // CHECK!!! can we enumerate uncompressed ref in compressed mode
                     }
                 }
             }
@@ -300,14 +301,14 @@
             for(i = 0; i <= si->stack.index; i++) {
                 if (si->stack.refs[i] == FLAG_OBJECT) {
                     DEBUG_GC("  Stack[" << i << "] ");
-                    CREF* cref = &si->stack.data[i].cr;
-                    ManagedObject *obj = UNCOMPRESS_REF(*cref);
+                    REF* ref = &si->stack.data[i].ref;
+                    ManagedObject *obj = UNCOMPRESS_INTERP(*ref);
                     if (obj == 0) {
                         DEBUG_GC("NULL");
                     } else {
                         DEBUG_GC(obj->vt()->clss->get_name()->bytes << endl);
                         vm_ti_enumerate_stack_root(ti_env,
-                            cref, (Managed_Object_Handle)obj, 
+                            ref, (Managed_Object_Handle)obj, 
                             JVMTI_HEAP_ROOT_STACK_LOCAL,
                             depth, method_id, slot++);
                     }
@@ -319,14 +320,14 @@
             for(j = 0; j < si->locals.varNum; j++) {
                 if (si->locals.refs[j] == FLAG_OBJECT) {
                     DEBUG_GC("  Locals[" << j << "] ");
-                    CREF* cref = &si->locals.var[j].cr;
-                    ManagedObject *obj = UNCOMPRESS_REF(*cref);
+                    REF* ref = &si->locals.vars[j].ref;
+                    ManagedObject *obj = UNCOMPRESS_INTERP(*ref);
                     if (obj == 0) {
                         DEBUG_GC("NULL\n");
                     } else {
                         DEBUG_GC(obj->vt()->clss->get_name()->bytes << endl);
                         vm_ti_enumerate_stack_root(ti_env,
-                            cref, (Managed_Object_Handle)obj, 
+                            ref, (Managed_Object_Handle)obj, 
                             JVMTI_HEAP_ROOT_STACK_LOCAL,
                             depth, method_id, slot++);
                     }

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp?rev=587522&r1=587521&r2=587522&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp Tue Oct 23 07:41:36 2007
@@ -162,7 +162,7 @@
 static inline void
 Opcode_ACONST_NULL(StackFrame& frame) {
     frame.stack.push();
-    frame.stack.pick().u = 0;
+    frame.stack.pick().ref = 0;
     frame.stack.ref() = FLAG_OBJECT;
     frame.ip++;
 }
@@ -230,7 +230,7 @@
     frame.stack.push();
     frame.stack.pick() = val;
     frame.stack.ref() = frame.locals.ref(varId);
-    if (frame.locals.ref(varId) == FLAG_OBJECT) { ASSERT_OBJECT(UNCOMPRESS_REF(val.cr)); }
+    if (frame.locals.ref(varId) == FLAG_OBJECT) { ASSERT_OBJECT(UNCOMPRESS_INTERP(val.ref)); }
     DEBUG_BYTECODE("var" << (int)varId << " -> stack (val = " << (int)frame.stack.pick().i << ")");
     frame.ip += 2;
 }
@@ -988,12 +988,10 @@
 #endif
 
     frame.stack.push();
-    if(cp.is_string(index)) {
-        // FIXME: is string reference packed??
-        // possibly not
+    if(cp.is_string(index))
+    {
         String* str = cp.get_string(index);
-        // FIXME: only compressed references
-        frame.stack.pick().cr = COMPRESS_REF(vm_instantiate_cp_string_resolved(str));
+        frame.stack.pick().ref = COMPRESS_INTERP(vm_instantiate_cp_string_resolved(str));
         frame.stack.ref() = FLAG_OBJECT;
         return !check_current_thread_exception();
     } 
@@ -1005,7 +1003,7 @@
         }
         assert(!hythread_is_suspend_enabled());
         
-        frame.stack.pick().cr = COMPRESS_REF(*(other_class->get_class_handle()));
+        frame.stack.pick().ref = COMPRESS_INTERP(*(other_class->get_class_handle()));
         frame.stack.ref() = FLAG_OBJECT;
         
         return !exn_raised();
@@ -1093,8 +1091,7 @@
         return;
     }
    
-    // COMPRESS_REF will fail assertion if array == 0 on ipf 
-    frame.stack.pick().cr = COMPRESS_REF((ManagedObject*)array);
+    frame.stack.pick().ref = COMPRESS_INTERP((ManagedObject*)array);
     DEBUG_BYTECODE(" (val = " << hex << (int)frame.stack.pick().i << ")");
     frame.stack.ref() = FLAG_OBJECT;
     frame.ip += 2;
@@ -1127,8 +1124,7 @@
     set_vector_length(array, length);
     DEBUG_BYTECODE("length = " << dec << length);
 
-    // COMPRESS_REF will fail assertion if array == 0 on ipf 
-    frame.stack.pick().cr = COMPRESS_REF((ManagedObject*)array);
+    frame.stack.pick().ref = COMPRESS_INTERP((ManagedObject*)array);
     frame.stack.ref() = FLAG_OBJECT;
     frame.ip += 3;
 }
@@ -1156,7 +1152,7 @@
             if (d < max_depth) max_depth = d;
         }
 
-        frame.stack.pick(depth - 1 - d).cr = 0;
+        frame.stack.pick(depth - 1 - d).ref = 0;
         frame.stack.ref(depth - 1 - d) = FLAG_OBJECT;
     }
 
@@ -1175,7 +1171,7 @@
         return false;
     }
     set_vector_length(array, length[0]);
-    frame.stack.pick(depth - 1).cr = COMPRESS_REF(array);
+    frame.stack.pick(depth - 1).ref = COMPRESS_INTERP(array);
     if (max_depth == 0) return true;
 
     d = 1;
@@ -1190,15 +1186,17 @@
         set_vector_length(element, length[d]);
 
         if (d != max_depth) {
-            frame.stack.pick(depth - 1 - d).cr = COMPRESS_REF(element);
+            frame.stack.pick(depth - 1 - d).ref = COMPRESS_INTERP(element);
             d++;
             continue;
         }
 
         while(true) {
-            array = UNCOMPRESS_REF(frame.stack.pick((depth - 1) - (d - 1)).cr);
-            CREF* addr = (CREF*) get_vector_element_address_ref(array, pos[d-1]);
-            *addr = COMPRESS_REF(element);
+            array = UNCOMPRESS_INTERP(frame.stack.pick((depth - 1) - (d - 1)).ref);
+            // addr can be a pointer to either ManagedObject* or COMPRESSED_REFERENCE
+            ManagedObject** addr = get_vector_element_address_ref(array, pos[d-1]);
+
+            STORE_UREF_BY_ADDR(addr, element);
             pos[d-1]++;
 
             if (pos[d-1] < length[d-1]) {
@@ -1262,8 +1260,7 @@
    
     frame.stack.push();
 
-    // COMPRESS_REF will fail assertion if obj == 0 on ipf 
-    frame.stack.pick().cr = COMPRESS_REF((ManagedObject*)obj);
+    frame.stack.pick().ref = COMPRESS_INTERP(obj);
     DEBUG_BYTECODE(" (val = " << hex << (int)frame.stack.pick().i << ")");
     frame.stack.ref() = FLAG_OBJECT;
     frame.ip += 3;
@@ -1399,12 +1396,12 @@
 
 static inline void 
 Opcode_ARRAYLENGTH(StackFrame& frame) {
-    CREF cref = frame.stack.pick().cr;
-    if (cref == 0) {
+    REF st_ref = frame.stack.pick().ref;
+    if (st_ref == 0) {
         throwNPE();
         return;
     }
-    ManagedObject *ref = UNCOMPRESS_REF(cref);
+    ManagedObject *ref = UNCOMPRESS_INTERP(st_ref);
 
     frame.stack.ref() = FLAG_NONE;
     frame.stack.pick().i = get_vector_length((Vector_Handle)ref);
@@ -1414,12 +1411,12 @@
 
 static inline void
 Opcode_AALOAD(StackFrame& frame) {
-    CREF cref = frame.stack.pick(1).cr;
-    if (cref == 0) {
+    REF st_ref = frame.stack.pick(1).ref;
+    if (st_ref == 0) {
         throwNPE();
         return;
     }
-    Vector_Handle array = (Vector_Handle) UNCOMPRESS_REF(cref);
+    Vector_Handle array = (Vector_Handle) UNCOMPRESS_INTERP(st_ref);
     uint32 length = get_vector_length(array);
     uint32 pos = frame.stack.pick(0).u;
 
@@ -1432,21 +1429,25 @@
 
     frame.stack.pop();
 
-    CREF* addr = (CREF*) get_vector_element_address_ref(array, pos);
-    /* FIXME: assume compressed reference */
-    frame.stack.pick().cr = *addr;
+    // Array contains elements according to REFS_IS_COMPRESSED_MODE
+    // But even in compressed mode on 64-bit platform interpreter's
+    // stack can contain uncompressed references (according to REF32)
+    // So we'll convert references if needed
+    ManagedObject** pelem = get_vector_element_address_ref(array, pos);
+    ManagedObject* urefelem = UNCOMPRESS_REF(*pelem);
+    frame.stack.pick().ref = COMPRESS_INTERP(urefelem);
     frame.ip++;
 }
 
 #define DEF_OPCODE_XALOAD(CODE,arraytype,type,store)                            \
 static inline void                                                              \
 Opcode_ ## CODE(StackFrame& frame) {                                            \
-    CREF cref = frame.stack.pick(1).cr;                         \
-    if (cref == 0) {                                                            \
+    REF ref = frame.stack.pick(1).ref;                                          \
+    if (ref == 0) {                                                             \
         throwNPE();                                                             \
         return;                                                                 \
     }                                                                           \
-    Vector_Handle array = (Vector_Handle) UNCOMPRESS_REF(cref);                 \
+    Vector_Handle array = (Vector_Handle) UNCOMPRESS_INTERP(ref);               \
     uint32 length = get_vector_length(array);                                   \
     uint32 pos = frame.stack.pick(0).u;                                         \
                                                                                 \
@@ -1459,8 +1460,7 @@
                                                                                 \
     frame.stack.pop();                                                          \
                                                                                 \
-    type* addr = (type*) get_vector_element_address_ ## arraytype(array, pos);  \
-    /* FIXME: assume compressed reference */                                    \
+    type* addr = get_vector_element_address_ ## arraytype(array, pos);          \
     frame.stack.pick().store = *addr;                                           \
     frame.stack.ref() = FLAG_NONE;                                              \
     frame.ip++;                                                                 \
@@ -1474,12 +1474,12 @@
 
 static inline void
 Opcode_LALOAD(StackFrame& frame) {
-    CREF cref = frame.stack.pick(1).cr;
-    if (cref == 0) {
+    REF ref = frame.stack.pick(1).ref;
+    if (ref == 0) {
         throwNPE();
         return;
     }
-    Vector_Handle array = (Vector_Handle) UNCOMPRESS_REF(cref);
+    Vector_Handle array = (Vector_Handle) UNCOMPRESS_INTERP(ref);
     uint32 length = get_vector_length(array);
     uint32 pos = frame.stack.pick(0).u;
 
@@ -1499,12 +1499,12 @@
 
 static inline void
 Opcode_AASTORE(StackFrame& frame) {
-    CREF cref = frame.stack.pick(2).cr;
-    if (cref == 0) {
+    REF ref = frame.stack.pick(2).ref;
+    if (ref == 0) {
         throwNPE();
         return;
     }
-    Vector_Handle array = (Vector_Handle) UNCOMPRESS_REF(cref);
+    Vector_Handle array = (Vector_Handle) UNCOMPRESS_INTERP(ref);
     uint32 length = get_vector_length(array);
     uint32 pos = frame.stack.pick(1).u;
 
@@ -1515,19 +1515,22 @@
         return;
     }
 
-    // TODO: check ArrayStoreException
+    // Check ArrayStoreException
     ManagedObject *arrayObj = (ManagedObject*) array;
     Class *arrayClass = arrayObj->vt()->clss;
     Class *elementClass = arrayClass->get_array_element_class();
-    ManagedObject* obj = UNCOMPRESS_REF(frame.stack.pick().cr);
-    if (!(obj == 0 || vm_instanceof(obj, elementClass))) {
+    ManagedObject* obj = UNCOMPRESS_INTERP(frame.stack.pick().ref);
+    if (!obj == 0 && !vm_instanceof(obj, elementClass)) {
         interp_throw_exception("java/lang/ArrayStoreException");
         return;
     }
 
-    // FIXME: compressed refs only
-    CREF* addr = (CREF*) get_vector_element_address_ref(array, pos);
-    *addr = frame.stack.pick().cr;
+    // Array contains elements according to REFS_IS_COMPRESSED_MODE
+    // But even in compressed mode on 64-bit platform interpreter's
+    // stack can contain uncompressed references (according to REF32)
+    // So we'll convert references if needed
+    ManagedObject** pelem = get_vector_element_address_ref(array, pos);
+    STORE_UREF_BY_ADDR(pelem, obj);
     frame.stack.ref(2) = FLAG_NONE;
     frame.stack.ref(0) = FLAG_NONE;
     frame.stack.pop(3);
@@ -1537,12 +1540,12 @@
 #define DEF_OPCODE_IASTORE(CODE,arraytype,type,ldtype)                          \
 static inline void                                                              \
 Opcode_ ## CODE(StackFrame& frame) {                                            \
-    CREF cref = frame.stack.pick(2).cr;                         \
-    if (cref == 0) {                                                            \
+    REF ref = frame.stack.pick(2).ref;                                          \
+    if (ref == 0) {                                                             \
         throwNPE();                                                             \
         return;                                                                 \
     }                                                                           \
-    Vector_Handle array = (Vector_Handle) UNCOMPRESS_REF(cref);                 \
+    Vector_Handle array = (Vector_Handle) UNCOMPRESS_INTERP(ref);               \
     uint32 length = get_vector_length(array);                                   \
     uint32 pos = frame.stack.pick(1).u;                                         \
                                                                                 \
@@ -1577,12 +1580,12 @@
 
 static inline void
 Opcode_LASTORE(StackFrame& frame) {
-    CREF cref = frame.stack.pick(3).cr;
-    if (cref == 0) {
+    REF ref = frame.stack.pick(3).ref;
+    if (ref == 0) {
         throwNPE();
         return;
     }
-    Vector_Handle array = (Vector_Handle) UNCOMPRESS_REF(cref);
+    Vector_Handle array = (Vector_Handle) UNCOMPRESS_INTERP(ref);
     uint32 length = get_vector_length(array);
     uint32 pos = frame.stack.pick(2).u;
 
@@ -1678,11 +1681,13 @@
 
         case VM_DATA_TYPE_ARRAY:
         case VM_DATA_TYPE_CLASS:
-            frame.stack.ref() = FLAG_NONE;
-            *(CREF*)addr = frame.stack.pick().cr;
-            frame.stack.pop();
-            break;
-
+            {
+                ManagedObject* val = UNCOMPRESS_INTERP(frame.stack.pick().ref);
+                STORE_UREF_BY_ADDR(addr, val);
+                frame.stack.ref() = FLAG_NONE;
+                frame.stack.pop();
+                break;
+            }
         case VM_DATA_TYPE_INT64:
         case VM_DATA_TYPE_F8:
             {
@@ -1691,6 +1696,7 @@
                 frame.stack.pop(2);
                 break;
             }
+
         default:
             ABORT("Unexpected data type");
     }
@@ -1756,10 +1762,12 @@
             break;
         case VM_DATA_TYPE_ARRAY:
         case VM_DATA_TYPE_CLASS:
-            frame.stack.pick().cr = *(CREF*)addr;
-            frame.stack.ref() = FLAG_OBJECT;
-            break;
-            
+            {
+                ManagedObject* val = UNCOMPRESS_REF(*((ManagedObject**)addr));
+                frame.stack.pick().ref = COMPRESS_INTERP(val);
+                frame.stack.ref() = FLAG_OBJECT;
+                break;
+            }
         case VM_DATA_TYPE_INT64:
         case VM_DATA_TYPE_F8:
             {
@@ -1767,8 +1775,8 @@
                 val.d = *(double*)addr;
                 frame.stack.push();
                 frame.stack.setLong(0, val);
+                break;
             }
-            break;
 
         default:
             ABORT("Unexpected data type");
@@ -1802,138 +1810,84 @@
     DEBUG_BYTECODE(field->get_name()->bytes << " " << field->get_descriptor()->bytes
             << " (val = " << hex << (int)frame.stack.pick().i << ")");
 
+    uint16 obj_ref_pos = 1;
+
+    if (field->get_java_type() == VM_DATA_TYPE_INT64 ||
+        field->get_java_type() == VM_DATA_TYPE_F8)
+        ++obj_ref_pos;
+
+    REF ref = frame.stack.pick(obj_ref_pos).ref;
+
+    if (ref == 0) {
+        throwNPE();
+        return;
+    }
+
+    ManagedObject *obj = UNCOMPRESS_INTERP(ref);
+    uint8* addr = ((uint8*)obj) + field->get_offset();
+
     switch (field->get_java_type()) {
 
 #ifdef COMPACT_FIELDS // use compact fields on ipf
         case VM_DATA_TYPE_BOOLEAN:
         case VM_DATA_TYPE_INT8:
-            {
-                uint32 val = frame.stack.pick(0).u;
-                CREF cref = frame.stack.pick(1).cr;
-                if (cref == 0) {
-                    throwNPE();
-                    return;
-                }
-                ManagedObject *obj = UNCOMPRESS_REF(cref);
-                uint8 *addr = ((uint8*)obj) + field->get_offset();
-                *(uint8*)addr = (uint8) val;
-                frame.stack.ref(1) = FLAG_NONE;
-                frame.stack.pop(2);
-                break;
-            }
+            *(uint8*)addr = (uint8)frame.stack.pick(0).u;
+            frame.stack.ref(1) = FLAG_NONE;
+            frame.stack.pop(2);
+            break;
 
         case VM_DATA_TYPE_CHAR:
         case VM_DATA_TYPE_INT16:
-            {
-                uint32 val = frame.stack.pick(0).u;
-                CREF cref = frame.stack.pick(1).cr;
-                if (cref == 0) {
-                    throwNPE();
-                    return;
-                }
-                ManagedObject *obj = UNCOMPRESS_REF(cref);
-                uint8 *addr = ((uint8*)obj) + field->get_offset();
-                *(uint16*)addr = (uint16) val;
-                frame.stack.ref(1) = FLAG_NONE;
-                frame.stack.pop(2);
-                break;
-            }
+            *(uint16*)addr = (uint16)frame.stack.pick(0).u;
+            frame.stack.ref(1) = FLAG_NONE;
+            frame.stack.pop(2);
+            break;
 
 #else // ia32 not using compact fields
         case VM_DATA_TYPE_BOOLEAN:
-            {
-                uint32 val = frame.stack.pick(0).u;
-                CREF cref = frame.stack.pick(1).cr;
-                if (cref == 0) {
-                    throwNPE();
-                    return;
-                }
-                ManagedObject *obj = UNCOMPRESS_REF(cref);
-                uint8 *addr = ((uint8*)obj) + field->get_offset();
-                *(uint32*)addr = (uint8) val;
-                frame.stack.ref(1) = FLAG_NONE;
-                frame.stack.pop(2);
-                break;
-            }
+            *(uint32*)addr = (uint8)frame.stack.pick(0).u;
+            frame.stack.ref(1) = FLAG_NONE;
+            frame.stack.pop(2);
+            break;
+
         case VM_DATA_TYPE_INT8:
-            {
-                int32 val = frame.stack.pick(0).i;
-                CREF cref = frame.stack.pick(1).cr;
-                if (cref == 0) {
-                    throwNPE();
-                    return;
-                }
-                ManagedObject *obj = UNCOMPRESS_REF(cref);
-                uint8 *addr = ((uint8*)obj) + field->get_offset();
-                *(int32*)addr = (int8) val;
-                frame.stack.ref(1) = FLAG_NONE;
-                frame.stack.pop(2);
-                break;
-            }
+            *(int32*)addr = (int8)frame.stack.pick(0).i;
+            frame.stack.ref(1) = FLAG_NONE;
+            frame.stack.pop(2);
+            break;
 
         case VM_DATA_TYPE_CHAR:
-            {
-                uint32 val = frame.stack.pick(0).u;
-                CREF cref = frame.stack.pick(1).cr;
-                if (cref == 0) {
-                    throwNPE();
-                    return;
-                }
-                ManagedObject *obj = UNCOMPRESS_REF(cref);
-                uint8 *addr = ((uint8*)obj) + field->get_offset();
-                *(uint32*)addr = (uint16) val;
-                frame.stack.ref(1) = FLAG_NONE;
-                frame.stack.pop(2);
-                break;
-            }
-        case VM_DATA_TYPE_INT16:
-            {
-                int32 val = frame.stack.pick(0).i;
-                CREF cref = frame.stack.pick(1).cr;
-                if (cref == 0) {
-                    throwNPE();
-                    return;
-                }
-                ManagedObject *obj = UNCOMPRESS_REF(cref);
-                uint8 *addr = ((uint8*)obj) + field->get_offset();
-                *(int32*)addr = (int16) val;
-                frame.stack.ref(1) = FLAG_NONE;
-                frame.stack.pop(2);
-                break;
-            }
+            *(uint32*)addr = (uint16)frame.stack.pick(0).u;
+            frame.stack.ref(1) = FLAG_NONE;
+            frame.stack.pop(2);
+            break;
 
+        case VM_DATA_TYPE_INT16:
+            *(int32*)addr = (int16)frame.stack.pick(0).i;
+            frame.stack.ref(1) = FLAG_NONE;
+            frame.stack.pop(2);
+            break;
 #endif
-        case VM_DATA_TYPE_ARRAY:
-        case VM_DATA_TYPE_CLASS:
         case VM_DATA_TYPE_INT32:
         case VM_DATA_TYPE_F4:
+            *(int32*)addr = frame.stack.pick(0).i;
+            frame.stack.ref(1) = FLAG_NONE;
+            frame.stack.pop(2);
+            break;
+
+        case VM_DATA_TYPE_ARRAY:
+        case VM_DATA_TYPE_CLASS:
             {
-                CREF val = frame.stack.pick(0).cr;
-                CREF cref = frame.stack.pick(1).cr;
-                if (cref == 0) {
-                    throwNPE();
-                    return;
-                }
-                ManagedObject *obj = UNCOMPRESS_REF(cref);
-                uint8 *addr = ((uint8*)obj) + field->get_offset();
-                // compressed references is uint32
-                *(CREF*)addr = val;
-                frame.stack.ref(1) = FLAG_NONE;
+                ManagedObject* val = UNCOMPRESS_INTERP(frame.stack.pick(0).ref);
+                STORE_UREF_BY_ADDR(addr, val);
                 frame.stack.ref(0) = FLAG_NONE;
+                frame.stack.ref(1) = FLAG_NONE;
                 frame.stack.pop(2);
                 break;
             }
-
         case VM_DATA_TYPE_INT64:
         case VM_DATA_TYPE_F8:
             {
-                CREF cref = frame.stack.pick(2).cr;
-                if (cref == 0) {
-                    throwNPE();
-                    return;
-                }
-                ManagedObject *obj = UNCOMPRESS_REF(cref);
-                uint8 *addr = ((uint8*)obj) + field->get_offset();
                 double *vaddr = (double*) addr;
                 *vaddr = frame.stack.getLong(0).d;
                 frame.stack.ref(2) = FLAG_NONE;
@@ -1963,12 +1917,12 @@
         M2N_FREE_MACRO;
     }
 
-    CREF cref = frame.stack.pick(0).cr;
-    if (cref == 0) {
+    REF ref = frame.stack.pick(0).ref;
+    if (ref == 0) {
         throwNPE();
         return;
     }
-    ManagedObject *obj = UNCOMPRESS_REF(cref);
+    ManagedObject *obj = UNCOMPRESS_INTERP(ref);
     uint8 *addr = ((uint8*)obj) + field->get_offset();
     frame.stack.ref() = FLAG_NONE;
 
@@ -1976,51 +1930,42 @@
 
 #ifdef COMPACT_FIELDS // use compact fields on ipf
         case VM_DATA_TYPE_BOOLEAN:
-            {
-                frame.stack.pick(0).u = (uint32) *(uint8*)addr;
-                break;
-            }
+            frame.stack.pick(0).u = (uint32) *(uint8*)addr;
+            break;
+
         case VM_DATA_TYPE_INT8:
-            {
-                frame.stack.pick(0).i = (int32) *(int8*)addr;
-                break;
-            }
+            frame.stack.pick(0).i = (int32) *(int8*)addr;
+            break;
 
         case VM_DATA_TYPE_CHAR:
-            {
-                frame.stack.pick(0).u = (uint32) *(uint16*)addr;
-                break;
-            }
+            frame.stack.pick(0).u = (uint32) *(uint16*)addr;
+            break;
+
         case VM_DATA_TYPE_INT16:
-            {
-                frame.stack.pick(0).i = (int32) *(int16*)addr;
-                break;
-            }
+            frame.stack.pick(0).i = (int32) *(int16*)addr;
+            break;
+
 #else // ia32 - not using compact fields
         case VM_DATA_TYPE_BOOLEAN:
         case VM_DATA_TYPE_CHAR:
-                frame.stack.pick(0).u = *(uint32*)addr;
-                break;
+            frame.stack.pick(0).u = *(uint32*)addr;
+            break;
         case VM_DATA_TYPE_INT8:
         case VM_DATA_TYPE_INT16:
 #endif
-
         case VM_DATA_TYPE_INT32:
         case VM_DATA_TYPE_F4:
-            {
-                frame.stack.pick(0).i = *(int32*)addr;
-                break;
-            }
+            frame.stack.pick(0).i = *(int32*)addr;
+            break;
 
         case VM_DATA_TYPE_ARRAY:
         case VM_DATA_TYPE_CLASS:
             {
+                ManagedObject* val = UNCOMPRESS_REF(*((ManagedObject**)addr));
+                frame.stack.pick(0).ref = COMPRESS_INTERP(val);
                 frame.stack.ref() = FLAG_OBJECT;
-                frame.stack.pick(0).cr = *(CREF*)addr;
-                ASSERT_OBJECT(UNCOMPRESS_REF(frame.stack.pick(0).cr));
                 break;
             }
-
         case VM_DATA_TYPE_INT64:
         case VM_DATA_TYPE_F8:
             {
@@ -2231,7 +2176,7 @@
     
     DEBUG_BYTECODE("class = " << class_get_name(objClass));
 
-    ManagedObject *obj = UNCOMPRESS_REF(frame.stack.pick().cr);
+    ManagedObject *obj = UNCOMPRESS_INTERP(frame.stack.pick().ref);
 
     if (!(obj == 0 || vm_instanceof(obj, objClass))) {
         interp_throw_exception("java/lang/ClassCastException", obj->vt()->clss->get_java_name()->bytes);
@@ -2249,28 +2194,24 @@
     
     DEBUG_BYTECODE("class = " << class_get_name(objClass));
 
-    ManagedObject *obj = UNCOMPRESS_REF(frame.stack.pick().cr);
-
-#ifdef COMPRESS_MODE
+    ManagedObject *obj = UNCOMPRESS_INTERP(frame.stack.pick().ref);
     // FIXME ivan 20041027: vm_instanceof checks null pointers, it assumes
     // that null is Class::managed_null, but uncompress_compressed_reference
     // doesn't return managed_null for null compressed references
-    frame.stack.pick().u = (!(obj == 0)) && vm_instanceof(obj, objClass);
-#else
-    frame.stack.pick().u = vm_instanceof(obj, objClass);
-#endif
+    frame.stack.pick().u = (obj != 0) && vm_instanceof(obj, objClass);
+
     frame.stack.ref() = FLAG_NONE;
     frame.ip += 3;
 }
 
 static inline void
 Opcode_MONITORENTER(StackFrame& frame) {
-    CREF cr = frame.stack.pick().cr;
-    if (cr == 0) {
+    REF ref = frame.stack.pick().ref;
+    if (ref == 0) {
         throwNPE();
         return;
     }
-    frame.locked_monitors->monitor = UNCOMPRESS_REF(cr);
+    frame.locked_monitors->monitor = UNCOMPRESS_INTERP(ref);
 
     M2N_ALLOC_MACRO;
     vm_monitor_enter_wrapper(frame.locked_monitors->monitor);
@@ -2285,13 +2226,13 @@
 
 static inline void
 Opcode_MONITOREXIT(StackFrame& frame) {
-    CREF cr = frame.stack.pick().cr;
-    if (cr == 0) {
+    REF ref = frame.stack.pick().ref;
+    if (ref == 0) {
         throwNPE();
         return;
     }
     M2N_ALLOC_MACRO;
-    vm_monitor_exit_wrapper(UNCOMPRESS_REF(cr));
+    vm_monitor_exit_wrapper(UNCOMPRESS_INTERP(ref));
     M2N_FREE_MACRO;
 
     if (check_current_thread_exception())
@@ -2310,8 +2251,8 @@
 
 static inline void
 Opcode_ATHROW(StackFrame& frame) {
-    CREF cr = frame.stack.pick().cr;
-    ManagedObject *obj = UNCOMPRESS_REF(cr);
+    REF ref = frame.stack.pick().ref;
+    ManagedObject *obj = UNCOMPRESS_INTERP(ref);
     if (obj == NULL) {
         throwNPE();
         return;
@@ -2538,7 +2479,7 @@
         case JAVA_TYPE_ARRAY:
         case JAVA_TYPE_STRING:
             h = oh_allocate_local_handle();
-            h->object = (ManagedObject*) UNCOMPRESS_REF(frame.stack.pick().cr);
+            h->object = UNCOMPRESS_INTERP(frame.stack.pick().ref);
             val.l = (jobject) h;
             break;
 
@@ -2620,7 +2561,7 @@
         if (frame.method->is_static()) {
             ml->monitor = *(frame.method->get_class()->get_class_handle());
         } else {
-            ml->monitor = UNCOMPRESS_REF(frame.locals(0).cr);
+            ml->monitor = UNCOMPRESS_INTERP(frame.locals(0).ref);
         }
         vm_monitor_enter_wrapper(ml->monitor);
     }
@@ -3088,7 +3029,7 @@
         if (processExceptionHandler(frame, &frame.exc)) {
             frame.stack.clear();
             frame.stack.push();
-            frame.stack.pick().cr = COMPRESS_REF(frame.exc);
+            frame.stack.pick().ref = COMPRESS_INTERP(frame.exc);
             frame.stack.ref() = FLAG_OBJECT;
             frame.exc = NULL;
             
@@ -3167,14 +3108,13 @@
 
     if(!method->is_static()) {
         frame.locals.ref(pos) = FLAG_OBJECT;
-        // COMPRESS_REF will fail assertion if obj == 0 on ipf
-        CREF cr = 0;
+        REF ref = 0;
         ObjectHandle h = (ObjectHandle) args[arg++].l;
         if (h) {
-            cr = COMPRESS_REF(h->object);
+            ref = COMPRESS_INTERP(h->object);
             frame.This = h->object;
         }
-        frame.locals(pos++).cr = cr;
+        frame.locals(pos++).ref = ref;
     }
 
     Arg_List_Iterator iter = method->get_argument_list();
@@ -3195,21 +3135,14 @@
             break;
         case JAVA_TYPE_CLASS:
         case JAVA_TYPE_ARRAY:
-            h = (ObjectHandle) args[arg++].l;
-#ifdef COMPRESS_MODE
-#ifdef REFS_USE_RUNTIME_SWITCH
-            assert(VM_Global_State::loader_env->compress_references);
-#endif // REFS_USE_RUNTIME_SWITCH
-#endif
-            CREF cref;
-            if (h == NULL) {
-                cref = 0;
-            } else {
-                cref = COMPRESS_REF(h->object);
-            }
-            frame.locals.ref(pos) = FLAG_OBJECT;
-            frame.locals(pos++).cr = cref;
-            ASSERT_OBJECT(UNCOMPRESS_REF(cref));
+            {
+                h = (ObjectHandle) args[arg++].l;
+
+                REF ref = (h == NULL) ? 0 : COMPRESS_INTERP(h->object);
+                frame.locals.ref(pos) = FLAG_OBJECT;
+                frame.locals(pos++).ref = ref;
+                ASSERT_OBJECT(UNCOMPRESS_INTERP(ref));
+            }
             break;
         case JAVA_TYPE_FLOAT:
             frame.locals(pos++).f = args[arg++].f;
@@ -3290,11 +3223,11 @@
         case JAVA_TYPE_STRING:
          
             { 
-                ASSERT_OBJECT(UNCOMPRESS_REF(frame.stack.pick().cr));
+                ASSERT_OBJECT(UNCOMPRESS_INTERP(frame.stack.pick().ref));
                 ObjectHandle h = 0; 
-                if (frame.stack.pick().cr) {
+                if (frame.stack.pick().ref) {
                     h = oh_allocate_local_handle();
-                    h->object = UNCOMPRESS_REF(frame.stack.pick().cr);
+                    h->object = UNCOMPRESS_INTERP(frame.stack.pick().ref);
                 } 
                 resultPtr->l = h;
             }
@@ -3490,14 +3423,14 @@
 interpreterInvokeVirtual(StackFrame& prevFrame, Method *method) {
 
     int args = method->get_num_arg_slots();
-    CREF cr = prevFrame.stack.pick(args-1).cr;
+    REF ref = prevFrame.stack.pick(args-1).ref;
 
-    if (cr == 0) {
+    if (ref == 0) {
         throwNPE();
         return;
     }
 
-    ManagedObject *obj = UNCOMPRESS_REF(cr);
+    ManagedObject *obj = UNCOMPRESS_INTERP(ref);
     ASSERT_OBJECT(obj);
 
     Class *objClass = obj->vt()->clss;
@@ -3524,14 +3457,14 @@
 interpreterInvokeInterface(StackFrame& prevFrame, Method *method) {
 
     int args = method->get_num_arg_slots();
-    CREF cr = prevFrame.stack.pick(args-1).cr;
+    REF ref = prevFrame.stack.pick(args-1).ref;
 
-    if (cr == 0) {
+    if (ref == 0) {
         throwNPE();
         return;
     }
 
-    ManagedObject *obj = UNCOMPRESS_REF(cr);
+    ManagedObject *obj = UNCOMPRESS_INTERP(ref);
     ASSERT_OBJECT(obj);
 
     if (!vm_instanceof(obj, method->get_class())) {
@@ -3580,9 +3513,9 @@
 interpreterInvokeSpecial(StackFrame& prevFrame, Method *method) {
 
     int args = method->get_num_arg_slots();
-    CREF cr = prevFrame.stack.pick(args-1).cr;
+    REF ref = prevFrame.stack.pick(args-1).ref;
 
-    if (cr == 0) {
+    if (ref == 0) {
         throwNPE();
         return;
     }
@@ -3595,7 +3528,7 @@
         return;
     }
 
-    ManagedObject *obj = UNCOMPRESS_REF(cr);
+    ManagedObject *obj = UNCOMPRESS_INTERP(ref);
 
     StackFrame frame;
     memset(&frame, 0, sizeof(frame));

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp?rev=587522&r1=587521&r2=587522&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter_ti.cpp Tue Oct 23 07:41:36 2007
@@ -177,7 +177,7 @@
 
     assert(hythread_is_suspend_enabled());
     hythread_suspend_disable();
-    ManagedObject *obj = UNCOMPRESS_REF(frame->locals(slot).cr);
+    ManagedObject *obj = UNCOMPRESS_INTERP(frame->locals(slot).ref);
     if (NULL == obj) {
         *value_ptr = NULL;
     } else {
@@ -263,7 +263,7 @@
     }
 
     ObjectHandle handle = (ObjectHandle) value;
-    frame->locals(slot).cr = COMPRESS_REF(handle->object);
+    frame->locals(slot).ref = COMPRESS_INTERP(handle->object);
     return JVMTI_ERROR_NONE;
 }
 
@@ -568,8 +568,8 @@
 void getfield_callback(Field *field, StackFrame& frame) {
     if (!field_event_mask(field, false)) return;
 
-    CREF cref = frame.stack.pick(0).cr;
-    ManagedObject *obj = UNCOMPRESS_REF(cref);
+    REF ref = frame.stack.pick(0).ref;
+    ManagedObject *obj = UNCOMPRESS_INTERP(ref);
     field_access_callback(field, frame, obj);
 }
 
@@ -595,7 +595,7 @@
         case VM_DATA_TYPE_CLASS:
         {
             ObjectHandle h = oh_allocate_local_handle();
-            h->object = UNCOMPRESS_REF(frame.stack.pick().cr);
+            h->object = UNCOMPRESS_INTERP(frame.stack.pick().ref);
             val.l = h;
         }
             break;
@@ -618,17 +618,17 @@
     if (!field_event_mask(field, true)) return;
 
     Java_Type type = field->get_java_type();
-    CREF cref;
+    REF ref;
 
     if (type == VM_DATA_TYPE_INT64 || type == VM_DATA_TYPE_F8) {
-        cref = frame.stack.pick(2).cr;
+        ref = frame.stack.pick(2).ref;
     } else {
-        cref = frame.stack.pick(1).cr;
+        ref = frame.stack.pick(1).ref;
     }
 
     M2N_ALLOC_MACRO;
     jvalue val = new_field_value(field, frame);
-    field_modification_callback(field, frame, UNCOMPRESS_REF(cref), val);
+    field_modification_callback(field, frame, UNCOMPRESS_INTERP(ref), val);
     M2N_FREE_MACRO;
 }
 



Mime
View raw message