RFR(XS): 8149973: Optimize object alignment check in debug builds.
Dmitry Dmitriev
dmitry.dmitriev at oracle.com
Thu Mar 3 08:52:12 UTC 2016
Hello David,
Good question, as Coleen wrote this is done implicitly. Let me add few
more details.
cast_from_oop is defined in share/vm/oops/oopsHierarchy.hpp:
template <class T> inline T cast_from_oop(oop o) {
return (T)(CHECK_UNHANDLED_OOPS_ONLY((void*))o);
}
CHECK_UNHANDLED_OOPS_ONLY is defined in share/vm/utilities/macros.hpp:
#ifdef CHECK_UNHANDLED_OOPS
#define CHECK_UNHANDLED_OOPS_ONLY(code) code
#define NOT_CHECK_UNHANDLED_OOPS(code)
#else
#define CHECK_UNHANDLED_OOPS_ONLY(code)
#define NOT_CHECK_UNHANDLED_OOPS(code) code
#endif // CHECK_UNHANDLED_OOPS
I.e. in case when CHECK_UNHANDLED_OOPS is defined cast_from_oop will
looks like this:
template <class T> inline T cast_from_oop(oop o) {
return (T)((void*)o);
}
oop have an explicit user conversions for 'void *':
operator void* () const { return (void *)obj(); }
I.e. cast_from_oop<intptr_t>(obj) will evaluates to the: (intptr_t)
(obj.obj())
Thanks,
Dmitry
On 03.03.2016 5:43, David Holmes wrote:
> On 3/03/2016 2:03 AM, Dmitry Dmitriev wrote:
>> Hello Coleen,
>>
>> I implement refactoring which removes repeating of '&' expression.
>> In g1OopClosures.inline.hpp and g1RemSet.inline.hpp I removed extracting
>> of oopDesc* from oop and added call to check_obj_alignment instead.
>> Updated webrev.01:
>> http://cr.openjdk.java.net/~ddmitriev/8149973/webrev.01/
>> <http://cr.openjdk.java.net/%7Eddmitriev/8149973/webrev.01/>
>> Testing: jprt, hotspot_all & vm.quick(still in progress, no new
>> failures).
>
> I'm unclear on how the CHECK_UNHANDLED_OOPS case is handled in the
> cast_from_oop. In the original we had to "unwrap" obj as obj.obj(),
> but that no longer appears anywhere. ??
>
> Thanks,
> David
>
>> Thanks,
>> Dmitry
>>
>>
>> On 24.02.2016 15:35, Coleen Phillimore wrote:
>>>
>>> From
>>> http://cr.openjdk.java.net/~ddmitriev/8149973/webrev.00/src/share/vm/gc/g1/g1OopClosures.inline.hpp.udiff.html
>>>
>>>
>>> http://cr.openjdk.java.net/~ddmitriev/8149973/webrev.00/src/share/vm/gc/g1/g1RemSet.inline.hpp.udiff.html
>>>
>>>
>>>
>>> Can you just call
>>>
>>> assert(check_obj_alignment(o), "not oop aligned");
>>>
>>> rather than repeating the & expression? The check_obj_alignment is
>>> inlined.
>>>
>>> Coleen
>>>
>>> On 2/24/16 5:42 AM, Dmitry Dmitriev wrote:
>>>> Hello,
>>>>
>>>> Please, review small optimization to the object alignment check in
>>>> the debug builds. In this fix I replace division by
>>>> MinObjAlignmentInBytes to bitwise AND operation with
>>>> MinObjAlignmentInBytesMask, because MinObjAlignmentInBytes is a power
>>>> of two. Suggested construction already used in MacroAssembler, e.g.
>>>> hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp).
>>>>
>>>> JBS: https://bugs.openjdk.java.net/browse/JDK-8149973
>>>> webrev.00: http://cr.openjdk.java.net/~ddmitriev/8149973/webrev.00/
>>>> <http://cr.openjdk.java.net/%7Eddmitriev/8149973/webrev.00/>
>>>> Testing: jprt, hotspot_all
>>>>
>>>> Thanks,
>>>> Dmitry
>>>
>>
More information about the hotspot-dev
mailing list