Java Code Examples for jdk.nashorn.internal.runtime.linker.NashornGuards#getMapGuard()

The following examples show how to use jdk.nashorn.internal.runtime.linker.NashornGuards#getMapGuard() . 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: ScriptObject.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Fall back if a function property is not found.
 * @param desc The call site descriptor
 * @param request the link request
 * @return GuardedInvocation to be invoked at call site.
 */
public GuardedInvocation noSuchMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final String       name      = desc.getNameToken(2);
    final FindProperty find      = findProperty(NO_SUCH_METHOD_NAME, true);
    final boolean      scopeCall = isScope() && NashornCallSiteDescriptor.isScope(desc);

    if (find == null) {
        return noSuchProperty(desc, request);
    }

    final Object value = getObjectValue(find);
    if (! (value instanceof ScriptFunction)) {
        return createEmptyGetter(desc, name);
    }

    final ScriptFunction func = (ScriptFunction)value;
    final Object thiz = scopeCall && func.isStrict() ? ScriptRuntime.UNDEFINED : this;
    // TODO: It'd be awesome if we could bind "name" without binding "this".
    return new GuardedInvocation(MH.dropArguments(MH.constant(ScriptFunction.class,
            func.makeBoundFunction(thiz, new Object[] { name })), 0, Object.class),
            null, NashornGuards.getMapGuard(getMap()));
}
 
Example 2
Source File: ScriptObject.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Fall back if a function property is not found.
 * @param desc The call site descriptor
 * @param request the link request
 * @return GuardedInvocation to be invoked at call site.
 */
public GuardedInvocation noSuchMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final String       name      = desc.getNameToken(2);
    final FindProperty find      = findProperty(NO_SUCH_METHOD_NAME, true);
    final boolean      scopeCall = isScope() && NashornCallSiteDescriptor.isScope(desc);

    if (find == null) {
        return noSuchProperty(desc, request);
    }

    final Object value = getObjectValue(find);
    if (! (value instanceof ScriptFunction)) {
        return createEmptyGetter(desc, name);
    }

    final ScriptFunction func = (ScriptFunction)value;
    final Object thiz = scopeCall && func.isStrict() ? ScriptRuntime.UNDEFINED : this;
    // TODO: It'd be awesome if we could bind "name" without binding "this".
    return new GuardedInvocation(MH.dropArguments(MH.constant(ScriptFunction.class,
            func.makeBoundFunction(thiz, new Object[] { name })), 0, Object.class),
            null, NashornGuards.getMapGuard(getMap()));
}
 
Example 3
Source File: ScriptObject.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Fall back if a function property is not found.
 * @param desc The call site descriptor
 * @param request the link request
 * @return GuardedInvocation to be invoked at call site.
 */
public GuardedInvocation noSuchMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final String       name      = desc.getNameToken(2);
    final FindProperty find      = findProperty(NO_SUCH_METHOD_NAME, true);
    final boolean      scopeCall = isScope() && NashornCallSiteDescriptor.isScope(desc);

    if (find == null) {
        return noSuchProperty(desc, request);
    }

    final Object value = getObjectValue(find);
    if (! (value instanceof ScriptFunction)) {
        return createEmptyGetter(desc, name);
    }

    final ScriptFunction func = (ScriptFunction)value;
    final Object thiz = scopeCall && func.isStrict() ? ScriptRuntime.UNDEFINED : this;
    // TODO: It'd be awesome if we could bind "name" without binding "this".
    return new GuardedInvocation(MH.dropArguments(MH.constant(ScriptFunction.class,
            func.makeBoundFunction(thiz, new Object[] { name })), 0, Object.class),
            null, NashornGuards.getMapGuard(getMap()));
}
 
Example 4
Source File: ScriptObject.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck, final String name) {
    if (NashornCallSiteDescriptor.isOptimistic(desc)) {
        throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT);
    }

    return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()),
            NashornGuards.getMapGuard(getMap(), explicitInstanceOfCheck), getProtoSwitchPoints(name, null),
            explicitInstanceOfCheck ? null : ClassCastException.class);
}
 
Example 5
Source File: ScriptObject.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck, final String name) {
    if (NashornCallSiteDescriptor.isOptimistic(desc)) {
        throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT);
    }

    return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()),
            NashornGuards.getMapGuard(getMap(), explicitInstanceOfCheck), getProtoSwitchPoint(name, null),
            explicitInstanceOfCheck ? null : ClassCastException.class);
}
 
Example 6
Source File: ScriptObject.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck, final String name) {
    if (NashornCallSiteDescriptor.isOptimistic(desc)) {
        throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT);
    }

    return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()),
            NashornGuards.getMapGuard(getMap(), explicitInstanceOfCheck), getProtoSwitchPoints(name, null),
            explicitInstanceOfCheck ? null : ClassCastException.class);
}
 
Example 7
Source File: ScriptObject.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck, final String name) {
    if (NashornCallSiteDescriptor.isOptimistic(desc)) {
        throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT);
    }

    return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()),
            NashornGuards.getMapGuard(getMap(), explicitInstanceOfCheck), getProtoSwitchPoints(name, null),
            explicitInstanceOfCheck ? null : ClassCastException.class);
}
 
Example 8
Source File: ScriptObject.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck, final String name) {
    if (NashornCallSiteDescriptor.isOptimistic(desc)) {
        throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT);
    }

    return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()),
            NashornGuards.getMapGuard(getMap(), explicitInstanceOfCheck), getProtoSwitchPoints(name, null),
            explicitInstanceOfCheck ? null : ClassCastException.class);
}
 
Example 9
Source File: ScriptObject.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck, final String name) {
    if (NashornCallSiteDescriptor.isOptimistic(desc)) {
        throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT);
    }

    return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()),
            NashornGuards.getMapGuard(getMap(), explicitInstanceOfCheck), getProtoSwitchPoints(name, null),
            explicitInstanceOfCheck ? null : ClassCastException.class);
}
 
Example 10
Source File: ScriptObject.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck, final String name) {
    if (NashornCallSiteDescriptor.isOptimistic(desc)) {
        throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT);
    }

    return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()),
            NashornGuards.getMapGuard(getMap(), explicitInstanceOfCheck), getProtoSwitchPoints(name, null),
            explicitInstanceOfCheck ? null : ClassCastException.class);
}
 
Example 11
Source File: ScriptObject.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final String name) {
    return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()), getMap().getProtoGetSwitchPoint(proto, name), NashornGuards.getMapGuard(getMap()));
}
 
Example 12
Source File: SetMethodCreator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private MethodHandle getGuard() {
    return needsNoGuard() ? null : NashornGuards.getMapGuard(getMap());
}
 
Example 13
Source File: ScriptObject.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final String name) {
    return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()), getMap().getProtoGetSwitchPoint(proto, name), NashornGuards.getMapGuard(getMap()));
}
 
Example 14
Source File: SetMethodCreator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private MethodHandle getGuard() {
    return needsNoGuard() ? null : NashornGuards.getMapGuard(getMap());
}
 
Example 15
Source File: ScriptObject.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
private GuardedInvocation createEmptyGetter(final CallSiteDescriptor desc, final String name) {
    return new GuardedInvocation(Lookup.emptyGetter(desc.getMethodType().returnType()), getMap().getProtoGetSwitchPoint(proto, name), NashornGuards.getMapGuard(getMap()));
}
 
Example 16
Source File: SetMethodCreator.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
private MethodHandle getGuard() {
    return needsNoGuard() ? null : NashornGuards.getMapGuard(getMap());
}