Java Code Examples for jdk.nashorn.internal.objects.annotations.SpecializedFunction.LinkLogic#EMPTY_INSTANCE

The following examples show how to use jdk.nashorn.internal.objects.annotations.SpecializedFunction.LinkLogic#EMPTY_INSTANCE . 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: ScriptFunction.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some receivers are primitive, in that case, according to the Spec we
 * create a new native object per callsite with the wrap filter. We can only
 * apply optimistic builtins if there is no per instance state saved for
 * these wrapped objects (e.g. currently NativeStrings), otherwise we can't
 * create optimistic versions
 *
 * @param self receiver
 * @param linkLogicClass linkLogicClass, or null if no link logic exists
 * @return link logic instance, or null if one could not be constructed for
 * this receiver
 */
private static LinkLogic getLinkLogic(final Object self, final Class<? extends LinkLogic> linkLogicClass) {
    if (linkLogicClass == null) {
        return LinkLogic.EMPTY_INSTANCE; //always OK to link this, specialization but without special linking logic
    }

    if (!Context.getContextTrusted().getEnv()._optimistic_types) {
        return null; //if optimistic types are off, optimistic builtins are too
    }

    final Object wrappedSelf = wrapFilter(self);
    if (wrappedSelf instanceof OptimisticBuiltins) {
        if (wrappedSelf != self && ((OptimisticBuiltins) wrappedSelf).hasPerInstanceAssumptions()) {
            return null; //pessimistic - we created a wrapped object different from the primitive, but the assumptions have instance state
        }
        return ((OptimisticBuiltins) wrappedSelf).getLinkLogic(linkLogicClass);
    }
    return null;
}
 
Example 2
Source File: ScriptFunction.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some receivers are primitive, in that case, according to the Spec we create a new
 * native object per callsite with the wrap filter. We can only apply optimistic builtins
 * if there is no per instance state saved for these wrapped objects (e.g. currently NativeStrings),
 * otherwise we can't create optimistic versions
 *
 * @param self            receiver
 * @param linkLogicClass  linkLogicClass, or null if no link logic exists
 * @return link logic instance, or null if one could not be constructed for this receiver
 */
private static LinkLogic getLinkLogic(final Object self, final Class<? extends LinkLogic> linkLogicClass) {
    if (linkLogicClass == null) {
        return LinkLogic.EMPTY_INSTANCE; //always OK to link this, specialization but without special linking logic
    }

    if (!Context.getContextTrusted().getEnv()._optimistic_types) {
        return null; //if optimistic types are off, optimistic builtins are too
    }

    final Object wrappedSelf = wrapFilter(self);
    if (wrappedSelf instanceof OptimisticBuiltins) {
        if (wrappedSelf != self && ((OptimisticBuiltins)wrappedSelf).hasPerInstanceAssumptions()) {
            return null; //pessimistic - we created a wrapped object different from the primitive, but the assumptions have instance state
        }
        return ((OptimisticBuiltins)wrappedSelf).getLinkLogic(linkLogicClass);
    }
    return null;
}
 
Example 3
Source File: ScriptFunction.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some receivers are primitive, in that case, according to the Spec we
 * create a new native object per callsite with the wrap filter. We can only
 * apply optimistic builtins if there is no per instance state saved for
 * these wrapped objects (e.g. currently NativeStrings), otherwise we can't
 * create optimistic versions
 *
 * @param self receiver
 * @param linkLogicClass linkLogicClass, or null if no link logic exists
 * @return link logic instance, or null if one could not be constructed for
 * this receiver
 */
private static LinkLogic getLinkLogic(final Object self, final Class<? extends LinkLogic> linkLogicClass) {
    if (linkLogicClass == null) {
        return LinkLogic.EMPTY_INSTANCE; //always OK to link this, specialization but without special linking logic
    }

    if (!Context.getContextTrusted().getEnv()._optimistic_types) {
        return null; //if optimistic types are off, optimistic builtins are too
    }

    final Object wrappedSelf = wrapFilter(self);
    if (wrappedSelf instanceof OptimisticBuiltins) {
        if (wrappedSelf != self && ((OptimisticBuiltins) wrappedSelf).hasPerInstanceAssumptions()) {
            return null; //pessimistic - we created a wrapped object different from the primitive, but the assumptions have instance state
        }
        return ((OptimisticBuiltins) wrappedSelf).getLinkLogic(linkLogicClass);
    }
    return null;
}
 
Example 4
Source File: ScriptFunction.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some receivers are primitive, in that case, according to the Spec we
 * create a new native object per callsite with the wrap filter. We can only
 * apply optimistic builtins if there is no per instance state saved for
 * these wrapped objects (e.g. currently NativeStrings), otherwise we can't
 * create optimistic versions
 *
 * @param self receiver
 * @param linkLogicClass linkLogicClass, or null if no link logic exists
 * @return link logic instance, or null if one could not be constructed for
 * this receiver
 */
