@@ -171,17 +171,26 @@ public static void subcallResolve_noa(Lookup caller, MutableCallSite cs, String
171
171
* and callsite with what they've been resolved to. Don't do it if
172
172
* it's a compiler stub, though. */
173
173
if (!cr .isCompilerStub && !shared ) {
174
- cs .setTarget (MethodHandles
175
- .insertArguments (
176
- MethodHandles .dropArguments (cr .staticInfo .mh , 0 , String .class , int .class ),
177
- 3 , cr , csd )
178
- .asVarargsCollector (Object [].class )
179
- .asType (cs .getTarget ().type ()));
174
+ try {
175
+ MethodType invType = MethodType .methodType (void .class ,
176
+ MethodHandle .class , String .class , CallSiteDescriptor .class ,
177
+ ThreadContext .class , Object [].class );
178
+ MethodHandle inv = caller .findStatic (IndyBootstrap .class , "subInvoker" , invType );
179
+ cs .setTarget (MethodHandles
180
+ .dropArguments (
181
+ MethodHandles .insertArguments (inv , 0 , cr .staticInfo .mh , name , csd ),
182
+ 0 , String .class , int .class )
183
+ .asVarargsCollector (Object [].class )
184
+ .asType (cs .getTarget ().type ()));
185
+ }
186
+ catch (Throwable t ) {
187
+ throw ExceptionHandling .dieInternal (tc , t );
188
+ }
180
189
}
181
190
182
191
/* Make the sub call directly for this initial call. */
183
192
try {
184
- cr .staticInfo .mh .invokeExact (tc , cr , csd , args );
193
+ cr .staticInfo .mh .invokeExact (tc , ( CodeRef ) cr , csd , args );
185
194
}
186
195
catch (ControlException e ) {
187
196
throw e ;
@@ -219,6 +228,27 @@ public static void lexotic_s_noa(long target, SixModelObject boxType, String _,
219
228
throw throwee ;
220
229
}
221
230
231
+ public static void subInvoker (MethodHandle mh , String name , CallSiteDescriptor csd , ThreadContext tc , Object [] args ) throws Throwable {
232
+ SixModelObject invokee = Ops .getlex (name , tc );
233
+ CodeRef cr ;
234
+ if (invokee instanceof CodeRef ) {
235
+ cr = (CodeRef )invokee ;
236
+ }
237
+ else {
238
+ InvocationSpec is = invokee .st .InvocationSpec ;
239
+ if (is == null )
240
+ throw ExceptionHandling .dieInternal (tc , "Can not invoke this object" );
241
+ if (is .ClassHandle != null )
242
+ cr = (CodeRef )invokee .get_attribute_boxed (tc , is .ClassHandle , is .AttrName , is .Hint );
243
+ else {
244
+ cr = (CodeRef )is .InvocationHandler ;
245
+ csd = csd .injectInvokee (tc , args , invokee );
246
+ args = tc .flatArgs ;
247
+ }
248
+ }
249
+ mh .invokeExact (tc , cr , csd , args );
250
+ }
251
+
222
252
public static CallSite indcall_noa (Lookup caller , String _, MethodType type ) {
223
253
try {
224
254
/* Look up indirect call invoker method. */
0 commit comments