Index: vm/vmcore/include/object_layout.h =================================================================== --- vm/vmcore/include/object_layout.h (revision 585625) +++ vm/vmcore/include/object_layout.h (working copy) @@ -84,7 +84,7 @@ #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_); + *((COMPRESSED_REFERENCE*)(_ref_addr_)) = (COMPRESSED_REFERENCE)(_val_) #elif defined(REFS_USE_UNCOMPRESSED) @@ -92,7 +92,7 @@ #define REF_SIZE (sizeof(ManagedObject*)) #define REF_MANAGED_NULL NULL #define REF_INIT_BY_ADDR(_ref_addr_, _val_) \ - *((ManagedObject**)(_ref_addr_)) = (ManagedObject*)(_val_); + *((ManagedObject**)(_ref_addr_)) = (ManagedObject*)(_val_) #else // for REFS_USE_RUNTIME_SWITCH @@ -159,24 +159,24 @@ // 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_); + 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_); + 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_); \ + 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_); \ + gc_heap_slot_write_ref((Managed_Object_Handle)(_object_), \ + (Managed_Object_Handle*)(_slot_addr_), \ + (Managed_Object_Handle)(_value_)); \ } #endif // REFS_USE_RUNTIME_SWITCH @@ -186,11 +186,11 @@ #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_)); + (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_)); + (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) { \ Index: vm/vmcore/src/jit/jit_runtime_support.cpp =================================================================== --- vm/vmcore/src/jit/jit_runtime_support.cpp (revision 585625) +++ vm/vmcore/src/jit/jit_runtime_support.cpp (working copy) @@ -497,16 +497,7 @@ #endif // VM_STATS 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 + REF_INIT_BY_ADDR(elem_ptr, NULL); } return NULL; } //rth_aastore @@ -3279,16 +3270,7 @@ // 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 + REF_INIT_BY_ADDR(elem_ptr, NULL); } return NULL; } //vm_rt_aastore Index: vm/vmcore/src/kernel_classes/native/org_apache_harmony_drlvm_VMHelper.cpp =================================================================== --- vm/vmcore/src/kernel_classes/native/org_apache_harmony_drlvm_VMHelper.cpp (revision 585625) +++ vm/vmcore/src/kernel_classes/native/org_apache_harmony_drlvm_VMHelper.cpp (working copy) @@ -41,16 +41,21 @@ } +/** @return vtable base offset if is in compressed-refs mode or -1*/ JNIEXPORT jlong JNICALL Java_org_apache_harmony_drlvm_VMHelper_getCompressedModeVTableBaseOffset(JNIEnv *, jclass) { #ifdef USE_COMPRESSED_VTABLE_POINTERS return (jlong)vm_get_vtable_base(); #else - return 0; + return -1; #endif } +/** @return object base offset if is in compressed-refs mode or -1*/ JNIEXPORT jlong JNICALL Java_org_apache_harmony_drlvm_VMHelper_getCompressedModeObjectBaseOffset(JNIEnv *, jclass) { - - return (jlong)(POINTER_SIZE_INT)REF_MANAGED_NULL; + if (REFS_IS_COMPRESSED_MODE) { + return (jlong)(POINTER_SIZE_INT)REF_MANAGED_NULL; + } else { + return -1; + } } Index: vm/vmcore/src/class_support/Prepare.cpp =================================================================== --- vm/vmcore/src/class_support/Prepare.cpp (revision 585625) +++ vm/vmcore/src/class_support/Prepare.cpp (working copy) @@ -452,7 +452,11 @@ if (cvalue.object == NULL) { //cvalue.string == NULL // We needn't deal with this case, because the object field must be set in static initializer. // initialize the field explicitly. - REF_INIT_BY_ADDR(field_addr, 0); // i.e., null +#ifdef REFS_RUNTIME_OR_COMPRESSED + REFS_RUNTIME_SWITCH_IF + REF_INIT_BY_ADDR(field_addr, 0); // i.e., null + REFS_RUNTIME_SWITCH_ENDIF +#endif // REFS_RUNTIME_OR_COMPRESSED break; } static const String* jlstring_desc_string = @@ -485,7 +489,11 @@ } else { if ((field_type == '[') || (field_type == 'L')) { // initialize the field explicitly. - REF_INIT_BY_ADDR(field_addr, 0); // i.e., null +#ifdef REFS_RUNTIME_OR_COMPRESSED + REFS_RUNTIME_SWITCH_IF + REF_INIT_BY_ADDR(field_addr, 0); // i.e., null + REFS_RUNTIME_SWITCH_ENDIF +#endif // REFS_RUNTIME_OR_COMPRESSED } } } // end if static field Index: vm/vmcore/src/thread/atomics_common.cpp =================================================================== --- vm/vmcore/src/thread/atomics_common.cpp (revision 585625) +++ vm/vmcore/src/thread/atomics_common.cpp (working copy) @@ -193,24 +193,21 @@ bool result; -#ifdef REFS_USE_RUNTIME_SWITCH - if (VM_Global_State::loader_env->compress_references) -#endif // REFS_USE_RUNTIME_SWITCH + REFS_RUNTIME_SWITCH_IF #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 + REFS_RUNTIME_SWITCH_ELSE #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 + REFS_RUNTIME_SWITCH_ENDIF tmn_suspend_enable(); return (jboolean)(result?JNI_TRUE:JNI_FALSE); Index: vm/vmcore/src/util/vm_strings.cpp =================================================================== --- vm/vmcore/src/util/vm_strings.cpp (revision 585625) +++ vm/vmcore/src/util/vm_strings.cpp (working copy) @@ -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, (ManagedObject**)(str_raw+f_value_offset), (ManagedObject*)chars); + STORE_REFERENCE(str, str_raw+f_value_offset, chars); } // GC must be disabled but at a same point Index: vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp =================================================================== --- vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (revision 585625) +++ vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (working copy) @@ -556,18 +556,7 @@ // 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. 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 - + REF_INIT_BY_ADDR(elem_ptr, NULL); return 0; } }