RFR: 8200113: Make Access load proxys smarter
Erik Österlund
erik.osterlund at oracle.com
Fri Mar 23 08:29:17 UTC 2018
Hi Per,
Thanks for the review.
/Erik
On 2018-03-23 09:05, Per Liden wrote:
> Looks good!
>
> /Per
>
> On 03/22/2018 05:03 PM, Erik Österlund wrote:
>> Looping in hotspot-dev.
>>
>> /Erik
>>
>> On 2018-03-22 15:19, Erik Österlund wrote:
>>> Hi,
>>>
>>> Access returns the result of loads through load proxy objects that
>>> implicity convert themselves to a template inferred type. This is a
>>> metaprogramming technique used to infer return types in C++.
>>>
>>> However, I have heard requests that it would be great if it could be
>>> a bit smarter and do more than just be assigned to a type.
>>>
>>> Example use cases that do not work today without workarounds:
>>>
>>> oop val = ...;
>>> narrowOop narrow = 0u;
>>> oop *oop_val = &val;
>>> narrowOop *narrow_val = &narrow;
>>> HeapWord *heap_word_val = reinterpret_cast<HeapWord*>(oop_val);
>>>
>>> if (val == HeapAccess<>::oop_load_at(val, 16)) {}
>>> if (HeapAccess<>::oop_load_at(val, 16) == val) {}
>>> if (val != HeapAccess<>::oop_load_at(val, 16)) {}
>>> if (HeapAccess<>::oop_load_at(val, 16) != val) {}
>>>
>>> if (HeapAccess<>::oop_load(oop_val) != val) {}
>>> if (HeapAccess<>::oop_load(heap_word_val) != val) {}
>>> if (RawAccess<>::oop_load(narrow_val) != narrow) {}
>>>
>>> if (HeapAccess<>::oop_load(oop_val) == val) {}
>>> if (HeapAccess<>::oop_load(heap_word_val) == val) {}
>>> if (RawAccess<>::oop_load(narrow_val) == narrow) {}
>>>
>>> if (val != HeapAccess<>::oop_load(oop_val)) {}
>>> if (val != HeapAccess<>::oop_load(heap_word_val)) {}
>>> if (narrow != RawAccess<>::oop_load(narrow_val)) {}
>>>
>>> if (val == HeapAccess<>::oop_load(oop_val)) {}
>>> if (val == HeapAccess<>::oop_load(heap_word_val)) {}
>>> if (narrow == RawAccess<>::oop_load(narrow_val)) {}
>>>
>>> if ((oop)HeapAccess<>::oop_load(oop_val) == NULL) {}
>>>
>>> oop tmp = true ? HeapAccess<>::oop_load(oop_val) : val;
>>>
>>> Here is a patch that solves this:
>>> http://cr.openjdk.java.net/~eosterlund/8200113/webrev.00/
>>>
>>> ...and here is the bug ID:
>>> https://bugs.openjdk.java.net/browse/JDK-8200113
>>>
>>> Thanks,
>>> /Erik
>>>
>>
More information about the hotspot-gc-dev
mailing list