On 02/24/2015 02:47 PM, Paul Sandoz wrote: > On Feb 24, 2015, at 2:48 PM, Andrew Haley <a...@redhat.com> wrote:
>>> With that in mind is there any need to intrinsify the new methods >>> at all given those new Java methods can defer to the older ones >>> based on a constant check? Also should that anyway be done for the >>> interpreter? >>> >>> public void putIntUnaligned(Object o, long offset, int x) { if >>> (IS_UNALIGNED || (offset & 3) == 0) { putInt(o, offset, x); } else if >>> (byteOrder == BIG_ENDIAN) { putIntB(o, offset, x); } else { putIntL(o, >>> offset, x); } } >> >> Yes. It certainly could be done like this but I think C1 doesn't do >> the optimization to remove the IS_UNALIGNED test, so we'd still want >> the C1 builtins. > > Hmm.... if i run the following code on my Mac: > > > public int x(int i) { > if (X || (i & 3) == 0) { > return i + i; > } > else { > return Integer.sum(i, i); > } > } > With the options: > > -XX:TieredStopAtLevel=1 -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly > > Then Y.x is compiled to: > > 0x000000011155ea80: mov %eax,-0x14000(%rsp) > 0x000000011155ea87: push %rbp > 0x000000011155ea88: sub $0x30,%rsp ;*getstatic X > ; - Y::x@0 (line 43) > > 0x000000011155ea8c: mov %rdx,%rax > 0x000000011155ea8f: add %edx,%eax > 0x000000011155ea91: add $0x30,%rsp > 0x000000011155ea95: pop %rbp > 0x000000011155ea96: test %eax,-0x62ca9c(%rip) # 0x0000000110f32000 > ; {poll_return} > 0x000000011155ea9c: retq Oh, right, better than I thought. I should know by now to check before posting. But even so, we don't know that the method will be inlined. >>> If we expose the endianness query via a new method in unsafe we >>> should reuse that in java.nio.Bits and get rid of the associated >>> static code block. >> >> Sure, I already did that. >> > > Locally i guess? (just in case i missed something in the current webrev). Ah. I used the query but I forgot to get rid of the static code block: http://cr.openjdk.java.net/~aph/unaligned.jdk.1/src/java.base/share/classes/java/nio/Bits.java.cdiff.html Andrew.