jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor的实例源码

项目:Openjsharp    文件Global.java   
@Override
public GuardedInvocation findgetmethod(final CallSiteDescriptor desc,final LinkRequest request,final String operator) {
    final String name = desc.getNametoken(CallSiteDescriptor.NAME_OPERAND);
    final boolean isScope = NashornCallSiteDescriptor.isScope(desc);

    if (lexicalScope != null && isScope && !NashornCallSiteDescriptor.isApplyToCall(desc)) {
        if (lexicalScope.hasOwnProperty(name)) {
            return lexicalScope.findgetmethod(desc,request,operator);
        }
    }

    final GuardedInvocation invocation =  super.findgetmethod(desc,operator);

    // We want to avoid adding our generic lexical scope switchpoint to global constant invocations,// because those are invalidated per-key in the addBoundProperties method above.
    // We therefor check if the invocation does already have a switchpoint and the property is non-inherited,// assuming this only applies to global constants. If other non-inherited properties will
    // start using switchpoints some time in the future we'll have to revisit this.
    if (isScope && context.getEnv()._es6 && (invocation.getSwitchPoints() == null || !hasOwnProperty(name))) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:Openjsharp    文件Global.java   
@Override
public GuardedInvocation findSetMethod(final CallSiteDescriptor desc,final LinkRequest request) {
    final boolean isScope = NashornCallSiteDescriptor.isScope(desc);

    if (lexicalScope != null && isScope) {
        final String name = desc.getNametoken(CallSiteDescriptor.NAME_OPERAND);
        if (lexicalScope.hasOwnProperty(name)) {
            return lexicalScope.findSetMethod(desc,request);
        }
    }

    final GuardedInvocation invocation = super.findSetMethod(desc,request);

    if (isScope && context.getEnv()._es6) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:Openjsharp    文件ContinuousArrayData.java   
/**
 * Return a fast linked array getter,or null if we have to dispatch to super class
 * @param desc     descriptor
 * @param request  link request
 * @return invocation or null if needs to be sent to slow relink
 */
@Override
public GuardedInvocation findFastGetIndexMethod(final Class<? extends ArrayData> clazz,final CallSiteDescriptor desc,final LinkRequest request) {
    final MethodType callType   = desc.getmethodType();
    final Class<?>   indexType  = callType.parameterType(1);
    final Class<?>   returnType = callType.returnType();

    if (ContinuousArrayData.class.isAssignableFrom(clazz) && indexType == int.class) {
        final Object[] args  = request.getArguments();
        final int      index = (int)args[args.length - 1];

        if (has(index)) {
            final MethodHandle getArray     = ScriptObject.GET_ARRAY.methodHandle();
            final int          programPoint = NashornCallSiteDescriptor.isOptimistic(desc) ? NashornCallSiteDescriptor.getProgramPoint(desc) : INVALID_PROGRAM_POINT;
            MethodHandle       getElement   = getElementGetter(returnType,programPoint);
            if (getElement != null) {
                getElement = MH.filterarguments(getElement,MH.asType(getArray,getArray.type().changeReturnType(clazz)));
                final MethodHandle guard = MH.insertArguments(FAST_ACCESS_GUARD,clazz);
                return new GuardedInvocation(getElement,guard,(SwitchPoint)null,ClassCastException.class);
            }
        }
    }

    return null;
}
项目:openjdk-jdk10    文件Global.java   
@Override
public GuardedInvocation findgetmethod(final CallSiteDescriptor desc,final LinkRequest request) {
    final String name = NashornCallSiteDescriptor.getoperand(desc);
    final boolean isScope = NashornCallSiteDescriptor.isScope(desc);

    if (lexicalScope != null && isScope && !NashornCallSiteDescriptor.isApplyToCall(desc)) {
        if (lexicalScope.hasOwnProperty(name)) {
            return lexicalScope.findgetmethod(desc,request);
        }
    }

    final GuardedInvocation invocation =  super.findgetmethod(desc,request);

    // We want to avoid adding our generic lexical scope switchpoint to global constant invocations,// because those are invalidated per-key in the addBoundProperties method above.
    // We therefore check if the invocation does already have a switchpoint and the property is non-inherited,// assuming this only applies to global constants. If other non-inherited properties will
    // start using switchpoints some time in the future we'll have to revisit this.
    if (isScope && context.getEnv()._es6 && (invocation.getSwitchPoints() == null || !hasOwnProperty(name))) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:openjdk-jdk10    文件Global.java   
@Override
public GuardedInvocation findSetMethod(final CallSiteDescriptor desc,final LinkRequest request) {
    final boolean isScope = NashornCallSiteDescriptor.isScope(desc);

    if (lexicalScope != null && isScope) {
        final String name = NashornCallSiteDescriptor.getoperand(desc);
        if (lexicalScope.hasOwnProperty(name)) {
            return lexicalScope.findSetMethod(desc,request);

    if (isScope && context.getEnv()._es6) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:openjdk-jdk10    文件ContinuousArrayData.java   
/**
 * Return a fast linked array getter,ClassCastException.class);
            }
        }
    }

    return null;
}
项目:openjdk-jdk10    文件Undefined.java   
/**
 * Lookup the appropriate method for an invoke dynamic call.
 * @param desc The invoke dynamic callsite descriptor.
 * @return GuardedInvocation to be invoked at call site.
 */
public static GuardedInvocation lookup(final CallSiteDescriptor desc) {
    switch (NashornCallSiteDescriptor.getStandardOperation(desc)) {
    case CALL:
    case NEW:
        final String name = NashornCallSiteDescriptor.getoperand(desc);
        final String msg = name != null? "not.a.function" : "cant.call.undefined";
        throw typeError(msg,name);
    case GET:
        // NOTE: we support GET:ELEMENT and SET:ELEMENT as JavaScript doesn't distinguish items from properties. Nashorn itself
        // emits "GET:PROPERTY|ELEMENT|METHOD:identifier" for "<expr>.<identifier>" and "GET:ELEMENT|PROPERTY|METHOD" for "<expr>[<expr>]",but we are
        // more flexible here and dispatch not on operation name (getProp vs. getElem),but rather on whether the
        // operation has an associated name or not.
        if (!(desc.getoperation() instanceof NamedOperation)) {
            return findGetIndexMethod(desc);
        }
        return findgetmethod(desc);
    case SET:
        if (!(desc.getoperation() instanceof NamedOperation)) {
            return findSetIndexMethod(desc);
        }
        return findSetMethod(desc);
    default:
    }
    return null;
}
项目:openjdk-jdk10    文件ScriptObject.java   
/**
 * Lookup method that,given a CallSiteDescriptor,looks up the target
 * MethodHandle and creates a GuardedInvocation
 * with the appropriate guard(s).
 *
 * @param desc call site descriptor
 * @param request the link request
 *
 * @return GuardedInvocation for the callsite
 */
public GuardedInvocation lookup(final CallSiteDescriptor desc,final LinkRequest request) {
    // NOTE: we support GET:ELEMENT and SET:ELEMENT as JavaScript doesn't distinguish items from properties. Nashorn itself
    // emits "GET:PROPERTY|ELEMENT|METHOD:identifier" for "<expr>.<identifier>" and "GET:ELEMENT|PROPERTY|METHOD" for "<expr>[<expr>]",but we are
    // more flexible here and dispatch not on operation name (getProp vs. getElem),but rather on whether the
    // operation has an associated name or not.
    switch (NashornCallSiteDescriptor.getStandardOperation(desc)) {
    case GET:
        return desc.getoperation() instanceof NamedOperation
                ? findgetmethod(desc,request)
                : findGetIndexMethod(desc,request);
    case SET:
        return desc.getoperation() instanceof NamedOperation
                ? findSetMethod(desc,request)
                : findSetIndexMethod(desc,request);
    case CALL:
        return findCallMethod(desc,request);
    case NEW:
        return findNewMethod(desc,request);
    default:
        return null;
    }
}
项目:openjdk9    文件Global.java   
@Override
public GuardedInvocation findgetmethod(final CallSiteDescriptor desc,final StandardOperation operation) {
    final String name = NashornCallSiteDescriptor.getoperand(desc);
    final boolean isScope = NashornCallSiteDescriptor.isScope(desc);

    if (lexicalScope != null && isScope && !NashornCallSiteDescriptor.isApplyToCall(desc)) {
        if (lexicalScope.hasOwnProperty(name)) {
            return lexicalScope.findgetmethod(desc,operation);
        }
    }

    final GuardedInvocation invocation =  super.findgetmethod(desc,operation);

    // We want to avoid adding our generic lexical scope switchpoint to global constant invocations,// assuming this only applies to global constants. If other non-inherited properties will
    // start using switchpoints some time in the future we'll have to revisit this.
    if (isScope && context.getEnv()._es6 && (invocation.getSwitchPoints() == null || !hasOwnProperty(name))) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:openjdk9    文件Global.java   
@Override
public GuardedInvocation findSetMethod(final CallSiteDescriptor desc,request);

    if (isScope && context.getEnv()._es6) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:openjdk9    文件ContinuousArrayData.java   
/**
 * Return a fast linked array getter,ClassCastException.class);
            }
        }
    }

    return null;
}
项目:kaziranga    文件Global.java   
@Override
public GuardedInvocation findgetmethod(final CallSiteDescriptor desc,// assuming this only applies to global constants. If other non-inherited properties will
    // start using switchpoints some time in the future we'll have to revisit this.
    if (isScope && context.getEnv()._es6 && (invocation.getSwitchPoints() == null || !hasOwnProperty(name))) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:kaziranga    文件Global.java   
@Override
public GuardedInvocation findSetMethod(final CallSiteDescriptor desc,request);

    if (isScope && context.getEnv()._es6) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:kaziranga    文件ContinuousArrayData.java   
/**
 * Return a fast linked array getter,ClassCastException.class);
            }
        }
    }

    return null;
}
项目:lookaside_java-1.8.0-openjdk    文件Global.java   
@Override
public GuardedInvocation findgetmethod(final CallSiteDescriptor desc,// assuming this only applies to global constants. If other non-inherited properties will
    // start using switchpoints some time in the future we'll have to revisit this.
    if (isScope && context.getEnv()._es6 && (invocation.getSwitchPoints() == null || !hasOwnProperty(name))) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:lookaside_java-1.8.0-openjdk    文件Global.java   
@Override
public GuardedInvocation findSetMethod(final CallSiteDescriptor desc,request);

    if (isScope && context.getEnv()._es6) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:lookaside_java-1.8.0-openjdk    文件ContinuousArrayData.java   
/**
 * Return a fast linked array getter,ClassCastException.class);
            }
        }
    }

    return null;
}
项目:jdk8u_nashorn    文件Global.java   
@Override
public GuardedInvocation findgetmethod(final CallSiteDescriptor desc,// assuming this only applies to global constants. If other non-inherited properties will
    // start using switchpoints some time in the future we'll have to revisit this.
    if (isScope && context.getEnv()._es6 && (invocation.getSwitchPoints() == null || !hasOwnProperty(name))) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:jdk8u_nashorn    文件Global.java   
@Override
public GuardedInvocation findSetMethod(final CallSiteDescriptor desc,request);

    if (isScope && context.getEnv()._es6) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:jdk8u_nashorn    文件ContinuousArrayData.java   
/**
 * Return a fast linked array getter,ClassCastException.class);
            }
        }
    }

    return null;
}
项目:infobip-open-jdk-8    文件Global.java   
@Override
public GuardedInvocation findgetmethod(final CallSiteDescriptor desc,// assuming this only applies to global constants. If other non-inherited properties will
    // start using switchpoints some time in the future we'll have to revisit this.
    if (isScope && context.getEnv()._es6 && (invocation.getSwitchPoints() == null || !hasOwnProperty(name))) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:infobip-open-jdk-8    文件Global.java   
@Override
public GuardedInvocation findSetMethod(final CallSiteDescriptor desc,request);

    if (isScope && context.getEnv()._es6) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
项目:infobip-open-jdk-8    文件ContinuousArrayData.java   
/**
 * Return a fast linked array getter,ClassCastException.class);
            }
        }
    }

    return null;
}
项目:OLD-OpenJDK8    文件ScriptObject.java   
@SuppressWarnings("unused")
private static void setSpillWithNew(final CallSiteDescriptor desc,final PropertyMap oldMap,final PropertyMap newMap,final int index,final Object self,final Object value) {
    final ScriptObject obj      = (ScriptObject)self;
    final boolean      isstrict = NashornCallSiteDescriptor.isstrict(desc);

    if (!obj.isExtensible()) {
        if (isstrict) {
            throw typeError("object.non.extensible",desc.getNametoken(2),ScriptRuntime.safetoString(obj));
        }
    } else if (obj.compareAndSetMap(oldMap,newMap)) {
        obj.spill = new Object[SPILL_RATE];
        obj.spill[index] = value;
    } else {
        obj.set(desc.getNametoken(2),value,isstrict);
    }
}
项目:OLD-OpenJDK8    文件ScriptObject.java   
@SuppressWarnings("unused")
private static void setSpillWithGrow(final CallSiteDescriptor desc,final int newLength,newMap)) {
        final int oldLength = obj.spill.length;
        final Object[] newSpill = new Object[newLength];
        System.arraycopy(obj.spill,newSpill,oldLength);
        obj.spill = newSpill;
        obj.spill[index] = value;
    } else {
        obj.set(desc.getNametoken(2),isstrict);
    }
}
项目:OLD-OpenJDK8    文件ScriptObject.java   
/**
 * 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 })),Object.class),null,NashornGuards.getMapGuard(getMap()));
}
项目:OLD-OpenJDK8    文件WithObject.java   
private static GuardedInvocation fixExpressionCallSite(final NashornCallSiteDescriptor desc,final GuardedInvocation link) {
    // If it's not a getmethod,just add an expression filter that converts WithObject in "this" position to its
    // expression.
    if(!"getmethod".equals(desc.getFirstOperator())) {
        return fixReceiverType(link,WITHEXPRESSIONFILTER).filterarguments(0,WITHEXPRESSIONFILTER);
    }

    final MethodHandle linkInvocation = link.getInvocation();
    final MethodType linkType = linkInvocation.type();
    final boolean linkReturnsFunction = ScriptFunction.class.isAssignableFrom(linkType.returnType());
    return link.replaceMethods(
            // Make sure getmethod will bind the script functions it receives to WithObject.expression
            MH.foldArguments(linkReturnsFunction ? BIND_TO_EXPRESSION_FN : BIND_TO_EXPRESSION_OBJ,filter(linkInvocation.asType(linkType.changeReturnType(
                            linkReturnsFunction ? ScriptFunction.class : Object.class)),WITHEXPRESSIONFILTER)),// No cLever things for the guard -- it is still identically filtered.
            filterGuard(link,WITHEXPRESSIONFILTER));
}
项目:nashorn-backport    文件ScriptObject.java   
@SuppressWarnings("unused")
private static void setSpillWithNew(final CallSiteDescriptor desc,isstrict);
    }
}
项目:nashorn-backport    文件ScriptObject.java   
@SuppressWarnings("unused")
private static void setSpillWithGrow(final CallSiteDescriptor desc,isstrict);
    }
}
项目:nashorn-backport    文件ScriptObject.java   
/**
 * 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,NashornGuards.getMapGuard(getMap()));
}
项目:nashorn-backport    文件WithObject.java   
private static GuardedInvocation fixExpressionCallSite(final NashornCallSiteDescriptor desc,WITHEXPRESSIONFILTER));
}
项目:nashorn    文件ScriptObject.java   
@SuppressWarnings("unused")
private static void setSpillWithNew(final CallSiteDescriptor desc,isstrict);
    }
}
项目:nashorn    文件ScriptObject.java   
@SuppressWarnings("unused")
private static void setSpillWithGrow(final CallSiteDescriptor desc,isstrict);
    }
}
项目:nashorn    文件ScriptObject.java   
/**
 * 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,NashornGuards.getMapGuard(getMap()));
}
项目:nashorn    文件WithObject.java   
private static GuardedInvocation fixExpressionCallSite(final NashornCallSiteDescriptor desc,WITHEXPRESSIONFILTER));
}
项目:Openjsharp    文件NativeDebug.java   
@SuppressWarnings("unchecked")
private static LinkedList<RuntimeEvent<?>> getEventQueue(final Object self) {
    final ScriptObject sobj = (ScriptObject)self;
    LinkedList<RuntimeEvent<?>> q;
    if (sobj.has(EVENT_QUEUE)) {
        q = (LinkedList<RuntimeEvent<?>>)((ScriptObject)self).get(EVENT_QUEUE);
    } else {
        ((ScriptObject)self).set(EVENT_QUEUE,q = new LinkedList<>(),NashornCallSiteDescriptor.CALLSITE_STRICT);
    }
    return q;
}
项目:Openjsharp    文件OptimisticReturnFilters.java   
/**
 * Given a guarded invocation and a callsite descriptor,perform return value filtering
 * according to the optimistic type coercion rules,using the return value from the descriptor
 * @param inv the invocation
 * @param desc the descriptor
 * @return filtered invocation
 */
public static GuardedInvocation filterOptimisticReturnValue(final GuardedInvocation inv,final CallSiteDescriptor desc) {
    if(!NashornCallSiteDescriptor.isOptimistic(desc)) {
        return inv;
    }
    return inv.replaceMethods(filterOptimisticReturnValue(inv.getInvocation(),desc.getmethodType().returnType(),NashornCallSiteDescriptor.getProgramPoint(desc)),inv.getGuard());
}
项目:Openjsharp    文件ScriptObject.java   
/**
 * Find a handle for a getIndex method
 * @param returnType     return type for getter
 * @param name           name
 * @param elementType    index type for getter
 * @param desc           call site descriptor
 * @return method handle for getter
 */
protected MethodHandle findGetIndexMethodHandle(final Class<?> returnType,final String name,final Class<?> elementType,final CallSiteDescriptor desc) {
    if (!returnType.isPrimitive()) {
        return findOwnMH_V(getClass(),name,returnType,elementType);
    }

    return MH.insertArguments(
            findOwnMH_V(getClass(),elementType,int.class),2,NashornCallSiteDescriptor.isOptimistic(desc) ?
                    NashornCallSiteDescriptor.getProgramPoint(desc) :
                    INVALID_PROGRAM_POINT);
}
项目:Openjsharp    文件ScriptObject.java   
/**
 * 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,request);
    }

    final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc,request);

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

    final ScriptFunction func = (ScriptFunction)value;
    final Object         thiz = scopeCall && func.isstrict() ? UNDEFINED : this;
    // Todo: It'd be awesome if we Could bind "name" without binding "this".
    // Since we're binding this we must use an identity guard here.
    return new GuardedInvocation(
            MH.dropArguments(
                    MH.constant(
                            ScriptFunction.class,NashornGuards.combineGuards(
                    NashornGuards.getIdentityguard(this),NashornGuards.getMapGuard(getMap(),true)));
}
项目:Openjsharp    文件ScriptObject.java   
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()),explicitInstanceOfCheck),getProtoSwitchPoint(name,null),explicitInstanceOfCheck ? null : ClassCastException.class);
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...