You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2007/10/14 21:05:50 UTC

svn commit: r584579 - in /harmony/enhanced/drlvm/trunk: build/make/ build/make/targets/ vm/include/ vm/interpreter/src/ vm/vmcore/include/ vm/vmcore/src/class_support/ vm/vmcore/src/exception/ vm/vmcore/src/gc/ vm/vmcore/src/init/ vm/vmcore/src/jit/ vm...

Author: gshimansky
Date: Sun Oct 14 12:05:47 2007
New Revision: 584579

URL: http://svn.apache.org/viewvc?rev=584579&view=rev
Log:
Applied patch from HARMONY-4940
[drlvm][linux][em64t] Enable compile-time compression mode selection


Modified:
    harmony/enhanced/drlvm/trunk/build/make/build.xml
    harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml
    harmony/enhanced/drlvm/trunk/vm/include/slot.h
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_layout.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_arrays.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_roots.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_drlvm_VMHelper.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/object_handles.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/vm_arrays.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/atomics_common.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/compile_em64t.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/ini_em64t.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/compile_IA32.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/optimize_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_stats.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_strings.cpp

Modified: harmony/enhanced/drlvm/trunk/build/make/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/build.xml?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/build.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/build.xml Sun Oct 14 12:05:47 2007
@@ -126,7 +126,7 @@
                 <equals arg1="${machine.arch}" arg2="amd64" />
             </or>
         </condition>
-	<condition property="build.arch" value="ppc32">
+        <condition property="build.arch" value="ppc32">
             <or>
                 <equals arg1="${os.arch}" arg2="ppc32" />
                 <equals arg1="${os.arch}" arg2="ppc" />
@@ -183,16 +183,16 @@
     <!-- initialization target specific for unix -->
     <target name="init.unix" if="if.unix">
         <property name="build.os.family" value="unix" />
-	<condition property="build.os" value="macosx">
+        <condition property="build.os" value="macosx">
             <isset property="if.macosx" />
         </condition>
         <property name="build.os" value="Linux" />
-	<condition property="build.os.short" value="macosx">
+        <condition property="build.os.short" value="macosx">
             <isset property="if.macosx" />
         </condition>
         <property name="build.os.short" value="lnx" />
         <property name="build.executable.pattern" value="\1" />
-	<condition property="build.shared.pattern" value="lib\1.dylib">
+        <condition property="build.shared.pattern" value="lib\1.dylib">
             <isset property="if.macosx" />
         </condition>
         <property name="build.shared.pattern" value="lib\1.so lib\1.so.*" />
@@ -273,10 +273,37 @@
     </target>
 
 
+    <target name="init.compressed.mode">
+        <!-- refs.comp.mode from command line -->
+        <condition property="refs.comp.mode.tmp" value="${COMPRESSED_MODE}">
+            <isset property="COMPRESSED_MODE" />
+        </condition>
+        <!-- refs.comp.mode from environment or properties.file -->
+        <condition property="refs.comp.mode.tmp" value="${env.COMPRESSED_MODE}">
+            <isset property="env.COMPRESSED_MODE" />
+        </condition>
+
+        <condition property="refs.comp.mode" value="REFS_USE_COMPRESSED">
+            <and>
+                <isset property="refs.comp.mode.tmp" />
+                <equals arg1="${refs.comp.mode.tmp}" arg2="compressed" />
+            </and>
+        </condition>
+        <condition property="refs.comp.mode" value="REFS_USE_UNCOMPRESSED">
+            <and>
+                <isset property="refs.comp.mode.tmp" />
+                <equals arg1="${refs.comp.mode.tmp}" arg2="uncompressed" />
+            </and>
+        </condition>
+        <property name="refs.comp.mode" value="REFS_USE_RUNTIME_SWITCH"/>
+    </target>
+
+
     <!-- initialization target: loading and setting build properties -->
     <target name="init" depends="detect.os.arch.cxx.cfg,
                                  init.unix,
                                  init.win,
+                                 init.compressed.mode,
                                  set.semis.dirs,
                                  plugin.antcontrib,
                                  set.externals,

Modified: harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml Sun Oct 14 12:05:47 2007
@@ -35,6 +35,8 @@
                 <pathelement location="${build.vm.home}/include" />
             </includepath>
 
+            <defineset define="${refs.comp.mode}" />
+
             <select cfg="release">
                 <defineset define="NDEBUG" />
             </select>

