Permalink
Browse files

Pass call site index as static data, not per call.

  • Loading branch information...
1 parent b1d4669 commit 55e954c9bda16469dbf24df633581dfc740c7f13 @jnthn jnthn committed Apr 25, 2013
Showing with 18 additions and 21 deletions.
  1. +3 −3 src/vm/jvm/QAST/Compiler.nqp
  2. +15 −18 src/vm/jvm/runtime/org/perl6/nqp/runtime/IndyBootstrap.java
View
6 src/vm/jvm/QAST/Compiler.nqp
@@ -1115,13 +1115,13 @@ QAST::OperationsJAST.add_core_op('call', sub ($qastcomp, $node) {
# Emit the call. Note, name passed as extra arg as some valid
# names in Perl 6 are not valid method names on the JVM.
$il.append(JAST::Instruction.new( :op('aload_1') ));
- $il.append(JAST::PushIndex.new( :value($cs_idx) ));
$il.append(JAST::Instruction.new( :op('aload'), @argstuff[1] ));
$il.append(JAST::InvokeDynamic.new(
- 'subcall', 'V', [$TYPE_TC, 'I', "[$TYPE_OBJ"],
+ 'subcall', 'V', [$TYPE_TC, "[$TYPE_OBJ"],
'org/perl6/nqp/runtime/IndyBootstrap', 'subcall',
[
- JAST::PushSVal.new( :value($node.name) )
+ JAST::PushSVal.new( :value($node.name) ),
+ JAST::PushIndex.new( :value($cs_idx) )
]
));
}
View
33 src/vm/jvm/runtime/org/perl6/nqp/runtime/IndyBootstrap.java
@@ -41,18 +41,18 @@ public static SixModelObject wvalResolve(MutableCallSite cs, String sc, long idx
return res;
}
- public static CallSite subcall(Lookup caller, String _, MethodType type, String name) {
+ public static CallSite subcall(Lookup caller, String _, MethodType type, String name, int csIdx) {
try {
/* Look up subcall resolver method. */
MethodType resType = MethodType.methodType(void.class,
Lookup.class, MutableCallSite.class, String.class,
- ThreadContext.class, int.class, Object[].class);
+ int.class, ThreadContext.class, Object[].class);
MethodHandle res = caller.findStatic(IndyBootstrap.class, "subcallResolve", resType);
/* Create a mutable callsite, and curry the resolver with it and
* the sub name. */
MutableCallSite cs = new MutableCallSite(type);
- cs.setTarget(MethodHandles.insertArguments(res, 0, caller, cs, name));
+ cs.setTarget(MethodHandles.insertArguments(res, 0, caller, cs, name, csIdx));
/* Produce callsite; it'll be updated with the resolved call upon the
* first invocation. */
@@ -63,7 +63,7 @@ public static CallSite subcall(Lookup caller, String _, MethodType type, String
}
}
- public static void subcallResolve(Lookup caller, MutableCallSite cs, String name, ThreadContext tc, int csIdx, Object[] args) {
+ public static void subcallResolve(Lookup caller, MutableCallSite cs, String name, int csIdx, ThreadContext tc, Object[] args) {
/* Locate the thing to call. */
SixModelObject invokee = Ops.getlex(name, tc);
@@ -84,7 +84,7 @@ public static void subcallResolve(Lookup caller, MutableCallSite cs, String name
try {
cs.setTarget(caller
.findStatic(IndyBootstrap.class, "lexotic_o",
- MethodType.methodType(long.class, ThreadContext.class, int.class, Object[].class))
+ MethodType.methodType(long.class, ThreadContext.class, Object[].class))
.bindTo(throwee.target));
}
catch (Exception e) {
@@ -97,7 +97,7 @@ public static void subcallResolve(Lookup caller, MutableCallSite cs, String name
try {
cs.setTarget(MethodHandles.insertArguments(
caller.findStatic(IndyBootstrap.class, "lexotic_i",
- MethodType.methodType(long.class, ThreadContext.class, int.class, Object[].class)),
+ MethodType.methodType(long.class, ThreadContext.class, Object[].class)),
0, throwee.target, intBoxType));
}
catch (Exception e) {
@@ -110,7 +110,7 @@ public static void subcallResolve(Lookup caller, MutableCallSite cs, String name
try {
cs.setTarget(MethodHandles.insertArguments(
caller.findStatic(IndyBootstrap.class, "lexotic_n",
- MethodType.methodType(long.class, ThreadContext.class, int.class, Object[].class)),
+ MethodType.methodType(long.class, ThreadContext.class, Object[].class)),
0, throwee.target, numBoxType));
}
catch (Exception e) {
@@ -123,7 +123,7 @@ public static void subcallResolve(Lookup caller, MutableCallSite cs, String name
try {
cs.setTarget(MethodHandles.insertArguments(
caller.findStatic(IndyBootstrap.class, "lexotic_s",
- MethodType.methodType(long.class, ThreadContext.class, int.class, Object[].class)),
+ MethodType.methodType(long.class, ThreadContext.class, Object[].class)),
0, throwee.target, strBoxType));
}
catch (Exception e) {
@@ -151,12 +151,9 @@ public static void subcallResolve(Lookup caller, MutableCallSite cs, String name
cr = (CodeRef)is.InvocationHandler;
}
- /* Now need to adapt to the target callsite. First, bind the CodeRef
- * and callsite with what they've been resolved to. Then target just
- * needs to drop the now-resolved callsite index. */
- MethodHandle withCRAndCSD = MethodHandles.insertArguments(
- cr.staticInfo.mh, 1, cr, csd);
- cs.setTarget(MethodHandles.dropArguments(withCRAndCSD, 1, int.class));
+ /* 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));
/* Make the sub call directly for this initial call. */
try {
@@ -170,28 +167,28 @@ public static void subcallResolve(Lookup caller, MutableCallSite cs, String name
}
}
- public static void lexotic_o(long target, ThreadContext tc, int csIdx, Object[] args) {
+ public static void lexotic_o(long target, ThreadContext tc, Object[] args) {
LexoticException throwee = tc.theLexotic;
throwee.target = target;
throwee.payload = (SixModelObject)args[0];
throw throwee;
}
- public static void lexotic_i(long target, SixModelObject boxType, ThreadContext tc, int csIdx, Object[] args) {
+ public static void lexotic_i(long target, SixModelObject boxType, ThreadContext tc, Object[] args) {
LexoticException throwee = tc.theLexotic;
throwee.target = target;
throwee.payload = Ops.box_i((long)args[0], boxType, tc);
throw throwee;
}
- public static void lexotic_n(long target, SixModelObject boxType, ThreadContext tc, int csIdx, Object[] args) {
+ public static void lexotic_n(long target, SixModelObject boxType, ThreadContext tc, Object[] args) {
LexoticException throwee = tc.theLexotic;
throwee.target = target;
throwee.payload = Ops.box_n((double)args[0], boxType, tc);
throw throwee;
}
- public static void lexotic_s(long target, SixModelObject boxType, ThreadContext tc, int csIdx, Object[] args) {
+ public static void lexotic_s(long target, SixModelObject boxType, ThreadContext tc, Object[] args) {
LexoticException throwee = tc.theLexotic;
throwee.target = target;
throwee.payload = Ops.box_s((String)args[0], boxType, tc);

0 comments on commit 55e954c

Please sign in to comment.