44 return metaAccess.lookupJavaMethod(m).asStackTraceElement(0);
45 }
46 }
47 throw new GraalError("could not find method named \"execute\" in " + c.getName());
48 }
49
50 protected boolean checkInjectedArgument(GraphBuilderContext b, ValueNode arg, ResolvedJavaMethod foldAnnotatedMethod) {
51 if (arg.isNullConstant()) {
52 return true;
53 }
54
55 MetaAccessProvider metaAccess = b.getMetaAccess();
56 ResolvedJavaMethod executeMethod = metaAccess.lookupJavaMethod(getExecuteMethod());
57 ResolvedJavaType thisClass = metaAccess.lookupJavaType(getClass());
58 ResolvedJavaMethod thisExecuteMethod = thisClass.resolveConcreteMethod(executeMethod, thisClass);
59 if (b.getMethod().equals(thisExecuteMethod)) {
60 // The "execute" method of this plugin is itself being compiled. In (only) this context,
61 // the injected argument of the call to the @Fold annotated method will be non-null.
62 return true;
63 }
64 throw new AssertionError("must pass null to injected argument of " + foldAnnotatedMethod.format("%H.%n(%p)"));
65 }
66
67 private static Method getExecuteMethod() {
68 try {
69 return GeneratedInvocationPlugin.class.getMethod("execute", GraphBuilderContext.class, ResolvedJavaMethod.class, InvocationPlugin.Receiver.class, ValueNode[].class);
70 } catch (NoSuchMethodException | SecurityException e) {
71 throw new GraalError(e);
72 }
73 }
74 }
|
44 return metaAccess.lookupJavaMethod(m).asStackTraceElement(0);
45 }
46 }
47 throw new GraalError("could not find method named \"execute\" in " + c.getName());
48 }
49
50 protected boolean checkInjectedArgument(GraphBuilderContext b, ValueNode arg, ResolvedJavaMethod foldAnnotatedMethod) {
51 if (arg.isNullConstant()) {
52 return true;
53 }
54
55 MetaAccessProvider metaAccess = b.getMetaAccess();
56 ResolvedJavaMethod executeMethod = metaAccess.lookupJavaMethod(getExecuteMethod());
57 ResolvedJavaType thisClass = metaAccess.lookupJavaType(getClass());
58 ResolvedJavaMethod thisExecuteMethod = thisClass.resolveConcreteMethod(executeMethod, thisClass);
59 if (b.getMethod().equals(thisExecuteMethod)) {
60 // The "execute" method of this plugin is itself being compiled. In (only) this context,
61 // the injected argument of the call to the @Fold annotated method will be non-null.
62 return true;
63 }
64 throw new AssertionError("must pass null to injected argument of " + foldAnnotatedMethod.format("%H.%n(%p)") + ", not " + arg);
65 }
66
67 private static Method getExecuteMethod() {
68 try {
69 return GeneratedInvocationPlugin.class.getMethod("execute", GraphBuilderContext.class, ResolvedJavaMethod.class, InvocationPlugin.Receiver.class, ValueNode[].class);
70 } catch (NoSuchMethodException | SecurityException e) {
71 throw new GraalError(e);
72 }
73 }
74 }
|