Modified: harmony/enhanced/drlvm/trunk/vm/include/slot.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/slot.h?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/slot.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/slot.h Sun Oct 14 12:05:47 2007
@@ -79,43 +79,55 @@
 
     // Dereferences the slot and converts it to a raw object pointer.
     void *dereference() {
-        if (VM_Global_State::loader_env->compress_references) {
+        REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
             assert(content.compressed != NULL);
             return (void*)((UDATA)*content.compressed + (UDATA)heap_base);
-        } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+        REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
             assert(content.raw != NULL);
             return *content.raw;
-        }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+        REFS_RUNTIME_SWITCH_ENDIF
     }
 
     // Writes a new object reference into the slot.
     void write(void *obj) {
-        if (VM_Global_State::loader_env->compress_references) {
+        REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
             if (obj != NULL) {
                 *content.compressed = (uint32) ((UDATA)obj - (UDATA)heap_base);
             } else {
                 *content.compressed = 0;
             }
-        } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+        REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
             *content.raw = obj;
-        }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+        REFS_RUNTIME_SWITCH_ENDIF
     }
 
     // Returns true if the slot points to a null reference.
     bool is_null() {
-        if (VM_Global_State::loader_env->compress_references) {
+        REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
             assert(content.compressed != NULL);
             return (*content.compressed == 0);
-        } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+        REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
             assert(content.raw != NULL);
             return (*content.raw == NULL);
-        }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+        REFS_RUNTIME_SWITCH_ENDIF
     }
 
     // Returns the raw value of a managed null, which may be different
     // depending on whether compressed references are used.
     static void *managed_null() {
-        return (VM_Global_State::loader_env->compress_references ? heap_base : NULL);
+        return VM_Global_State::loader_env->managed_null;
     }
 
 };

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=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp Sun Oct 14 12:05:47 2007
@@ -3197,7 +3197,9 @@
         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) {

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h Sun Oct 14 12:05:47 2007
@@ -64,7 +64,9 @@
      */
     bool is_hyperthreading_enabled; // VM automatically detects HT status at startup.
     bool use_lil_stubs;             // 20030307: Use LIL stubs instead of hand crafted ones.  Default off (IPF) on (IA32).
+#ifdef REFS_USE_RUNTIME_SWITCH
     bool compress_references;       // 20030311 Compress references in references and vector elements.
+#endif
     bool strings_are_compressed;    // 2003-05-19: The VM searches the java.lang.String class for a "byte[] bvalue" field at startup,
                                     // as an indication that the Java class library supports compressed strings with 8-bit characters.
     bool use_large_pages;           // 20040109 Use large pages for class-related data such as vtables.

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_layout.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_layout.h?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_layout.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/object_layout.h Sun Oct 14 12:05:47 2007
@@ -18,20 +18,18 @@
 #ifndef _OBJECT_LAYOUT_H_
 #define _OBJECT_LAYOUT_H_
 
-// Define USE_COMPRESSED_VTABLE_POINTERS here to explicitly enable compressed vtable
+// Define USE_COMPRESSED_VTABLE_POINTERS here to enable compressed vtable
 // pointers within objects.
-// Define USE_UNCOMPRESSED_VTABLE_POINTERS to explicitly disable them.
-#if defined _IPF_ || defined _EM64T_
+#ifdef POINTER64
 #define USE_COMPRESSED_VTABLE_POINTERS
-#else // !_IPF_
-#define USE_UNCOMPRESSED_VTABLE_POINTERS
-#endif // _IPF_
+#endif // POINTER64
 
 #include <assert.h>
 #include "open/types.h"
 #include "open/hythread_ext.h"
 #include "jni.h"
 #include "open/vm.h"
+#include "open/gc.h"
 
 typedef struct VTable VTable;
 
@@ -39,51 +37,172 @@
 extern "C" {
 #endif
 
+#ifdef POINTER64
+
+#if !defined(REFS_USE_COMPRESSED) && !defined(REFS_USE_UNCOMPRESSED)
+#ifndef REFS_USE_RUNTIME_SWITCH
+#define REFS_USE_RUNTIME_SWITCH
+#endif
+#endif
+
+#else // POINTER64
+// 32-bit platform always uses uncompressed 32-bit references
+#ifdef REFS_USE_COMPRESSED
+#undef REFS_USE_COMPRESSED
+#endif
+#ifdef REFS_USE_RUNTIME_SWITCH
+#undef REFS_USE_RUNTIME_SWITCH
+#endif
+
+#ifndef REFS_USE_UNCOMPRESSED
+#define REFS_USE_UNCOMPRESSED
+#endif
+
+#endif // POINTER64
+
+// Definitions for building ifdefs
+#if defined(REFS_USE_RUNTIME_SWITCH) || defined(REFS_USE_UNCOMPRESSED)
+#define REFS_RUNTIME_OR_UNCOMPRESSED
+#endif
+
+#if defined(REFS_USE_RUNTIME_SWITCH) || defined(REFS_USE_COMPRESSED)
+#define REFS_RUNTIME_OR_COMPRESSED
+#endif
+
 /// Raw and compressed reference pointers
 
 typedef ManagedObject*  RAW_REFERENCE;
 typedef uint32          COMPRESSED_REFERENCE;
 
-VMEXPORT bool is_compressed_reference(COMPRESSED_REFERENCE value);
-VMEXPORT bool is_null_compressed_reference(COMPRESSED_REFERENCE value);
+// Useful macros: REFS_IS_COMPRESSED_MODE effectively specifies compressed mode
+// REF_SIZE returns size of type used for references
+// REF_MANAGED_NULL defines 'null' reference value for current compression mode
+// REF_INIT_BY_ADDR initializes reference with value of proper size
+#if defined(REFS_USE_COMPRESSED)
+
+#define REFS_IS_COMPRESSED_MODE 1
+#define REF_SIZE (sizeof(uint32))
+#define REF_MANAGED_NULL VM_Global_State::loader_env->heap_base
+#define REF_INIT_BY_ADDR(_ref_addr_, _val_)                                 \
+    *((COMPRESSED_REFERENCE*)(_ref_addr_)) = (COMPRESSED_REFERENCE)(_val_);
+
+#elif defined(REFS_USE_UNCOMPRESSED)
+
+#define REFS_IS_COMPRESSED_MODE 0
+#define REF_SIZE (sizeof(ManagedObject*))
+#define REF_MANAGED_NULL NULL
+#define REF_INIT_BY_ADDR(_ref_addr_, _val_)                                 \
+    *((ManagedObject**)(_ref_addr_)) = (ManagedObject*)(_val_);
+
+#else // for REFS_USE_RUNTIME_SWITCH
+
+#define REFS_IS_COMPRESSED_MODE                                             \
+                    (VM_Global_State::loader_env->compress_references)
+#define REF_SIZE (VM_Global_State::loader_env->compress_references ?        \
+                    sizeof(COMPRESSED_REFERENCE) :                          \
+                    sizeof(ManagedObject *))
+#define REF_MANAGED_NULL                                                    \
+    (VM_Global_State::loader_env->compress_references ?                     \
+            VM_Global_State::loader_env->heap_base : NULL)
+#define REF_INIT_BY_ADDR(_ref_addr_, _val_)                                 \
+    if (VM_Global_State::loader_env->compress_references) {                 \
+        *((COMPRESSED_REFERENCE*)(_ref_addr_)) =                            \
+                                    (COMPRESSED_REFERENCE)(_val_);          \
+    } else {                                                                \
+        *((ManagedObject**)(_ref_addr_)) = (ManagedObject*)(_val_);         \
+    }
+#endif
+
+// Helper macros for using in 'if'
+#ifdef REFS_USE_RUNTIME_SWITCH
+#define REFS_RUNTIME_SWITCH_IF if (REFS_IS_COMPRESSED_MODE) {
+#define REFS_RUNTIME_SWITCH_ELSE } else {
+#define REFS_RUNTIME_SWITCH_ENDIF }
+#else // REFS_USE_RUNTIME_SWITCH
+#define REFS_RUNTIME_SWITCH_IF
+#define REFS_RUNTIME_SWITCH_ELSE
+#define REFS_RUNTIME_SWITCH_ENDIF
+#endif // REFS_USE_RUNTIME_SWITCH
+
+
+bool is_compressed_reference(COMPRESSED_REFERENCE value);
 
 VMEXPORT COMPRESSED_REFERENCE compress_reference(ManagedObject *obj);
 VMEXPORT ManagedObject* uncompress_compressed_reference(COMPRESSED_REFERENCE compressed_ref);
-VMEXPORT ManagedObject* get_raw_reference_pointer(ManagedObject **slot_addr);
 
-// Store the reference "VALUE" in the slot at address "SLOT_ADDR"
-// in the object "CONTAINING_OBJECT".
-// Signature: void store_reference(ManagedObject* CONTAINING_OBJECT,
-//                                 ManagedObject** SLOT_ADDR,
-//                                 ManagedObject* VALUE);
-#define STORE_REFERENCE(CONTAINING_OBJECT, SLOT_ADDR, VALUE)                                  \
-    {                                                                                         \
-        if (VM_Global_State::loader_env->compress_references) {                               \
-            gc_heap_slot_write_ref_compressed((Managed_Object_Handle)(CONTAINING_OBJECT),     \
-                                              (uint32*)(SLOT_ADDR),                           \
-                                              (Managed_Object_Handle)(VALUE));                \
-        } else {                                                                              \
-            gc_heap_slot_write_ref((Managed_Object_Handle)(CONTAINING_OBJECT),                \
-                                   (Managed_Object_Handle*)(SLOT_ADDR),                      \
-                                   (Managed_Object_Handle)(VALUE));                           \
-        }                                                                                     \
-    }
-
-// Store the reference "VALUE" in the static field or
-// other global slot at address "SLOT_ADDR".
-// Signature: void store_global_reference(COMPRESSED_REFERENCE* SLOT_ADDR,
-//                                        ManagedObject* VALUE);
-#define STORE_GLOBAL_REFERENCE(SLOT_ADDR, VALUE)                              \
-    {                                                                         \
-        if (VM_Global_State::loader_env->compress_references) {               \
-            gc_heap_write_global_slot_compressed((uint32*)(SLOT_ADDR),        \
-                (Managed_Object_Handle)(VALUE));                              \
-        } else {                                                              \
-            gc_heap_write_global_slot((Managed_Object_Handle*)(SLOT_ADDR),    \
-                                      (Managed_Object_Handle)(VALUE));        \
-        }                                                                     \
+
+// Given the address of a slot containing a reference, returns the raw reference pointer whether the slot held
+// a compressed or uncompressed.reference.
+inline ManagedObject *get_raw_reference_pointer(ManagedObject **slot_addr)
+{
+#ifdef REFS_USE_RUNTIME_SWITCH
+    if (vm_references_are_compressed()) {
+#endif // REFS_USE_RUNTIME_SWITCH
+#ifdef REFS_RUNTIME_OR_COMPRESSED
+    COMPRESSED_REFERENCE offset = *((COMPRESSED_REFERENCE *)slot_addr);
+    assert(is_compressed_reference(offset));
+    if (offset != 0) {
+        return (ManagedObject*)((POINTER_SIZE_INT)vm_heap_base_address() + offset);
     }
 
+    return NULL;
+#endif // REFS_RUNTIME_OR_COMPRESSED
+REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
+        return *slot_addr;
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+REFS_RUNTIME_SWITCH_ENDIF
+} //get_raw_reference_pointer
+
+
+// Store the reference "_value_" in the slot at address "_slot_addr_"
+// in the object "_object_".
+#if defined(REFS_USE_COMPRESSED)
+#define STORE_REFERENCE(_object_, _slot_addr_, _value_)                     \
+        gc_heap_slot_write_ref_compressed((Managed_Object_Handle)_object_,  \
+                                          (uint32*)_slot_addr_,             \
+                                          (Managed_Object_Handle)_value_);
+#elif defined(REFS_USE_UNCOMPRESSED)
+#define STORE_REFERENCE(_object_, _slot_addr_, _value_)                     \
+        gc_heap_slot_write_ref((Managed_Object_Handle)_object_,             \
+                               (Managed_Object_Handle*)_slot_addr_,         \
+                               (Managed_Object_Handle)_value_);
+#else // for REFS_USE_RUNTIME_SWITCH
+#define STORE_REFERENCE(_object_, _slot_addr_, _value_)                     \
+    if (VM_Global_State::loader_env->compress_references) {                 \
+        gc_heap_slot_write_ref_compressed((Managed_Object_Handle)_object_,  \
+                                          (uint32*)_slot_addr_,             \
+                                          (Managed_Object_Handle)_value_);  \
+    } else {                                                                \
+        gc_heap_slot_write_ref((Managed_Object_Handle)_object_,             \
+                               (Managed_Object_Handle*)_slot_addr_,         \
+                               (Managed_Object_Handle)_value_);             \
+    }
+#endif // REFS_USE_RUNTIME_SWITCH
+
+
+// Store the reference "value" in the static field or
+// other global slot at address "slot_addr".
+#if defined(REFS_USE_COMPRESSED)
+#define STORE_GLOBAL_REFERENCE(_slot_addr_, _value_)                    \
+        gc_heap_write_global_slot_compressed((uint32*)(_slot_addr_),    \
+                                   (Managed_Object_Handle)(_value_));
+#elif defined(REFS_USE_UNCOMPRESSED)
+#define STORE_GLOBAL_REFERENCE(_slot_addr_, _value_)                    \
+        gc_heap_write_global_slot((Managed_Object_Handle*)(_slot_addr_),\
+                                  (Managed_Object_Handle)(_value_));
+#else // for REFS_USE_RUNTIME_SWITCH
+#define STORE_GLOBAL_REFERENCE(_slot_addr_, _value_)                    \
+    if (VM_Global_State::loader_env->compress_references) {             \
+        gc_heap_write_global_slot_compressed((uint32*)(_slot_addr_),    \
+                                  (Managed_Object_Handle)(_value_));    \
+    } else {                                                            \
+        gc_heap_write_global_slot((Managed_Object_Handle*)(_slot_addr_),\
+                                  (Managed_Object_Handle)(_value_));    \
+    }
+#endif // REFS_USE_RUNTIME_SWITCH
+
+
 
 // The object layout is currently as follows
 //
@@ -110,7 +229,7 @@
     }
     static unsigned header_offset() { return sizeof(uint32); }
     static bool are_vtable_pointers_compressed() { return true; }
-#elif defined USE_UNCOMPRESSED_VTABLE_POINTERS
+#else // USE_COMPRESSED_VTABLE_POINTERS
     VTable *vt_raw;
     POINTER_SIZE_INT obj_info;
     VTable *vt_unsafe() { return vt_raw; }
@@ -120,7 +239,7 @@
     }
     static unsigned header_offset() { return sizeof(VTable *); }
     static bool are_vtable_pointers_compressed() { return false; }
-#endif
+#endif // USE_COMPRESSED_VTABLE_POINTERS
     /// returns the size of constant object header part (vt pointer and obj_info)
     static size_t get_constant_header_size() { return sizeof(ManagedObject); }
     /// returns the size of object header including dynamically enabled fields.

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_arrays.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_arrays.h?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_arrays.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_arrays.h Sun Oct 14 12:05:47 2007
@@ -122,8 +122,7 @@
 {
     return (ManagedObject **)((POINTER_SIZE_INT)vector + 
                                       (POINTER_SIZE_INT)VM_VECTOR_FIRST_ELEM_OFFSET_REF + 
-                                      ((POINTER_SIZE_INT)idx * 
-                                       (VM_Global_State::loader_env->compress_references? sizeof(COMPRESSED_REFERENCE) : sizeof(ManagedObject *))));
+                                      ((POINTER_SIZE_INT)idx * REF_SIZE));
 } //get_vector_element_address_ref
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp Sun Oct 14 12:05:47 2007
@@ -793,11 +793,15 @@
     assert(str);
 
     bool must_instantiate;
