< 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




 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);
 169                     tool.replaceWithVirtual(virtualObject);
 170                 }
 171             }
 172         }
 173     }
 174 
 175     protected VirtualInstanceNode createVirtualInstanceNode(ResolvedJavaType type, boolean hasIdentity) {
 176         return new VirtualInstanceNode(type, hasIdentity);
 177     }


 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);
 169                     tool.replaceWithVirtual(virtualObject);
 170                 }
 171             }
 172         }
 173     }
 174 
 175     protected VirtualInstanceNode createVirtualInstanceNode(ResolvedJavaType type, boolean hasIdentity) {
 176         return new VirtualInstanceNode(type, hasIdentity);
 177     }
< prev index next >