changeset 11667:8e1e41cd2c75

Common out code for frame state constructors.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 16 Sep 2013 19:53:27 +0200
parents 3967f9f306f8
children 05230c6c8d52
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java
diffstat 1 files changed, 11 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Mon Sep 16 15:35:14 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Mon Sep 16 19:53:27 2013 +0200
@@ -103,7 +103,6 @@
     public FrameState(ResolvedJavaMethod method, int bci, List<ValueNode> values, int localsSize, int stackSize, boolean rethrowException, boolean duringCall,
                     List<EscapeObjectState> virtualObjectMappings) {
         assert stackSize >= 0;
-        assert (bci >= 0 && method != null) || (bci < 0 && method == null && values.isEmpty());
         this.method = method;
         this.bci = bci;
         this.localsSize = localsSize;
@@ -125,29 +124,24 @@
     }
 
     public FrameState(ResolvedJavaMethod method, int bci, ValueNode[] locals, List<ValueNode> stack, ValueNode[] locks, boolean rethrowException, boolean duringCall) {
-        this.method = method;
-        this.bci = bci;
-        this.localsSize = locals.length;
-        this.stackSize = stack.size();
-        final ValueNode[] newValues = new ValueNode[locals.length + stack.size() + locks.length];
-        int pos = 0;
+        this(method, bci, createValues(locals, stack, locks), locals.length, stack.size(), rethrowException, duringCall, Collections.<EscapeObjectState> emptyList());
+    }
+
+    private static List<ValueNode> createValues(ValueNode[] locals, List<ValueNode> stack, ValueNode[] locks) {
+        List<ValueNode> newValues = new ArrayList<>(locals.length + stack.size() + locks.length);
         for (ValueNode value : locals) {
-            newValues[pos++] = value;
+            newValues.add(value);
+            assert value == null || value.isAlive();
         }
         for (ValueNode value : stack) {
-            newValues[pos++] = value;
+            newValues.add(value);
+            assert value == null || value.isAlive();
         }
         for (ValueNode value : locks) {
-            newValues[pos++] = value;
-        }
-        for (ValueNode value : newValues) {
+            newValues.add(value);
             assert value == null || value.isAlive();
         }
-        this.values = new NodeInputList<>(this, newValues);
-        this.virtualObjectMappings = new NodeInputList<>(this);
-        this.rethrowException = rethrowException;
-        this.duringCall = duringCall;
-        assert !rethrowException || stackSize == 1 : "must have exception on top of the stack";
+        return newValues;
     }
 
     public NodeInputList<ValueNode> values() {