Java Code Examples for java.lang.invoke.SwitchPoint#hasBeenInvalidated()

The following examples show how to use java.lang.invoke.SwitchPoint#hasBeenInvalidated() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompiledFunction.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a pair of an invocation created with a passed-in supplier and a non-invalidated switch point for
 * optimistic assumptions (or null for the switch point if the function can not be deoptimized). While the method
 * makes a best effort to return a non-invalidated switch point (compensating for possible deoptimizing
 * recompilation happening on another thread) it is still possible that by the time this method returns the
 * switchpoint has been invalidated by a {@code RewriteException} triggered on another thread for this function.
 * This is not a problem, though, as these switch points are always used to produce call sites that fall back to
 * relinking when they are invalidated, and in this case the execution will end up here again. What this method
 * basically does is minimize such busy-loop relinking while the function is being recompiled on a different thread.
 * @param invocationSupplier the supplier that constructs the actual invocation method handle; should use the
 * {@code CompiledFunction} method itself in some capacity.
 * @return a tuple object containing the method handle as created by the supplier and an optimistic assumptions
 * switch point that is guaranteed to not have been invalidated before the call to this method (or null if the
 * function can't be further deoptimized).
 */
private synchronized HandleAndAssumptions getValidOptimisticInvocation(final Supplier<MethodHandle> invocationSupplier) {
    for(;;) {
        final MethodHandle handle = invocationSupplier.get();
        final SwitchPoint assumptions = canBeDeoptimized() ? optimismInfo.optimisticAssumptions : null;
        if(assumptions != null && assumptions.hasBeenInvalidated()) {
            // We can be in a situation where one thread is in the middle of a deoptimizing compilation when we hit
            // this and thus, it has invalidated the old switch point, but hasn't created the new one yet. Note that
            // the behavior of invalidating the old switch point before recompilation, and only creating the new one
            // after recompilation is by design. If we didn't wait here for the recompilation to complete, we would
            // be busy looping through the fallback path of the invalidated switch point, relinking the call site
            // again with the same invalidated switch point, invoking the fallback, etc. stealing CPU cycles from
            // the recompilation task we're dependent on. This can still happen if the switch point gets invalidated
            // after we grabbed it here, in which case we'll indeed do one busy relink immediately.
            try {
                wait();
            } catch (final InterruptedException e) {
                // Intentionally ignored. There's nothing meaningful we can do if we're interrupted
            }
        } else {
            return new HandleAndAssumptions(handle, assumptions);
        }
    }
}
 
Example 2
Source File: CompiledFunction.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a pair of an invocation created with a passed-in supplier and a non-invalidated switch point for
 * optimistic assumptions (or null for the switch point if the function can not be deoptimized). While the method
 * makes a best effort to return a non-invalidated switch point (compensating for possible deoptimizing
 * recompilation happening on another thread) it is still possible that by the time this method returns the
 * switchpoint has been invalidated by a {@code RewriteException} triggered on another thread for this function.
 * This is not a problem, though, as these switch points are always used to produce call sites that fall back to
 * relinking when they are invalidated, and in this case the execution will end up here again. What this method
 * basically does is minimize such busy-loop relinking while the function is being recompiled on a different thread.
 * @param invocationSupplier the supplier that constructs the actual invocation method handle; should use the
 * {@code CompiledFunction} method itself in some capacity.
 * @return a tuple object containing the method handle as created by the supplier and an optimistic assumptions
 * switch point that is guaranteed to not have been invalidated before the call to this method (or null if the
 * function can't be further deoptimized).
 */
private synchronized HandleAndAssumptions getValidOptimisticInvocation(final Supplier<MethodHandle> invocationSupplier) {
    for(;;) {
        final MethodHandle handle = invocationSupplier.get();
        final SwitchPoint assumptions = canBeDeoptimized() ? optimismInfo.optimisticAssumptions : null;
        if(assumptions != null && assumptions.hasBeenInvalidated()) {
            // We can be in a situation where one thread is in the middle of a deoptimizing compilation when we hit
            // this and thus, it has invalidated the old switch point, but hasn't created the new one yet. Note that
            // the behavior of invalidating the old switch point before recompilation, and only creating the new one
            // after recompilation is by design. If we didn't wait here for the recompilation to complete, we would
            // be busy looping through the fallback path of the invalidated switch point, relinking the call site
            // again with the same invalidated switch point, invoking the fallback, etc. stealing CPU cycles from
            // the recompilation task we're dependent on. This can still happen if the switch point gets invalidated
            // after we grabbed it here, in which case we'll indeed do one busy relink immediately.
            try {
                wait();
            } catch (final InterruptedException e) {
                // Intentionally ignored. There's nothing meaningful we can do if we're interrupted
            }
        } else {
            return new HandleAndAssumptions(handle, assumptions);
        }
    }
}
 
Example 3
Source File: ScriptObject.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private SwitchPoint findBuiltinSwitchPoint(final String key) {
    for (ScriptObject myProto = getProto(); myProto != null; myProto = myProto.getProto()) {
        final Property prop = myProto.getMap().findProperty(key);
        if (prop != null) {
            final SwitchPoint sp = prop.getBuiltinSwitchPoint();
            if (sp != null && !sp.hasBeenInvalidated()) {
                return sp;
            }
        }
    }
    return null;
}
 
Example 4
Source File: ScriptObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private SwitchPoint findBuiltinSwitchPoint(final String key) {
    for (ScriptObject myProto = getProto(); myProto != null; myProto = myProto.getProto()) {
        final Property prop = myProto.getMap().findProperty(key);
        if (prop != null) {
            final SwitchPoint sp = prop.getBuiltinSwitchPoint();
            if (sp != null && !sp.hasBeenInvalidated()) {
                return sp;
            }
        }
    }
    return null;
}
 
Example 5
Source File: Global.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private synchronized SwitchPoint getLexicalScopeSwitchPoint() {
    SwitchPoint switchPoint = lexicalScopeSwitchPoint;
    if (switchPoint == null || switchPoint.hasBeenInvalidated()) {
        switchPoint = lexicalScopeSwitchPoint = new SwitchPoint();
    }
    return switchPoint;
}
 
Example 6
Source File: WithObject.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private static boolean hasBeenInvalidated(final SwitchPoint[] switchPoints) {
    if (switchPoints != null) {
        for (final SwitchPoint switchPoint : switchPoints) {
            if (switchPoint.hasBeenInvalidated()) {
                return true;
            }
        }
    }
    return false;
}
 
Example 7
Source File: WithObject.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static boolean hasBeenInvalidated(final SwitchPoint[] switchPoints) {
    if (switchPoints != null) {
        for (final SwitchPoint switchPoint : switchPoints) {
            if (switchPoint.hasBeenInvalidated()) {
                return true;
            }
        }
    }
    return false;
}
 
Example 8
Source File: WithObject.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static boolean hasBeenInvalidated(final SwitchPoint[] switchPoints) {
    if (switchPoints != null) {
        for (final SwitchPoint switchPoint : switchPoints) {
            if (switchPoint.hasBeenInvalidated()) {
                return true;
            }
        }
    }
    return false;
}
 
Example 9
Source File: GuardedInvocation.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if and only if this guarded invocation has a switchpoint, and that switchpoint has been invalidated.
 * @return true if and only if this guarded invocation has a switchpoint, and that switchpoint has been invalidated.
 */
public boolean hasBeenInvalidated() {
    if (switchPoints == null) {
        return false;
    }
    for (final SwitchPoint sp : switchPoints) {
        if (sp.hasBeenInvalidated()) {
            return true;
        }
    }
    return false;
}
 
Example 10
Source File: GuardedInvocation.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if and only if this guarded invocation has a switchpoint, and that switchpoint has been invalidated.
 * @return true if and only if this guarded invocation has a switchpoint, and that switchpoint has been invalidated.
 */
public boolean hasBeenInvalidated() {
    if (switchPoints == null) {
        return false;
    }
    for (final SwitchPoint sp : switchPoints) {
        if (sp.hasBeenInvalidated()) {
            return true;
        }
    }
    return false;
}
 
Example 11
Source File: ScriptObject.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private SwitchPoint findBuiltinSwitchPoint(final Object key) {
    for (ScriptObject myProto = getProto(); myProto != null; myProto = myProto.getProto()) {
        final Property prop = myProto.getMap().findProperty(key);
        if (prop != null) {
            final SwitchPoint sp = prop.getBuiltinSwitchPoint();
            if (sp != null && !sp.hasBeenInvalidated()) {
                return sp;
            }
        }
    }
    return null;
}
 
Example 12
Source File: ScriptObject.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private SwitchPoint findBuiltinSwitchPoint(final String key) {
    for (ScriptObject myProto = getProto(); myProto != null; myProto = myProto.getProto()) {
        final Property prop = myProto.getMap().findProperty(key);
        if (prop != null) {
            final SwitchPoint sp = prop.getBuiltinSwitchPoint();
            if (sp != null && !sp.hasBeenInvalidated()) {
                return sp;
            }
        }
    }
    return null;
}
 
Example 13
Source File: Global.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private synchronized SwitchPoint getLexicalScopeSwitchPoint() {
    SwitchPoint switchPoint = lexicalScopeSwitchPoint;
    if (switchPoint == null || switchPoint.hasBeenInvalidated()) {
        switchPoint = lexicalScopeSwitchPoint = new SwitchPoint();
    }
    return switchPoint;
}
 
Example 14
Source File: GuardedInvocation.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if and only if this guarded invocation has a switchpoint, and that switchpoint has been invalidated.
 * @return true if and only if this guarded invocation has a switchpoint, and that switchpoint has been invalidated.
 */
public boolean hasBeenInvalidated() {
    if (switchPoints == null) {
        return false;
    }
    for (final SwitchPoint sp : switchPoints) {
        if (sp.hasBeenInvalidated()) {
            return true;
        }
    }
    return false;
}
 
Example 15
Source File: WithObject.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static boolean hasBeenInvalidated(final SwitchPoint[] switchPoints) {
    if (switchPoints != null) {
        for (final SwitchPoint switchPoint : switchPoints) {
            if (switchPoint.hasBeenInvalidated()) {
                return true;
            }
        }
    }
    return false;
}
 
Example 16
Source File: Global.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private synchronized SwitchPoint getLexicalScopeSwitchPoint() {
    SwitchPoint switchPoint = lexicalScopeSwitchPoint;
    if (switchPoint == null || switchPoint.hasBeenInvalidated()) {
        switchPoint = lexicalScopeSwitchPoint = new SwitchPoint();
    }
    return switchPoint;
}
 
Example 17
Source File: GuardedInvocation.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if and only if this guarded invocation has at least one
 * invalidated switch point.
 * @return true if and only if this guarded invocation has at least one
 * invalidated switch point.
 */
public boolean hasBeenInvalidated() {
    if (switchPoints == null) {
        return false;
    }
    for (final SwitchPoint sp : switchPoints) {
        if (sp.hasBeenInvalidated()) {
            return true;
        }
    }
    return false;
}
 
Example 18
Source File: Global.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private synchronized SwitchPoint getLexicalScopeSwitchPoint() {
    SwitchPoint switchPoint = lexicalScopeSwitchPoint;
    if (switchPoint == null || switchPoint.hasBeenInvalidated()) {
        switchPoint = lexicalScopeSwitchPoint = new SwitchPoint();
    }
    return switchPoint;
}
 
Example 19
Source File: WithObject.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unused")
private static boolean withExpressionGuard(final Object receiver, final PropertyMap map, final SwitchPoint sp) {
    return ((WithObject)receiver).expression.getMap() == map && (sp == null || !sp.hasBeenInvalidated());
}
 
Example 20
Source File: WithObject.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unused")
private static boolean withExpressionGuard(final Object receiver, final PropertyMap map, final SwitchPoint sp) {
    return ((WithObject)receiver).expression.getMap() == map && (sp == null || !sp.hasBeenInvalidated());
}