RFR: 8200113: Make Access load proxys smarter (original) (raw)

Erik Ă–sterlund erik.osterlund at oracle.com
Thu Mar 22 14:19:55 UTC 2018


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