-    if (env->compress_references) {
+    REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
         must_instantiate = (str->intern.compressed_ref == 0 /*NULL*/);
-    } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
         must_instantiate = (str->intern.raw_ref == NULL);
-    }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+    REFS_RUNTIME_SWITCH_ENDIF
 
     if (must_instantiate) {
         BEGIN_RAISE_AREA;
@@ -809,11 +813,15 @@
         END_RAISE_AREA;
     }
 
-    if (env->compress_references) {
+    REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
         return &(str->intern.compressed_ref);
-    } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
         return &(str->intern.raw_ref);
-    }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+    REFS_RUNTIME_SWITCH_ENDIF
 } //class_get_const_string_intern_addr
 
 
@@ -2440,7 +2448,7 @@
 
 VMEXPORT Boolean vm_references_are_compressed()
 {
-    return VM_Global_State::loader_env->compress_references;
+    return REFS_IS_COMPRESSED_MODE;
 } //vm_references_are_compressed
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp Sun Oct 14 12:05:47 2007
@@ -940,6 +940,7 @@
 ////////////////////////////////////////////////////////////////////
 // begin Support for compressed and raw reference pointers
 
+#ifndef REFS_USE_UNCOMPRESSED
 bool is_compressed_reference(COMPRESSED_REFERENCE compressed_ref) 
 {
     // A compressed reference is an offset into the heap.
@@ -950,16 +951,10 @@
 
 
 
-bool is_null_compressed_reference(COMPRESSED_REFERENCE compressed_ref)
-{
-    // Null compressed references are represented as 0.
-    return (compressed_ref == 0); 
-} //is_null_compressed_reference
-
-
-
 COMPRESSED_REFERENCE compress_reference(ManagedObject *obj) {
+#ifdef REFS_USE_RUNTIME_SWITCH
     assert(VM_Global_State::loader_env->compress_references);
+#endif // REFS_USE_RUNTIME_SWITCH
      COMPRESSED_REFERENCE compressed_ref;
      if(obj == NULL)
          compressed_ref = 0;
@@ -973,7 +968,9 @@
 
 
 ManagedObject *uncompress_compressed_reference(COMPRESSED_REFERENCE compressed_ref) {
+#ifdef REFS_USE_RUNTIME_SWITCH
     assert(VM_Global_State::loader_env->compress_references);
+#endif // REFS_USE_RUNTIME_SWITCH
     assert(is_compressed_reference(compressed_ref));
     if (compressed_ref == 0) {
         return NULL;
@@ -981,25 +978,7 @@
         return (ManagedObject *)(VM_Global_State::loader_env->heap_base + compressed_ref);
     }
 } //uncompress_compressed_reference
-
-
-
-// Given the address of a slot containing a reference, returns the raw reference pointer whether the slot held
-// a compressed or uncompressed.reference.
-ManagedObject *get_raw_reference_pointer(ManagedObject **slot_addr)
-{
-    ManagedObject *obj = NULL;
-    if (VM_Global_State::loader_env->compress_references) {
-        COMPRESSED_REFERENCE offset = *((COMPRESSED_REFERENCE *)slot_addr);
-        assert(is_compressed_reference(offset));
-        if (offset != 0) {
-            obj = (ManagedObject *)(VM_Global_State::loader_env->heap_base + offset);
-        }
-    } else {
-        obj = *slot_addr;
-    }
-    return obj;
-} //get_raw_reference_pointer
+#endif // REFS_USE_UNCOMPRESSED
 
 
 // end Support for compressed and raw reference pointers
@@ -1212,7 +1191,7 @@
 
 void* Class::code_alloc(size_t size, size_t alignment, Code_Allocation_Action action)
 {
-	assert (m_class_loader);
+    assert (m_class_loader);
     return m_class_loader->CodeAlloc(size, alignment, action);
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp Sun Oct 14 12:05:47 2007
@@ -109,11 +109,13 @@
     // HT support from command line disabled. VM should automatically detect HT status at startup.
     is_hyperthreading_enabled = false;
     use_lil_stubs = true;
-#if defined _IPF_ || defined _EM64T_
+#ifdef REFS_USE_RUNTIME_SWITCH
+#ifdef POINTER64
     compress_references = true;
-#else // !_IPF_
+#else // POINTER64
     compress_references = false;
-#endif // !_IPF_
+#endif // POINTER64
+#endif // REFS_USE_RUNTIME_SWITCH
 
     strings_are_compressed = false;
 
@@ -129,14 +131,14 @@
 
     GlobalCodeMemoryManager = new PoolManager(DEFAULT_COMMOT_JIT_CODE_POOL_SIZE, system_page_size, use_large_pages, 
         true/*is_code*/, true/*is_resize_allowed*/);
-	if (vm_vtable_pointers_are_compressed()) {
+    if (vm_vtable_pointers_are_compressed()) {
         VTableMemoryManager = new PoolManager(DEFAULT_COMMOT_VTABLE_POOL_SIZE_NO_RESIZE, system_page_size, use_large_pages, 
             false/*is_code*/, false/*is_resize_allowed*/);
-	}
-	else {
-		VTableMemoryManager = new PoolManager(DEFAULT_VTABLE_POOL_SIZE, system_page_size, use_large_pages, 
-			false/*is_code*/, true/*is_resize_allowed*/);
-	}
+    }
+    else {
+        VTableMemoryManager = new PoolManager(DEFAULT_VTABLE_POOL_SIZE, system_page_size, use_large_pages, 
+            false/*is_code*/, true/*is_resize_allowed*/);
+    }
 
     verify_all = false;
     verify_strict = false;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp Sun Oct 14 12:05:47 2007
@@ -95,11 +95,8 @@
         {
             if (field->is_magic_type()) {
                 sz = get_magic_type_size(field);
-            } else if (VM_Global_State::loader_env->compress_references) {
-                // compress static reference fields.
-                sz = sizeof(COMPRESSED_REFERENCE);
             } else {
-                sz = OBJECT_REF_SIZE;
+                sz = REF_SIZE;
             }
         }
         break;
@@ -454,10 +451,8 @@
                     // compress static reference fields.
                     if (cvalue.object == NULL) { //cvalue.string == NULL
                         // We needn't deal with this case, because the object field must be set in static initializer.
-                        if (VM_Global_State::loader_env->compress_references) {
-                            // initialize the field explicitly.
-                            *((COMPRESSED_REFERENCE *)field_addr) = 0;  // i.e., null
-                        }
+                        // initialize the field explicitly.
+                        REF_INIT_BY_ADDR(field_addr, 0); // i.e., null
                         break;
                     }
                     static const String* jlstring_desc_string =
@@ -474,7 +469,7 @@
                                 << clss->get_name()->bytes << "." << field->get_name()->bytes);
                             return false;
                         }
-                        STORE_GLOBAL_REFERENCE((COMPRESSED_REFERENCE *)field_addr, str);
+                        STORE_GLOBAL_REFERENCE(field_addr, str);
                         // ------------------------------------------------------------^^
                     } else {
                         ABORT("Unexpected type descriptor");
@@ -489,10 +484,8 @@
                 // ... if field isn't constant it will be initialized by 0, and <clinit> shall initialize it in future.
             } else {
                 if ((field_type == '[') || (field_type == 'L')) {
-                    if (VM_Global_State::loader_env->compress_references) {
-                        // initialize the field explicitly.
-                        *((COMPRESSED_REFERENCE *)field_addr) = 0;  // i.e., null
-                    }
+                    // initialize the field explicitly.
+                    REF_INIT_BY_ADDR(field_addr, 0); // i.e., null
                 }
             }
         } // end if static field

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp Sun Oct 14 12:05:47 2007
@@ -353,7 +353,8 @@
 
     // Atomically update the string structure since some other thread might be trying to make the same update.
     // The GC won't be able to enumerate here since GC is disabled, so there are no race conditions with GC.
