Mercurial > hg > truffle
comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java @ 13122:c6ab6ae1b360
Allow subclasses of NewInstanceNode and NewArrayNode to provide the default values used by escape analysis
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Fri, 22 Nov 2013 11:55:13 -0800 |
parents | e027a51bdd33 |
children | 1f4c9729c9f0 |
comparison
equal
deleted
inserted
replaced
13121:a4eb86dc383e | 13122:c6ab6ae1b360 |
---|---|
34 | 34 |
35 /** | 35 /** |
36 * The {@code NewInstanceNode} represents the allocation of an instance class object. | 36 * The {@code NewInstanceNode} represents the allocation of an instance class object. |
37 */ | 37 */ |
38 @NodeInfo(nameTemplate = "New {p#instanceClass/s}") | 38 @NodeInfo(nameTemplate = "New {p#instanceClass/s}") |
39 public final class NewInstanceNode extends DeoptimizingFixedWithNextNode implements Canonicalizable, Lowerable, VirtualizableAllocation { | 39 public class NewInstanceNode extends DeoptimizingFixedWithNextNode implements Canonicalizable, Lowerable, VirtualizableAllocation { |
40 | 40 |
41 private final ResolvedJavaType instanceClass; | 41 private final ResolvedJavaType instanceClass; |
42 private final boolean fillContents; | 42 private final boolean fillContents; |
43 | 43 |
44 /** | 44 /** |
94 if (!tool.getMetaAccessProvider().lookupJavaType(Reference.class).isAssignableFrom(instanceClass)) { | 94 if (!tool.getMetaAccessProvider().lookupJavaType(Reference.class).isAssignableFrom(instanceClass)) { |
95 VirtualInstanceNode virtualObject = new VirtualInstanceNode(instanceClass(), true); | 95 VirtualInstanceNode virtualObject = new VirtualInstanceNode(instanceClass(), true); |
96 ResolvedJavaField[] fields = virtualObject.getFields(); | 96 ResolvedJavaField[] fields = virtualObject.getFields(); |
97 ValueNode[] state = new ValueNode[fields.length]; | 97 ValueNode[] state = new ValueNode[fields.length]; |
98 for (int i = 0; i < state.length; i++) { | 98 for (int i = 0; i < state.length; i++) { |
99 state[i] = ConstantNode.defaultForKind(fields[i].getType().getKind(), graph()); | 99 state[i] = defaultFieldValue(fields[i]); |
100 } | 100 } |
101 tool.createVirtualObject(virtualObject, state, null); | 101 tool.createVirtualObject(virtualObject, state, null); |
102 tool.replaceWithVirtual(virtualObject); | 102 tool.replaceWithVirtual(virtualObject); |
103 } | 103 } |
104 } | |
105 | |
106 /* Factored out in a separate method so that subclasses can override it. */ | |
107 protected ConstantNode defaultFieldValue(ResolvedJavaField field) { | |
108 return ConstantNode.defaultForKind(field.getType().getKind(), graph()); | |
104 } | 109 } |
105 | 110 |
106 @Override | 111 @Override |
107 public boolean canDeoptimize() { | 112 public boolean canDeoptimize() { |
108 return true; | 113 return true; |