1022 ValueNode replacedFrom = tool.getAlias(from);
1023 if (!replacedNewLength.isConstant() || !replacedFrom.isConstant() || !replacedSourceLength.isConstant()) {
1024 return;
1025 }
1026
1027 assert newComponentType != null : "An array copy can be virtualized only if the real type of the resulting array is known statically.";
1028
1029 int fromInt = replacedFrom.asJavaConstant().asInt();
1030 int newLengthInt = replacedNewLength.asJavaConstant().asInt();
1031 int sourceLengthInt = replacedSourceLength.asJavaConstant().asInt();
1032 if (sourceAlias instanceof VirtualObjectNode) {
1033 VirtualObjectNode sourceVirtual = (VirtualObjectNode) sourceAlias;
1034 assert sourceLengthInt == sourceVirtual.entryCount();
1035 }
1036
1037 if (fromInt < 0 || newLengthInt < 0 || fromInt > sourceLengthInt) {
1038 /* Illegal values for either from index, the new length or the source length. */
1039 return;
1040 }
1041
1042 if (newLengthInt >= tool.getMaximumEntryCount()) {
1043 /* The new array size is higher than maximum allowed size of virtualized objects. */
1044 return;
1045 }
1046
1047 ValueNode[] newEntryState = new ValueNode[newLengthInt];
1048 int readLength = Math.min(newLengthInt, sourceLengthInt - fromInt);
1049
1050 if (sourceAlias instanceof VirtualObjectNode) {
1051 /* The source array is virtualized, just copy over the values. */
1052 VirtualObjectNode sourceVirtual = (VirtualObjectNode) sourceAlias;
1053 boolean alwaysAssignable = newComponentType.getJavaKind() == JavaKind.Object && newComponentType.isJavaLangObject();
1054 for (int i = 0; i < readLength; i++) {
1055 ValueNode entry = tool.getEntry(sourceVirtual, fromInt + i);
1056 if (!alwaysAssignable) {
1057 ResolvedJavaType entryType = StampTool.typeOrNull(entry, tool.getMetaAccess());
1058 if (entryType == null) {
1059 return;
1060 }
1061 if (!newComponentType.isAssignableFrom(entryType)) {
1062 return;
|
1022 ValueNode replacedFrom = tool.getAlias(from);
1023 if (!replacedNewLength.isConstant() || !replacedFrom.isConstant() || !replacedSourceLength.isConstant()) {
1024 return;
1025 }
1026
1027 assert newComponentType != null : "An array copy can be virtualized only if the real type of the resulting array is known statically.";
1028
1029 int fromInt = replacedFrom.asJavaConstant().asInt();
1030 int newLengthInt = replacedNewLength.asJavaConstant().asInt();
1031 int sourceLengthInt = replacedSourceLength.asJavaConstant().asInt();
1032 if (sourceAlias instanceof VirtualObjectNode) {
1033 VirtualObjectNode sourceVirtual = (VirtualObjectNode) sourceAlias;
1034 assert sourceLengthInt == sourceVirtual.entryCount();
1035 }
1036
1037 if (fromInt < 0 || newLengthInt < 0 || fromInt > sourceLengthInt) {
1038 /* Illegal values for either from index, the new length or the source length. */
1039 return;
1040 }
1041
1042 if (newLengthInt > tool.getMaximumEntryCount()) {
1043 /* The new array size is higher than maximum allowed size of virtualized objects. */
1044 return;
1045 }
1046
1047 ValueNode[] newEntryState = new ValueNode[newLengthInt];
1048 int readLength = Math.min(newLengthInt, sourceLengthInt - fromInt);
1049
1050 if (sourceAlias instanceof VirtualObjectNode) {
1051 /* The source array is virtualized, just copy over the values. */
1052 VirtualObjectNode sourceVirtual = (VirtualObjectNode) sourceAlias;
1053 boolean alwaysAssignable = newComponentType.getJavaKind() == JavaKind.Object && newComponentType.isJavaLangObject();
1054 for (int i = 0; i < readLength; i++) {
1055 ValueNode entry = tool.getEntry(sourceVirtual, fromInt + i);
1056 if (!alwaysAssignable) {
1057 ResolvedJavaType entryType = StampTool.typeOrNull(entry, tool.getMetaAccess());
1058 if (entryType == null) {
1059 return;
1060 }
1061 if (!newComponentType.isAssignableFrom(entryType)) {
1062 return;
|