Mercurial > hg > truffle
changeset 20019:fa9d90e73569
check whether a StateSplit node being added via GraphBuilderContext has a null stateAfter before setting one
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 24 Mar 2015 11:56:10 +0100 |
parents | 3cbb0846337c |
children | af1e4c16b00f |
files | graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/GraphBuilderContext.java graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java |
diffstat | 2 files changed, 24 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/GraphBuilderContext.java Tue Mar 24 11:36:52 2015 +0100 +++ b/graal/com.oracle.graal.graphbuilderconf/src/com/oracle/graal/graphbuilderconf/GraphBuilderContext.java Tue Mar 24 11:56:10 2015 +0100 @@ -85,49 +85,55 @@ void push(Kind kind, ValueNode value); /** - * Appends a node with a void kind to the graph. If the node is a {@link StateSplit}, then its - * {@linkplain StateSplit#stateAfter() frame state} is also set. + * Appends a node with a void kind to the graph. If the returned node is a {@link StateSplit}, + * with a null {@linkplain StateSplit#stateAfter() frame state}, the frame state is initialized. + * + * @param value the value to add to the graph and push to the stack. The {@code value.getKind()} + * kind is used when type checking this operation. + * @return a node equivalent to {@code value} in the graph */ default <T extends ValueNode> T add(T value) { assert value.getKind() == Kind.Void; T appended = append(value); if (appended instanceof StateSplit) { StateSplit stateSplit = (StateSplit) appended; - assert stateSplit.stateAfter() == null; - stateSplit.setStateAfter(createStateAfter()); + if (stateSplit.stateAfter() == null) { + stateSplit.setStateAfter(createStateAfter()); + } } return appended; } /** - * Adds a node with a non-void kind to the graph, pushes it to the stack. If the node is a - * {@link StateSplit}, then its {@linkplain StateSplit#stateAfter() frame state} is also set. + * Adds a node with a non-void kind to the graph, pushes it to the stack. If the returned node + * is a {@link StateSplit}, with a null {@linkplain StateSplit#stateAfter() frame state}, the + * frame state is initialized. * - * @param value the value to push to the stack. The value must already have been - * {@linkplain #append(ValueNode) appended}. The {@code value.getKind()} kind is used - * when type checking this operation. - * @return the version of {@code value} in the graph which may be different than {@code value} + * @param value the value to add to the graph and push to the stack. The {@code value.getKind()} + * kind is used when type checking this operation. + * @return a node equivalent to {@code value} in the graph */ default <T extends ValueNode> T addPush(T value) { return addPush(value.getKind().getStackKind(), value); } /** - * Adds a node with a non-void kind to the graph, pushes it to the stack. If the node is a - * {@link StateSplit}, then its {@linkplain StateSplit#stateAfter() frame state} is also set. + * Adds a node with a non-void kind to the graph, pushes it to the stack. If the returned node + * is a {@link StateSplit}, with a null {@linkplain StateSplit#stateAfter() frame state}, the + * frame state is initialized. * * @param kind the kind to use when type checking this operation - * @param value the value to push to the stack. The value must already have been - * {@linkplain #append(ValueNode) appended}. - * @return the version of {@code value} in the graph which may be different than {@code value} + * @param value the value to add to the graph and push to the stack + * @return a node equivalent to {@code value} in the graph */ default <T extends ValueNode> T addPush(Kind kind, T value) { T appended = append(value); push(kind, appended); if (appended instanceof StateSplit) { StateSplit stateSplit = (StateSplit) appended; - assert stateSplit.stateAfter() == null; - stateSplit.setStateAfter(createStateAfter()); + if (stateSplit.stateAfter() == null) { + stateSplit.setStateAfter(createStateAfter()); + } } return appended; }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue Mar 24 11:36:52 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Tue Mar 24 11:56:10 2015 +0100 @@ -2413,6 +2413,7 @@ } public void push(Kind kind, ValueNode value) { + assert value.isAlive(); assert kind == kind.getStackKind(); frameState.push(kind, value); }