Skip to content

Commit

Permalink
Don't wire callsite to compiler thunks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Apr 29, 2013
1 parent 8a230e7 commit 98861e4
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions src/vm/jvm/runtime/org/perl6/nqp/runtime/IndyBootstrap.java
Expand Up @@ -194,12 +194,15 @@ public static void subcallResolve(Lookup caller, MutableCallSite cs, String name
}

/* Now need to adapt to the target callsite by binding the CodeRef
* and callsite with what they've been resolved to. */
cs.setTarget(MethodHandles
.insertArguments(cr.staticInfo.mh, 1, cr, csd)
.asVarargsCollector(Object[].class)
.asType(cs.getTarget().type()));

* and callsite with what they've been resolved to. Don't do it if
* it's a compiler stub, though. */
if (!cr.isCompilerStub) {
cs.setTarget(MethodHandles
.insertArguments(cr.staticInfo.mh, 1, cr, csd)
.asVarargsCollector(Object[].class)
.asType(cs.getTarget().type()));
}

/* Make the sub call directly for this initial call. */
try {
cr.staticInfo.mh.invokeExact(tc, cr, csd, args);
Expand Down Expand Up @@ -351,26 +354,29 @@ public static void methcallResolve(Lookup caller, MutableCallSite cs, String nam
cr = (CodeRef)is.InvocationHandler;
}

/* Update callsite, stacking up guarded clauses. */
MethodType gType = MethodType.methodType(boolean.class,
STable.class, ThreadContext.class, SixModelObject.class);
MethodHandle guard;
try {
guard = caller.findStatic(IndyBootstrap.class, "stGuard", gType);
}
catch (Exception e) {
throw new RuntimeException(e);
/* Update callsite, stacking up guarded clauses. Don't do it if it
* is a dynamic compiler stub, though. */
if (!cr.isCompilerStub) {
MethodType gType = MethodType.methodType(boolean.class,
STable.class, ThreadContext.class, SixModelObject.class);
MethodHandle guard;
try {
guard = caller.findStatic(IndyBootstrap.class, "stGuard", gType);
}
catch (Exception e) {
throw new RuntimeException(e);
}
cs.setTarget(MethodHandles
.guardWithTest(
MethodHandles.insertArguments(guard, 0, invocant.st),
MethodHandles
.insertArguments(cr.staticInfo.mh, 1, cr, csd)
.asVarargsCollector(Object[].class)
.asType(cs.getTarget().type()),
cs.getTarget()));
}
cs.setTarget(MethodHandles
.guardWithTest(
guard.bindTo(invocant.st),
MethodHandles
.insertArguments(cr.staticInfo.mh, 1, cr, csd)
.asVarargsCollector(Object[].class)
.asType(cs.getTarget().type()),
cs.getTarget()));

/* Make the sub call directly for this initial call. */

/* Make the call directly for this initial call. */
try {
cr.staticInfo.mh.invokeExact(tc, cr, csd, args);
}
Expand Down

0 comments on commit 98861e4

Please sign in to comment.