[REDO] Elide more final field's write memory barrier with escape analysis result

Hui Shi hui.shi at linaro.org
Tue Oct 27 14:49:27 UTC 2015

Fixing regression https://bugs.openjdk.java.net/browse/JDK-8139750, root
cause is stable field's allocation doesn't always dominate MemBarRelease
node created for stable field write. Could someone help review and sponsor
this changeset?

bug: https://bugs.openjdk.java.net/browse/JDK-8139758
webrev: http://cr.openjdk.java.net/~hshi/8139758/webrev_v2/

Analyzing java/util/Map/Defaults.java Error message is "assert(!had_error)
failed: bad dominance". Assertion fails because MemBarRelease's Precedent
input (checkCastPP node) doesn't dominate MemBarRelease node. Checking fail
compilation method java/lang/invoke/MethodType.makeImpl
1. early return when mt is not null.
2. stable field write is applied on newly created MethodType object.
3. MemBarRelease is created with Precedent input (allocation "new
MethodType(rtype, ptypes, trusted)")
4. MemBarRelease is created at the exit of this method. As early return
exits in this method, MemBarRealse is not dominated by its Precedent input.
This problem doesn't show up before my early change, because Precedent
input is only set for boxed type instance and no stable field in boxed type.

    MethodType makeImpl(Class<?> rtype, Class<?>[] ptypes, boolean trusted)
        MethodType mt = internTable.get(new MethodType(ptypes, rtype));
        if (mt != null)
            return mt;
        if (ptypes.length == 0) {
            ptypes = NO_PTYPES; trusted = true;
        mt = new MethodType(rtype, ptypes, trusted);
        // promote the object to the Real Thing, and reprobe
        mt.form = MethodTypeForm.findForm(mt);  // stable field write
        return internTable.add(mt);

For this reason, adding Precedent input for stable field store's
MemBarRealse is skipped in new patch. For final field store, allocation
always dominate MemBarRelease. Because allocation is immediately before
initializer method and method has only one entry.

New patch includes:
1. In do_put_xxx, set_alloc_with_final when filed is final and can find its
allocation. Remove constrains for boxed type check.
2. Skip setting MemBarRelease's Precedent input for stable field write.
There is no performance degradation here, before this change MemBarRelease
precedent input isn't set as alloc_with_final is only update for boxed
class and no stable field in boxed class.

Early discussion about why these constrains need removed and can be removed
is in

Shi Hui
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20151027/ec7f331b/attachment.html>

More information about the hotspot-compiler-dev mailing list