# HG changeset patch # User lagergren # Date 1367930217 -7200 # Node ID 544e17632e964d5d8b47be64833341a7fb380ce1 # Parent f3dcb12c84398986e981e83aed31f9fa20c6f5ff 8013913: Removed Source field from all nodes except FunctionNode in order to save footprint Reviewed-by: jlaskey, attila diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/api/scripting/NashornScriptEngine.java --- a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java Tue May 07 14:36:57 2013 +0200 @@ -78,7 +78,6 @@ this(factory, DEFAULT_OPTIONS, appLoader); } - @SuppressWarnings("LeakingThisInConstructor") NashornScriptEngine(final NashornScriptEngineFactory factory, final String[] args, final ClassLoader appLoader) { this.factory = factory; final Options options = new Options("nashorn"); @@ -102,7 +101,7 @@ }); // create new global object - this.global = createNashornGlobal(); + this.global = createNashornGlobal(); // set the default engine scope for the default context context.setBindings(new ScriptObjectMirror(global, global), ScriptContext.ENGINE_SCOPE); diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/codegen/Attr.java --- a/src/jdk/nashorn/internal/codegen/Attr.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/codegen/Attr.java Tue May 07 14:36:57 2013 +0200 @@ -435,7 +435,6 @@ final IdentNode callee = compilerConstant(CALLEE); VarNode selfInit = new VarNode( - newFunctionNode.getSource(), newFunctionNode.getToken(), newFunctionNode.getFinish(), newFunctionNode.getIdent(), @@ -531,6 +530,7 @@ setBlockScope(name, symbol); if (symbol != null && !identNode.isInitializedHere()) { + symbol.increaseUseCount(); } addLocalUse(identNode.getName()); @@ -914,7 +914,6 @@ final FunctionNode functionNode = getLexicalContext().getCurrentFunction(); return (IdentNode) new IdentNode( - functionNode.getSource(), functionNode.getToken(), functionNode.getFinish(), cc.symbolName()). diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/codegen/CodeGenerator.java --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java Tue May 07 14:36:57 2013 +0200 @@ -261,14 +261,15 @@ return method.load(symbol); } - final String name = symbol.getName(); + final String name = symbol.getName(); + final Source source = getLexicalContext().getCurrentFunction().getSource(); if (CompilerConstants.__FILE__.name().equals(name)) { - return method.load(identNode.getSource().getName()); + return method.load(source.getName()); } else if (CompilerConstants.__DIR__.name().equals(name)) { - return method.load(identNode.getSource().getBase()); + return method.load(source.getBase()); } else if (CompilerConstants.__LINE__.name().equals(name)) { - return method.load(identNode.getSource().getLine(identNode.position())).convert(Type.OBJECT); + return method.load(source.getLine(identNode.position())).convert(Type.OBJECT); } else { assert identNode.getSymbol().isScope() : identNode + " is not in scope!"; @@ -2005,8 +2006,9 @@ public boolean enterThrowNode(final ThrowNode throwNode) { method._new(ECMAException.class).dup(); + final Source source = getLexicalContext().getCurrentFunction().getSource(); + final Node expression = throwNode.getExpression(); - final Source source = throwNode.getSource(); final int position = throwNode.position(); final int line = source.getLine(position); final int column = source.getColumn(position); @@ -3013,7 +3015,6 @@ return; } - @SuppressWarnings("resource") final PrintWriter out = compiler.getEnv().getErr(); out.println("[BLOCK in '" + ident + "']"); if (!block.printSymbols(out)) { diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/codegen/FinalizeTypes.java --- a/src/jdk/nashorn/internal/codegen/FinalizeTypes.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/codegen/FinalizeTypes.java Tue May 07 14:36:57 2013 +0200 @@ -773,7 +773,7 @@ private Node convert(final Node node, final Type to) { assert !to.isUnknown() : "unknown type for " + node + " class=" + node.getClass(); assert node != null : "node is null"; - assert node.getSymbol() != null : "node " + node + " " + node.getClass() + " has no symbol! " + getLexicalContext().getCurrentFunction() + " " + node.getSource(); + assert node.getSymbol() != null : "node " + node + " " + node.getClass() + " has no symbol! " + getLexicalContext().getCurrentFunction(); assert node.tokenType() != TokenType.CONVERT : "assert convert in convert " + node + " in " + getLexicalContext().getCurrentFunction(); final Type from = node.getType(); @@ -798,7 +798,7 @@ assert node instanceof TypeOverride; return setTypeOverride(node, to); } - resultNode = new UnaryNode(node.getSource(), Token.recast(node.getToken(), TokenType.CONVERT), node); + resultNode = new UnaryNode(Token.recast(node.getToken(), TokenType.CONVERT), node); } LOG.info("CONVERT('", node, "', ", to, ") => '", resultNode, "'"); @@ -813,7 +813,7 @@ private static Node discard(final Node node) { if (node.getSymbol() != null) { - final Node discard = new UnaryNode(node.getSource(), Token.recast(node.getToken(), TokenType.DISCARD), node); + final Node discard = new UnaryNode(Token.recast(node.getToken(), TokenType.DISCARD), node); //discard never has a symbol in the discard node - then it would be a nop assert !node.isTerminal(); return discard; @@ -881,15 +881,15 @@ LiteralNode literalNode = null; if (type.isString()) { - literalNode = LiteralNode.newInstance(source, token, finish, JSType.toString(value)); + literalNode = LiteralNode.newInstance(token, finish, JSType.toString(value)); } else if (type.isBoolean()) { - literalNode = LiteralNode.newInstance(source, token, finish, JSType.toBoolean(value)); + literalNode = LiteralNode.newInstance(token, finish, JSType.toBoolean(value)); } else if (type.isInteger()) { - literalNode = LiteralNode.newInstance(source, token, finish, JSType.toInt32(value)); + literalNode = LiteralNode.newInstance(token, finish, JSType.toInt32(value)); } else if (type.isLong()) { - literalNode = LiteralNode.newInstance(source, token, finish, JSType.toLong(value)); + literalNode = LiteralNode.newInstance(token, finish, JSType.toLong(value)); } else if (type.isNumber() || parent.getType().isNumeric() && !parent.getType().isNumber()) { - literalNode = LiteralNode.newInstance(source, token, finish, JSType.toNumber(value)); + literalNode = LiteralNode.newInstance(token, finish, JSType.toNumber(value)); } if (literalNode != null) { diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/codegen/FoldConstants.java --- a/src/jdk/nashorn/internal/codegen/FoldConstants.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/codegen/FoldConstants.java Tue May 07 14:36:57 2013 +0200 @@ -41,7 +41,6 @@ import jdk.nashorn.internal.runtime.DebugLogger; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptRuntime; -import jdk.nashorn.internal.runtime.Source; /** * Simple constant folding pass, executed before IR is starting to be lowered. @@ -112,13 +111,11 @@ */ abstract static class ConstantEvaluator { protected T parent; - protected final Source source; protected final long token; protected final int finish; protected ConstantEvaluator(final T parent) { this.parent = parent; - this.source = parent.getSource(); this.token = parent.getToken(); this.finish = parent.getFinish(); } @@ -152,23 +149,23 @@ switch (parent.tokenType()) { case ADD: if (rhsInteger) { - literalNode = LiteralNode.newInstance(source, token, finish, rhs.getInt32()); + literalNode = LiteralNode.newInstance(token, finish, rhs.getInt32()); } else { - literalNode = LiteralNode.newInstance(source, token, finish, rhs.getNumber()); + literalNode = LiteralNode.newInstance(token, finish, rhs.getNumber()); } break; case SUB: if (rhsInteger && rhs.getInt32() != 0) { // @see test/script/basic/minuszero.js - literalNode = LiteralNode.newInstance(source, token, finish, -rhs.getInt32()); + literalNode = LiteralNode.newInstance(token, finish, -rhs.getInt32()); } else { - literalNode = LiteralNode.newInstance(source, token, finish, -rhs.getNumber()); + literalNode = LiteralNode.newInstance(token, finish, -rhs.getNumber()); } break; case NOT: - literalNode = LiteralNode.newInstance(source, token, finish, !rhs.getBoolean()); + literalNode = LiteralNode.newInstance(token, finish, !rhs.getBoolean()); break; case BIT_NOT: - literalNode = LiteralNode.newInstance(source, token, finish, ~rhs.getInt32()); + literalNode = LiteralNode.newInstance(token, finish, ~rhs.getInt32()); break; default: return null; @@ -234,7 +231,7 @@ break; } assert res instanceof CharSequence : res + " was not a CharSequence, it was a " + res.getClass(); - return LiteralNode.newInstance(source, token, finish, res.toString()); + return LiteralNode.newInstance(token, finish, res.toString()); } return null; case MUL: @@ -247,33 +244,33 @@ value = lhs.getNumber() - rhs.getNumber(); break; case SHR: - return LiteralNode.newInstance(source, token, finish, (lhs.getInt32() >>> rhs.getInt32()) & JSType.MAX_UINT); + return LiteralNode.newInstance(token, finish, (lhs.getInt32() >>> rhs.getInt32()) & JSType.MAX_UINT); case SAR: - return LiteralNode.newInstance(source, token, finish, lhs.getInt32() >> rhs.getInt32()); + return LiteralNode.newInstance(token, finish, lhs.getInt32() >> rhs.getInt32()); case SHL: - return LiteralNode.newInstance(source, token, finish, lhs.getInt32() << rhs.getInt32()); + return LiteralNode.newInstance(token, finish, lhs.getInt32() << rhs.getInt32()); case BIT_XOR: - return LiteralNode.newInstance(source, token, finish, lhs.getInt32() ^ rhs.getInt32()); + return LiteralNode.newInstance(token, finish, lhs.getInt32() ^ rhs.getInt32()); case BIT_AND: - return LiteralNode.newInstance(source, token, finish, lhs.getInt32() & rhs.getInt32()); + return LiteralNode.newInstance(token, finish, lhs.getInt32() & rhs.getInt32()); case BIT_OR: - return LiteralNode.newInstance(source, token, finish, lhs.getInt32() | rhs.getInt32()); + return LiteralNode.newInstance(token, finish, lhs.getInt32() | rhs.getInt32()); case GE: - return LiteralNode.newInstance(source, token, finish, ScriptRuntime.GE(lhs.getObject(), rhs.getObject())); + return LiteralNode.newInstance(token, finish, ScriptRuntime.GE(lhs.getObject(), rhs.getObject())); case LE: - return LiteralNode.newInstance(source, token, finish, ScriptRuntime.LE(lhs.getObject(), rhs.getObject())); + return LiteralNode.newInstance(token, finish, ScriptRuntime.LE(lhs.getObject(), rhs.getObject())); case GT: - return LiteralNode.newInstance(source, token, finish, ScriptRuntime.GT(lhs.getObject(), rhs.getObject())); + return LiteralNode.newInstance(token, finish, ScriptRuntime.GT(lhs.getObject(), rhs.getObject())); case LT: - return LiteralNode.newInstance(source, token, finish, ScriptRuntime.LT(lhs.getObject(), rhs.getObject())); + return LiteralNode.newInstance(token, finish, ScriptRuntime.LT(lhs.getObject(), rhs.getObject())); case NE: - return LiteralNode.newInstance(source, token, finish, ScriptRuntime.NE(lhs.getObject(), rhs.getObject())); + return LiteralNode.newInstance(token, finish, ScriptRuntime.NE(lhs.getObject(), rhs.getObject())); case NE_STRICT: - return LiteralNode.newInstance(source, token, finish, ScriptRuntime.NE_STRICT(lhs.getObject(), rhs.getObject())); + return LiteralNode.newInstance(token, finish, ScriptRuntime.NE_STRICT(lhs.getObject(), rhs.getObject())); case EQ: - return LiteralNode.newInstance(source, token, finish, ScriptRuntime.EQ(lhs.getObject(), rhs.getObject())); + return LiteralNode.newInstance(token, finish, ScriptRuntime.EQ(lhs.getObject(), rhs.getObject())); case EQ_STRICT: - return LiteralNode.newInstance(source, token, finish, ScriptRuntime.EQ_STRICT(lhs.getObject(), rhs.getObject())); + return LiteralNode.newInstance(token, finish, ScriptRuntime.EQ_STRICT(lhs.getObject(), rhs.getObject())); default: return null; } @@ -282,12 +279,12 @@ isLong &= value != 0.0 && JSType.isRepresentableAsLong(value); if (isInteger) { - return LiteralNode.newInstance(source, token, finish, JSType.toInt32(value)); + return LiteralNode.newInstance(token, finish, JSType.toInt32(value)); } else if (isLong) { - return LiteralNode.newInstance(source, token, finish, JSType.toLong(value)); + return LiteralNode.newInstance(token, finish, JSType.toLong(value)); } - return LiteralNode.newInstance(source, token, finish, value); + return LiteralNode.newInstance(token, finish, value); } } } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/codegen/Lower.java --- a/src/jdk/nashorn/internal/codegen/Lower.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/codegen/Lower.java Tue May 07 14:36:57 2013 +0200 @@ -118,8 +118,9 @@ @Override public boolean enterBlock(final Block block) { final LexicalContext lc = getLexicalContext(); - if (lc.isFunctionBody() && lc.getCurrentFunction().isProgram() && !lc.getCurrentFunction().hasDeclaredFunctions()) { - new ExecuteNode(block.getSource(), block.getToken(), block.getFinish(), LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED)).accept(this); + final FunctionNode function = lc.getCurrentFunction(); + if (lc.isFunctionBody() && function.isProgram() && !function.hasDeclaredFunctions()) { + new ExecuteNode(block.getToken(), block.getFinish(), LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED)).accept(this); } return true; } @@ -137,7 +138,6 @@ final FunctionNode currentFunction = getLexicalContext().getCurrentFunction(); final boolean isProgram = currentFunction.isProgram(); final ReturnNode returnNode = new ReturnNode( - currentFunction.getSource(), currentFunction.getToken(), currentFunction.getFinish(), isProgram ? @@ -193,7 +193,6 @@ if (!isInternalExpression(expr) && !isEvalResultAssignment(expr)) { node = executeNode.setExpression( new BinaryNode( - executeNode.getSource(), Token.recast( executeNode.getToken(), TokenType.ASSIGN), @@ -284,17 +283,16 @@ } private Block catchAllBlock(final TryNode tryNode) { - final Source source = tryNode.getSource(); final long token = tryNode.getToken(); final int finish = tryNode.getFinish(); - final IdentNode exception = new IdentNode(source, token, finish, getLexicalContext().getCurrentFunction().uniqueName("catch_all")); + final IdentNode exception = new IdentNode(token, finish, getLexicalContext().getCurrentFunction().uniqueName("catch_all")); - final Block catchBody = new Block(source, token, finish, new ThrowNode(source, token, finish, new IdentNode(exception))). + final Block catchBody = new Block(token, finish, new ThrowNode(token, finish, new IdentNode(exception))). setIsTerminal(getLexicalContext(), true); //ends with throw, so terminal - final CatchNode catchAllNode = new CatchNode(source, token, finish, new IdentNode(exception), null, catchBody); - final Block catchAllBlock = new Block(source, token, finish, catchAllNode); + final CatchNode catchAllNode = new CatchNode(token, finish, new IdentNode(exception), null, catchBody); + final Block catchAllBlock = new Block(token, finish, catchAllNode); //catchallblock -> catchallnode (catchnode) -> exception -> throw @@ -303,7 +301,7 @@ private IdentNode compilerConstant(final CompilerConstants cc) { final FunctionNode functionNode = getLexicalContext().getCurrentFunction(); - return new IdentNode(functionNode.getSource(), functionNode.getToken(), functionNode.getFinish(), cc.symbolName()); + return new IdentNode(functionNode.getToken(), functionNode.getFinish(), cc.symbolName()); } private static boolean isTerminal(final List statements) { @@ -318,7 +316,6 @@ * @return new try node after splicing finally code (same if nop) */ private Node spliceFinally(final TryNode tryNode, final List rethrows, final Block finallyBody) { - final Source source = tryNode.getSource(); final int finish = tryNode.getFinish(); assert tryNode.getFinallyBody() == null; @@ -345,7 +342,7 @@ if (!isTerminal(newStatements)) { newStatements.add(throwNode); } - return new Block(source, throwNode.getToken(), throwNode.getFinish(), newStatements); + return new Block(throwNode.getToken(), throwNode.getFinish(), newStatements); } return throwNode; } @@ -370,7 +367,7 @@ //we need to evaluate the result of the return in case it is complex while //still in the try block, store it in a result value and return it afterwards resultNode = new IdentNode(Lower.this.compilerConstant(RETURN)); - newStatements.add(new ExecuteNode(new BinaryNode(source, Token.recast(returnNode.getToken(), TokenType.ASSIGN), resultNode, expr))); + newStatements.add(new ExecuteNode(new BinaryNode(Token.recast(returnNode.getToken(), TokenType.ASSIGN), resultNode, expr))); } else { resultNode = null; } @@ -380,7 +377,7 @@ newStatements.add(expr == null ? returnNode : returnNode.setExpression(resultNode)); } - return new ExecuteNode(new Block(source, returnNode.getToken(), getLexicalContext().getCurrentBlock().getFinish(), newStatements)); + return new ExecuteNode(new Block(returnNode.getToken(), getLexicalContext().getCurrentBlock().getFinish(), newStatements)); } private Node copy(final Node endpoint, final Node targetNode) { @@ -389,7 +386,7 @@ if (!isTerminal(newStatements)) { newStatements.add(endpoint); } - return new ExecuteNode(new Block(source, endpoint.getToken(), finish, newStatements)); + return new ExecuteNode(new Block(endpoint.getToken(), finish, newStatements)); } return endpoint; } @@ -451,7 +448,7 @@ if (tryNode.getCatchBlocks().isEmpty()) { newTryNode = tryNode.setFinallyBody(null); } else { - Block outerBody = new Block(tryNode.getSource(), tryNode.getToken(), tryNode.getFinish(), new ArrayList(Arrays.asList(tryNode.setFinallyBody(null)))); + Block outerBody = new Block(tryNode.getToken(), tryNode.getFinish(), new ArrayList(Arrays.asList(tryNode.setFinallyBody(null)))); newTryNode = tryNode.setBody(outerBody).setCatchBlocks(null); } @@ -468,19 +465,19 @@ public Node leaveVarNode(final VarNode varNode) { addStatement(varNode); if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION) && getLexicalContext().getCurrentFunction().isProgram()) { - new ExecuteNode(varNode.getSource(), varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this); + new ExecuteNode(varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this); } return varNode; } @Override public Node leaveWhileNode(final WhileNode whileNode) { - final Node test = whileNode.getTest(); + final Node test = whileNode.getTest(); final Block body = whileNode.getBody(); if (conservativeAlwaysTrue(test)) { //turn it into a for node without a test. - final ForNode forNode = (ForNode)new ForNode(whileNode.getSource(), whileNode.getToken(), whileNode.getFinish(), null, null, body, null, ForNode.IS_FOR).accept(this); + final ForNode forNode = (ForNode)new ForNode(whileNode.getToken(), whileNode.getFinish(), null, null, body, null, ForNode.IS_FOR).accept(this); getLexicalContext().replace(whileNode, forNode); return forNode; } @@ -525,11 +522,12 @@ * @param node a node * @return eval location */ - private static String evalLocation(final IdentNode node) { + private String evalLocation(final IdentNode node) { + final Source source = getLexicalContext().getCurrentFunction().getSource(); return new StringBuilder(). - append(node.getSource().getName()). + append(source.getName()). append('#'). - append(node.getSource().getLine(node.position())). + append(source.getLine(node.position())). append(""). toString(); } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/codegen/Splitter.java --- a/src/jdk/nashorn/internal/codegen/Splitter.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/codegen/Splitter.java Tue May 07 14:36:57 2013 +0200 @@ -42,7 +42,6 @@ import jdk.nashorn.internal.ir.SplitNode; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.runtime.DebugLogger; -import jdk.nashorn.internal.runtime.Source; import jdk.nashorn.internal.runtime.options.Options; /** @@ -221,12 +220,11 @@ * @return New split node. */ private SplitNode createBlockSplitNode(final Block parent, final FunctionNode function, final List statements, final long weight) { - final Source source = parent.getSource(); final long token = parent.getToken(); final int finish = parent.getFinish(); final String name = function.uniqueName(SPLIT_PREFIX.symbolName()); - final Block newBlock = new Block(source, token, finish, statements); + final Block newBlock = new Block(token, finish, statements); return new SplitNode(name, newBlock, compiler.findUnit(weight + WeighNodes.FUNCTION_WEIGHT)); } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/AccessNode.java --- a/src/jdk/nashorn/internal/ir/AccessNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/AccessNode.java Tue May 07 14:36:57 2013 +0200 @@ -28,7 +28,6 @@ import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation of a property access (period operator.) @@ -41,14 +40,13 @@ /** * Constructor * - * @param source source code * @param token token * @param finish finish * @param base base node * @param property property */ - public AccessNode(final Source source, final long token, final int finish, final Node base, final IdentNode property) { - super(source, token, finish, base, false, false); + public AccessNode(final long token, final int finish, final Node base, final IdentNode property) { + super(token, finish, base, false, false); this.property = property.setIsPropertyName(); } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/BaseNode.java --- a/src/jdk/nashorn/internal/ir/BaseNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/BaseNode.java Tue May 07 14:36:57 2013 +0200 @@ -29,7 +29,6 @@ import jdk.nashorn.internal.codegen.ObjectClassGenerator; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Immutable; -import jdk.nashorn.internal.runtime.Source; /** * IR base for accessing/indexing nodes. @@ -50,15 +49,14 @@ /** * Constructor * - * @param source source code * @param token token * @param finish finish * @param base base node * @param isFunction is this a function * @param hasCallSiteType does this access have a callsite type */ - public BaseNode(final Source source, final long token, final int finish, final Node base, final boolean isFunction, final boolean hasCallSiteType) { - super(source, token, base.getStart(), finish); + public BaseNode(final long token, final int finish, final Node base, final boolean isFunction, final boolean hasCallSiteType) { + super(token, base.getStart(), finish); this.base = base; this.isFunction = isFunction; this.hasCallSiteType = hasCallSiteType; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/BinaryNode.java --- a/src/jdk/nashorn/internal/ir/BinaryNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/BinaryNode.java Tue May 07 14:36:57 2013 +0200 @@ -29,7 +29,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.TokenType; -import jdk.nashorn.internal.runtime.Source; /** * BinaryNode nodes represent two operand operations. @@ -44,13 +43,12 @@ /** * Constructor * - * @param source source code * @param token token * @param lhs left hand side * @param rhs right hand side */ - public BinaryNode(final Source source, final long token, final Node lhs, final Node rhs) { - super(source, token, lhs.getStart(), rhs.getFinish()); + public BinaryNode(final long token, final Node lhs, final Node rhs) { + super(token, lhs.getStart(), rhs.getFinish()); this.lhs = lhs; this.rhs = rhs; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/Block.java --- a/src/jdk/nashorn/internal/ir/Block.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/Block.java Tue May 07 14:36:57 2013 +0200 @@ -36,7 +36,6 @@ import jdk.nashorn.internal.codegen.Label; import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for a list of statements and functions. All provides the @@ -77,13 +76,12 @@ /** * Constructor * - * @param source source code * @param token token * @param finish finish * @param statements statements */ - public Block(final Source source, final long token, final int finish, final Node... statements) { - super(source, token, finish, new Label("block_break")); + public Block(final long token, final int finish, final Node... statements) { + super(token, finish, new Label("block_break")); this.statements = Arrays.asList(statements); this.symbols = new LinkedHashMap<>(); @@ -94,13 +92,12 @@ /** * Constructor * - * @param source source code * @param token token * @param finish finish * @param statements statements */ - public Block(final Source source, final long token, final int finish, final List statements) { - this(source, token, finish, statements.toArray(new Node[statements.size()])); + public Block(final long token, final int finish, final List statements) { + this(token, finish, statements.toArray(new Node[statements.size()])); } private Block(final Block block, final int finish, final List statements, final int flags, final Map symbols) { diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/BreakNode.java --- a/src/jdk/nashorn/internal/ir/BreakNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/BreakNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for {@code break} statements. @@ -40,13 +39,12 @@ /** * Constructor * - * @param source source code * @param token token * @param finish finish * @param label label for break or null if none */ - public BreakNode(final Source source, final long token, final int finish, final IdentNode label) { - super(source, token, finish); + public BreakNode(final long token, final int finish, final IdentNode label) { + super(token, finish); this.label = label; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/BreakableNode.java --- a/src/jdk/nashorn/internal/ir/BreakableNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/BreakableNode.java Tue May 07 14:36:57 2013 +0200 @@ -30,7 +30,6 @@ import jdk.nashorn.internal.codegen.Label; import jdk.nashorn.internal.ir.annotations.Immutable; -import jdk.nashorn.internal.runtime.Source; /** * This class represents a node from which control flow can execute @@ -45,13 +44,12 @@ /** * Constructor * - * @param source source code * @param token token * @param finish finish * @param breakLabel break label */ - protected BreakableNode(final Source source, final long token, final int finish, final Label breakLabel) { - super(source, token, finish); + protected BreakableNode(final long token, final int finish, final Label breakLabel) { + super(token, finish); this.breakLabel = breakLabel; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/CallNode.java --- a/src/jdk/nashorn/internal/ir/CallNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/CallNode.java Tue May 07 14:36:57 2013 +0200 @@ -31,7 +31,6 @@ import jdk.nashorn.internal.ir.annotations.Ignore; import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for a function call. @@ -137,14 +136,13 @@ /** * Constructors * - * @param source the source * @param token token * @param finish finish * @param function the function to call * @param args args to the call */ - public CallNode(final Source source, final long token, final int finish, final Node function, final List args) { - super(source, token, finish); + public CallNode(final long token, final int finish, final Node function, final List args) { + super(token, finish); this.function = function; this.args = args; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/CaseNode.java --- a/src/jdk/nashorn/internal/ir/CaseNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/CaseNode.java Tue May 07 14:36:57 2013 +0200 @@ -28,7 +28,6 @@ import jdk.nashorn.internal.codegen.Label; import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation of CASE clause. @@ -48,14 +47,13 @@ /** * Constructors * - * @param source the source * @param token token * @param finish finish * @param test case test node, can be any node in JavaScript * @param body case body */ - public CaseNode(final Source source, final long token, final int finish, final Node test, final Block body) { - super(source, token, finish); + public CaseNode(final long token, final int finish, final Node test, final Block body) { + super(token, finish); this.test = test; this.body = body; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/CatchNode.java --- a/src/jdk/nashorn/internal/ir/CatchNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/CatchNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation of a catch clause. @@ -46,16 +45,14 @@ /** * Constructors * - * @param source the source * @param token token * @param finish finish * @param exception variable name of exception * @param exceptionCondition exception condition * @param body catch body */ - public CatchNode(final Source source, final long token, final int finish, final IdentNode exception, final Node exceptionCondition, final Block body) { - super(source, token, finish); - + public CatchNode(final long token, final int finish, final IdentNode exception, final Node exceptionCondition, final Block body) { + super(token, finish); this.exception = exception; this.exceptionCondition = exceptionCondition; this.body = body; @@ -63,7 +60,6 @@ private CatchNode(final CatchNode catchNode, final IdentNode exception, final Node exceptionCondition, final Block body) { super(catchNode); - this.exception = exception; this.exceptionCondition = exceptionCondition; this.body = body; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/ContinueNode.java --- a/src/jdk/nashorn/internal/ir/ContinueNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/ContinueNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for CONTINUE statements. @@ -40,13 +39,12 @@ /** * Constructor * - * @param source source code * @param token token * @param finish finish * @param label label for break or null if none */ - public ContinueNode(final Source source, final long token, final int finish, final IdentNode label) { - super(source, token, finish); + public ContinueNode(final long token, final int finish, final IdentNode label) { + super(token, finish); this.label = label; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/EmptyNode.java --- a/src/jdk/nashorn/internal/ir/EmptyNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/EmptyNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for an empty statement. @@ -47,12 +46,11 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish */ - public EmptyNode(final Source source, final long token, final int finish) { - super(source, token, finish); + public EmptyNode(final long token, final int finish) { + super(token, finish); } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/ExecuteNode.java --- a/src/jdk/nashorn/internal/ir/ExecuteNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/ExecuteNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for executing bare expressions. Basically, an expression @@ -42,13 +41,12 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param expression the expression to execute */ - public ExecuteNode(final Source source, final long token, final int finish, final Node expression) { - super(source, token, finish); + public ExecuteNode(final long token, final int finish, final Node expression) { + super(token, finish); this.expression = expression; } @@ -63,7 +61,7 @@ * @param expression an expression to wrap, from which source, tokens and finish are also inherited */ public ExecuteNode(final Node expression) { - super(expression.getSource(), expression.getToken(), expression.getFinish()); + super(expression.getToken(), expression.getFinish()); this.expression = expression; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/ForNode.java --- a/src/jdk/nashorn/internal/ir/ForNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/ForNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representing a FOR statement. @@ -57,7 +56,6 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param init init @@ -66,8 +64,8 @@ * @param modify modify * @param flags flags */ - public ForNode(final Source source, final long token, final int finish, final Node init, final Node test, final Block body, final Node modify, final int flags) { - super(source, token, finish, test, body, false); + public ForNode(final long token, final int finish, final Node init, final Node test, final Block body, final Node modify, final int flags) { + super(token, finish, test, body, false); this.init = init; this.modify = modify; this.flags = flags; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/FunctionNode.java --- a/src/jdk/nashorn/internal/ir/FunctionNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/FunctionNode.java Tue May 07 14:36:57 2013 +0200 @@ -86,6 +86,8 @@ /** method has been emitted to bytecode */ EMITTED } + /** Source of entity. */ + private final Source source; /** External function identifier. */ @Ignore @@ -223,8 +225,9 @@ final List parameters, final FunctionNode.Kind kind, final int flags) { - super(source, token, finish); + super(token, finish); + this.source = source; this.ident = ident; this.name = name; this.kind = kind; @@ -265,6 +268,7 @@ this.hints = hints; // the fields below never change - they are final and assigned in constructor + this.source = functionNode.source; this.name = functionNode.name; this.ident = functionNode.ident; this.namespace = functionNode.namespace; @@ -282,6 +286,14 @@ } /** + * Get the source for this function + * @return the source + */ + public Source getSource() { + return source; + } + + /** * Get the version of this function node's code as it looked upon construction * i.e typically parsed and nothing else * @return initial version of function node @@ -300,6 +312,9 @@ if (this.snapshot == this) { return this; } + if (isProgram() || parameters.isEmpty()) { + return this; //never specialize anything that won't be recompiled + } return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, returnType, compileUnit, compilationState, body, parameters, this, hints)); } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/IdentNode.java --- a/src/jdk/nashorn/internal/ir/IdentNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/IdentNode.java Tue May 07 14:36:57 2013 +0200 @@ -34,7 +34,6 @@ import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for an identifier. @@ -56,13 +55,12 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish position * @param name name of identifier */ - public IdentNode(final Source source, final long token, final int finish, final String name) { - super(source, token, finish); + public IdentNode(final long token, final int finish, final String name) { + super(token, finish); this.name = name; this.callSiteType = null; this.flags = 0; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/IfNode.java --- a/src/jdk/nashorn/internal/ir/IfNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/IfNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for an IF statement. @@ -46,15 +45,14 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param test test * @param pass block to execute when test passes * @param fail block to execute when test fails or null */ - public IfNode(final Source source, final long token, final int finish, final Node test, final Block pass, final Block fail) { - super(source, token, finish); + public IfNode(final long token, final int finish, final Node test, final Block pass, final Block fail) { + super(token, finish); this.test = test; this.pass = pass; this.fail = fail; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/IndexNode.java --- a/src/jdk/nashorn/internal/ir/IndexNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/IndexNode.java Tue May 07 14:36:57 2013 +0200 @@ -28,7 +28,6 @@ import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation of an indexed access (brackets operator.) @@ -41,14 +40,13 @@ /** * Constructors * - * @param source the source * @param token token * @param finish finish * @param base base node for access * @param index index for access */ - public IndexNode(final Source source, final long token, final int finish, final Node base, final Node index) { - super(source, token, finish, base, false, false); + public IndexNode(final long token, final int finish, final Node base, final Node index) { + super(token, finish, base, false, false); this.index = index; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/LabelNode.java --- a/src/jdk/nashorn/internal/ir/LabelNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/LabelNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for a labeled statement. @@ -43,14 +42,13 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param label label identifier * @param body body of label node */ - public LabelNode(final Source source, final long token, final int finish, final IdentNode label, final Block body) { - super(source, token, finish); + public LabelNode(final long token, final int finish, final IdentNode label, final Block body) { + super(token, finish); this.label = label; this.body = body; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/LexicalContext.java --- a/src/jdk/nashorn/internal/ir/LexicalContext.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/LexicalContext.java Tue May 07 14:36:57 2013 +0200 @@ -392,8 +392,7 @@ */ public boolean isFunctionDefinedInCurrentCall(FunctionNode functionNode) { final LexicalContextNode parent = stack[sp - 2]; - if(parent instanceof CallNode && ((CallNode)parent).getFunction() == functionNode) { - assert functionNode.getSource() == peek().getSource(); + if (parent instanceof CallNode && ((CallNode)parent).getFunction() == functionNode) { return true; } return false; @@ -540,13 +539,16 @@ sb.append('@'); sb.append(Debug.id(node)); sb.append(':'); - final Source source = node.getSource(); - String src = source.toString(); - if (src.indexOf(File.pathSeparator) != -1) { - src = src.substring(src.lastIndexOf(File.pathSeparator)); + if (node instanceof FunctionNode) { + final Source source = ((FunctionNode)node).getSource(); + String src = source.toString(); + if (src.indexOf(File.pathSeparator) != -1) { + src = src.substring(src.lastIndexOf(File.pathSeparator)); + } + src += ' '; + src += source.getLine(node.getStart()); + sb.append(src); } - src += ' '; - src += source.getLine(node.getStart()); sb.append(' '); } sb.append(" ==> ]"); diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/LexicalContextNode.java --- a/src/jdk/nashorn/internal/ir/LexicalContextNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/LexicalContextNode.java Tue May 07 14:36:57 2013 +0200 @@ -25,7 +25,6 @@ package jdk.nashorn.internal.ir; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * Superclass for nodes that can be part of the lexical context @@ -35,12 +34,11 @@ /** * Constructor * - * @param source source * @param token token * @param finish finish */ - protected LexicalContextNode(final Source source, final long token, final int finish) { - super(source, token, finish); + protected LexicalContextNode(final long token, final int finish) { + super(token, finish); } /** diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/LineNumberNode.java --- a/src/jdk/nashorn/internal/ir/LineNumberNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/LineNumberNode.java Tue May 07 14:36:57 2013 +0200 @@ -28,7 +28,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.Token; -import jdk.nashorn.internal.runtime.Source; /** * IR Node representing a line number @@ -41,12 +40,11 @@ /** * Constructor * - * @param source the source * @param token token * @param lineNumber the line number */ - public LineNumberNode(final Source source, final long token, final int lineNumber) { - super(source, token, Token.descPosition(token)); + public LineNumberNode(final long token, final int lineNumber) { + super(token, Token.descPosition(token)); this.lineNumber = lineNumber; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/LiteralNode.java --- a/src/jdk/nashorn/internal/ir/LiteralNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/LiteralNode.java Tue May 07 14:36:57 2013 +0200 @@ -37,7 +37,6 @@ import jdk.nashorn.internal.parser.TokenType; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptRuntime; -import jdk.nashorn.internal.runtime.Source; import jdk.nashorn.internal.runtime.Undefined; /** @@ -50,16 +49,15 @@ /** Literal value */ protected final T value; - /** + /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param value the value of the literal */ - protected LiteralNode(final Source source, final long token, final int finish, final T value) { - super(source, token, finish); + protected LiteralNode(final long token, final int finish, final T value) { + super(token, finish); this.value = value; } @@ -238,14 +236,13 @@ /** * Create a new null literal * - * @param source the source * @param token token * @param finish finish * * @return the new literal node */ - public static LiteralNode newInstance(final Source source, final long token, final int finish) { - return new NodeLiteralNode(source, token, finish); + public static LiteralNode newInstance(final long token, final int finish) { + return new NodeLiteralNode(token, finish); } /** @@ -256,14 +253,14 @@ * @return the new literal node */ public static LiteralNode newInstance(final Node parent) { - return new NodeLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish()); + return new NodeLiteralNode(parent.getToken(), parent.getFinish()); } @Immutable private static final class BooleanLiteralNode extends LiteralNode { - private BooleanLiteralNode(final Source source, final long token, final int finish, final boolean value) { - super(source, Token.recast(token, value ? TokenType.TRUE : TokenType.FALSE), finish, value); + private BooleanLiteralNode(final long token, final int finish, final boolean value) { + super(Token.recast(token, value ? TokenType.TRUE : TokenType.FALSE), finish, value); } private BooleanLiteralNode(final BooleanLiteralNode literalNode) { @@ -289,15 +286,14 @@ /** * Create a new boolean literal * - * @param source the source * @param token token * @param finish finish * @param value true or false * * @return the new literal node */ - public static LiteralNode newInstance(final Source source, final long token, final int finish, final boolean value) { - return new BooleanLiteralNode(source, token, finish, value); + public static LiteralNode newInstance(final long token, final int finish, final boolean value) { + return new BooleanLiteralNode(token, finish, value); } /** @@ -309,7 +305,7 @@ * @return the new literal node */ public static LiteralNode newInstance(final Node parent, final boolean value) { - return new BooleanLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value); + return new BooleanLiteralNode(parent.getToken(), parent.getFinish(), value); } @Immutable @@ -317,8 +313,8 @@ private final Type type = numberGetType(value); - private NumberLiteralNode(final Source source, final long token, final int finish, final Number value) { - super(source, Token.recast(token, TokenType.DECIMAL), finish, value); + private NumberLiteralNode(final long token, final int finish, final Number value) { + super(Token.recast(token, TokenType.DECIMAL), finish, value); } private NumberLiteralNode(final NumberLiteralNode literalNode) { @@ -353,15 +349,14 @@ /** * Create a new number literal * - * @param source the source * @param token token * @param finish finish * @param value literal value * * @return the new literal node */ - public static LiteralNode newInstance(final Source source, final long token, final int finish, final Number value) { - return new NumberLiteralNode(source, token, finish, value); + public static LiteralNode newInstance(final long token, final int finish, final Number value) { + return new NumberLiteralNode(token, finish, value); } /** @@ -373,12 +368,12 @@ * @return the new literal node */ public static LiteralNode newInstance(final Node parent, final Number value) { - return new NumberLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value); + return new NumberLiteralNode(parent.getToken(), parent.getFinish(), value); } private static class UndefinedLiteralNode extends LiteralNode { - private UndefinedLiteralNode(final Source source, final long token, final int finish) { - super(source, Token.recast(token, TokenType.OBJECT), finish, ScriptRuntime.UNDEFINED); + private UndefinedLiteralNode(final long token, final int finish) { + super(Token.recast(token, TokenType.OBJECT), finish, ScriptRuntime.UNDEFINED); } private UndefinedLiteralNode(final UndefinedLiteralNode literalNode) { @@ -389,15 +384,14 @@ /** * Create a new undefined literal * - * @param source the source * @param token token * @param finish finish * @param value undefined value, passed only for polymorphisism discrimination * * @return the new literal node */ - public static LiteralNode newInstance(final Source source, final long token, final int finish, final Undefined value) { - return new UndefinedLiteralNode(source, token, finish); + public static LiteralNode newInstance(final long token, final int finish, final Undefined value) { + return new UndefinedLiteralNode(token, finish); } /** @@ -409,13 +403,13 @@ * @return the new literal node */ public static LiteralNode newInstance(final Node parent, final Undefined value) { - return new UndefinedLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish()); + return new UndefinedLiteralNode(parent.getToken(), parent.getFinish()); } @Immutable private static class StringLiteralNode extends LiteralNode { - private StringLiteralNode(final Source source, final long token, final int finish, final String value) { - super(source, Token.recast(token, TokenType.STRING), finish, value); + private StringLiteralNode(final long token, final int finish, final String value) { + super(Token.recast(token, TokenType.STRING), finish, value); } private StringLiteralNode(final StringLiteralNode literalNode) { @@ -433,15 +427,14 @@ /** * Create a new string literal * - * @param source the source * @param token token * @param finish finish * @param value string value * * @return the new literal node */ - public static LiteralNode newInstance(final Source source, final long token, final int finish, final String value) { - return new StringLiteralNode(source, token, finish, value); + public static LiteralNode newInstance(final long token, final int finish, final String value) { + return new StringLiteralNode(token, finish, value); } /** @@ -453,13 +446,13 @@ * @return the new literal node */ public static LiteralNode newInstance(final Node parent, final String value) { - return new StringLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value); + return new StringLiteralNode(parent.getToken(), parent.getFinish(), value); } @Immutable private static class LexerTokenLiteralNode extends LiteralNode { - private LexerTokenLiteralNode(final Source source, final long token, final int finish, final LexerToken value) { - super(source, Token.recast(token, TokenType.STRING), finish, value); //TODO is string the correct token type here? + private LexerTokenLiteralNode(final long token, final int finish, final LexerToken value) { + super(Token.recast(token, TokenType.STRING), finish, value); //TODO is string the correct token type here? } private LexerTokenLiteralNode(final LexerTokenLiteralNode literalNode) { @@ -480,15 +473,14 @@ /** * Create a new literal node for a lexer token * - * @param source the source * @param token token * @param finish finish * @param value lexer token value * * @return the new literal node */ - public static LiteralNode newInstance(final Source source, final long token, final int finish, final LexerToken value) { - return new LexerTokenLiteralNode(source, token, finish, value); + public static LiteralNode newInstance(final long token, final int finish, final LexerToken value) { + return new LexerTokenLiteralNode(token, finish, value); } /** @@ -500,17 +492,17 @@ * @return the new literal node */ public static LiteralNode newInstance(final Node parent, final LexerToken value) { - return new LexerTokenLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value); + return new LexerTokenLiteralNode(parent.getToken(), parent.getFinish(), value); } private static final class NodeLiteralNode extends LiteralNode { - private NodeLiteralNode(final Source source, final long token, final int finish) { - this(source, token, finish, null); + private NodeLiteralNode(final long token, final int finish) { + this(token, finish, null); } - private NodeLiteralNode(final Source source, final long token, final int finish, final Node value) { - super(source, Token.recast(token, TokenType.OBJECT), finish, value); + private NodeLiteralNode(final long token, final int finish, final Node value) { + super(Token.recast(token, TokenType.OBJECT), finish, value); } private NodeLiteralNode(final LiteralNode literalNode) { @@ -550,15 +542,14 @@ /** * Create a new node literal for an arbitrary node * - * @param source the source * @param token token * @param finish finish * @param value the literal value node * * @return the new literal node */ - public static LiteralNode newInstance(final Source source, final long token, final int finish, final Node value) { - return new NodeLiteralNode(source, token, finish, value); + public static LiteralNode newInstance(final long token, final int finish, final Node value) { + return new NodeLiteralNode(token, finish, value); } /** @@ -570,7 +561,7 @@ * @return the new literal node */ public static LiteralNode newInstance(final Node parent, final Node value) { - return new NodeLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value); + return new NodeLiteralNode(parent.getToken(), parent.getFinish(), value); } /** @@ -645,13 +636,12 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param value array literal value, a Node array */ - protected ArrayLiteralNode(final Source source, final long token, final int finish, final Node[] value) { - super(source, Token.recast(token, TokenType.ARRAY), finish, value); + protected ArrayLiteralNode(final long token, final int finish, final Node[] value) { + super(Token.recast(token, TokenType.ARRAY), finish, value); this.elementType = Type.UNKNOWN; } @@ -886,15 +876,14 @@ /** * Create a new array literal of Nodes from a list of Node values * - * @param source the source * @param token token * @param finish finish * @param value literal value list * * @return the new literal node */ - public static LiteralNode newInstance(final Source source, final long token, final int finish, final List value) { - return new ArrayLiteralNode(source, token, finish, value.toArray(new Node[value.size()])); + public static LiteralNode newInstance(final long token, final int finish, final List value) { + return new ArrayLiteralNode(token, finish, value.toArray(new Node[value.size()])); } @@ -907,20 +896,19 @@ * @return the new literal node */ public static LiteralNode newInstance(final Node parent, final List value) { - return new ArrayLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value.toArray(new Node[value.size()])); + return new ArrayLiteralNode(parent.getToken(), parent.getFinish(), value.toArray(new Node[value.size()])); } /** * Create a new array literal of Nodes * - * @param source the source * @param token token * @param finish finish * @param value literal value array * * @return the new literal node */ - public static LiteralNode newInstance(final Source source, final long token, final int finish, final Node[] value) { - return new ArrayLiteralNode(source, token, finish, value); + public static LiteralNode newInstance(final long token, final int finish, final Node[] value) { + return new ArrayLiteralNode(token, finish, value); } } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/Location.java --- a/src/jdk/nashorn/internal/ir/Location.java Fri May 03 22:50:51 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.nashorn.internal.ir; - -import jdk.nashorn.internal.parser.Token; -import jdk.nashorn.internal.parser.TokenType; -import jdk.nashorn.internal.runtime.Source; - -/** - * Used to locate an entity back to it's source file. - */ -public class Location implements Cloneable { - /** Source of entity. */ - private final Source source; - - /** Token descriptor. */ - private final long token; - - /** - * Constructor - * - * @param source the source - * @param token token - */ - public Location(final Source source, final long token) { - this.source = source; - this.token = token; - } - - /** - * Copy constructor - * - * @param location source node - */ - protected Location(final Location location) { - this.source = location.source; - this.token = location.token; - } - - @Override - protected Object clone() { - try { - return super.clone(); - } catch(CloneNotSupportedException e) { - throw new AssertionError(e); - } - } - - @Override - public final boolean equals(final Object other) { - return super.equals(other); - } - - @Override - public final int hashCode() { - return super.hashCode(); - } - - /** - * Return token position from a token descriptor. - * - * @return Start position of the token in the source. - */ - public int position() { - return Token.descPosition(token); - } - - /** - * Return token length from a token descriptor. - * - * @return Length of the token. - */ - public int length() { - return Token.descLength(token); - } - - /** - * Return token tokenType from a token descriptor. - * - * @return Type of token. - */ - public TokenType tokenType() { - return Token.descType(token); - } - - /** - * Test token tokenType. - * - * @param type a type to check this token against - * @return true if token types match. - */ - public boolean isTokenType(final TokenType type) { - return Token.descType(token) == type; - } - - /** - * Get the source for this location - * @return the source - */ - public Source getSource() { - return source; - } - - /** - * Get the token for this location - * @return the token - */ - public long getToken() { - return token; - } -} diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/LoopNode.java --- a/src/jdk/nashorn/internal/ir/LoopNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/LoopNode.java Tue May 07 14:36:57 2013 +0200 @@ -29,7 +29,6 @@ import java.util.List; import jdk.nashorn.internal.codegen.Label; -import jdk.nashorn.internal.runtime.Source; /** * A loop node, for example a while node, do while node or for node @@ -50,15 +49,14 @@ /** * Constructor * - * @param source source * @param token token * @param finish finish * @param test test, or null if infinite loop * @param body loop body * @param controlFlowEscapes controlFlowEscapes */ - protected LoopNode(final Source source, final long token, final int finish, final Node test, final Block body, final boolean controlFlowEscapes) { - super(source, token, finish, new Label("while_break")); + protected LoopNode(final long token, final int finish, final Node test, final Block body, final boolean controlFlowEscapes) { + super(token, finish, new Label("while_break")); this.continueLabel = new Label("while_continue"); this.test = test; this.body = body; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/Node.java --- a/src/jdk/nashorn/internal/ir/Node.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/Node.java Tue May 07 14:36:57 2013 +0200 @@ -31,12 +31,12 @@ import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.Token; -import jdk.nashorn.internal.runtime.Source; +import jdk.nashorn.internal.parser.TokenType; /** * Nodes are used to compose Abstract Syntax Trees. */ -public abstract class Node extends Location { +public abstract class Node implements Cloneable { /** Node symbol. */ private Symbol symbol; @@ -46,16 +46,17 @@ /** End of source range. */ protected int finish; + /** Token descriptor. */ + private final long token; + /** * Constructor * - * @param source the source * @param token token * @param finish finish */ - public Node(final Source source, final long token, final int finish) { - super(source, token); - + public Node(final long token, final int finish) { + this.token = token; this.start = Token.descPosition(token); this.finish = finish; } @@ -63,16 +64,14 @@ /** * Constructor * - * @param source source * @param token token * @param start start * @param finish finish */ - protected Node(final Source source, final long token, final int start, final int finish) { - super(source, token); - + protected Node(final long token, final int start, final int finish) { this.start = start; this.finish = finish; + this.token = token; } /** @@ -81,8 +80,7 @@ * @param node source node */ protected Node(final Node node) { - super(node); - + this.token = node.token; this.symbol = node.symbol; this.start = node.start; this.finish = node.finish; @@ -248,6 +246,15 @@ return symbol; } + @Override + protected Object clone() { + try { + return super.clone(); + } catch (final CloneNotSupportedException e) { + throw new AssertionError(e); + } + } + /** * Assign a symbol to this node. See {@link Node#getSymbol()} for explanation * of what a symbol is @@ -265,6 +272,62 @@ return newNode; } + + @Override + public final boolean equals(final Object other) { + return super.equals(other); + } + + @Override + public final int hashCode() { + return super.hashCode(); + } + + /** + * Return token position from a token descriptor. + * + * @return Start position of the token in the source. + */ + public int position() { + return Token.descPosition(token); + } + + /** + * Return token length from a token descriptor. + * + * @return Length of the token. + */ + public int length() { + return Token.descLength(token); + } + + /** + * Return token tokenType from a token descriptor. + * + * @return Type of token. + */ + public TokenType tokenType() { + return Token.descType(token); + } + + /** + * Test token tokenType. + * + * @param type a type to check this token against + * @return true if token types match. + */ + public boolean isTokenType(final TokenType type) { + return Token.descType(token) == type; + } + + /** + * Get the token for this location + * @return the token + */ + public long getToken() { + return token; + } + /** * Is this a terminal Node, i.e. does it end control flow like a throw or return * expression does? diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/ObjectNode.java --- a/src/jdk/nashorn/internal/ir/ObjectNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/ObjectNode.java Tue May 07 14:36:57 2013 +0200 @@ -30,7 +30,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation of an object literal. @@ -44,13 +43,12 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param elements the elements used to initialize this ObjectNode */ - public ObjectNode(final Source source, final long token, final int finish, final List elements) { - super(source, token, finish); + public ObjectNode(final long token, final int finish, final List elements) { + super(token, finish); this.elements = elements; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/PropertyNode.java --- a/src/jdk/nashorn/internal/ir/PropertyNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/PropertyNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation of an object literal property. @@ -50,7 +49,6 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param key the key of this property @@ -58,8 +56,8 @@ * @param getter getter function body * @param setter setter function body */ - public PropertyNode(final Source source, final long token, final int finish, final PropertyKey key, final Node value, final FunctionNode getter, final FunctionNode setter) { - super(source, token, finish); + public PropertyNode(final long token, final int finish, final PropertyKey key, final Node value, final FunctionNode getter, final FunctionNode setter) { + super(token, finish); this.key = key; this.value = value; this.getter = getter; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/ReturnNode.java --- a/src/jdk/nashorn/internal/ir/ReturnNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/ReturnNode.java Tue May 07 14:36:57 2013 +0200 @@ -29,7 +29,6 @@ import static jdk.nashorn.internal.parser.TokenType.YIELD; import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for RETURN or YIELD statements. @@ -42,13 +41,12 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param expression expression to return */ - public ReturnNode(final Source source, final long token, final int finish, final Node expression) { - super(source, token, finish); + public ReturnNode(final long token, final int finish, final Node expression) { + super(token, finish); this.expression = expression; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/RuntimeNode.java --- a/src/jdk/nashorn/internal/ir/RuntimeNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/RuntimeNode.java Tue May 07 14:36:57 2013 +0200 @@ -33,7 +33,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.TokenType; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for a runtime call. @@ -280,14 +279,13 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param request the request * @param args arguments to request */ - public RuntimeNode(final Source source, final long token, final int finish, final Request request, final List args) { - super(source, token, finish); + public RuntimeNode(final long token, final int finish, final Request request, final List args) { + super(token, finish); this.request = request; this.args = args; @@ -307,14 +305,13 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param request the request * @param args arguments to request */ - public RuntimeNode(final Source source, final long token, final int finish, final Request request, final Node... args) { - this(source, token, finish, request, Arrays.asList(args)); + public RuntimeNode(final long token, final int finish, final Request request, final Node... args) { + this(token, finish, request, Arrays.asList(args)); } /** diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/SplitNode.java --- a/src/jdk/nashorn/internal/ir/SplitNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/SplitNode.java Tue May 07 14:36:57 2013 +0200 @@ -51,7 +51,7 @@ * @param compileUnit compile unit to use for the body */ public SplitNode(final String name, final Node body, final CompileUnit compileUnit) { - super(body.getSource(), body.getToken(), body.getFinish()); + super(body.getToken(), body.getFinish()); this.name = name; this.body = body; this.compileUnit = compileUnit; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/SwitchNode.java --- a/src/jdk/nashorn/internal/ir/SwitchNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/SwitchNode.java Tue May 07 14:36:57 2013 +0200 @@ -32,7 +32,6 @@ import jdk.nashorn.internal.codegen.Label; import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation of a SWITCH statement. @@ -54,15 +53,14 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param expression switch expression * @param cases cases * @param defaultCase the default case node - null if none, otherwise has to be present in cases list */ - public SwitchNode(final Source source, final long token, final int finish, final Node expression, final List cases, final CaseNode defaultCase) { - super(source, token, finish, new Label("switch_break")); + public SwitchNode(final long token, final int finish, final Node expression, final List cases, final CaseNode defaultCase) { + super(token, finish, new Label("switch_break")); this.expression = expression; this.cases = cases; this.defaultCaseIndex = defaultCase == null ? -1 : cases.indexOf(defaultCase); diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/TernaryNode.java --- a/src/jdk/nashorn/internal/ir/TernaryNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/TernaryNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * TernaryNode nodes represent three operand operations (?:). @@ -44,14 +43,13 @@ /** * Constructor * - * @param source the source * @param token token * @param lhs left hand side node * @param rhs right hand side node * @param third third node */ - public TernaryNode(final Source source, final long token, final Node lhs, final Node rhs, final Node third) { - super(source, token, third.getFinish()); + public TernaryNode(final long token, final Node lhs, final Node rhs, final Node third) { + super(token, third.getFinish()); this.lhs = lhs; this.rhs = rhs; this.third = third; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/ThrowNode.java --- a/src/jdk/nashorn/internal/ir/ThrowNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/ThrowNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for THROW statements. @@ -40,14 +39,12 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param expression expression to throw */ - public ThrowNode(final Source source, final long token, final int finish, final Node expression) { - super(source, token, finish); - + public ThrowNode(final long token, final int finish, final Node expression) { + super(token, finish); this.expression = expression; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/TryNode.java --- a/src/jdk/nashorn/internal/ir/TryNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/TryNode.java Tue May 07 14:36:57 2013 +0200 @@ -32,7 +32,6 @@ import jdk.nashorn.internal.codegen.Label; import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation of a TRY statement. @@ -60,15 +59,14 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param body try node body * @param catchBlocks list of catch blocks in order * @param finallyBody body of finally block or null if none */ - public TryNode(final Source source, final long token, final int finish, final Block body, final List catchBlocks, final Block finallyBody) { - super(source, token, finish); + public TryNode(final long token, final int finish, final Block body, final List catchBlocks, final Block finallyBody) { + super(token, finish); this.body = body; this.catchBlocks = catchBlocks; this.finallyBody = finallyBody; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/UnaryNode.java --- a/src/jdk/nashorn/internal/ir/UnaryNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/UnaryNode.java Tue May 07 14:36:57 2013 +0200 @@ -35,7 +35,6 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor; import jdk.nashorn.internal.parser.Token; import jdk.nashorn.internal.parser.TokenType; -import jdk.nashorn.internal.runtime.Source; /** * UnaryNode nodes represent single operand operations. @@ -48,24 +47,23 @@ /** * Constructor * - * @param source the source * @param token token * @param rhs expression */ - public UnaryNode(final Source source, final long token, final Node rhs) { - this(source, token, Math.min(rhs.getStart(), Token.descPosition(token)), Math.max(Token.descPosition(token) + Token.descLength(token), rhs.getFinish()), rhs); + public UnaryNode(final long token, final Node rhs) { + this(token, Math.min(rhs.getStart(), Token.descPosition(token)), Math.max(Token.descPosition(token) + Token.descLength(token), rhs.getFinish()), rhs); } /** * Constructor - * @param source the source + * * @param token token * @param start start * @param finish finish * @param rhs expression */ - public UnaryNode(final Source source, final long token, final int start, final int finish, final Node rhs) { - super(source, token, start, finish); + public UnaryNode(final long token, final int start, final int finish, final Node rhs) { + super(token, start, finish); this.rhs = rhs; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/VarNode.java --- a/src/jdk/nashorn/internal/ir/VarNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/VarNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * Node represents a var/let declaration. @@ -54,14 +53,13 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param name name of variable * @param init init node or null if just a declaration */ - public VarNode(final Source source, final long token, final int finish, final IdentNode name, final Node init) { - this(source, token, finish, name, init, IS_STATEMENT); + public VarNode(final long token, final int finish, final IdentNode name, final Node init) { + this(token, finish, name, init, IS_STATEMENT); } private VarNode(final VarNode varNode, final IdentNode name, final Node init, final int flags) { @@ -74,15 +72,14 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param name name of variable * @param init init node or null if just a declaration * @param flags flags */ - public VarNode(final Source source, final long token, final int finish, final IdentNode name, final Node init, final int flags) { - super(source, token, finish); + public VarNode(final long token, final int finish, final IdentNode name, final Node init, final int flags) { + super(token, finish); this.name = init == null ? name : name.setIsInitializedHere(); this.init = init; diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/WhileNode.java --- a/src/jdk/nashorn/internal/ir/WhileNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/WhileNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for a WHILE statement. This is the superclass of all @@ -42,13 +41,12 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish * @param isDoWhile is this a do while loop? */ - public WhileNode(final Source source, final long token, final int finish, final boolean isDoWhile) { - super(source, token, finish, null, null, false); + public WhileNode(final long token, final int finish, final boolean isDoWhile) { + super(token, finish, null, null, false); this.isDoWhile = isDoWhile; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/WithNode.java --- a/src/jdk/nashorn/internal/ir/WithNode.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/WithNode.java Tue May 07 14:36:57 2013 +0200 @@ -27,7 +27,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable; import jdk.nashorn.internal.ir.visitor.NodeVisitor; -import jdk.nashorn.internal.runtime.Source; /** * IR representation for {@code with} statements. @@ -43,20 +42,17 @@ /** * Constructor * - * @param source the source * @param token token * @param finish finish */ - public WithNode(final Source source, final long token, final int finish) { - super(source, token, finish); - + public WithNode(final long token, final int finish) { + super(token, finish); this.expression = null; this.body = null; } private WithNode(final WithNode node, final Node expression, final Block body) { super(node); - this.expression = expression; this.body = body; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/ir/debug/JSONWriter.java --- a/src/jdk/nashorn/internal/ir/debug/JSONWriter.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/ir/debug/JSONWriter.java Tue May 07 14:36:57 2013 +0200 @@ -971,7 +971,7 @@ objectStart("loc"); // source name - final Source src = node.getSource(); + final Source src = getLexicalContext().getCurrentFunction().getSource(); property("source", src.getName()); comma(); diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/objects/NativeDebug.java --- a/src/jdk/nashorn/internal/objects/NativeDebug.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/objects/NativeDebug.java Tue May 07 14:36:57 2013 +0200 @@ -178,7 +178,6 @@ * @param self self reference * @return undefined */ - @SuppressWarnings("resource") @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object dumpCounters(final Object self) { final PrintWriter out = Context.getCurrentErr(); diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/parser/AbstractParser.java --- a/src/jdk/nashorn/internal/parser/AbstractParser.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/parser/AbstractParser.java Tue May 07 14:36:57 2013 +0200 @@ -364,7 +364,7 @@ next(); // Create IDENT node. - return new IdentNode(source, identToken, finish, ident); + return new IdentNode(identToken, finish, ident); } // Get IDENT. @@ -373,7 +373,7 @@ return null; } // Create IDENT node. - return new IdentNode(source, identToken, finish, ident); + return new IdentNode(identToken, finish, ident); } /** @@ -408,7 +408,7 @@ final String ident = (String)getValue(identToken); next(); // Create IDENT node. - return new IdentNode(source, identToken, finish, ident); + return new IdentNode(identToken, finish, ident); } else { expect(IDENT); return null; @@ -433,11 +433,11 @@ LiteralNode node = null; if (value == null) { - node = LiteralNode.newInstance(source, literalToken, finish); + node = LiteralNode.newInstance(literalToken, finish); } else if (value instanceof Number) { - node = LiteralNode.newInstance(source, literalToken, finish, (Number)value); + node = LiteralNode.newInstance(literalToken, finish, (Number)value); } else if (value instanceof String) { - node = LiteralNode.newInstance(source, literalToken, finish, (String)value); + node = LiteralNode.newInstance(literalToken, finish, (String)value); } else if (value instanceof LexerToken) { if (value instanceof RegexToken) { final RegexToken regex = (RegexToken)value; @@ -447,7 +447,7 @@ throw error(e.getMessage()); } } - node = LiteralNode.newInstance(source, literalToken, finish, (LexerToken)value); + node = LiteralNode.newInstance(literalToken, finish, (LexerToken)value); } else { assert false : "unknown type for LiteralNode: " + value.getClass(); } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/parser/JSONParser.java --- a/src/jdk/nashorn/internal/parser/JSONParser.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/parser/JSONParser.java Tue May 07 14:36:57 2013 +0200 @@ -193,13 +193,13 @@ return getLiteral(); case FALSE: next(); - return LiteralNode.newInstance(source, literalToken, finish, false); + return LiteralNode.newInstance(literalToken, finish, false); case TRUE: next(); - return LiteralNode.newInstance(source, literalToken, finish, true); + return LiteralNode.newInstance(literalToken, finish, true); case NULL: next(); - return LiteralNode.newInstance(source, literalToken, finish); + return LiteralNode.newInstance(literalToken, finish); case LBRACKET: return arrayLiteral(); case LBRACE: @@ -218,7 +218,7 @@ if (value instanceof Number) { next(); - return new UnaryNode(source, literalToken, LiteralNode.newInstance(source, realToken, finish, (Number)value)); + return new UnaryNode(literalToken, LiteralNode.newInstance(realToken, finish, (Number)value)); } throw error(AbstractParser.message("expected", "number", type.getNameOrType())); @@ -250,7 +250,7 @@ switch (type) { case RBRACKET: next(); - result = LiteralNode.newInstance(source, arrayToken, finish, elements); + result = LiteralNode.newInstance(arrayToken, finish, elements); break loop; case COMMARIGHT: @@ -310,7 +310,7 @@ } // Construct new object literal. - return new ObjectNode(source, objectToken, finish, elements); + return new ObjectNode(objectToken, finish, elements); } /** @@ -331,7 +331,7 @@ if (name != null) { expect(COLON); final Node value = jsonLiteral(); - return new PropertyNode(source, propertyToken, value.getFinish(), name, value, null, null); + return new PropertyNode(propertyToken, value.getFinish(), name, value, null, null); } // Raise an error. diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/parser/Parser.java --- a/src/jdk/nashorn/internal/parser/Parser.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/parser/Parser.java Tue May 07 14:36:57 2013 +0200 @@ -275,8 +275,7 @@ * @return New block. */ private Block newBlock() { - final Block block = new Block(source, token, Token.descPosition(token)); - return lc.push(block); + return lc.push(new Block(token, Token.descPosition(token))); } /** @@ -479,7 +478,7 @@ } // Build up node. - return new BinaryNode(source, op, lhs, rhs); + return new BinaryNode(op, lhs, rhs); } /** @@ -490,12 +489,12 @@ * @param isPostfix Prefix or postfix. * @return Reduced expression. */ - private Node incDecExpression(final long firstToken, final TokenType tokenType, final Node expression, final boolean isPostfix) { + private static Node incDecExpression(final long firstToken, final TokenType tokenType, final Node expression, final boolean isPostfix) { if (isPostfix) { - return new UnaryNode(source, Token.recast(firstToken, tokenType == DECPREFIX ? DECPOSTFIX : INCPOSTFIX), expression.getStart(), Token.descPosition(firstToken) + Token.descLength(firstToken), expression); + return new UnaryNode(Token.recast(firstToken, tokenType == DECPREFIX ? DECPOSTFIX : INCPOSTFIX), expression.getStart(), Token.descPosition(firstToken) + Token.descLength(firstToken), expression); } - return new UnaryNode(source, firstToken, expression); + return new UnaryNode(firstToken, expression); } /** @@ -524,7 +523,7 @@ FunctionNode script = newFunctionNode( functionToken, - new IdentNode(source, functionToken, Token.descPosition(functionToken), scriptName), + new IdentNode(functionToken, Token.descPosition(functionToken), scriptName), new ArrayList(), FunctionNode.Kind.SCRIPT); @@ -774,7 +773,7 @@ private void block() { final Block newBlock = getBlock(true); // Force block execution. - appendStatement(new ExecuteNode(source, newBlock.getToken(), finish, newBlock)); + appendStatement(new ExecuteNode(newBlock.getToken(), finish, newBlock)); } /** @@ -867,7 +866,7 @@ } // Allocate var node. - final VarNode var = new VarNode(source, varToken, finish, name, init); + final VarNode var = new VarNode(varToken, finish, name, init); vars.add(var); appendStatement(var); @@ -899,7 +898,7 @@ */ private void emptyStatement() { if (env._empty_statements) { - appendStatement(new EmptyNode(source, token, Token.descPosition(token) + Token.descLength(token))); + appendStatement(new EmptyNode(token, Token.descPosition(token) + Token.descLength(token))); } // SEMICOLON checked in caller. @@ -923,7 +922,7 @@ ExecuteNode executeNode = null; if (expression != null) { - executeNode = new ExecuteNode(source, expressionToken, finish, expression); + executeNode = new ExecuteNode(expressionToken, finish, expression); appendStatement(executeNode); } else { expect(null); @@ -963,7 +962,7 @@ fail = getStatement(); } - appendStatement(new IfNode(source, ifToken, fail != null ? fail.getFinish() : pass.getFinish(), test, pass, fail)); + appendStatement(new IfNode(ifToken, fail != null ? fail.getFinish() : pass.getFinish(), test, pass, fail)); } /** @@ -980,7 +979,7 @@ */ private void forStatement() { // Create FOR node, capturing FOR token. - ForNode forNode = new ForNode(source, token, Token.descPosition(token), null, null, null, null, ForNode.IS_FOR); + ForNode forNode = new ForNode(token, Token.descPosition(token), null, null, null, null, ForNode.IS_FOR); // Set up new block for scope of vars. Captures first token. @@ -1084,7 +1083,7 @@ outer = restoreBlock(outer); } - appendStatement(new ExecuteNode(source, outer.getToken(), outer.getFinish(), outer)); + appendStatement(new ExecuteNode(outer.getToken(), outer.getFinish(), outer)); } /** @@ -1120,7 +1119,7 @@ next(); // Construct WHILE node. - WhileNode whileNode = new WhileNode(source, whileToken, Token.descPosition(whileToken), false); + WhileNode whileNode = new WhileNode(whileToken, Token.descPosition(whileToken), false); lc.push(whileNode); try { @@ -1150,7 +1149,7 @@ // DO tested in the caller. next(); - WhileNode doWhileNode = new WhileNode(source, doToken, Token.descPosition(doToken), true); + WhileNode doWhileNode = new WhileNode(doToken, Token.descPosition(doToken), true); lc.push(doWhileNode); try { @@ -1216,7 +1215,7 @@ endOfLine(); // Construct and add CONTINUE node. - appendStatement(new ContinueNode(source, continueToken, finish, label == null ? null : new IdentNode(label))); + appendStatement(new ContinueNode(continueToken, finish, label == null ? null : new IdentNode(label))); } /** @@ -1263,7 +1262,7 @@ endOfLine(); // Construct and add BREAK node. - appendStatement(new BreakNode(source, breakToken, finish, label == null ? null : new IdentNode(label))); + appendStatement(new BreakNode(breakToken, finish, label == null ? null : new IdentNode(label))); } /** @@ -1302,7 +1301,7 @@ endOfLine(); // Construct and add RETURN node. - appendStatement(new ReturnNode(source, returnToken, finish, expression)); + appendStatement(new ReturnNode(returnToken, finish, expression)); } /** @@ -1336,7 +1335,7 @@ endOfLine(); // Construct and add YIELD node. - appendStatement(new ReturnNode(source, yieldToken, finish, expression)); + appendStatement(new ReturnNode(yieldToken, finish, expression)); } /** @@ -1359,7 +1358,7 @@ } // Get WITH expression. - WithNode withNode = new WithNode(source, withToken, finish); + WithNode withNode = new WithNode(withToken, finish); try { lc.push(withNode); @@ -1402,7 +1401,7 @@ next(); // Create and add switch statement. - SwitchNode switchNode = new SwitchNode(source, switchToken, Token.descPosition(switchToken), null, new ArrayList(), null); + SwitchNode switchNode = new SwitchNode(switchToken, Token.descPosition(switchToken), null, new ArrayList(), null); lc.push(switchNode); try { @@ -1444,7 +1443,7 @@ // Get CASE body. final Block statements = getBlock(false); - final CaseNode caseNode = new CaseNode(source, caseToken, finish, caseExpression, statements); + final CaseNode caseNode = new CaseNode(caseToken, finish, caseExpression, statements); statements.setFinish(finish); if (caseExpression == null) { @@ -1484,7 +1483,7 @@ throw error(AbstractParser.message("duplicate.label", ident.getName()), labelToken); } - LabelNode labelNode = new LabelNode(source, labelToken, finish, ident, null); + LabelNode labelNode = new LabelNode(labelToken, finish, ident, null); try { lc.push(labelNode); labelNode = labelNode.setBody(lc, getStatement()); @@ -1530,7 +1529,7 @@ endOfLine(); - appendStatement(new ThrowNode(source, throwToken, finish, expression)); + appendStatement(new ThrowNode(throwToken, finish, expression)); } /** @@ -1588,7 +1587,7 @@ try { // Get CATCH body. final Block catchBody = getBlock(true); - final CatchNode catchNode = new CatchNode(source, catchToken, finish, exception, ifExpression, catchBody); + final CatchNode catchNode = new CatchNode(catchToken, finish, exception, ifExpression, catchBody); appendStatement(catchNode); } finally { catchBlock = restoreBlock(catchBlock); @@ -1614,7 +1613,7 @@ throw error(AbstractParser.message("missing.catch.or.finally"), tryToken); } - final TryNode tryNode = new TryNode(source, tryToken, Token.descPosition(tryToken), tryBody, catchBlocks, finallyStatements); + final TryNode tryNode = new TryNode(tryToken, Token.descPosition(tryToken), tryBody, catchBlocks, finallyStatements); // Add try. assert lc.peek() == outer; appendStatement(tryNode); @@ -1626,7 +1625,7 @@ outer = restoreBlock(outer); } - appendStatement(new ExecuteNode(source, outer.getToken(), outer.getFinish(), outer)); + appendStatement(new ExecuteNode(outer.getToken(), outer.getFinish(), outer)); } /** @@ -1643,7 +1642,7 @@ // DEBUGGER tested in caller. next(); endOfLine(); - appendStatement(new RuntimeNode(source, debuggerToken, finish, RuntimeNode.Request.DEBUGGER, new ArrayList())); + appendStatement(new RuntimeNode(debuggerToken, finish, RuntimeNode.Request.DEBUGGER, new ArrayList())); } /** @@ -1669,7 +1668,7 @@ case THIS: final String name = type.getName(); next(); - return new IdentNode(source, primaryToken, finish, name); + return new IdentNode(primaryToken, finish, name); case IDENT: final IdentNode ident = getIdent(); if (ident == null) { @@ -1693,13 +1692,13 @@ return execString(primaryToken); case FALSE: next(); - return LiteralNode.newInstance(source, primaryToken, finish, false); + return LiteralNode.newInstance(primaryToken, finish, false); case TRUE: next(); - return LiteralNode.newInstance(source, primaryToken, finish, true); + return LiteralNode.newInstance(primaryToken, finish, true); case NULL: next(); - return LiteralNode.newInstance(source, primaryToken, finish); + return LiteralNode.newInstance(primaryToken, finish); case LBRACKET: return arrayLiteral(); case LBRACE: @@ -1736,7 +1735,7 @@ */ Node execString(final long primaryToken) { // Synthesize an ident to call $EXEC. - final IdentNode execIdent = new IdentNode(source, primaryToken, finish, ScriptingFunctions.EXEC_NAME); + final IdentNode execIdent = new IdentNode(primaryToken, finish, ScriptingFunctions.EXEC_NAME); // Skip over EXECSTRING. next(); // Set up argument list for call. @@ -1748,7 +1747,7 @@ // Skip ending of edit string expression. expect(RBRACE); - return new CallNode(source, primaryToken, finish, execIdent, arguments); + return new CallNode(primaryToken, finish, execIdent, arguments); } /** @@ -1819,7 +1818,7 @@ } } - return LiteralNode.newInstance(source, arrayToken, finish, elements); + return LiteralNode.newInstance(arrayToken, finish, elements); } /** @@ -1926,7 +1925,7 @@ map.put(key, newProperty = newProperty.setValue(value)); } else { final long propertyToken = Token.recast(newProperty.getToken(), COMMARIGHT); - map.put(key, newProperty = newProperty.setValue(new BinaryNode(source, propertyToken, prevValue, value))); + map.put(key, newProperty = newProperty.setValue(new BinaryNode(propertyToken, prevValue, value))); } map.put(key, newProperty = newProperty.setGetter(null).setSetter(null)); @@ -1943,7 +1942,7 @@ } } - return new ObjectNode(source, objectToken, finish, new ArrayList(map.values())); + return new ObjectNode(objectToken, finish, new ArrayList(map.values())); } /** @@ -2013,16 +2012,16 @@ case "get": final PropertyKey getIdent = propertyName(); final String getterName = getIdent.getPropertyName(); - final IdentNode getNameNode = new IdentNode(source, ((Node)getIdent).getToken(), finish, "get " + getterName); + final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + getterName); expect(LPAREN); expect(RPAREN); functionNode = functionBody(getSetToken, getNameNode, new ArrayList(), FunctionNode.Kind.GETTER); - return new PropertyNode(source, propertyToken, finish, getIdent, null, functionNode, null); + return new PropertyNode(propertyToken, finish, getIdent, null, functionNode, null); case "set": final PropertyKey setIdent = propertyName(); final String setterName = setIdent.getPropertyName(); - final IdentNode setNameNode = new IdentNode(source, ((Node)setIdent).getToken(), finish, "set " + setterName); + final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + setterName); expect(LPAREN); final IdentNode argIdent = getIdent(); verifyStrictIdent(argIdent, "setter argument"); @@ -2030,21 +2029,21 @@ List parameters = new ArrayList<>(); parameters.add(argIdent); functionNode = functionBody(getSetToken, setNameNode, parameters, FunctionNode.Kind.SETTER); - return new PropertyNode(source, propertyToken, finish, setIdent, null, null, functionNode); + return new PropertyNode(propertyToken, finish, setIdent, null, null, functionNode); default: break; } } - propertyName = new IdentNode(source, propertyToken, finish, ident); + propertyName = new IdentNode(propertyToken, finish, ident); } else { propertyName = propertyName(); } expect(COLON); - return new PropertyNode(source, propertyToken, finish, propertyName, assignmentExpression(false), null, null); + return new PropertyNode(propertyToken, finish, propertyName, assignmentExpression(false), null, null); } /** @@ -2076,7 +2075,7 @@ detectSpecialFunction((IdentNode)lhs); } - lhs = new CallNode(source, callToken, finish, lhs, arguments); + lhs = new CallNode(callToken, finish, lhs, arguments); } loop: @@ -2090,7 +2089,7 @@ final List arguments = argumentList(); // Create call node. - lhs = new CallNode(source, callToken, finish, lhs, arguments); + lhs = new CallNode(callToken, finish, lhs, arguments); break; @@ -2103,7 +2102,7 @@ expect(RBRACKET); // Create indexing node. - lhs = new IndexNode(source, callToken, finish, lhs, rhs); + lhs = new IndexNode(callToken, finish, lhs, rhs); break; @@ -2113,7 +2112,7 @@ final IdentNode property = getIdentifierName(); // Create property access node. - lhs = new AccessNode(source, callToken, finish, lhs, property); + lhs = new AccessNode(callToken, finish, lhs, property); break; @@ -2169,9 +2168,9 @@ arguments.add(objectLiteral()); } - final CallNode callNode = new CallNode(source, constructor.getToken(), finish, constructor, arguments); - - return new UnaryNode(source, newToken, callNode); + final CallNode callNode = new CallNode(constructor.getToken(), finish, constructor, arguments); + + return new UnaryNode(newToken, callNode); } /** @@ -2223,7 +2222,7 @@ expect(RBRACKET); // Create indexing node. - lhs = new IndexNode(source, callToken, finish, lhs, index); + lhs = new IndexNode(callToken, finish, lhs, index); break; @@ -2237,7 +2236,7 @@ final IdentNode property = getIdentifierName(); // Create property access node. - lhs = new AccessNode(source, callToken, finish, lhs, property); + lhs = new AccessNode(callToken, finish, lhs, property); break; @@ -2326,7 +2325,7 @@ boolean isAnonymous = false; if (name == null) { final String tmpName = "_L" + source.getLine(Token.descPosition(token)); - name = new IdentNode(source, functionToken, Token.descPosition(functionToken), tmpName); + name = new IdentNode(functionToken, Token.descPosition(functionToken), tmpName); isAnonymous = true; } @@ -2377,7 +2376,7 @@ // rename in non-strict mode parameterName = functionNode.uniqueName(parameterName); final long parameterToken = parameter.getToken(); - parameters.set(i, new IdentNode(source, parameterToken, Token.descPosition(parameterToken), functionNode.uniqueName(parameterName))); + parameters.set(i, new IdentNode(parameterToken, Token.descPosition(parameterToken), functionNode.uniqueName(parameterName))); } parametersSet.add(parameterName); @@ -2389,7 +2388,7 @@ } if (isStatement) { - final VarNode varNode = new VarNode(source, functionToken, finish, name, functionNode, VarNode.IS_STATEMENT); + final VarNode varNode = new VarNode(functionToken, finish, name, functionNode, VarNode.IS_STATEMENT); if (topLevel) { functionDeclarations.add(lineNumber); functionDeclarations.add(varNode); @@ -2469,7 +2468,7 @@ assert lc.getCurrentBlock() == lc.getFunctionBody(functionNode); // create a return statement - this creates code in itself and does not need to be // wrapped into an ExecuteNode - final ReturnNode returnNode = new ReturnNode(source, expr.getToken(), finish, expr); + final ReturnNode returnNode = new ReturnNode(expr.getToken(), finish, expr); appendStatement(returnNode); lastToken = token; functionNode.setFinish(Token.descPosition(token) + Token.descLength(token)); @@ -2511,16 +2510,16 @@ } } - private RuntimeNode referenceError(final Node lhs, final Node rhs) { + private static RuntimeNode referenceError(final Node lhs, final Node rhs) { final ArrayList args = new ArrayList<>(); args.add(lhs); if (rhs == null) { - args.add(LiteralNode.newInstance(source, lhs.getToken(), lhs.getFinish())); + args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish())); } else { args.add(rhs); } - args.add(LiteralNode.newInstance(source, lhs.getToken(), lhs.getFinish(), lhs.toString())); - return new RuntimeNode(source, lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args); + args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString())); + return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args); } /* @@ -2570,7 +2569,7 @@ case NOT: next(); final Node expr = unaryExpression(); - return new UnaryNode(source, unaryToken, expr); + return new UnaryNode(unaryToken, expr); case INCPREFIX: case DECPREFIX: @@ -2759,7 +2758,7 @@ final Node third = expression(unaryExpression(), ASSIGN.getPrecedence(), noIn); // Build up node. - lhs = new TernaryNode(source, op, lhs, rhs, third); + lhs = new TernaryNode(op, lhs, rhs, third); } else { // Skip operator. next(); @@ -2820,7 +2819,7 @@ */ private LineNumberNode lineNumber() { if (env._debug_lines) { - return new LineNumberNode(source, token, line); + return new LineNumberNode(token, line); } return null; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java --- a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Tue May 07 14:36:57 2013 +0200 @@ -229,6 +229,10 @@ } final FunctionNode snapshot = functionNode.getSnapshot(); + if (snapshot == null) { + return mh; + } + int i; //classes known at runtime diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/runtime/ScriptObject.java --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java Tue May 07 14:36:57 2013 +0200 @@ -970,9 +970,7 @@ * @param bindName null or name to bind to second argument (property not found method.) * * @return value of property as a MethodHandle or null. - * */ - @SuppressWarnings("static-method") protected MethodHandle getCallMethodHandle(final FindProperty find, final MethodType type, final String bindName) { return getCallMethodHandle(getObjectValue(find), type, bindName); } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java --- a/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java Tue May 07 14:36:57 2013 +0200 @@ -57,7 +57,6 @@ * Is this a reverse order iteration? * @return true if reverse */ - @SuppressWarnings("static-method") public boolean isReverse() { return false; } diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java --- a/src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java Tue May 07 14:36:57 2013 +0200 @@ -275,7 +275,6 @@ } static class ProfileDumper implements Runnable { - @SuppressWarnings("resource") @Override public void run() { PrintWriter out = null; @@ -447,7 +446,7 @@ * * @throws Throwable if invocation fails or throws exception/error */ - @SuppressWarnings({"unused", "resource"}) + @SuppressWarnings("unused") public Object traceObject(final MethodHandle mh, final Object... args) throws Throwable { final PrintWriter out = Context.getCurrentErr(); tracePrint(out, "ENTER ", args, null); @@ -465,7 +464,7 @@ * * @throws Throwable if invocation fails or throws exception/error */ - @SuppressWarnings({"unused", "resource"}) + @SuppressWarnings("unused") public void traceVoid(final MethodHandle mh, final Object... args) throws Throwable { final PrintWriter out = Context.getCurrentErr(); tracePrint(out, "ENTER ", args, null); diff -r f3dcb12c8439 -r 544e17632e96 src/jdk/nashorn/tools/Shell.java --- a/src/jdk/nashorn/tools/Shell.java Fri May 03 22:50:51 2013 +0200 +++ b/src/jdk/nashorn/tools/Shell.java Tue May 07 14:36:57 2013 +0200 @@ -392,7 +392,6 @@ * @param global global scope object to use * @return return code */ - @SuppressWarnings("resource") private static int readEvalPrint(final Context context, final ScriptObject global) { final String prompt = bundle.getString("shell.prompt"); final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));