Java Code Examples for jdk.nashorn.internal.ir.Statement#isTerminal()
The following examples show how to use
jdk.nashorn.internal.ir.Statement#isTerminal() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Lower.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void addStatementEnclosedInBlock(final Statement stmt) { BlockStatement b = BlockStatement.createReplacement(stmt, Collections.<Statement>singletonList(stmt)); if(stmt.isTerminal()) { b = b.setBlock(b.getBlock().setIsTerminal(null, true)); } addStatement(b); }
Example 2
Source File: Lower.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void addStatementEnclosedInBlock(final Statement stmt) { BlockStatement b = BlockStatement.createReplacement(stmt, Collections.<Statement>singletonList(stmt)); if(stmt.isTerminal()) { b = b.setBlock(b.getBlock().setIsTerminal(null, true)); } addStatement(b); }
Example 3
Source File: Splitter.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * Split a block into sub methods. * * @param block Block or function to split. * * @return new weight for the resulting block. */ private Block splitBlock(final Block block, final FunctionNode function) { final List<Statement> splits = new ArrayList<>(); List<Statement> statements = new ArrayList<>(); long statementsWeight = 0; for (final Statement statement : block.getStatements()) { final long weight = WeighNodes.weigh(statement, weightCache); if (statementsWeight + weight >= SPLIT_THRESHOLD || statement.isTerminal()) { if (!statements.isEmpty()) { splits.add(createBlockSplitNode(block, function, statements, statementsWeight)); statements = new ArrayList<>(); statementsWeight = 0; } } if (statement.isTerminal()) { splits.add(statement); } else { statements.add(statement); statementsWeight += weight; } } if (!statements.isEmpty()) { splits.add(createBlockSplitNode(block, function, statements, statementsWeight)); } return block.setStatements(lc, splits); }
Example 4
Source File: Lower.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void addStatementEnclosedInBlock(final Statement stmt) { BlockStatement b = BlockStatement.createReplacement(stmt, Collections.<Statement>singletonList(stmt)); if(stmt.isTerminal()) { b = b.setBlock(b.getBlock().setIsTerminal(null, true)); } addStatement(b); }
Example 5
Source File: Splitter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Split a block into sub methods. * * @param block Block or function to split. * * @return new weight for the resulting block. */ private Block splitBlock(final Block block, final FunctionNode function) { final List<Statement> splits = new ArrayList<>(); List<Statement> statements = new ArrayList<>(); long statementsWeight = 0; for (final Statement statement : block.getStatements()) { final long weight = WeighNodes.weigh(statement, weightCache); if (statementsWeight + weight >= SPLIT_THRESHOLD || statement.isTerminal()) { if (!statements.isEmpty()) { splits.add(createBlockSplitNode(block, function, statements, statementsWeight)); statements = new ArrayList<>(); statementsWeight = 0; } } if (statement.isTerminal()) { splits.add(statement); } else { statements.add(statement); statementsWeight += weight; } } if (!statements.isEmpty()) { splits.add(createBlockSplitNode(block, function, statements, statementsWeight)); } return block.setStatements(lc, splits); }
Example 6
Source File: Lower.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void addStatementEnclosedInBlock(final Statement stmt) { BlockStatement b = BlockStatement.createReplacement(stmt, Collections.<Statement>singletonList(stmt)); if(stmt.isTerminal()) { b = b.setBlock(b.getBlock().setIsTerminal(null, true)); } addStatement(b); }
Example 7
Source File: Lower.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void addStatementEnclosedInBlock(final Statement stmt) { BlockStatement b = BlockStatement.createReplacement(stmt, Collections.<Statement>singletonList(stmt)); if(stmt.isTerminal()) { b = b.setBlock(b.getBlock().setIsTerminal(null, true)); } addStatement(b); }
Example 8
Source File: Splitter.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * Split a block into sub methods. * * @param block Block or function to split. * * @return new weight for the resulting block. */ private Block splitBlock(final Block block, final FunctionNode function) { final List<Statement> splits = new ArrayList<>(); List<Statement> statements = new ArrayList<>(); long statementsWeight = 0; for (final Statement statement : block.getStatements()) { final long weight = WeighNodes.weigh(statement, weightCache); if (statementsWeight + weight >= SPLIT_THRESHOLD || statement.isTerminal()) { if (!statements.isEmpty()) { splits.add(createBlockSplitNode(block, function, statements, statementsWeight)); statements = new ArrayList<>(); statementsWeight = 0; } } if (statement.isTerminal()) { splits.add(statement); } else { statements.add(statement); statementsWeight += weight; } } if (!statements.isEmpty()) { splits.add(createBlockSplitNode(block, function, statements, statementsWeight)); } return block.setStatements(lc, splits); }
Example 9
Source File: Lower.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
/** * Constructor. */ Lower(final Compiler compiler) { super(new BlockLexicalContext() { @Override public List<Statement> popStatements() { final List<Statement> newStatements = new ArrayList<>(); boolean terminated = false; final List<Statement> statements = super.popStatements(); for (final Statement statement : statements) { if (!terminated) { newStatements.add(statement); if (statement.isTerminal() || statement instanceof JumpStatement) { //TODO hasGoto? But some Loops are hasGoto too - why? terminated = true; } } else { FoldConstants.extractVarNodesFromDeadCode(statement, newStatements); } } return newStatements; } @Override protected Block afterSetStatements(final Block block) { final List<Statement> stmts = block.getStatements(); for(final ListIterator<Statement> li = stmts.listIterator(stmts.size()); li.hasPrevious();) { final Statement stmt = li.previous(); // popStatements() guarantees that the only thing after a terminal statement are uninitialized // VarNodes. We skip past those, and set the terminal state of the block to the value of the // terminal state of the first statement that is not an uninitialized VarNode. if(!(stmt instanceof VarNode && ((VarNode)stmt).getInit() == null)) { return block.setIsTerminal(this, stmt.isTerminal()); } } return block.setIsTerminal(this, false); } }); this.log = initLogger(compiler.getContext()); }
Example 10
Source File: PrintVisitor.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); int lastIndex = sb.length() - 1; char lastChar = sb.charAt(lastIndex); while (Character.isWhitespace(lastChar) && lastIndex >= 0) { lastChar = sb.charAt(--lastIndex); } if (lastChar != '}' && lastChar != ';') { sb.append(';'); } if (statement.hasGoto()) { sb.append(" [GOTO]"); } if (statement.isTerminal()) { sb.append(" [TERMINAL]"); } } indent -= TABWIDTH; sb.append(EOLN); indent(); sb.append('}'); printLocalVariableConversion(block); return false; }
Example 11
Source File: Lower.java From nashorn with GNU General Public License v2.0 | 4 votes |
/** * Constructor. */ Lower() { super(new BlockLexicalContext() { @Override public List<Statement> popStatements() { final List<Statement> newStatements = new ArrayList<>(); boolean terminated = false; final List<Statement> statements = super.popStatements(); for (final Statement statement : statements) { if (!terminated) { newStatements.add(statement); if (statement.isTerminal() || statement instanceof BreakNode || statement instanceof ContinueNode) { //TODO hasGoto? But some Loops are hasGoto too - why? terminated = true; } } else { statement.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { @Override public boolean enterVarNode(final VarNode varNode) { newStatements.add(varNode.setInit(null)); return false; } }); } } return newStatements; } @Override protected Block afterSetStatements(final Block block) { final List<Statement> stmts = block.getStatements(); for(final ListIterator<Statement> li = stmts.listIterator(stmts.size()); li.hasPrevious();) { final Statement stmt = li.previous(); // popStatements() guarantees that the only thing after a terminal statement are uninitialized // VarNodes. We skip past those, and set the terminal state of the block to the value of the // terminal state of the first statement that is not an uninitialized VarNode. if(!(stmt instanceof VarNode && ((VarNode)stmt).getInit() == null)) { return block.setIsTerminal(this, stmt.isTerminal()); } } return block.setIsTerminal(this, false); } }); }
Example 12
Source File: PrintVisitor.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); int lastIndex = sb.length() - 1; char lastChar = sb.charAt(lastIndex); while (Character.isWhitespace(lastChar) && lastIndex >= 0) { lastChar = sb.charAt(--lastIndex); } if (lastChar != '}' && lastChar != ';') { sb.append(';'); } if (statement.hasGoto()) { sb.append(" [GOTO]"); } if (statement.isTerminal()) { sb.append(" [TERMINAL]"); } } indent -= TABWIDTH; sb.append(EOLN); indent(); sb.append('}'); printLocalVariableConversion(block); return false; }
Example 13
Source File: Lower.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Constructor. */ Lower(final Compiler compiler) { super(new BlockLexicalContext() { @Override public List<Statement> popStatements() { final List<Statement> newStatements = new ArrayList<>(); boolean terminated = false; final List<Statement> statements = super.popStatements(); for (final Statement statement : statements) { if (!terminated) { newStatements.add(statement); if (statement.isTerminal() || statement instanceof JumpStatement) { //TODO hasGoto? But some Loops are hasGoto too - why? terminated = true; } } else { FoldConstants.extractVarNodesFromDeadCode(statement, newStatements); } } return newStatements; } @Override protected Block afterSetStatements(final Block block) { final List<Statement> stmts = block.getStatements(); for(final ListIterator<Statement> li = stmts.listIterator(stmts.size()); li.hasPrevious();) { final Statement stmt = li.previous(); // popStatements() guarantees that the only thing after a terminal statement are uninitialized // VarNodes. We skip past those, and set the terminal state of the block to the value of the // terminal state of the first statement that is not an uninitialized VarNode. if(!(stmt instanceof VarNode && ((VarNode)stmt).getInit() == null)) { return block.setIsTerminal(this, stmt.isTerminal()); } } return block.setIsTerminal(this, false); } }); this.log = initLogger(compiler.getContext()); }
Example 14
Source File: PrintVisitor.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); int lastIndex = sb.length() - 1; char lastChar = sb.charAt(lastIndex); while (Character.isWhitespace(lastChar) && lastIndex >= 0) { lastChar = sb.charAt(--lastIndex); } if (lastChar != '}' && lastChar != ';') { sb.append(';'); } if (statement.hasGoto()) { sb.append(" [GOTO]"); } if (statement.isTerminal()) { sb.append(" [TERMINAL]"); } } indent -= TABWIDTH; sb.append(EOLN); indent(); sb.append('}'); printLocalVariableConversion(block); return false; }
Example 15
Source File: Lower.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Constructor. */ Lower(final CodeInstaller<?> installer) { super(new BlockLexicalContext() { @Override public List<Statement> popStatements() { final List<Statement> newStatements = new ArrayList<>(); boolean terminated = false; final List<Statement> statements = super.popStatements(); for (final Statement statement : statements) { if (!terminated) { newStatements.add(statement); if (statement.isTerminal() || statement instanceof BreakNode || statement instanceof ContinueNode) { //TODO hasGoto? But some Loops are hasGoto too - why? terminated = true; } } else { statement.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { @Override public boolean enterVarNode(final VarNode varNode) { newStatements.add(varNode.setInit(null)); return false; } }); } } return newStatements; } @Override protected Block afterSetStatements(final Block block) { final List<Statement> stmts = block.getStatements(); for(final ListIterator<Statement> li = stmts.listIterator(stmts.size()); li.hasPrevious();) { final Statement stmt = li.previous(); // popStatements() guarantees that the only thing after a terminal statement are uninitialized // VarNodes. We skip past those, and set the terminal state of the block to the value of the // terminal state of the first statement that is not an uninitialized VarNode. if(!(stmt instanceof VarNode && ((VarNode)stmt).getInit() == null)) { return block.setIsTerminal(this, stmt.isTerminal()); } } return block.setIsTerminal(this, false); } }); this.installer = installer; }
Example 16
Source File: PrintVisitor.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); int lastIndex = sb.length() - 1; char lastChar = sb.charAt(lastIndex); while (Character.isWhitespace(lastChar) && lastIndex >= 0) { lastChar = sb.charAt(--lastIndex); } if (lastChar != '}' && lastChar != ';') { sb.append(';'); } if (statement.hasGoto()) { sb.append(" [GOTO]"); } if (statement.isTerminal()) { sb.append(" [TERMINAL]"); } } indent -= TABWIDTH; sb.append(EOLN); indent(); sb.append('}'); printLocalVariableConversion(block); return false; }
Example 17
Source File: PrintVisitor.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); int lastIndex = sb.length() - 1; char lastChar = sb.charAt(lastIndex); while (Character.isWhitespace(lastChar) && lastIndex >= 0) { lastChar = sb.charAt(--lastIndex); } if (lastChar != '}' && lastChar != ';') { sb.append(';'); } if (statement.hasGoto()) { sb.append(" [GOTO]"); } if (statement.isTerminal()) { sb.append(" [TERMINAL]"); } } indent -= TABWIDTH; sb.append(EOLN); indent(); sb.append('}'); printLocalVariableConversion(block); return false; }
Example 18
Source File: Lower.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Constructor. */ Lower(final Compiler compiler) { super(new BlockLexicalContext() { @Override public List<Statement> popStatements() { final List<Statement> newStatements = new ArrayList<>(); boolean terminated = false; final List<Statement> statements = super.popStatements(); for (final Statement statement : statements) { if (!terminated) { newStatements.add(statement); if (statement.isTerminal() || statement instanceof JumpStatement) { //TODO hasGoto? But some Loops are hasGoto too - why? terminated = true; } } else { statement.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { @Override public boolean enterVarNode(final VarNode varNode) { newStatements.add(varNode.setInit(null)); return false; } }); } } return newStatements; } @Override protected Block afterSetStatements(final Block block) { final List<Statement> stmts = block.getStatements(); for(final ListIterator<Statement> li = stmts.listIterator(stmts.size()); li.hasPrevious();) { final Statement stmt = li.previous(); // popStatements() guarantees that the only thing after a terminal statement are uninitialized // VarNodes. We skip past those, and set the terminal state of the block to the value of the // terminal state of the first statement that is not an uninitialized VarNode. if(!(stmt instanceof VarNode && ((VarNode)stmt).getInit() == null)) { return block.setIsTerminal(this, stmt.isTerminal()); } } return block.setIsTerminal(this, false); } }); this.log = initLogger(compiler.getContext()); }
Example 19
Source File: PrintVisitor.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
@Override public boolean enterBlock(final Block block) { sb.append(' '); sb.append('{'); indent += TABWIDTH; final List<Statement> statements = block.getStatements(); for (final Statement statement : statements) { if (printLineNumbers) { final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); sb.append("[|").append(lineNumber).append("|];").append('\n'); } lastLineNumber = lineNumber; } indent(); statement.accept(this); int lastIndex = sb.length() - 1; char lastChar = sb.charAt(lastIndex); while (Character.isWhitespace(lastChar) && lastIndex >= 0) { lastChar = sb.charAt(--lastIndex); } if (lastChar != '}' && lastChar != ';') { sb.append(';'); } if (statement.hasGoto()) { sb.append(" [GOTO]"); } if (statement.isTerminal()) { sb.append(" [TERMINAL]"); } } indent -= TABWIDTH; sb.append(EOLN); indent(); sb.append('}'); printLocalVariableConversion(block); return false; }
Example 20
Source File: Lower.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Constructor. */ Lower(final Compiler compiler) { super(new BlockLexicalContext() { @Override public List<Statement> popStatements() { final List<Statement> newStatements = new ArrayList<>(); boolean terminated = false; final List<Statement> statements = super.popStatements(); for (final Statement statement : statements) { if (!terminated) { newStatements.add(statement); if (statement.isTerminal() || statement instanceof JumpStatement) { //TODO hasGoto? But some Loops are hasGoto too - why? terminated = true; } } else { FoldConstants.extractVarNodesFromDeadCode(statement, newStatements); } } return newStatements; } @Override protected Block afterSetStatements(final Block block) { final List<Statement> stmts = block.getStatements(); for(final ListIterator<Statement> li = stmts.listIterator(stmts.size()); li.hasPrevious();) { final Statement stmt = li.previous(); // popStatements() guarantees that the only thing after a terminal statement are uninitialized // VarNodes. We skip past those, and set the terminal state of the block to the value of the // terminal state of the first statement that is not an uninitialized VarNode. if(!(stmt instanceof VarNode && ((VarNode)stmt).getInit() == null)) { return block.setIsTerminal(this, stmt.isTerminal()); } } return block.setIsTerminal(this, false); } }); this.log = initLogger(compiler.getContext()); }