-    if (VM_Global_State::loader_env->compress_references) {
+    REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
         COMPRESSED_REFERENCE compressed_lang_string =
             compress_reference(string->object);
         assert(is_compressed_reference(compressed_lang_string));
@@ -371,7 +372,9 @@
         }
         // Some other thread may have beaten us to the slot.
         lang_string = (ManagedObject *)uncompress_compressed_reference(str->intern.compressed_ref);
-    } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
         void *result =
             (void *)apr_atomic_casptr(
             /*destination*/ (volatile void **)&str->intern.raw_ref,
@@ -387,7 +390,9 @@
         }
         // Some other thread may have beaten us to the slot.
         lang_string = str->intern.raw_ref;
-    }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+    REFS_RUNTIME_SWITCH_ENDIF
+
     oh_discard_local_handle(string);
     return lang_string;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp Sun Oct 14 12:05:47 2007
@@ -1573,11 +1573,17 @@
     // can cause GC and we would like to get away with code that doesn't
     // protect references from GC.
     ManagedObject* jstr;
-    if (env->compress_references) {
+    
+    REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
         jstr = uncompress_compressed_reference(class_name_with_dots->intern.compressed_ref);
-    } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
         jstr = class_name_with_dots->intern.raw_ref;
-    }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+    REFS_RUNTIME_SWITCH_ENDIF
+
     if (jstr != NULL) {
         ObjectHandle h = oh_allocate_local_handle();
         h->object = jstr;
@@ -1662,7 +1668,7 @@
         //      signal successful loading for our CL
         SuccessLoadingClass(className);
     } else
-    	INFO2("class", "[Loaded " << (NULL != className ? className->bytes : "NULL") <<
+        INFO2("class", "[Loaded " << (NULL != className ? className->bytes : "NULL") <<
               " by " << (NULL != clss->get_class_loader()->GetName() ? clss->get_class_loader()->GetName()->bytes : "NULL")
                << "]");
     return clss;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp Sun Oct 14 12:05:47 2007
@@ -646,13 +646,18 @@
         "m2n_save_all;" "out platform:ref,pint,pint,pint:void;");
     assert(cs);
 
-    if (VM_Global_State::loader_env->compress_references)
+    REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
         cs = lil_parse_onto_end(cs,
             "jc i0=%0i:ref,%n;"
             "o0=i0;" "j %o;" ":%g;" "o0=0:ref;" ":%g;",
             VM_Global_State::loader_env->heap_base);
-    else
+#endif // REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
         cs = lil_parse_onto_end(cs, "o0=i0;");
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+    REFS_RUNTIME_SWITCH_ENDIF
     assert(cs);
 
     lil_parse_onto_end(cs,

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp Sun Oct 14 12:05:47 2007
@@ -375,7 +375,7 @@
                                            Managed_Object_Handle *p_slot,
                                            Managed_Object_Handle value)
 {
-    assert(!VM_Global_State::loader_env->compress_references);
+    assert(!REFS_IS_COMPRESSED_MODE);
     assert(p_slot != NULL);
     *p_slot = value;
 } //default_gc_heap_slot_write_ref
@@ -387,7 +387,8 @@
 {
     // p_slot is the address of a 32 bit slot holding the offset of a referenced object in the heap.
     // That slot is being updated, so store the heap offset of value's object. If value is NULL, store a 0 offset.
-    assert(VM_Global_State::loader_env->compress_references);
+    assert(REFS_IS_COMPRESSED_MODE);
+#ifndef REFS_USE_UNCOMPRESSED
     assert(p_slot != NULL);
     if (value != NULL) {
         COMPRESSED_REFERENCE value_offset = compress_reference((ManagedObject *)value);
@@ -395,6 +396,7 @@
     } else {
         *p_slot = 0;
     }
+#endif // REFS_USE_UNCOMPRESSED
 } //default_gc_heap_slot_write_ref_compressed
 
 
@@ -413,7 +415,8 @@
 {
     // p_slot is the address of a 32 bit global variable holding the offset of a referenced object in the heap.
     // That slot is being updated, so store the heap offset of value's object. If value is NULL, store a 0 offset.
-    assert(VM_Global_State::loader_env->compress_references);
+    assert(REFS_IS_COMPRESSED_MODE);
+#ifndef REFS_USE_UNCOMPRESSED
     assert(p_slot != NULL);
     if (value != NULL) {
         COMPRESSED_REFERENCE value_offset = compress_reference((ManagedObject *)value);
@@ -421,6 +424,7 @@
     } else {
         *p_slot = 0;
     }
+#endif // REFS_USE_UNCOMPRESSED
 } //default_gc_heap_write_global_slot_compressed
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/root_set_enum_common.cpp Sun Oct 14 12:05:47 2007
@@ -41,7 +41,8 @@
     String *ps = VM_Global_State::loader_env->string_pool.get_first_string_intern();
     // 20030405 Don't enumerate references that are *unmanaged null* (i.e. zero/NULL)
     // since vm_enumerate_root_reference() expects to be called with slots containing managed refs.
