changeset 19483:625633886e25

Reduce number of fields in BytecodeParser.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 18 Feb 2015 18:36:11 +0100
parents 63965fcb019b
children 13d2019e24f1
files graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java
diffstat 1 files changed, 12 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Wed Feb 18 18:23:05 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Wed Feb 18 18:36:11 2015 +0100
@@ -173,7 +173,7 @@
 
         public class BytecodeParser extends AbstractBytecodeParser<ValueNode, HIRFrameStateBuilder> implements GraphBuilderContext {
 
-            private BciBlock[] loopHeaders;
+            private BciBlockMapping blockMap;
             private LocalLiveness liveness;
             protected final int entryBCI;
             private int currentDepth;
@@ -183,8 +183,6 @@
             private int currentLineNumber;
 
             private ValueNode methodSynchronizedObject;
-            private ExceptionDispatchBlock unwindBlock;
-            private BciBlock returnBlock;
 
             private ValueNode returnValue;
             private FixedWithNextNode beforeReturnNode;
@@ -195,7 +193,6 @@
             private final boolean explodeLoops;
             private Stack<ExplodedLoopContext> explodeLoopsContext;
             private int nextPeelIteration = 1;
-            private int returnCount;
             private boolean controlFlowSplit;
 
             /**
@@ -247,8 +244,7 @@
                 try (Indent indent = Debug.logAndIndent("build graph for %s", method)) {
 
                     // compute the block map, setup exception handlers and get the entrypoint(s)
-                    BciBlockMapping blockMap = BciBlockMapping.create(stream, method);
-                    loopHeaders = blockMap.getLoopHeaders();
+                    this.blockMap = BciBlockMapping.create(stream, method);
 
                     if (graphBuilderConfig.doLivenessAnalysis()) {
                         try (Scope s = Debug.scope("LivenessAnalysis")) {
@@ -258,7 +254,6 @@
                             throw Debug.handle(e);
                         }
                     }
-                    returnCount = blockMap.getReturnCount();
 
                     lastInstr = startInstruction;
                     this.setCurrentFrameState(startFrameState);
@@ -299,8 +294,6 @@
 
                     int index = 0;
                     BciBlock[] blocks = blockMap.getBlocks();
-                    this.returnBlock = blockMap.getReturnBlock();
-                    this.unwindBlock = blockMap.getUnwindBlock();
                     while (index < blocks.length) {
                         BciBlock block = blocks[index];
                         index = iterateBlock(blocks, block);
@@ -354,14 +347,6 @@
                 return header.loopEnd + 1;
             }
 
-            private BciBlock returnBlock() {
-                return returnBlock;
-            }
-
-            private BciBlock unwindBlock() {
-                return unwindBlock;
-            }
-
             /**
              * @param type the unresolved type of the constant
              */
@@ -477,7 +462,7 @@
                  * unwind immediately.
                  */
                 if (bci != currentBlock.endBci || dispatchBlock == null) {
-                    dispatchBlock = unwindBlock();
+                    dispatchBlock = blockMap.getUnwindBlock();
                 }
 
                 HIRFrameStateBuilder dispatchState = frameState.copy();
@@ -1012,8 +997,9 @@
                     beforeReturn(x);
                     append(new ReturnNode(x));
                 } else {
-                    if (returnCount == 1 || !controlFlowSplit) {
+                    if (blockMap.getReturnCount() == 1 || !controlFlowSplit) {
                         // There is only a single return.
+                        beforeReturn(x);
                         this.returnValue = x;
                         this.beforeReturnNode = this.lastInstr;
                         this.lastInstr = null;
@@ -1023,8 +1009,8 @@
                         if (x != null) {
                             frameState.push(x.getKind(), x);
                         }
-                        assert returnCount > 1;
-                        appendGoto(returnBlock());
+                        assert blockMap.getReturnCount() > 1;
+                        appendGoto(blockMap.getReturnBlock());
                     }
                 }
             }
@@ -1184,7 +1170,7 @@
                         do {
                             long lMask = 1L << pos;
                             if ((exits & lMask) != 0) {
-                                exitLoops.add(loopHeaders[pos]);
+                                exitLoops.add(blockMap.getLoopHeader(pos));
                                 exits &= ~lMask;
                             }
                             pos++;
@@ -1429,14 +1415,14 @@
                         }
                     }
 
-                    if (block == returnBlock) {
+                    if (block == blockMap.getReturnBlock()) {
                         Kind returnKind = method.getSignature().getReturnKind().getStackKind();
                         ValueNode x = returnKind == Kind.Void ? null : frameState.pop(returnKind);
                         assert frameState.stackSize() == 0;
                         beforeReturn(x);
                         this.returnValue = x;
                         this.beforeReturnNode = this.lastInstr;
-                    } else if (block == unwindBlock) {
+                    } else if (block == blockMap.getUnwindBlock()) {
                         if (currentDepth == 0) {
                             frameState.setRethrowException(false);
                             createUnwind();
@@ -1513,7 +1499,7 @@
                     ResolvedJavaType resolvedCatchType = (ResolvedJavaType) catchType;
                     for (ResolvedJavaType skippedType : graphBuilderConfig.getSkippedExceptionTypes()) {
                         if (skippedType.isAssignableFrom(resolvedCatchType)) {
-                            BciBlock nextBlock = block.getSuccessorCount() == 1 ? unwindBlock() : block.getSuccessor(1);
+                            BciBlock nextBlock = block.getSuccessorCount() == 1 ? blockMap.getUnwindBlock() : block.getSuccessor(1);
                             ValueNode exception = frameState.stackAt(0);
                             FixedNode trueSuccessor = currentGraph.add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode));
                             FixedNode nextDispatch = createTarget(nextBlock, frameState);
@@ -1524,7 +1510,7 @@
                 }
 
                 if (initialized) {
-                    BciBlock nextBlock = block.getSuccessorCount() == 1 ? unwindBlock() : block.getSuccessor(1);
+                    BciBlock nextBlock = block.getSuccessorCount() == 1 ? blockMap.getUnwindBlock() : block.getSuccessor(1);
                     ValueNode exception = frameState.stackAt(0);
                     CheckCastNode checkCast = currentGraph.add(new CheckCastNode((ResolvedJavaType) catchType, exception, null, false));
                     frameState.apop();