[9] RFR (M): VM should constant fold Unsafe.get*() loads from final fields (original) (raw)

Paul Sandoz paul.sandoz at oracle.com
Wed Jun 24 13:37:53 UTC 2015


On Jun 24, 2015, at 2:59 PM, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> wrote:

Thanks, Paul!

I like the test, you have almost hand rolled your own specializer :-) I tried hard to avoid bytecode generation, but having 8 almost identical copies of the same logic is too much :-)

I agree, i like it and will likely use a similar approach in some tests i need to write.

A minor point. Since you have created a ClassWriter with "ClassWriter.COMPUTEMAXS | ClassWriter.COMPUTEFRAMES" can you remove the "mv.visitMax(0, 0)" calls?

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) { ... } ? Though I've removed WB.isCompileConstat() in the updated version,

Ok, i definitely understand the updated version :-)

I'll elaborate on that. WB.isCompileConstat() returns 3 values: * 0: the argument is not a compile-time constant; * 1: the argument is a compile-time constant; * -1: it's not known whether it is constant or not

"-1" signals that there's no data from JIT. WB.isCompileConstat() is intrinsified by a JIT-compiler. I implemented the intrinsics only in C2, so if you run the test in -Xint mode or with Client VM, WB.isCompileConstant() will always return -1. In order to be resilient, the test ignores "-1" when it checks the results.

Ah, thanks, that makes sense now, Paul. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 841 bytes Desc: Message signed with OpenPGP using GPGMail URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20150624/9d44c22a/signature.asc>



More information about the hotspot-compiler-dev mailing list