62 super(c, StampFactory.objectNonNull(TypeReference.createExactTrusted(type)), fillContents, stateBefore);
63 assert !type.isArray() && !type.isInterface() && !type.isPrimitive() && !type.isAbstract();
64 this.instanceClass = type;
65 }
66
67 /**
68 * Gets the instance class being allocated by this node.
69 *
70 * @return the instance class allocated
71 */
72 public ResolvedJavaType instanceClass() {
73 return instanceClass;
74 }
75
76 @Override
77 public void virtualize(VirtualizerTool tool) {
78 /*
79 * Reference objects can escape into their ReferenceQueue at any safepoint, therefore
80 * they're excluded from escape analysis.
81 */
82 if (!tool.getMetaAccessProvider().lookupJavaType(Reference.class).isAssignableFrom(instanceClass)) {
83 VirtualInstanceNode virtualObject = createVirtualInstanceNode(true);
84 ResolvedJavaField[] fields = virtualObject.getFields();
85 ValueNode[] state = new ValueNode[fields.length];
86 for (int i = 0; i < state.length; i++) {
87 state[i] = defaultFieldValue(fields[i]);
88 }
89 tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList(), false);
90 tool.replaceWithVirtual(virtualObject);
91 }
92 }
93
94 protected VirtualInstanceNode createVirtualInstanceNode(boolean hasIdentity) {
95 return new VirtualInstanceNode(instanceClass(), hasIdentity);
96 }
97
98 /* Factored out in a separate method so that subclasses can override it. */
99 protected ConstantNode defaultFieldValue(ResolvedJavaField field) {
100 return ConstantNode.defaultForKind(field.getType().getJavaKind(), graph());
101 }
102 }
|
62 super(c, StampFactory.objectNonNull(TypeReference.createExactTrusted(type)), fillContents, stateBefore);
63 assert !type.isArray() && !type.isInterface() && !type.isPrimitive() && !type.isAbstract();
64 this.instanceClass = type;
65 }
66
67 /**
68 * Gets the instance class being allocated by this node.
69 *
70 * @return the instance class allocated
71 */
72 public ResolvedJavaType instanceClass() {
73 return instanceClass;
74 }
75
76 @Override
77 public void virtualize(VirtualizerTool tool) {
78 /*
79 * Reference objects can escape into their ReferenceQueue at any safepoint, therefore
80 * they're excluded from escape analysis.
81 */
82 if (!tool.getMetaAccess().lookupJavaType(Reference.class).isAssignableFrom(instanceClass)) {
83 VirtualInstanceNode virtualObject = createVirtualInstanceNode(true);
84 ResolvedJavaField[] fields = virtualObject.getFields();
85 ValueNode[] state = new ValueNode[fields.length];
86 for (int i = 0; i < state.length; i++) {
87 state[i] = defaultFieldValue(fields[i]);
88 }
89 tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList(), false);
90 tool.replaceWithVirtual(virtualObject);
91 }
92 }
93
94 protected VirtualInstanceNode createVirtualInstanceNode(boolean hasIdentity) {
95 return new VirtualInstanceNode(instanceClass(), hasIdentity);
96 }
97
98 /* Factored out in a separate method so that subclasses can override it. */
99 protected ConstantNode defaultFieldValue(ResolvedJavaField field) {
100 return ConstantNode.defaultForKind(field.getType().getJavaKind(), graph());
101 }
102 }
|