jdk.nashorn.internal.ir.RuntimeNode.Request Java Examples
The following examples show how to use
jdk.nashorn.internal.ir.RuntimeNode.Request.
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: AssignSymbols.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private Node leaveTYPEOF(final UnaryNode unaryNode) { final Expression rhs = unaryNode.getExpression(); final List<Expression> args = new ArrayList<>(); if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) { args.add(compilerConstantIdentifier(SCOPE)); args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null } else { args.add(rhs); args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this' } final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args); end(unaryNode); return runtimeNode; }
Example #2
Source File: AssignSymbols.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private Node leaveTYPEOF(final UnaryNode unaryNode) { final Expression rhs = unaryNode.getExpression(); final List<Expression> args = new ArrayList<>(); if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) { args.add(compilerConstantIdentifier(SCOPE)); args.add((Expression)LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName()).accept(this)); //null } else { args.add(rhs); args.add((Expression)LiteralNode.newInstance(unaryNode).accept(this)); //null, do not reuse token of identifier rhs, it can be e.g. 'this' } final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args).accept(this); end(unaryNode); return runtimeNode; }
Example #3
Source File: FinalizeTypes.java From nashorn with GNU General Public License v2.0 | 6 votes |
/** * Add is a special binary, as it works not only on arithmetic, but for * strings etc as well. */ @Override public Expression leaveADD(final BinaryNode binaryNode) { final Expression lhs = binaryNode.lhs(); final Expression rhs = binaryNode.rhs(); final Type type = binaryNode.getType(); if (type.isObject()) { if (!isAddString(binaryNode)) { return new RuntimeNode(binaryNode, Request.ADD); } } return binaryNode.setLHS(convert(lhs, type)).setRHS(convert(rhs, type)); }
Example #4
Source File: AssignSymbols.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private Node leaveTYPEOF(final UnaryNode unaryNode) { final Expression rhs = unaryNode.getExpression(); final List<Expression> args = new ArrayList<>(); if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) { args.add(compilerConstantIdentifier(SCOPE)); args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null } else { args.add(rhs); args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this' } final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args); end(unaryNode); return runtimeNode; }
Example #5
Source File: AssignSymbols.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private Node leaveTYPEOF(final UnaryNode unaryNode) { final Expression rhs = unaryNode.getExpression(); final List<Expression> args = new ArrayList<>(); if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) { args.add(compilerConstantIdentifier(SCOPE)); args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null } else { args.add(rhs); args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this' } final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args); end(unaryNode); return runtimeNode; }
Example #6
Source File: AssignSymbols.java From hottub with GNU General Public License v2.0 | 6 votes |
private Node leaveTYPEOF(final UnaryNode unaryNode) { final Expression rhs = unaryNode.getExpression(); final List<Expression> args = new ArrayList<>(); if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) { args.add(compilerConstantIdentifier(SCOPE)); args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null } else { args.add(rhs); args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this' } final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args); end(unaryNode); return runtimeNode; }
Example #7
Source File: AssignSymbols.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
private Node leaveTYPEOF(final UnaryNode unaryNode) { final Expression rhs = unaryNode.getExpression(); final List<Expression> args = new ArrayList<>(); if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) { args.add(compilerConstantIdentifier(SCOPE)); args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null } else { args.add(rhs); args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this' } final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args); end(unaryNode); return runtimeNode; }
Example #8
Source File: AssignSymbols.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private Node leaveTYPEOF(final UnaryNode unaryNode) { final Expression rhs = unaryNode.getExpression(); final List<Expression> args = new ArrayList<>(); if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) { args.add(compilerConstantIdentifier(SCOPE)); args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null } else { args.add(rhs); args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this' } final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args); end(unaryNode); return runtimeNode; }
Example #9
Source File: Attr.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private Node leaveBinaryRuntimeOperator(final BinaryNode binaryNode, final Request request) { try { // Don't do a full RuntimeNode.accept, as we don't want to double-visit the binary node operands return leaveRuntimeNode(new RuntimeNode(binaryNode, request)); } finally { end(binaryNode); } }
Example #10
Source File: LocalVariableTypesCalculator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final Request request = runtimeNode.getRequest(); final boolean isEqStrict = request == Request.EQ_STRICT; if(isEqStrict || request == Request.NE_STRICT) { return createIsUndefined(runtimeNode, runtimeNode.getArgs().get(0), runtimeNode.getArgs().get(1), isEqStrict ? Request.IS_UNDEFINED : Request.IS_NOT_UNDEFINED); } return runtimeNode; }
Example #11
Source File: RuntimeCallSite.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static Type firstTypeGuessForObject(final Request request) { switch (request) { case ADD: return INT; default: return BOOLEAN; } }
Example #12
Source File: CodeGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private boolean specializationCheck(final RuntimeNode.Request request, final Expression node, final List<Expression> args) { if (!request.canSpecialize()) { return false; } assert args.size() == 2; final Type returnType = node.getType(); load(args.get(0)); load(args.get(1)); Request finalRequest = request; //if the request is a comparison, i.e. one that can be reversed //it keeps its semantic, but make sure that the object comes in //last final Request reverse = Request.reverse(request); if (method.peekType().isObject() && reverse != null) { //rhs is object if (!method.peekType(1).isObject()) { //lhs is not object method.swap(); //prefer object as lhs finalRequest = reverse; } } method.dynamicRuntimeCall( new SpecializedRuntimeNode( finalRequest, new Type[] { method.peekType(1), method.peekType() }, returnType).getInitialName(), returnType, finalRequest); method.convert(node.getType()); method.store(node.getSymbol()); return true; }
Example #13
Source File: Attr.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private Node leaveBinaryRuntimeOperator(final BinaryNode binaryNode, final Request request) { try { // Don't do a full RuntimeNode.accept, as we don't want to double-visit the binary node operands return leaveRuntimeNode(new RuntimeNode(binaryNode, request)); } finally { end(binaryNode); } }
Example #14
Source File: RuntimeCallSite.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static Type firstTypeGuessForObject(final Request request) { switch (request) { case ADD: return INT; default: return BOOLEAN; } }
Example #15
Source File: CodeGenerator.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private boolean specializationCheck(final RuntimeNode.Request request, final Expression node, final List<Expression> args) { if (!request.canSpecialize()) { return false; } assert args.size() == 2; final Type returnType = node.getType(); load(args.get(0)); load(args.get(1)); Request finalRequest = request; //if the request is a comparison, i.e. one that can be reversed //it keeps its semantic, but make sure that the object comes in //last final Request reverse = Request.reverse(request); if (method.peekType().isObject() && reverse != null) { //rhs is object if (!method.peekType(1).isObject()) { //lhs is not object method.swap(); //prefer object as lhs finalRequest = reverse; } } method.dynamicRuntimeCall( new SpecializedRuntimeNode( finalRequest, new Type[] { method.peekType(1), method.peekType() }, returnType).getInitialName(), returnType, finalRequest); method.convert(node.getType()); method.store(node.getSymbol()); return true; }
Example #16
Source File: LocalVariableTypesCalculator.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final Request request = runtimeNode.getRequest(); final boolean isEqStrict = request == Request.EQ_STRICT; if(isEqStrict || request == Request.NE_STRICT) { return createIsUndefined(runtimeNode, runtimeNode.getArgs().get(0), runtimeNode.getArgs().get(1), isEqStrict ? Request.IS_UNDEFINED : Request.IS_NOT_UNDEFINED); } return runtimeNode; }
Example #17
Source File: Attr.java From nashorn with GNU General Public License v2.0 | 5 votes |
private Node leaveBinaryRuntimeOperator(final BinaryNode binaryNode, final Request request) { try { // Don't do a full RuntimeNode.accept, as we don't want to double-visit the binary node operands return leaveRuntimeNode(new RuntimeNode(binaryNode, request)); } finally { end(binaryNode); } }
Example #18
Source File: RuntimeCallSite.java From nashorn with GNU General Public License v2.0 | 5 votes |
private static Type firstTypeGuessForObject(final Request request) { switch (request) { case ADD: return INT; default: return BOOLEAN; } }
Example #19
Source File: FinalizeTypes.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * Exit a comparison node and do the appropriate replacements. We need to introduce runtime * nodes late for comparisons as types aren't known until the last minute * * Both compares and adds may turn into runtimes node at this level as when we first bump * into the op in Attr, we may type it according to what we know there, which may be wrong later * * e.g. i (int) < 5 -> normal compare * i = object * then the post pass that would add the conversion to the 5 needs to * * @param binaryNode binary node to leave * @param request runtime request * @return lowered cmp node */ @SuppressWarnings("fallthrough") private Node leaveCmp(final BinaryNode binaryNode, final RuntimeNode.Request request) { final Expression lhs = binaryNode.lhs(); final Expression rhs = binaryNode.rhs(); Type widest = Type.widest(lhs.getType(), rhs.getType()); boolean newRuntimeNode = false, finalized = false; switch (request) { case EQ_STRICT: case NE_STRICT: if (lhs.getType().isBoolean() != rhs.getType().isBoolean()) { newRuntimeNode = true; widest = Type.OBJECT; finalized = true; } //fallthru default: if (newRuntimeNode || widest.isObject()) { return new RuntimeNode(binaryNode, request).setIsFinal(finalized); } break; } return binaryNode.setLHS(convert(lhs, widest)).setRHS(convert(rhs, widest)); }
Example #20
Source File: CodeGenerator.java From nashorn with GNU General Public License v2.0 | 5 votes |
private boolean specializationCheck(final RuntimeNode.Request request, final Expression node, final List<Expression> args) { if (!request.canSpecialize()) { return false; } assert args.size() == 2; final Type returnType = node.getType(); load(args.get(0)); load(args.get(1)); Request finalRequest = request; //if the request is a comparison, i.e. one that can be reversed //it keeps its semantic, but make sure that the object comes in //last final Request reverse = Request.reverse(request); if (method.peekType().isObject() && reverse != null) { //rhs is object if (!method.peekType(1).isObject()) { //lhs is not object method.swap(); //prefer object as lhs finalRequest = reverse; } } method.dynamicRuntimeCall( new SpecializedRuntimeNode( finalRequest, new Type[] { method.peekType(1), method.peekType() }, returnType).getInitialName(), returnType, finalRequest); method.convert(node.getType()); method.store(node.getSymbol()); return true; }
Example #21
Source File: LocalVariableTypesCalculator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final Request request = runtimeNode.getRequest(); final boolean isEqStrict = request == Request.EQ_STRICT; if(isEqStrict || request == Request.NE_STRICT) { return createIsUndefined(runtimeNode, runtimeNode.getArgs().get(0), runtimeNode.getArgs().get(1), isEqStrict ? Request.IS_UNDEFINED : Request.IS_NOT_UNDEFINED); } return runtimeNode; }
Example #22
Source File: LocalVariableTypesCalculator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final Request request = runtimeNode.getRequest(); final boolean isEqStrict = request == Request.EQ_STRICT; if(isEqStrict || request == Request.NE_STRICT) { return createIsUndefined(runtimeNode, runtimeNode.getArgs().get(0), runtimeNode.getArgs().get(1), isEqStrict ? Request.IS_UNDEFINED : Request.IS_NOT_UNDEFINED); } return runtimeNode; }
Example #23
Source File: LocalVariableTypesCalculator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final Request request = runtimeNode.getRequest(); final boolean isEqStrict = request == Request.EQ_STRICT; if(isEqStrict || request == Request.NE_STRICT) { return createIsUndefined(runtimeNode, runtimeNode.getArgs().get(0), runtimeNode.getArgs().get(1), isEqStrict ? Request.IS_UNDEFINED : Request.IS_NOT_UNDEFINED); } return runtimeNode; }
Example #24
Source File: LocalVariableTypesCalculator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final Request request = runtimeNode.getRequest(); final boolean isEqStrict = request == Request.EQ_STRICT; if(isEqStrict || request == Request.NE_STRICT) { return createIsUndefined(runtimeNode, runtimeNode.getArgs().get(0), runtimeNode.getArgs().get(1), isEqStrict ? Request.IS_UNDEFINED : Request.IS_NOT_UNDEFINED); } return runtimeNode; }
Example #25
Source File: LocalVariableTypesCalculator.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveRuntimeNode(final RuntimeNode runtimeNode) { final Request request = runtimeNode.getRequest(); final boolean isEqStrict = request == Request.EQ_STRICT; if(isEqStrict || request == Request.NE_STRICT) { return createIsUndefined(runtimeNode, runtimeNode.getArgs().get(0), runtimeNode.getArgs().get(1), isEqStrict ? Request.IS_UNDEFINED : Request.IS_NOT_UNDEFINED); } return runtimeNode; }
Example #26
Source File: FinalizeTypes.java From nashorn with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveGE(final BinaryNode binaryNode) { return leaveCmp(binaryNode, Request.GE); }
Example #27
Source File: Attr.java From nashorn with GNU General Public License v2.0 | 4 votes |
@Override public Node leaveINSTANCEOF(final BinaryNode binaryNode) { return leaveBinaryRuntimeOperator(binaryNode, Request.INSTANCEOF); }
Example #28
Source File: LocalVariableTypesCalculator.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private static Expression createIsUndefined(final Expression parent, final Expression lhs, final Expression rhs, final Request request) { if (isUndefinedIdent(lhs) || isUndefinedIdent(rhs)) { return new RuntimeNode(parent, request, lhs, rhs); } return parent; }
Example #29
Source File: RuntimeCallSite.java From nashorn with GNU General Public License v2.0 | 4 votes |
Request getRequest() { return request; }
Example #30
Source File: LocalVariableTypesCalculator.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private static Expression createIsUndefined(final Expression parent, final Expression lhs, final Expression rhs, final Request request) { if (isUndefinedIdent(lhs) || isUndefinedIdent(rhs)) { return new RuntimeNode(parent, request, lhs, rhs); } return parent; }