# HG changeset patch # User Thomas Wuerthinger # Date 1421956906 -3600 # Node ID 14599c77560ac49b9f17db3a15e65da254ffcb1e # Parent 6338dfaf6a443ae476fe4866994ec8fa0ddb12d6 Do not always allocate monitorId NodeInputList. Allow null NodeInputList. diff -r 6338dfaf6a44 -r 14599c77560a graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Edges.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Edges.java Thu Jan 22 18:46:04 2015 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Edges.java Thu Jan 22 21:01:46 2015 +0100 @@ -124,11 +124,13 @@ } while (index < getCount()) { NodeList list = getNodeList(node, index); - int size = list.initialSize; - NodeList newList = type == Edges.Type.Inputs ? new NodeInputList<>(node, size) : new NodeSuccessorList<>(node, size); + if (list != null) { + int size = list.initialSize; + NodeList newList = type == Edges.Type.Inputs ? new NodeInputList<>(node, size) : new NodeSuccessorList<>(node, size); - // replacing with a new list object is the expected behavior! - initializeList(node, index, newList); + // replacing with a new list object is the expected behavior! + initializeList(node, index, newList); + } index++; } } @@ -144,9 +146,11 @@ int index = getDirectCount(); while (index < getCount()) { NodeList list = getNodeList(prototype, index); - int size = list.initialSize; - NodeList newList = type == Edges.Type.Inputs ? new NodeInputList<>(node, size) : new NodeSuccessorList<>(node, size); - initializeList(node, index, newList); + if (list != null) { + int size = list.initialSize; + NodeList newList = type == Edges.Type.Inputs ? new NodeInputList<>(node, size) : new NodeSuccessorList<>(node, size); + initializeList(node, index, newList); + } index++; } } @@ -201,9 +205,10 @@ } while (index < getCount()) { NodeList list = getNodeList(node, index); - assert list != null : this; - if (list.replaceFirst(key, replacement)) { - return true; + if (list != null) { + if (list.replaceFirst(key, replacement)) { + return true; + } } index++; } @@ -256,7 +261,8 @@ } } for (int i = directCount; i < getCount(); i++) { - if (getNodeList(node, i).contains(value)) { + NodeList curList = getNodeList(node, i); + if (curList != null && curList.contains(value)) { return true; } } @@ -277,7 +283,7 @@ } while (index < getCount()) { NodeList list = getNodeList(other, index); - if (!list.equals(getNodeList(node, index))) { + if (!Objects.equals(list, getNodeList(node, index))) { return false; } index++; @@ -329,12 +335,14 @@ if (subIndex == 0) { list = edges.getNodeList(node, index); } - while (subIndex < list.size()) { - nextElement = list.get(subIndex); - if (nextElement != null) { - return; + if (list != null) { + while (subIndex < list.size()) { + nextElement = list.get(subIndex); + if (nextElement != null) { + return; + } + subIndex++; } - subIndex++; } subIndex = 0; index++; @@ -404,9 +412,11 @@ if (subIndex == 0) { list = edges.getNodeList(node, index); } - if (subIndex < list.size()) { - nextElement = list.get(subIndex); - return; + if (list != null) { + if (subIndex < list.size()) { + nextElement = list.get(subIndex); + return; + } } subIndex = 0; index++; diff -r 6338dfaf6a44 -r 14599c77560a graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Thu Jan 22 18:46:04 2015 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Thu Jan 22 21:01:46 2015 +0100 @@ -597,8 +597,9 @@ while (index < edges.getCount()) { NodeList list = edges.getNodeList(node, index); - assert list != null : edges; - edges.initializeList(node, index, updateEdgeListCopy(node, list, duplicationReplacement, edges.type())); + if (list != null) { + edges.initializeList(node, index, updateEdgeListCopy(node, list, duplicationReplacement, edges.type())); + } index++; } } diff -r 6338dfaf6a44 -r 14599c77560a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java Thu Jan 22 18:46:04 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java Thu Jan 22 21:01:46 2015 +0100 @@ -56,8 +56,7 @@ ParameterNode arg0 = g.unique(new ParameterNode(0, StampFactory.forKind(Kind.Object))); ParameterNode arg1 = g.unique(new ParameterNode(1, StampFactory.forKind(Kind.Object))); ParameterNode arg2 = g.unique(new ParameterNode(2, StampFactory.forKind(Kind.Object))); - FrameState frameState = g.add(new FrameState(null, method, 0, Arrays.asList(new ValueNode[]{arg0, arg1, arg2}), 3, 0, false, false, new ArrayList(), - new ArrayList())); + FrameState frameState = g.add(new FrameState(null, method, 0, Arrays.asList(new ValueNode[]{arg0, arg1, arg2}), 3, 0, false, false, null, new ArrayList())); g.start().setStateAfter(frameState); List parameters = new ArrayList<>(); FixedWithNextNode fixedWithNext = getParameters(g, arg0, argumentTypes.length, argumentTypes, parameters, providers); diff -r 6338dfaf6a44 -r 14599c77560a graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Jan 22 18:46:04 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Jan 22 21:01:46 2015 +0100 @@ -157,6 +157,7 @@ private ValueNode methodSynchronizedObject; private ExceptionDispatchBlock unwindBlock; private BciBlock returnBlock; + private ValueNode returnValue; private FixedWithNextNode beforeReturnNode; private ValueNode unwindValue; diff -r 6338dfaf6a44 -r 14599c77560a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java Thu Jan 22 18:46:04 2015 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java Thu Jan 22 21:01:46 2015 +0100 @@ -75,7 +75,7 @@ protected final ResolvedJavaMethod method; public FrameState(FrameState outerFrameState, ResolvedJavaMethod method, int bci, List values, int localsSize, int stackSize, boolean rethrowException, boolean duringCall, - List monitorIds, List virtualObjectMappings) { + MonitorIdNode[] monitorIds, List virtualObjectMappings) { assert stackSize >= 0; this.outerFrameState = outerFrameState; this.method = method; @@ -83,7 +83,9 @@ this.localsSize = localsSize; this.stackSize = stackSize; this.values = new NodeInputList<>(this, values); - this.monitorIds = new NodeInputList<>(this, monitorIds); + if (monitorIds != null && monitorIds.length > 0) { + this.monitorIds = new NodeInputList<>(this, monitorIds); + } this.virtualObjectMappings = new NodeInputList<>(this, virtualObjectMappings); this.rethrowException = rethrowException; this.duringCall = duringCall; @@ -93,15 +95,14 @@ } public FrameState(int bci) { - this(null, null, bci, Collections. emptyList(), 0, 0, false, false, Collections. emptyList(), Collections. emptyList()); + this(null, null, bci, Collections. emptyList(), 0, 0, false, false, null, Collections. emptyList()); assert bci == BytecodeFrame.BEFORE_BCI || bci == BytecodeFrame.AFTER_BCI || bci == BytecodeFrame.AFTER_EXCEPTION_BCI || bci == BytecodeFrame.UNKNOWN_BCI || bci == BytecodeFrame.INVALID_FRAMESTATE_BCI; } public FrameState(FrameState outerFrameState, ResolvedJavaMethod method, int bci, ValueNode[] locals, List stack, ValueNode[] locks, MonitorIdNode[] monitorIds, boolean rethrowException, boolean duringCall) { - this(outerFrameState, method, bci, createValues(locals, stack, locks), locals.length, stack.size(), rethrowException, duringCall, Arrays.asList(monitorIds), - Collections. emptyList()); + this(outerFrameState, method, bci, createValues(locals, stack, locks), locals.length, stack.size(), rethrowException, duringCall, monitorIds, Collections. emptyList()); } private static List createValues(ValueNode[] locals, List stack, ValueNode[] locks) { @@ -125,10 +126,6 @@ return values; } - public NodeInputList monitorIds() { - return monitorIds; - } - public FrameState outerFrameState() { return outerFrameState; } @@ -173,7 +170,7 @@ * Gets a copy of this frame state. */ public FrameState duplicate(int newBci) { - return graph().add(new FrameState(outerFrameState(), method, newBci, values, localsSize, stackSize, rethrowException, duringCall, monitorIds, virtualObjectMappings)); + return graph().add(new FrameState(outerFrameState(), method, newBci, values, localsSize, stackSize, rethrowException, duringCall, duplicateMonitorIds(), virtualObjectMappings)); } /** @@ -197,7 +194,7 @@ for (EscapeObjectState state : virtualObjectMappings) { newVirtualMappings.add(state.duplicateWithVirtualState()); } - return graph().add(new FrameState(newOuterFrameState, method, bci, values, localsSize, stackSize, rethrowException, duringCall, monitorIds, newVirtualMappings)); + return graph().add(new FrameState(newOuterFrameState, method, bci, values, localsSize, stackSize, rethrowException, duringCall, duplicateMonitorIds(), newVirtualMappings)); } /** @@ -248,7 +245,15 @@ copy.addAll(values.subList(localsSize + stackSize, values.size())); assert checkStackDepth(bci, stackSize, duringCall, newBci, newStackSize, newDuringCall); - return graph().add(new FrameState(outerFrameState(), method, newBci, copy, localsSize, newStackSize, newRethrowException, newDuringCall, monitorIds, virtualObjectMappings)); + return graph().add(new FrameState(outerFrameState(), method, newBci, copy, localsSize, newStackSize, newRethrowException, newDuringCall, duplicateMonitorIds(), virtualObjectMappings)); + } + + private MonitorIdNode[] duplicateMonitorIds() { + if (monitorIds == null) { + return null; + } else { + return monitorIds.toArray(new MonitorIdNode[monitorIds.size()]); + } } /** @@ -343,7 +348,7 @@ * Get the MonitorIdNode that corresponds to the locked object at the specified index. */ public MonitorIdNode monitorIdAt(int i) { - assert i >= 0 && i < locksSize(); + assert monitorIds != null && i >= 0 && i < locksSize(); return monitorIds.get(i); } @@ -429,9 +434,11 @@ for (ValueNode value : values.nonNull()) { closure.apply(this, value); } - for (MonitorIdNode monitorId : monitorIds) { - if (monitorId != null) { - closure.apply(this, monitorId); + if (monitorIds != null) { + for (MonitorIdNode monitorId : monitorIds) { + if (monitorId != null) { + closure.apply(this, monitorId); + } } } for (EscapeObjectState state : virtualObjectMappings) {