[9] RFR (M): VM should constant fold Unsafe.get*() loads from final fields (original) (raw)
Remi Forax forax at univ-mlv.fr
Thu Jun 18 12:12:32 UTC 2015
- Previous message: [9] RFR (M): VM should constant fold Unsafe.get*() loads from final fields
- Next message: [9] RFR (M): VM should constant fold Unsafe.get*() loads from final fields
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Paul,
On 06/18/2015 02:03 PM, Paul Sandoz wrote:
Hi Vladimir,
I like the test, you have almost hand rolled your own specializer :-) A minor point. Since you have created a ClassWriter with "ClassWriter.COMPUTEMAXS | ClassWriter.COMPUTEFRAMES" can you remove the "mv.visitMax(0, 0)" calls?
no, you can't. even if you ask ASM to compute the maxs, you still need to call visitMaxs() or kitten will die.
Rémi
I was a little confused by the code that checked the expected result against the actual result. I am guessing the white box methods return -1 if the value is not a constant and 1 if it is. (Perhaps that can be documented, if even those methods may eventually reside somewhere else.) Whereas, Generator.expected returns 0 or 1. 118 if (direct != unsafe || // difference between testDirect & testUnsafe 119 (unsafe != -1 && expected != unsafe)) // differs from expected, but ignore "unknown"(-1) result 120 { 121 throw new AssertionError(String.format("%s: e=%d; d=%d; u=%d", t.name(), expected, direct, unsafe)); 122 } I don't quite understand why "unknown"(-1) can be ignored. Can that be changed to the following if Generator.expected returned the same values as the WB methods? if (direct != unsafe || unsafe != expected) { ... } ? Paul. On Jun 17, 2015, at 6:38 PM, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> wrote: http://cr.openjdk.java.net/~vlivanov/8078629/webrev.00/ https://bugs.openjdk.java.net/browse/JDK-8078629
Direct(getfield/getstatic) read operations are faster than unsafe reads from constant Java fields, since VM doesn't constant fold unsafe loads. Though VM tries hard to recover field metadata from its offset, it doesn't optimize unsafe ones even if it has all necessary info in its hands. The fix is to align the behavior and share relevant code between C2 parser and intrinsic expansion logic. For testing purposes, I extended whitebox API to check whether a value is a compile-time constant. The whitebox test enumerates all combinations of a field and ensures that the behavior is consistent between bytecode and unsafe reads. Testing: focused whitebox tests, hotspot/test/compiler, jdk/test/java/lang/invoke, octane (for performance measurements) Thanks! Best regards, Vladimir Ivanov
- Previous message: [9] RFR (M): VM should constant fold Unsafe.get*() loads from final fields
- Next message: [9] RFR (M): VM should constant fold Unsafe.get*() loads from final fields
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the hotspot-compiler-dev mailing list