< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/nodes/BasicObjectCloneNode.java

Print this page
rev 52509 : [mq]: graal


 128                 tool.replaceWithVirtual(newVirtual);
 129             }
 130         } else {
 131             ResolvedJavaType type = getConcreteType(originalAlias.stamp(NodeView.DEFAULT));
 132             if (type == null) {
 133                 return;
 134             }
 135             if (!type.isArray()) {
 136                 VirtualInstanceNode newVirtual = createVirtualInstanceNode(type, true);
 137                 ResolvedJavaField[] fields = newVirtual.getFields();
 138 
 139                 ValueNode[] state = new ValueNode[fields.length];
 140                 for (int i = 0; i < fields.length; i++) {
 141                     LoadFieldNode load = genLoadFieldNode(graph().getAssumptions(), originalAlias, fields[i]);
 142                     state[i] = load;
 143                     tool.addNode(load);
 144                 }
 145                 tool.createVirtualObject(newVirtual, state, Collections.<MonitorIdNode> emptyList(), false);
 146                 tool.replaceWithVirtual(newVirtual);
 147             } else {
 148                 ValueNode length = findLength(FindLengthMode.SEARCH_ONLY, tool.getConstantReflectionProvider());
 149                 if (length == null) {
 150                     return;
 151                 }
 152                 ValueNode lengthAlias = tool.getAlias(length);
 153                 if (!lengthAlias.isConstant()) {
 154                     return;
 155                 }
 156                 int constantLength = lengthAlias.asJavaConstant().asInt();
 157                 if (constantLength >= 0 && constantLength < tool.getMaximumEntryCount()) {
 158                     ValueNode[] state = new ValueNode[constantLength];
 159                     ResolvedJavaType componentType = type.getComponentType();
 160                     for (int i = 0; i < constantLength; i++) {
 161                         ConstantNode index = ConstantNode.forInt(i);
 162                         LoadIndexedNode load = genLoadIndexedNode(graph().getAssumptions(), originalAlias, index, componentType.getJavaKind());
 163                         state[i] = load;
 164                         tool.addNode(index);
 165                         tool.addNode(load);
 166                     }
 167                     VirtualObjectNode virtualObject = new VirtualArrayNode(componentType, constantLength);
 168                     tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList(), false);


 128                 tool.replaceWithVirtual(newVirtual);
 129             }
 130         } else {
 131             ResolvedJavaType type = getConcreteType(originalAlias.stamp(NodeView.DEFAULT));
 132             if (type == null) {
 133                 return;
 134             }
 135             if (!type.isArray()) {
 136                 VirtualInstanceNode newVirtual = createVirtualInstanceNode(type, true);
 137                 ResolvedJavaField[] fields = newVirtual.getFields();
 138 
 139                 ValueNode[] state = new ValueNode[fields.length];
 140                 for (int i = 0; i < fields.length; i++) {
 141                     LoadFieldNode load = genLoadFieldNode(graph().getAssumptions(), originalAlias, fields[i]);
 142                     state[i] = load;
 143                     tool.addNode(load);
 144                 }
 145                 tool.createVirtualObject(newVirtual, state, Collections.<MonitorIdNode> emptyList(), false);
 146                 tool.replaceWithVirtual(newVirtual);
 147             } else {
 148                 ValueNode length = findLength(FindLengthMode.SEARCH_ONLY, tool.getConstantReflection());
 149                 if (length == null) {
 150                     return;
 151                 }
 152                 ValueNode lengthAlias = tool.getAlias(length);
 153                 if (!lengthAlias.isConstant()) {
 154                     return;
 155                 }
 156                 int constantLength = lengthAlias.asJavaConstant().asInt();
 157                 if (constantLength >= 0 && constantLength < tool.getMaximumEntryCount()) {
 158                     ValueNode[] state = new ValueNode[constantLength];
 159                     ResolvedJavaType componentType = type.getComponentType();
 160                     for (int i = 0; i < constantLength; i++) {
 161                         ConstantNode index = ConstantNode.forInt(i);
 162                         LoadIndexedNode load = genLoadIndexedNode(graph().getAssumptions(), originalAlias, index, componentType.getJavaKind());
 163                         state[i] = load;
 164                         tool.addNode(index);
 165                         tool.addNode(load);
 166                     }
 167                     VirtualObjectNode virtualObject = new VirtualArrayNode(componentType, constantLength);
 168                     tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList(), false);
< prev index next >