303 * concrete than the argument type.
304 *
305 * @param adder
306 * @param index of the argument to be cast
307 * @param type the type the argument should be cast to
308 */
309 private static void maybeCastArgument(GraphAdder adder, ValueNode[] arguments, int index, JavaType type) {
310 ValueNode argument = arguments[index];
311 if (type instanceof ResolvedJavaType && !((ResolvedJavaType) type).isJavaLangObject()) {
312 Assumptions assumptions = adder.getAssumptions();
313 TypeReference targetType = TypeReference.create(assumptions, (ResolvedJavaType) type);
314 /*
315 * When an argument is a Word type, we can have a mismatch of primitive/object types
316 * here. Not inserting a PiNode is a safe fallback, and Word types need no additional
317 * type information anyway.
318 */
319 if (targetType != null && !targetType.getType().isPrimitive() && !argument.getStackKind().isPrimitive()) {
320 ResolvedJavaType argumentType = StampTool.typeOrNull(argument.stamp());
321 if (argumentType == null || (argumentType.isAssignableFrom(targetType.getType()) && !argumentType.equals(targetType.getType()))) {
322 LogicNode inst = InstanceOfNode.createAllowNull(targetType, argument, null, null);
323 if (!inst.isTautology()) {
324 inst = adder.add(inst);
325 AnchoringNode guardAnchor = adder.getGuardAnchor();
326 DeoptimizationReason reason = DeoptimizationReason.ClassCastException;
327 DeoptimizationAction action = DeoptimizationAction.InvalidateRecompile;
328 JavaConstant speculation = JavaConstant.NULL_POINTER;
329 GuardingNode guard;
330 if (guardAnchor == null) {
331 FixedGuardNode fixedGuard = adder.add(new FixedGuardNode(inst, reason, action, speculation, false));
332 guard = fixedGuard;
333 } else {
334 GuardNode newGuard = adder.add(new GuardNode(inst, guardAnchor, reason, action, false, speculation));
335 adder.add(new ValueAnchorNode(newGuard));
336 guard = newGuard;
337 }
338 ValueNode valueNode = adder.add(PiNode.create(argument, StampFactory.object(targetType), guard.asNode()));
339 arguments[index] = valueNode;
340 } else {
341 inst.safeDelete();
342 }
343 }
344 }
345 }
346 }
347
348 /**
349 * Creates an {@link InvokeNode} for the given target method. The {@link CallTargetNode} passed
350 * to the InvokeNode is in fact a {@link ResolvedMethodHandleCallTargetNode}.
351 *
352 * @return invoke node for the member name target
353 */
354 private static InvokeNode createTargetInvokeNode(Assumptions assumptions, IntrinsicMethod intrinsicMethod, ResolvedJavaMethod target, ResolvedJavaMethod original, int bci, StampPair returnStamp,
355 ValueNode[] arguments) {
356 InvokeKind targetInvokeKind = target.isStatic() ? InvokeKind.Static : InvokeKind.Special;
357 JavaType targetReturnType = target.getSignature().getReturnType(null);
358
359 // MethodHandleLinkTo* nodes have a trailing MemberName argument which
360 // needs to be popped.
361 ValueNode[] targetArguments;
|
303 * concrete than the argument type.
304 *
305 * @param adder
306 * @param index of the argument to be cast
307 * @param type the type the argument should be cast to
308 */
309 private static void maybeCastArgument(GraphAdder adder, ValueNode[] arguments, int index, JavaType type) {
310 ValueNode argument = arguments[index];
311 if (type instanceof ResolvedJavaType && !((ResolvedJavaType) type).isJavaLangObject()) {
312 Assumptions assumptions = adder.getAssumptions();
313 TypeReference targetType = TypeReference.create(assumptions, (ResolvedJavaType) type);
314 /*
315 * When an argument is a Word type, we can have a mismatch of primitive/object types
316 * here. Not inserting a PiNode is a safe fallback, and Word types need no additional
317 * type information anyway.
318 */
319 if (targetType != null && !targetType.getType().isPrimitive() && !argument.getStackKind().isPrimitive()) {
320 ResolvedJavaType argumentType = StampTool.typeOrNull(argument.stamp());
321 if (argumentType == null || (argumentType.isAssignableFrom(targetType.getType()) && !argumentType.equals(targetType.getType()))) {
322 LogicNode inst = InstanceOfNode.createAllowNull(targetType, argument, null, null);
323 assert !inst.isAlive();
324 if (!inst.isTautology()) {
325 inst = adder.add(inst);
326 AnchoringNode guardAnchor = adder.getGuardAnchor();
327 DeoptimizationReason reason = DeoptimizationReason.ClassCastException;
328 DeoptimizationAction action = DeoptimizationAction.InvalidateRecompile;
329 JavaConstant speculation = JavaConstant.NULL_POINTER;
330 GuardingNode guard;
331 if (guardAnchor == null) {
332 FixedGuardNode fixedGuard = adder.add(new FixedGuardNode(inst, reason, action, speculation, false));
333 guard = fixedGuard;
334 } else {
335 GuardNode newGuard = adder.add(new GuardNode(inst, guardAnchor, reason, action, false, speculation));
336 adder.add(new ValueAnchorNode(newGuard));
337 guard = newGuard;
338 }
339 ValueNode valueNode = adder.add(PiNode.create(argument, StampFactory.object(targetType), guard.asNode()));
340 arguments[index] = valueNode;
341 }
342 }
343 }
344 }
345 }
346
347 /**
348 * Creates an {@link InvokeNode} for the given target method. The {@link CallTargetNode} passed
349 * to the InvokeNode is in fact a {@link ResolvedMethodHandleCallTargetNode}.
350 *
351 * @return invoke node for the member name target
352 */
353 private static InvokeNode createTargetInvokeNode(Assumptions assumptions, IntrinsicMethod intrinsicMethod, ResolvedJavaMethod target, ResolvedJavaMethod original, int bci, StampPair returnStamp,
354 ValueNode[] arguments) {
355 InvokeKind targetInvokeKind = target.isStatic() ? InvokeKind.Static : InvokeKind.Special;
356 JavaType targetReturnType = target.getSignature().getReturnType(null);
357
358 // MethodHandleLinkTo* nodes have a trailing MemberName argument which
359 // needs to be popped.
360 ValueNode[] targetArguments;
|