-    if (VM_Global_State::loader_env->compress_references) {
+    REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
         while (ps != NULL) {
             COMPRESSED_REFERENCE compressed_ref = ps->intern.compressed_ref;
             assert(is_compressed_reference(compressed_ref));
@@ -50,7 +51,9 @@
                 VM_Global_State::loader_env->pin_interned_strings);
             ps = VM_Global_State::loader_env->string_pool.get_next_string_intern();
         }
-    } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
         while (ps != NULL) {
             ManagedObject* s = ps->intern.raw_ref;
             assert(s != NULL);
@@ -58,7 +61,8 @@
                 VM_Global_State::loader_env->pin_interned_strings);
             ps = VM_Global_State::loader_env->string_pool.get_next_string_intern();
         }
-    }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+    REFS_RUNTIME_SWITCH_ENDIF
 } //vm_enumerate_interned_strings
 
 
@@ -81,7 +85,6 @@
 
 static void vm_enumerate_class_static(Class* c)
 {
-    Global_Env *global_env = VM_Global_State::loader_env;
     assert (c);
     ConstPoolEntry* cp = c->get_constant_pool().get_error_chain();
     while(cp) {
@@ -97,11 +100,15 @@
             if(f->is_static()) {
                 if(field_is_enumerable_reference(f)){
                     // The field is static and it is a reference.
-                    if (global_env->compress_references) {
+                    REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
                         vm_enumerate_compressed_root_reference((uint32 *)f->get_address(), FALSE);
-                    } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+                    REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
                         vm_enumerate_root_reference((void **)f->get_address(), FALSE);
-                    }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+                    REFS_RUNTIME_SWITCH_ENDIF
                 }
             }
         }
@@ -147,7 +154,8 @@
 #ifdef _DEBUG
 static void check_ref(void** ref)
 {
-    if (VM_Global_State::loader_env->compress_references) {
+#ifdef REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_IF
         // 20030324 DEBUG: verify the slot whose reference is being passed.
         ManagedObject **p_obj = (ManagedObject **)ref;  
         ManagedObject* obj = *p_obj;
@@ -156,7 +164,8 @@
             assert(((POINTER_SIZE_INT)VM_Global_State::loader_env->heap_base <= (POINTER_SIZE_INT)obj)
                 && ((POINTER_SIZE_INT)obj <= (POINTER_SIZE_INT)VM_Global_State::loader_env->heap_end));
         } 
-    }
+    REFS_RUNTIME_SWITCH_ENDIF
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
 }
 #endif // _DEBUG
 
@@ -189,9 +198,10 @@
 // Resembles vm_enumerate_root_reference() but is passed the address of a uint32 slot containing a compressed reference.
 VMEXPORT void vm_enumerate_compressed_root_reference(uint32 *ref, Boolean is_pinned)
 {
-    assert(VM_Global_State::loader_env->compress_references);
+    assert(REFS_IS_COMPRESSED_MODE);
 
 #if _DEBUG
+#ifndef REFS_USE_UNCOMPRESSED
         // 20030324 Temporary: verify the slot whose reference is being passed.
         COMPRESSED_REFERENCE compressed_ref = *ref;
         ManagedObject* obj = (ManagedObject *)uncompress_compressed_reference(compressed_ref);
@@ -199,6 +209,7 @@
         bool is_in_heap = (((POINTER_SIZE_INT)VM_Global_State::loader_env->heap_base <= (POINTER_SIZE_INT)obj)
             && ((POINTER_SIZE_INT)obj <= (POINTER_SIZE_INT)VM_Global_State::loader_env->heap_end));
         assert (is_null || is_in_heap);
+#endif // REFS_USE_UNCOMPRESSED
 #endif // _DEBUG
 
     gc_add_compressed_root_set_entry(ref, is_pinned);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Sun Oct 14 12:05:47 2007
@@ -687,7 +687,7 @@
     parse_vm_arguments(vm_env);
 
     vm_env->verify = get_boolean_property("vm.use_verifier", TRUE, VM_PROPERTIES);
-#ifdef POINTER64
+#if defined(POINTER64) && defined(REFS_USE_RUNTIME_SWITCH)
     vm_env->compress_references = get_boolean_property("vm.compress_references", TRUE, VM_PROPERTIES);
 #endif
 
@@ -721,7 +721,7 @@
     // TODO: find another way to initialize the following.
     vm_env->heap_base = (Byte *)gc_heap_base_address();
     vm_env->heap_end  = (Byte *)gc_heap_ceiling_address();
-    vm_env->managed_null = (vm_references_are_compressed() ? vm_env->heap_base : NULL);
+    vm_env->managed_null = REF_MANAGED_NULL;
 
     // 20030404 This handshaking protocol isn't quite correct. It doesn't
     // work at the moment because JIT has not yet been modified to support

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp Sun Oct 14 12:05:47 2007
@@ -351,7 +351,8 @@
     for(i=(is_static?0:1); i<num_args; i++) {
         if (is_reference(method_args_get_type_info(msh, i))) {
             POINTER_SIZE_INT handle_offset = oh_get_handle_offset(hn);
-            if (VM_Global_State::loader_env->compress_references) {
+            REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
                 cs = lil_parse_onto_end(cs,
                                         "jc i%0i=%1i:ref,%n;"
                                         "o%2i=l0+%3i;"
@@ -362,7 +363,9 @@
                                         i,
                                         VM_Global_State::loader_env->managed_null,
                                         arg_base+i, handle_offset, arg_base+i);
-            } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+            REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
                 cs = lil_parse_onto_end(cs,
                                         "jc i%0i=0:ref,%n;"
                                         "o%1i=l0+%2i;"
@@ -373,7 +376,8 @@
                                         i,
                                         arg_base+i, handle_offset,
                                         arg_base+i);
-            }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+            REFS_RUNTIME_SWITCH_ENDIF
             hn++;
         } else {
             cs = lil_parse_onto_end(cs, "o%0i=i%1i;", arg_base+i, i);
@@ -477,13 +481,15 @@
                                 "jc l1=0,ret_done;"
                                 "ld l1,[l1+0:ref];"
                                 ":ret_done;");
-        if (VM_Global_State::loader_env->compress_references) {
+#ifdef REFS_RUNTIME_OR_COMPRESSED
+        REFS_RUNTIME_SWITCH_IF
             cs = lil_parse_onto_end(cs,
                                     "jc l1!=0,done_translating_ret;"
                                     "l1=%0i:ref;"
                                     ":done_translating_ret;",
                                     VM_Global_State::loader_env->managed_null);
-        }
+        REFS_RUNTIME_SWITCH_ENDIF
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
         assert(cs);
     }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp Sun Oct 14 12:05:47 2007
@@ -490,17 +490,23 @@
             return env->java_lang_ArrayStoreException_Class;
         }
     } else {
-        // elem is null. We don't have to check types for a null reference. We also don't have to record stores of null references.
+        // elem is null. We don't have to check types for a null reference.
+        // We also don't have to record stores of null references.
 #ifdef VM_STATS
         VM_Statistics::get_vm_stats().num_aastore_null ++;
 #endif // VM_STATS
-        if (VM_Global_State::loader_env->compress_references) {
-            COMPRESSED_REFERENCE* elem_ptr = (COMPRESSED_REFERENCE*)get_vector_element_address_ref(array, idx);
-            *elem_ptr = (COMPRESSED_REFERENCE)NULL;
-        } else {
-            ManagedObject** elem_ptr = get_vector_element_address_ref(array, idx);
-            *elem_ptr = (ManagedObject*)NULL;
-        }
+
+        ManagedObject** elem_ptr = get_vector_element_address_ref(array, idx);
+
+        REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
+            *((COMPRESSED_REFERENCE*)elem_ptr) = (COMPRESSED_REFERENCE)NULL;
+#endif // REFS_RUNTIME_OR_COMPRESSED
+        REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
+            *elem_ptr= (ManagedObject*)NULL;
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+        REFS_RUNTIME_SWITCH_ENDIF
     }
     return NULL;
 } //rth_aastore
