RFR: Some patches for sherman

Martin Buchholz martinrb at google.com
Sat Mar 31 00:26:05 UTC 2018

On Fri, Mar 30, 2018 at 5:01 PM, Paul Sandoz <paul.sandoz at oracle.com> wrote:

> If the res field is non-volatile then is C2 already capable of hoisting
> the field access out of the loop as if the result was assigned to a local
> variable?
> final ZipFile z = …
> final z_res = z.res;
> while (...) {
>   use(z_res);
> }

It can do this if it can inline everything and determine that nothing
inside the loop writes to res AND there is no synchronization happening
(else you would need to prove no other thread is writing to the field).  So
I would be surprised if any JIT would do this in practice for a complex

Relatedly, I have a local mod to ZipFile that does:

        final byte[] cen;
        final int[] entries;
        final int entryCount;
        final ZipCoder zc = this.zc;
        // Acquire the lock once briefly to obtain immutable data
        synchronized (ZipFile.this) {
            cen = zsrc.cen;
            entries = zsrc.entries;
            entryCount = zsrc.total;

.... use(cen, entries, entryCount, zc)

More information about the core-libs-dev mailing list