changeset 470:f74faac51bfb

8021244: Inconsistent stackmap with splitter threshold set very low Reviewed-by: sundar, lagergren
author hannesw
date Thu, 25 Jul 2013 11:56:12 +0200
parents 5c035c4ccc61
children f22ca0f9b6ee
files src/jdk/nashorn/internal/codegen/Lower.java src/jdk/nashorn/internal/ir/Block.java
diffstat 2 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/codegen/Lower.java	Thu Jul 25 14:05:03 2013 +0530
+++ b/src/jdk/nashorn/internal/codegen/Lower.java	Thu Jul 25 11:56:12 2013 +0200
@@ -88,8 +88,6 @@
 
     /**
      * Constructor.
-     *
-     * @param compiler the compiler
      */
     Lower() {
         super(new BlockLexicalContext() {
@@ -307,8 +305,8 @@
 
         final IdentNode exception = new IdentNode(token, finish, lc.getCurrentFunction().uniqueName("catch_all"));
 
-        final Block catchBody = new Block(token, finish, new ThrowNode(lineNumber, token, finish, new IdentNode(exception), ThrowNode.IS_SYNTHETIC_RETHROW)).
-                setIsTerminal(lc, true); //ends with throw, so terminal
+        final Block catchBody = new Block(token, finish, new ThrowNode(lineNumber, token, finish, new IdentNode(exception), ThrowNode.IS_SYNTHETIC_RETHROW));
+        assert catchBody.isTerminal(); //ends with throw, so terminal
 
         final CatchNode catchAllNode  = new CatchNode(lineNumber, token, finish, new IdentNode(exception), null, catchBody, CatchNode.IS_SYNTHETIC_RETHROW);
         final Block     catchAllBlock = new Block(token, finish, catchAllNode);
@@ -330,13 +328,12 @@
     /**
      * Splice finally code into all endpoints of a trynode
      * @param tryNode the try node
-     * @param list of rethrowing throw nodes from synthetic catch blocks
+     * @param rethrows list of rethrowing throw nodes from synthetic catch blocks
      * @param finallyBody the code in the original finally block
      * @return new try node after splicing finally code (same if nop)
      */
     private Node spliceFinally(final TryNode tryNode, final List<ThrowNode> rethrows, final Block finallyBody) {
         assert tryNode.getFinallyBody() == null;
-        final int            finish = tryNode.getFinish();
 
         final TryNode newTryNode = (TryNode)tryNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
             final List<Node> insideTry = new ArrayList<>();
@@ -404,7 +401,7 @@
                     if (!isTerminal(newStatements)) {
                         newStatements.add(endpoint);
                     }
-                    return BlockStatement.createReplacement(endpoint, finish, newStatements);
+                    return BlockStatement.createReplacement(endpoint, tryNode.getFinish(), newStatements);
                 }
                 return endpoint;
             }
@@ -466,7 +463,7 @@
         if (tryNode.getCatchBlocks().isEmpty()) {
             newTryNode = tryNode.setFinallyBody(null);
         } else {
-            Block outerBody = new Block(tryNode.getToken(), tryNode.getFinish(), new ArrayList<Statement>(Arrays.asList(tryNode.setFinallyBody(null))));
+            Block outerBody = new Block(tryNode.getToken(), tryNode.getFinish(), tryNode.setFinallyBody(null));
             newTryNode = tryNode.setBody(outerBody).setCatchBlocks(null);
         }
 
--- a/src/jdk/nashorn/internal/ir/Block.java	Thu Jul 25 14:05:03 2013 +0530
+++ b/src/jdk/nashorn/internal/ir/Block.java	Thu Jul 25 11:56:12 2013 +0200
@@ -93,7 +93,8 @@
         this.symbols    = new LinkedHashMap<>();
         this.entryLabel = new Label("block_entry");
         this.breakLabel = new Label("block_break");
-        this.flags     =  0;
+        final int len = statements.length;
+        this.flags = (len > 0 && statements[len - 1].hasTerminalFlags()) ? IS_TERMINAL : 0;
     }
 
     /**