Mercurial > hg > truffle
comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java @ 12380:e027a51bdd33
exclude java.lang.ref.Reference from Escape Analysis
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Mon, 14 Oct 2013 10:45:02 +0200 |
parents | 0fc653a9e019 |
children | c6ab6ae1b360 |
comparison
equal
deleted
inserted
replaced
12379:edb2e6bd6a01 | 12380:e027a51bdd33 |
---|---|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.graal.nodes.java; | 23 package com.oracle.graal.nodes.java; |
24 | |
25 import java.lang.ref.*; | |
24 | 26 |
25 import com.oracle.graal.api.meta.*; | 27 import com.oracle.graal.api.meta.*; |
26 import com.oracle.graal.graph.*; | 28 import com.oracle.graal.graph.*; |
27 import com.oracle.graal.graph.spi.*; | 29 import com.oracle.graal.graph.spi.*; |
28 import com.oracle.graal.nodes.*; | 30 import com.oracle.graal.nodes.*; |
46 * @param fillContents determines whether the new object's fields should be initialized to | 48 * @param fillContents determines whether the new object's fields should be initialized to |
47 * zero/null. | 49 * zero/null. |
48 */ | 50 */ |
49 public NewInstanceNode(ResolvedJavaType type, boolean fillContents) { | 51 public NewInstanceNode(ResolvedJavaType type, boolean fillContents) { |
50 super(StampFactory.exactNonNull(type)); | 52 super(StampFactory.exactNonNull(type)); |
53 assert !type.isArray(); | |
51 this.instanceClass = type; | 54 this.instanceClass = type; |
52 this.fillContents = fillContents; | 55 this.fillContents = fillContents; |
53 } | 56 } |
54 | 57 |
55 /** | 58 /** |
82 tool.getLowerer().lower(this, tool); | 85 tool.getLowerer().lower(this, tool); |
83 } | 86 } |
84 | 87 |
85 @Override | 88 @Override |
86 public void virtualize(VirtualizerTool tool) { | 89 public void virtualize(VirtualizerTool tool) { |
87 if (instanceClass != null) { | 90 /* |
88 assert !instanceClass().isArray(); | 91 * Reference objects can escape into their ReferenceQueue at any safepoint, therefore |
92 * they're excluded from escape analysis. | |
93 */ | |
94 if (!tool.getMetaAccessProvider().lookupJavaType(Reference.class).isAssignableFrom(instanceClass)) { | |
89 VirtualInstanceNode virtualObject = new VirtualInstanceNode(instanceClass(), true); | 95 VirtualInstanceNode virtualObject = new VirtualInstanceNode(instanceClass(), true); |
90 ResolvedJavaField[] fields = virtualObject.getFields(); | 96 ResolvedJavaField[] fields = virtualObject.getFields(); |
91 ValueNode[] state = new ValueNode[fields.length]; | 97 ValueNode[] state = new ValueNode[fields.length]; |
92 for (int i = 0; i < state.length; i++) { | 98 for (int i = 0; i < state.length; i++) { |
93 state[i] = ConstantNode.defaultForKind(fields[i].getType().getKind(), graph()); | 99 state[i] = ConstantNode.defaultForKind(fields[i].getType().getKind(), graph()); |