Mercurial > hg > graal-compiler
changeset 18926:b4633ae1b31b
Make allocation of virtual object mapping lazy.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 22 Jan 2015 21:14:53 +0100 |
parents | 14599c77560a |
children | 8da21b779982 |
files | graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java |
diffstat | 2 files changed, 38 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Thu Jan 22 21:01:46 2015 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Thu Jan 22 21:14:53 2015 +0100 @@ -57,10 +57,12 @@ // collect all VirtualObjectField instances: FrameState current = topState; do { - for (EscapeObjectState state : current.virtualObjectMappings()) { - if (!objectStates.containsKey(state.object())) { - if (!(state instanceof MaterializedObjectState) || ((MaterializedObjectState) state).materializedValue() != state.object()) { - objectStates.put(state.object(), state); + if (current.virtualObjectMappingCount() > 0) { + for (EscapeObjectState state : current.virtualObjectMappings()) { + if (!objectStates.containsKey(state.object())) { + if (!(state instanceof MaterializedObjectState) || ((MaterializedObjectState) state).materializedValue() != state.object()) { + objectStates.put(state.object(), state); + } } } }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java Thu Jan 22 21:01:46 2015 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java Thu Jan 22 21:14:53 2015 +0100 @@ -65,7 +65,7 @@ @OptionalInput(InputType.Association) NodeInputList<MonitorIdNode> monitorIds; - @Input(InputType.State) NodeInputList<EscapeObjectState> virtualObjectMappings; + @OptionalInput(InputType.State) NodeInputList<EscapeObjectState> virtualObjectMappings; /** * The bytecode index to which this frame state applies. @@ -86,7 +86,9 @@ if (monitorIds != null && monitorIds.length > 0) { this.monitorIds = new NodeInputList<>(this, monitorIds); } - this.virtualObjectMappings = new NodeInputList<>(this, virtualObjectMappings); + if (virtualObjectMappings != null && virtualObjectMappings.size() > 0) { + this.virtualObjectMappings = new NodeInputList<>(this, virtualObjectMappings); + } this.rethrowException = rethrowException; this.duringCall = duringCall; assert !this.rethrowException || this.stackSize == 1 : "must have exception on top of the stack"; @@ -151,10 +153,16 @@ } public void addVirtualObjectMapping(EscapeObjectState virtualObject) { + if (virtualObjectMappings == null) { + virtualObjectMappings = new NodeInputList<>(this); + } virtualObjectMappings.add(virtualObject); } public int virtualObjectMappingCount() { + if (virtualObjectMappings == null) { + return 0; + } return virtualObjectMappings.size(); } @@ -190,9 +198,12 @@ if (newOuterFrameState != null) { newOuterFrameState = newOuterFrameState.duplicateWithVirtualState(); } - ArrayList<EscapeObjectState> newVirtualMappings = new ArrayList<>(virtualObjectMappings.size()); - for (EscapeObjectState state : virtualObjectMappings) { - newVirtualMappings.add(state.duplicateWithVirtualState()); + ArrayList<EscapeObjectState> newVirtualMappings = null; + if (virtualObjectMappings != null) { + newVirtualMappings = new ArrayList<>(virtualObjectMappings.size()); + for (EscapeObjectState state : virtualObjectMappings) { + newVirtualMappings.add(state.duplicateWithVirtualState()); + } } return graph().add(new FrameState(newOuterFrameState, method, bci, values, localsSize, stackSize, rethrowException, duringCall, duplicateMonitorIds(), newVirtualMappings)); } @@ -434,6 +445,7 @@ for (ValueNode value : values.nonNull()) { closure.apply(this, value); } + if (monitorIds != null) { for (MonitorIdNode monitorId : monitorIds) { if (monitorId != null) { @@ -441,9 +453,13 @@ } } } - for (EscapeObjectState state : virtualObjectMappings) { - state.applyToNonVirtual(closure); + + if (virtualObjectMappings != null) { + for (EscapeObjectState state : virtualObjectMappings) { + state.applyToNonVirtual(closure); + } } + if (outerFrameState() != null) { outerFrameState().applyToNonVirtual(closure); } @@ -452,8 +468,10 @@ @Override public void applyToVirtual(VirtualClosure closure) { closure.apply(this); - for (EscapeObjectState state : virtualObjectMappings) { - state.applyToVirtual(closure); + if (virtualObjectMappings != null) { + for (EscapeObjectState state : virtualObjectMappings) { + state.applyToVirtual(closure); + } } if (outerFrameState() != null) { outerFrameState().applyToVirtual(closure); @@ -468,9 +486,11 @@ if (outerFrameState() != null && outerFrameState().isPartOfThisState(state)) { return true; } - for (EscapeObjectState objectState : virtualObjectMappings) { - if (objectState.isPartOfThisState(state)) { - return true; + if (virtualObjectMappings != null) { + for (EscapeObjectState objectState : virtualObjectMappings) { + if (objectState.isPartOfThisState(state)) { + return true; + } } } return false;