diff --git a/enhanced/drlvm/trunk/vm/vmcore/include/annotation.h b/enhanced/drlvm/trunk/vm/vmcore/include/annotation.h index d305b35..50ae5a8 100644 --- a/enhanced/drlvm/trunk/vm/vmcore/include/annotation.h +++ b/enhanced/drlvm/trunk/vm/vmcore/include/annotation.h @@ -87,4 +87,5 @@ struct AnnotationTable { Annotation* table[1]; }; -#endif \ No newline at end of file +#endif + diff --git a/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp b/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp index 291bfe2..c5ffe57 100644 --- a/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp +++ b/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp @@ -71,6 +71,9 @@ #include "vm_stats.h" #define OFFSET(Struct, Field) \ ((POINTER_SIZE_SINT) (&(((Struct *) NULL)->Field) - NULL)) +#define OFFSET_INST(inst_ptr, Field) \ + ((POINTER_SIZE_SINT) ((char*)inst_ptr->Field - (char*)inst_ptr)) + // macro that gets the size of a field within a struct or class #define SIZE(Struct, Field) \ (sizeof(((Struct *) NULL)->Field)) @@ -263,8 +266,9 @@ static LilCodeStub* rth_gen_lil_type_tes } // Fast sequence - const POINTER_SIZE_INT is_fast_off = (POINTER_SIZE_INT)&((Class*)NULL)->is_suitable_for_fast_instanceof; - const POINTER_SIZE_INT depth_off = (POINTER_SIZE_INT)&((Class*)NULL)->depth; + Class* dummy = NULL; + const POINTER_SIZE_INT is_fast_off = OFFSET_INST(dummy, is_suitable_for_fast_instanceof); + const POINTER_SIZE_INT depth_off = OFFSET_INST(dummy, depth); const POINTER_SIZE_INT supertable_off = (POINTER_SIZE_INT)&((VTable*)NULL)->superclasses; bool do_slow = true; if (type) { @@ -2410,12 +2414,13 @@ static LilCodeStub* gen_lil_typecheck_fa object_get_vtable_offset()); } + Class* dummy = NULL; cs2 = lil_parse_onto_end (cs2, "ld l1, [i1 + %0i: g4],zx;" "ld l2, [l0 + %1i*l1 + %2i: pint];" "jc i1 != l2, failed;", - OFFSET(Class, depth), + OFFSET_INST(dummy, depth), sizeof(Class*), OFFSET(VTable, superclasses) - sizeof(Class*) + (vm_vtable_pointers_are_compressed() ? vm_get_vtable_base() : 0) ); @@ -2458,8 +2463,11 @@ static LilCodeStub* gen_lil_typecheck_fa LilCodeStub *gen_lil_typecheck_stub(bool is_checkcast) { // assert that some sizes are what we expect them to be - assert(SIZE(Class, is_suitable_for_fast_instanceof) == 4); - assert(SIZE(Class, depth) == 4); +#ifndef NDEBUG + Class* dummy_sizeof = NULL; + assert(sizeof(dummy_sizeof->is_suitable_for_fast_instanceof) == 4); + assert(sizeof(dummy_sizeof->depth) == 4); +#endif LilCodeStub* cs = NULL; @@ -2483,6 +2491,7 @@ LilCodeStub *gen_lil_typecheck_stub(bool Class::managed_null); } + Class* dummy = NULL; // check whether the fast or the slow path is appropriate cs = lil_parse_onto_end (cs, @@ -2491,7 +2500,7 @@ LilCodeStub *gen_lil_typecheck_stub(bool // check if super->is_suitable_for_fast_instanceof "ld l0, [i1 + %0i: g4];" "jc l0!=0:g4, fast;", - OFFSET(Class, is_suitable_for_fast_instanceof)); + OFFSET_INST(dummy, is_suitable_for_fast_instanceof)); // append the slow path right here cs = gen_lil_typecheck_slowpath(cs, is_checkcast);