@@ -3265,14 +3271,19 @@
 #ifdef VM_STATS
         VM_Statistics::get_vm_stats().num_aastore_null ++;
 #endif // VM_STATS
-        // elem is null. We don't have to check types for a null reference. We also don't have to record stores of null references.
-        if (VM_Global_State::loader_env->compress_references) {
-            COMPRESSED_REFERENCE *elem_ptr = (COMPRESSED_REFERENCE *)get_vector_element_address_ref(array, idx);
-            *elem_ptr = (COMPRESSED_REFERENCE)NULL;
-        } else {
-            ManagedObject **elem_ptr = get_vector_element_address_ref(array, idx);
-            *elem_ptr = (ManagedObject *)NULL;
-        }
+        // elem is null. We don't have to check types for a null reference.
+        // We also don't have to record stores of null references.
+        ManagedObject** elem_ptr = get_vector_element_address_ref(array, idx);
+
+        REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
+            *((COMPRESSED_REFERENCE*)elem_ptr) = (COMPRESSED_REFERENCE)NULL;
+#endif // REFS_RUNTIME_OR_COMPRESSED
+        REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
+            *elem_ptr= (ManagedObject*)NULL;
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+        REFS_RUNTIME_SWITCH_ENDIF
     }
     return NULL;
 } //vm_rt_aastore

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp Sun Oct 14 12:05:47 2007
@@ -108,17 +108,22 @@
     // only if the elem is non-null.
     if (elem != NULL) {
         ManagedObject **elems = (ManagedObject **)get_vector_element_address_ref(vector, 0);
-        if (vm_env->compress_references) {
+
+        REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
             COMPRESSED_REFERENCE elem_offset = compress_reference((ManagedObject *)elem);
             COMPRESSED_REFERENCE *compressed_elems = (COMPRESSED_REFERENCE *)elems;
             for (int i = 0; i < length; i++) {
                 compressed_elems[i] = elem_offset;
             }
-        } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+        REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
             for (int i = 0; i < length; i++) {
                 elems[i] = elem;
             }
-        }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+        REFS_RUNTIME_SWITCH_ENDIF
     }
 
     ObjectHandle new_handle = oh_allocate_local_handle();

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp Sun Oct 14 12:05:47 2007
@@ -951,7 +951,7 @@
     if (!ensure_initialised(jni_env, f->get_class())) return;
     assert(f->is_static());
     tmn_suspend_disable();       //---------------------------------v
-    ManagedObject **field_addr = (ManagedObject **)f->get_address();
+    void* field_addr = f->get_address();
     ObjectHandle v = (ObjectHandle)value;
 
     ManagedObject *val = NULL;
@@ -959,7 +959,7 @@
         val = v->object;
     }
     // compress static fields.