private static LinkLogic getLinkLogic(final Object self, final Class<? extends LinkLogic> linkLogicClass) {
    if (linkLogicClass == null) {
        return LinkLogic.EMPTY_INSTANCE; //always OK to link this, specialization but without special linking logic
    }

    if (!Context.getContextTrusted().getEnv()._optimistic_types) {
        return null; //if optimistic types are off, optimistic builtins are too
    }

    final Object wrappedSelf = wrapFilter(self);
    if (wrappedSelf instanceof OptimisticBuiltins) {
        if (wrappedSelf != self && ((OptimisticBuiltins) wrappedSelf).hasPerInstanceAssumptions()) {
            return null; //pessimistic - we created a wrapped object different from the primitive, but the assumptions have instance state
        }
        return ((OptimisticBuiltins) wrappedSelf).getLinkLogic(linkLogicClass);
    }
    return null;
}
 
Example 5
Source File: ScriptFunction.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some receivers are primitive, in that case, according to the Spec we
 * create a new native object per callsite with the wrap filter. We can only
 * apply optimistic builtins if there is no per instance state saved for
 * these wrapped objects (e.g. currently NativeStrings), otherwise we can't
 * create optimistic versions
 *
 * @param self receiver
 * @param linkLogicClass linkLogicClass, or null if no link logic exists
 * @return link logic instance, or null if one could not be constructed for
 * this receiver
 */
private static LinkLogic getLinkLogic(final Object self, final Class<? extends LinkLogic> linkLogicClass) {
    if (linkLogicClass == null) {
        return LinkLogic.EMPTY_INSTANCE; //always OK to link this, specialization but without special linking logic
    }

    if (!Context.getContextTrusted().getEnv()._optimistic_types) {
        return null; //if optimistic types are off, optimistic builtins are too
    }

    final Object wrappedSelf = wrapFilter(self);
    if (wrappedSelf instanceof OptimisticBuiltins) {
        if (wrappedSelf != self && ((OptimisticBuiltins) wrappedSelf).hasPerInstanceAssumptions()) {
            return null; //pessimistic - we created a wrapped object different from the primitive, but the assumptions have instance state
        }
        return ((OptimisticBuiltins) wrappedSelf).getLinkLogic(linkLogicClass);
    }
    return null;
}
 
Example 6
Source File: ScriptFunction.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some receivers are primitive, in that case, according to the Spec we
 * create a new native object per callsite with the wrap filter. We can only
 * apply optimistic builtins if there is no per instance state saved for
 * these wrapped objects (e.g. currently NativeStrings), otherwise we can't
 * create optimistic versions
 *
 * @param self receiver
 * @param linkLogicClass linkLogicClass, or null if no link logic exists
 * @return link logic instance, or null if one could not be constructed for
 * this receiver
 */
private static LinkLogic getLinkLogic(final Object self, final Class<? extends LinkLogic> linkLogicClass) {
    if (linkLogicClass == null) {
        return LinkLogic.EMPTY_INSTANCE; //always OK to link this, specialization but without special linking logic
    }

    if (!Context.getContextTrusted().getEnv()._optimistic_types) {
        return null; //if optimistic types are off, optimistic builtins are too
    }

    final Object wrappedSelf = wrapFilter(self);
    if (wrappedSelf instanceof OptimisticBuiltins) {
        if (wrappedSelf != self && ((OptimisticBuiltins) wrappedSelf).hasPerInstanceAssumptions()) {
            return null; //pessimistic - we created a wrapped object different from the primitive, but the assumptions have instance state
        }
        return ((OptimisticBuiltins) wrappedSelf).getLinkLogic(linkLogicClass);
    }
    return null;
}
 
Example 7
Source File: ScriptFunction.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some receivers are primitive, in that case, according to the Spec we
 * create a new native object per callsite with the wrap filter. We can only
 * apply optimistic builtins if there is no per instance state saved for
 * these wrapped objects (e.g. currently NativeStrings), otherwise we can't
 * create optimistic versions
 *
 * @param self receiver
 * @param linkLogicClass linkLogicClass, or null if no link logic exists
 * @return link logic instance, or null if one could not be constructed for
 * this receiver
 */
private static LinkLogic getLinkLogic(final Object self, final Class<? extends LinkLogic> linkLogicClass) {
    if (linkLogicClass == null) {
        return LinkLogic.EMPTY_INSTANCE; //always OK to link this, specialization but without special linking logic
    }

    if (!Context.getContextTrusted().getEnv()._optimistic_types) {
        return null; //if optimistic types are off, optimistic builtins are too
    }

    final Object wrappedSelf = wrapFilter(self);
    if (wrappedSelf instanceof OptimisticBuiltins) {
        if (wrappedSelf != self && ((OptimisticBuiltins) wrappedSelf).hasPerInstanceAssumptions()) {
            return null; //pessimistic - we created a wrapped object different from the primitive, but the assumptions have instance state
        }
        return ((OptimisticBuiltins) wrappedSelf).getLinkLogic(linkLogicClass);
    }
    return null;
}