--- 17/hotspot/src/share/vm/opto/parseHelper.cpp 2007-11-05 19:34:46.623027000 +0100 +++ 17_adapted/hotspot/src/share/vm/opto/parseHelper.cpp 2007-11-05 16:28:03.269223000 +0100 @@ -318,9 +318,19 @@ Node* adr_node = method_data_addressing(md, data, counter_offset, idx, stride); const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr(); + // The following code is tricky because the counters are defiend as elements of an 'intptr_t' array + // in the 'DataLayout' class in 'methodDataOop.hpp'. So if we are in 64-bit mode, they are 64-bit + // values. If we treat them here as 32-bit values (T_INT) and if we are on a big-endian archtecture + // like SPARC, we end up incrementing the wrong 32 bits of the 64-bit counter. (vs) +#ifdef _LP64 + Node* cnt = make_load(NULL, adr_node, TypeLong::LONG, T_LONG, adr_type); + Node* incr = _gvn.transform(new (C, 3) AddLNode(cnt, _gvn.longcon(DataLayout::counter_increment))); + store_to_memory(NULL, adr_node, incr, T_LONG, adr_type ); +#else Node* cnt = make_load(NULL, adr_node, TypeInt::INT, T_INT, adr_type); Node* incr = _gvn.transform(new (C, 3) AddINode(cnt, _gvn.intcon(DataLayout::counter_increment))); store_to_memory(NULL, adr_node, incr, T_INT, adr_type ); +#endif } //--------------------------test_for_osr_md_counter_at------------------------- @@ -328,7 +338,15 @@ Node* adr_node = method_data_addressing(md, data, counter_offset); const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr(); + // The following code is tricky because the counters are defiend as elements of an 'intptr_t' array + // in the 'DataLayout' class in 'methodDataOop.hpp'. So if we are in 64-bit mode, they are 64-bit + // values. If we treat them here as 32-bit values (T_INT) and if we are on a big-endian archtecture + // like SPARC, we end up using the wrong 32 bits of the 64-bit counter. (vs) +#ifdef _LP64 + Node* cnt = make_load(NULL, adr_node, TypeLong::LONG, T_LONG, adr_type); +#else Node* cnt = make_load(NULL, adr_node, TypeInt::INT, T_INT, adr_type); +#endif test_counter_against_threshold(cnt, limit); }