Skip to content

Commit 251fa9b

Browse files
committed
[JDK-8347367] Ensure that fields loaded by InvocationPlugins are properly type checked
PullRequest: graal/19905
2 parents 33aadeb + 3013bc1 commit 251fa9b

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/PiNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public static boolean intrinsify(GraphBuilderContext b, ValueNode object, Resolv
188188
nonNull || StampTool.isPointerNonNull(object.stamp(NodeView.DEFAULT)));
189189
ValueNode value = canonical(object, stamp, (GuardingNode) guard, null);
190190
if (value == null) {
191-
value = new PiNode(object, stamp);
191+
value = new PiNode(object, stamp, guard);
192192
}
193193
b.push(JavaKind.Object, b.append(value));
194194
return true;

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/StandardGraphBuilderPlugins.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,8 +2407,9 @@ public ValueNode readEmbeddedAESCryptKArrayStart(GraphBuilderContext b,
24072407
ResolvedJavaField embeddedCipherField = helper.getField(receiverType, "embeddedCipher");
24082408
ValueNode embeddedCipher = b.nullCheckedValue(helper.loadField(receiver, embeddedCipherField));
24092409
LogicNode typeCheck = InstanceOfNode.create(TypeReference.create(b.getAssumptions(), typeAESCrypt), embeddedCipher);
2410-
helper.doFallbackIfNot(typeCheck, GraalDirectives.UNLIKELY_PROBABILITY);
2411-
return readFieldArrayStart(b, helper, typeAESCrypt, "K", embeddedCipher, JavaKind.Int);
2410+
GuardingNode guard = helper.doFallbackIfNot(typeCheck, GraalDirectives.UNLIKELY_PROBABILITY);
2411+
ValueNode cast = b.add(PiNode.create(embeddedCipher, StampFactory.objectNonNull(TypeReference.create(b.getAssumptions(), typeAESCrypt)), guard.asNode()));
2412+
return readFieldArrayStart(b, helper, typeAESCrypt, "K", cast, JavaKind.Int);
24122413
}
24132414
}
24142415

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/arraycopy/ArrayCopySnippets.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,16 @@ protected void doExactArraycopyWithExpandedLoopSnippet(Object src, int srcPos, O
306306
long sourceOffset = arrayBaseOffset + srcPos * scale;
307307
long destOffset = arrayBaseOffset + destPos * scale;
308308

309-
GuardingNode anchor = SnippetAnchorNode.anchor();
310309
if (probability(FREQUENT_PROBABILITY, src == dest) && probability(NOT_FREQUENT_PROBABILITY, srcPos < destPos)) {
311310
// bad aliased case so we need to copy the array from back to front
312311
for (int position = length - 1; probability(FAST_PATH_PROBABILITY, position >= 0); position--) {
312+
GuardingNode anchor = SnippetAnchorNode.anchor();
313313
Object value = GuardedUnsafeLoadNode.guardedLoad(src, sourceOffset + position * scale, elementKind, arrayLocation, anchor);
314314
RawStoreNode.storeObject(dest, destOffset + position * scale, value, elementKind, arrayLocation, true);
315315
}
316316
} else {
317317
for (int position = 0; probability(FAST_PATH_PROBABILITY, position < length); position++) {
318+
GuardingNode anchor = SnippetAnchorNode.anchor();
318319
Object value = GuardedUnsafeLoadNode.guardedLoad(src, sourceOffset + position * scale, elementKind, arrayLocation, anchor);
319320
RawStoreNode.storeObject(dest, destOffset + position * scale, value, elementKind, arrayLocation, true);
320321
}

0 commit comments

Comments
 (0)