-    STORE_GLOBAL_REFERENCE((COMPRESSED_REFERENCE *)field_addr, val);
+    STORE_GLOBAL_REFERENCE(field_addr, val);
 
     tmn_suspend_enable();        //---------------------------------^
 } //SetStaticObjectField

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_roots.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_roots.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_roots.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_roots.cpp Sun Oct 14 12:05:47 2007
@@ -218,9 +218,12 @@
         uint32 *ref, 
         Boolean UNREF pinned)
 {
+    assert(REFS_IS_COMPRESSED_MODE);
+#ifndef REFS_USE_UNCOMPRESSED
     Managed_Object_Handle obj = (Managed_Object_Handle)
         uncompress_compressed_reference(*ref);
     ti_enumerate_root(ref, obj);
+#endif // REFS_USE_UNCOMPRESSED
 }
 
 //

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_drlvm_VMHelper.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_drlvm_VMHelper.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_drlvm_VMHelper.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_drlvm_VMHelper.cpp Sun Oct 14 12:05:47 2007
@@ -29,7 +29,7 @@
 
 
 JNIEXPORT jboolean JNICALL Java_org_apache_harmony_drlvm_VMHelper_isCompressedRefsMode(JNIEnv *, jclass) {
-    return (jboolean)VM_Global_State::loader_env->compress_references;
+    return (jboolean)REFS_IS_COMPRESSED_MODE;
 }
 
 JNIEXPORT jboolean JNICALL Java_org_apache_harmony_drlvm_VMHelper_isCompressedVTableMode(JNIEnv *, jclass) {
@@ -42,18 +42,15 @@
 
 
 JNIEXPORT jlong JNICALL Java_org_apache_harmony_drlvm_VMHelper_getCompressedModeVTableBaseOffset(JNIEnv *, jclass) {
-    bool cm = (jboolean)VM_Global_State::loader_env->compress_references;
-    if (cm) {
-        return (jlong)vm_get_vtable_base();
-    }
-    return -1;
+#ifdef USE_COMPRESSED_VTABLE_POINTERS
+    return (jlong)vm_get_vtable_base();
+#else
+    return 0;
+#endif
 }
 
 
 JNIEXPORT jlong JNICALL Java_org_apache_harmony_drlvm_VMHelper_getCompressedModeObjectBaseOffset(JNIEnv *, jclass) {
-    bool cm = (jboolean)VM_Global_State::loader_env->compress_references;
-    if (cm) {
-        return (jlong)(POINTER_SIZE_INT)VM_Global_State::loader_env->heap_base;;
-    }
-    return -1;
+
+    return (jlong)(POINTER_SIZE_INT)REF_MANAGED_NULL;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/object_handles.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/object_handles.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/object_handles.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/object_handles.cpp Sun Oct 14 12:05:47 2007
@@ -548,7 +548,7 @@
 {
     char buf[200];
     POINTER_SIZE_INT offset = oh_get_handle_offset(handle_indx);
-    if (null_check && VM_Global_State::loader_env->compress_references) {
+    if (null_check && REFS_IS_COMPRESSED_MODE) {
         sprintf(buf,
                 "jc %s=0x%"PI_FMT"X:ref,%%n; st [%s+%"PI_FMT"d:ref],%s; j %%o; :%%g; st [%s+%"PI_FMT"d:ref],0; :%%g;",
                 val, (POINTER_SIZE_INT)VM_Global_State::loader_env->heap_base,

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/vm_arrays.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/vm_arrays.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/vm_arrays.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/vm_arrays.cpp Sun Oct 14 12:05:47 2007
@@ -560,11 +560,7 @@
 #ifdef VM_STATS
                 increment_array_copy_counter(VM_Statistics::get_vm_stats().num_arraycopy_object_same_type);
 #endif // VM_STATS
-                if (VM_Global_State::loader_env->compress_references) {
-                    memmove(dst_body, src_body, length * sizeof(COMPRESSED_REFERENCE));
-                } else {
-                    memmove(dst_body, src_body, length * sizeof(RAW_REFERENCE));  // length pointers, each a ManagedObject*
-                }
+                memmove(dst_body, src_body, length * REF_SIZE);
             } else {
                 // If the types are different, the arrays are different and no overlap of the source and destination is possible.
 #ifdef VM_STATS
@@ -573,7 +569,8 @@
                 Class* dst_elem_clss = dst_class->get_array_element_class();
                 assert(dst_elem_clss);
                 
-                if (VM_Global_State::loader_env->compress_references) {
+                REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
                     COMPRESSED_REFERENCE *src_body_compressed = (COMPRESSED_REFERENCE *)src_body;
                     COMPRESSED_REFERENCE *dst_body_compressed = (COMPRESSED_REFERENCE *)dst_body;
                     for (int count = 0; count < length; count++) {
@@ -594,7 +591,9 @@
                         dst_body_compressed[count] = src_body_compressed[count];
                         // There is not a gc_heap_write_ref call here since gc is disabled and we use gc_heap_wrote_object interface below.
                     }
-                } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+                REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
                      for (int count = 0; count < length; count++) {
                         // For non-null elements check if types are compatible.
                         if (src_body[count] != NULL) {
@@ -611,7 +610,8 @@
                         dst_body[count] = src_body[count];
                         // There is not a gc_heap_write_ref call here since gc is disabled and we use gc_heap_wrote_object interface below.
                     }
-                }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+                REFS_RUNTIME_SWITCH_ENDIF
             }
 
             gc_heap_wrote_object(dst);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/atomics_common.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/atomics_common.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/atomics_common.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/atomics_common.cpp Sun Oct 14 12:05:47 2007
@@ -35,6 +35,7 @@
  * Platform dependent atomic functions are in corresponding arch/ subfolders.
  */
 
+#ifndef REFS_USE_UNCOMPRESSED
 bool gc_heap_slot_cas_ref_compressed (Managed_Object_Handle p_base_of_object_with_slot,
                                       COMPRESSED_REFERENCE *p_slot,
                                       Managed_Object_Handle expected,
@@ -54,8 +55,9 @@
     //INTERNAL(gc_write_barrier) (p_base_of_object_with_slot);
     return result;
 }
+#endif // REFS_USE_UNCOMPRESSED
 
-
+#ifndef REFS_USE_COMPRESSED
 bool gc_heap_slot_cas_ref (Managed_Object_Handle p_base_of_object_with_slot,
                            Managed_Object_Handle *p_slot,
                            Managed_Object_Handle expected,
@@ -68,6 +70,7 @@
     //INTERNAL(gc_write_barrier) (p_base_of_object_with_slot);
     return res;
 }
+#endif // REFS_USE_COMPRESSED
 
 
 JNIEXPORT jlong getFieldOffset(JNIEnv * env, jobject field) 
@@ -96,19 +99,21 @@
 
     bool result;
 
-    if (VM_Global_State::loader_env->compress_references) {
+    REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
         result = gc_heap_slot_cas_ref_compressed((Managed_Object_Handle)(java_ref),
                                                  (COMPRESSED_REFERENCE *)(field_addr),
                                                  (Managed_Object_Handle)(exp),
                                                  (Managed_Object_Handle)(val));
-    }
-    else
-    {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
         result = gc_heap_slot_cas_ref((Managed_Object_Handle)(java_ref),
                                       (Managed_Object_Handle *)(field_addr),
                                       (Managed_Object_Handle)(exp),
                                       (Managed_Object_Handle)(val));
-    }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+    REFS_RUNTIME_SWITCH_ENDIF
 
     tmn_suspend_enable();
     return  (jboolean)(result?JNI_TRUE:JNI_FALSE);
@@ -188,19 +193,24 @@
 
     bool result;
 
-    if (VM_Global_State::loader_env->compress_references) {
+#ifdef REFS_USE_RUNTIME_SWITCH
+    if (VM_Global_State::loader_env->compress_references)
+#endif // REFS_USE_RUNTIME_SWITCH
+#ifdef REFS_RUNTIME_OR_COMPRESSED
         result = gc_heap_slot_cas_ref_compressed((Managed_Object_Handle)(vector_handle),
                                                  (COMPRESSED_REFERENCE *)(element_address),
                                                  (Managed_Object_Handle)(exp),
                                                  (Managed_Object_Handle)(val));
-    }
+#endif // REFS_RUNTIME_OR_COMPRESSED
+#ifdef REFS_USE_RUNTIME_SWITCH
     else
-    {
+#endif // REFS_USE_RUNTIME_SWITCH
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
         result = gc_heap_slot_cas_ref((Managed_Object_Handle)(vector_handle),
                                       (Managed_Object_Handle *)(element_address),
                                       (Managed_Object_Handle)(exp),
                                       (Managed_Object_Handle)(val));
-    }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
 
     tmn_suspend_enable();
     return (jboolean)(result?JNI_TRUE:JNI_FALSE);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/compile_em64t.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/compile_em64t.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/compile_em64t.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/compile_em64t.cpp Sun Oct 14 12:05:47 2007
@@ -146,7 +146,8 @@
 // (represented by heap_base) to an unmanaged one (NULL/0). Uses %rdi.
 char * gen_convert_managed_to_unmanaged_null_em64t(char * ss,
                                                   const R_Opnd & input_param1) {
-    if (VM_Global_State::loader_env->compress_references) {
+#ifdef REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_IF
         ss = mov(ss, r11_opnd, Imm_Opnd(size_64, (int64)VM_Global_State::loader_env->heap_base));
         ss = alu(ss, cmp_opc, input_param1, r11_opnd, size_64);
         ss = branch8(ss, Condition_NE, Imm_Opnd(size_8, 0));  // not null, branch around the mov 0
@@ -154,7 +155,8 @@
         ss = mov(ss, input_param1, Imm_Opnd(0));
         POINTER_SIZE_SINT offset = (POINTER_SIZE_SINT)ss - (POINTER_SIZE_SINT)backpatch_address__not_managed_null - 1;
         *backpatch_address__not_managed_null = (char)offset;
-    }
+    REFS_RUNTIME_SWITCH_ENDIF
+#endif // REFS_RUNTIME_OR_COMPRESSED
     return ss;
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/ini_em64t.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/ini_em64t.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/ini_em64t.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/ini_em64t.cpp Sun Oct 14 12:05:47 2007
@@ -243,10 +243,8 @@
     if(!method->is_static()) {
         ObjectHandle handle = (ObjectHandle) args[arg_num++].l;
         assert(handle);
-        // only compressed references are supported yet
-        assert(VM_Global_State::loader_env->compress_references);
         // convert from native to managed NULL
-        gr_args[gr_nargs++] = handle->object != NULL
+        gr_args[gr_nargs++] = (handle->object != NULL)
             ? (uint64) handle->object : (uint64) VM_Global_State::loader_env->managed_null;
     }
 
@@ -259,8 +257,6 @@
         case JAVA_TYPE_ARRAY: {
             ObjectHandle handle = (ObjectHandle) args[arg_num++].l;
             uint64 ref = handle ? (uint64) handle->object : 0;
-            // only compressed references are supported yet
-            assert(VM_Global_State::loader_env->compress_references);
             // convert from native to managed NULL
             ref = ref ? ref : (uint64) VM_Global_State::loader_env->managed_null;
             if (gr_nargs < MAX_GR) {
@@ -356,10 +352,8 @@
             method_entry_point,
             gr_nargs,  fr_nargs, stack_nargs,
             gr_args, fr_args, stack_args);
-        // only compressed references are supported yet
-        assert(VM_Global_State::loader_env->compress_references);
         // convert from managed to native NULL
-        ref = ref != (uint64) VM_Global_State::loader_env->managed_null ? ref : (uint64) NULL;
+        ref = (ref != (uint64) VM_Global_State::loader_env->managed_null) ? ref : (uint64) NULL;
         if (ref) {
             handle = oh_allocate_local_handle();
             handle->object = (ManagedObject*) ref;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/compile_IA32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/compile_IA32.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/compile_IA32.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/compile_IA32.cpp Sun Oct 14 12:05:47 2007
@@ -154,7 +154,8 @@
 // (represented by heap_base) to an unmanaged one (NULL/0). Uses %eax.
 char * gen_convert_managed_to_unmanaged_null_ia32(char * ss,
                                                   unsigned stack_pointer_offset) {
-    if (VM_Global_State::loader_env->compress_references) {
+#ifdef REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_IF
         ss = mov(ss,  eax_opnd,  M_Base_Opnd(esp_reg, stack_pointer_offset));
         ss = alu(ss, cmp_opc,  eax_opnd,  Imm_Opnd((int32)VM_Global_State::loader_env->heap_base) );
         ss = branch8(ss, Condition_NE,  Imm_Opnd(size_8, 0));  // not null, branch around the mov 0
@@ -162,7 +163,8 @@
         ss = mov(ss,  M_Base_Opnd(esp_reg, stack_pointer_offset),  Imm_Opnd(0));
         signed offset = (signed)ss - (signed)backpatch_address__not_managed_null - 1;
         *backpatch_address__not_managed_null = (char)offset;
-    } 
+    REFS_RUNTIME_SWITCH_ENDIF
+#endif // REFS_RUNTIME_OR_COMPRESSED
     return ss;
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp Sun Oct 14 12:05:47 2007
@@ -113,7 +113,7 @@
         lil_free_code_stub(cs);
         return addr;
     }
-    const int stub_size = (VM_Global_State::loader_env->compress_references? 82 : 58);
+    const int stub_size = (REFS_IS_COMPRESSED_MODE ? 82 : 58);
     char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_COLD, CAA_Allocate);
 #ifdef _DEBUG
     memset(stub, 0xcc /*int 3*/, stub_size);
@@ -128,13 +128,17 @@
 #endif // VM_STATS
 
     ss = mov(ss,  eax_opnd,  M_Base_Opnd(esp_reg, +4) );
-    if (VM_Global_State::loader_env->compress_references) {
-        ss = alu(ss, cmp_opc,  eax_opnd,  Imm_Opnd((unsigned)VM_Global_State::loader_env->heap_base)); //is eax == NULL?
+    REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
+        ss = alu(ss, cmp_opc,  eax_opnd,  Imm_Opnd((unsigned)VM_Global_State::loader_env->managed_null)); //is eax == NULL?
         ss = branch8(ss, Condition_NZ,  Imm_Opnd(size_8, 0));
-    } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
         ss = test(ss,  eax_opnd,  eax_opnd);
         ss = branch8(ss, Condition_NE,  Imm_Opnd(size_8, 0));  // will get backpatched
-    }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+    REFS_RUNTIME_SWITCH_ENDIF
     char *backpatch_address__not_null = ((char *)ss) - 1;
 
     // The object reference is null, so return null.     
@@ -253,7 +257,7 @@
              (void *)class_initialize,
              APR_OFFSETOF(VM_thread, thread_exception.exc_object),
              APR_OFFSETOF(VM_thread, thread_exception.exc_class),
-	     (void*)exn_rethrow);
+             (void*)exn_rethrow);
         assert(lil_is_valid(cs));
         addr = LilCodeGenerator::get_platform()->compile(cs);
 
@@ -502,15 +506,17 @@
             int idx,
             Vector_Handle array)
 {
-    if (VM_Global_State::loader_env->compress_references) {
+#ifdef REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_IF
         // 20030321 Convert a null reference from a managed (heap_base) to an unmanaged null (NULL/0).
-        if (elem == (volatile ManagedObject *)VM_Global_State::loader_env->heap_base) {
+        if (elem == (volatile ManagedObject *)VM_Global_State::loader_env->managed_null) {
             elem = NULL;
         }
-        if (array == (ManagedObject *)VM_Global_State::loader_env->heap_base) {
+        if (array == (ManagedObject *)VM_Global_State::loader_env->managed_null) {
             array = NULL;
         }
-    }
+    REFS_RUNTIME_SWITCH_ENDIF
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
 
     assert ((elem == NULL) || (((ManagedObject *)elem)->vt() != NULL));
 #ifdef VM_STATS
@@ -549,13 +555,19 @@
             // 20030502 Someone earlier commented out a call to the GC interface function gc_heap_slot_write_ref() and replaced it
             // by code to directly store a NULL in the element without notifying the GC. I've retained that change here but I wonder if
             // there could be a problem later with, say, concurrent GCs.
-            if (VM_Global_State::loader_env->compress_references) {
-                COMPRESSED_REFERENCE *elem_ptr = (COMPRESSED_REFERENCE *)get_vector_element_address_ref(array, idx);
-                *elem_ptr = (COMPRESSED_REFERENCE)NULL;
-            } else {
-                ManagedObject **elem_ptr = get_vector_element_address_ref(array, idx);
+            ManagedObject **elem_ptr = get_vector_element_address_ref(array, idx);
+            
+            REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
+                *((COMPRESSED_REFERENCE*)elem_ptr) = (COMPRESSED_REFERENCE)NULL;
+#endif // REFS_RUNTIME_OR_COMPRESSED
+            REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
+                
                 *elem_ptr = (ManagedObject *)NULL;
-            }
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+            REFS_RUNTIME_SWITCH_ENDIF
+
             return 0;
         }
     }
@@ -793,7 +805,7 @@
         return addr;
     }
 
-    const int stub_size = (VM_Global_State::loader_env->compress_references? 69 : 50);
+    const int stub_size = (REFS_IS_COMPRESSED_MODE ? 69 : 50);
     char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_DEFAULT, CAA_Allocate);
 #ifdef _DEBUG
     memset(stub, 0xcc /*int 3*/, stub_size);
@@ -1005,15 +1017,17 @@
 
     ss = push(ss,  ecx_opnd);
 
-    if (VM_Global_State::loader_env->compress_references) {
+#ifdef REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_IF
         // 20030321 Convert a null reference in %ecx from a managed (heap_base) to an unmanaged null (0/NULL). 
-        ss = test(ss,  ecx_opnd,  Imm_Opnd((unsigned)VM_Global_State::loader_env->heap_base));
+        ss = test(ss,  ecx_opnd,  Imm_Opnd((unsigned)VM_Global_State::loader_env->managed_null));
         ss = branch8(ss, Condition_NE,  Imm_Opnd(size_8, 0));  // branch around mov 0
         char *backpatch_address__not_managed_null = ((char *)ss) - 1;
         ss = mov(ss,  ecx_opnd,  Imm_Opnd(0));
         signed offset = (signed)ss - (signed)backpatch_address__not_managed_null - 1;
         *backpatch_address__not_managed_null = (char)offset;
-    }
+    REFS_RUNTIME_SWITCH_ENDIF
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
 
     ss = call(ss, (char *)gc_write_barrier);
     ss = alu(ss, add_opc,  esp_opnd,  Imm_Opnd(4));

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/optimize_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/optimize_ia32.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/optimize_ia32.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/optimize_ia32.cpp Sun Oct 14 12:05:47 2007
@@ -57,10 +57,7 @@
 
 static bool enable_fast_char_arraycopy()
 {
-    Global_Env *env = VM_Global_State::loader_env;
-    if (env->compress_references)
-        return false;
-    return true;
+    return !(REFS_IS_COMPRESSED_MODE);
 }
 
 static ManagedObject *

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_stats.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_stats.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_stats.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_stats.cpp Sun Oct 14 12:05:47 2007
@@ -543,7 +543,7 @@
             
             bool is_interned = false;
             String * string = string_pool.lookup(key, key_len);
-            if (VM_Global_State::loader_env->compress_references) {
+            if (REFS_IS_COMPRESSED_MODE) {
                 if (string->intern.compressed_ref) {
                     is_interned = true;
                 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_strings.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_strings.cpp?rev=584579&r1=584578&r2=584579&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_strings.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_strings.cpp Sun Oct 14 12:05:47 2007
@@ -225,7 +225,7 @@
     Byte* str_raw = (Byte*)str;
     *(uint32*)(str_raw+f_count_offset) = length;
     *(uint32*)(str_raw+f_offset_offset) = offset;
-    STORE_REFERENCE(str_raw, str_raw+f_value_offset, chars);
+    STORE_REFERENCE(str, (ManagedObject**)(str_raw+f_value_offset), (ManagedObject*)chars);
 }
 
 // GC must be disabled but at a same point
@@ -550,17 +550,21 @@
 {
     ASSERT_RAISE_AREA;
     assert(!hythread_is_suspend_enabled());
-    Global_Env *env = VM_Global_State::loader_env;
-    if (env->compress_references) {
+
+    REFS_RUNTIME_SWITCH_IF
+#ifdef REFS_RUNTIME_OR_COMPRESSED
         if (str->intern.compressed_ref != 0) {
             return uncompress_compressed_reference(str->intern.compressed_ref);
         }
-    } else {
+#endif // REFS_RUNTIME_OR_COMPRESSED
+    REFS_RUNTIME_SWITCH_ELSE
+#ifdef REFS_RUNTIME_OR_UNCOMPRESSED
         if (str->intern.raw_ref != NULL) {
             return str->intern.raw_ref;
         }
-    }
-    return env->string_pool.intern(str);
+#endif // REFS_RUNTIME_OR_UNCOMPRESSED
+    REFS_RUNTIME_SWITCH_ENDIF
+    return VM_Global_State::loader_env->string_pool.intern(str);
 } //vm_instantiate_cp_string_resolved
 
 // Interning of strings