Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Prepare for handling callsite as arg, not field.
  • Loading branch information
jnthn committed Mar 2, 2013
1 parent f000cc7 commit da4616f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
11 changes: 9 additions & 2 deletions lib/QAST/JASTCompiler.nqp
Expand Up @@ -1970,8 +1970,14 @@ class QAST::CompilerJAST {
$cra.append(JAST::Instruction.new( :op('getstatic'),
'Ljava/lang/Void;', 'TYPE', $TYPE_CLASS ));
$cra.append(JAST::PushCVal.new( :value($TYPE_TC) ));
$cra.append(JAST::PushIndex.new( :value(1) ));
$cra.append(JAST::Instruction.new( :op('newarray'), $TYPE_CLASS ));
$cra.append(JAST::Instruction.new( :op('dup') ));
$cra.append(JAST::PushIndex.new( :value(0) ));
$cra.append(JAST::PushCVal.new( :value($TYPE_CSD) ));
$cra.append(JAST::Instruction.new( :op('aastore') ));
$cra.append(JAST::Instruction.new( :op('invokestatic'),
$TYPE_MT, 'methodType', $TYPE_MT, $TYPE_CLASS, $TYPE_CLASS ));
$TYPE_MT, 'methodType', $TYPE_MT, $TYPE_CLASS, $TYPE_CLASS, "[$TYPE_CLASS" ));
$cra.append(JAST::Instruction.new( :op('astore'), 'mt' ));

# Create array.
Expand Down Expand Up @@ -2597,8 +2603,9 @@ class QAST::CompilerJAST {
$*CODEREFS.set_outer($node.cuid, $outer.qast.cuid);
}

# Always take ThreadContext as argument.
# Always take ThreadContext and callsite descriptor as arguments.
$*JMETH.add_argument('tc', $TYPE_TC);
$*JMETH.add_argument('csd', $TYPE_CSD);

# Set up temporaries allocator.
my $*BLOCK_TA := BlockTempAlloc.new();
Expand Down
2 changes: 1 addition & 1 deletion src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -1284,7 +1284,7 @@ private static void invokeInternal(ThreadContext tc, SixModelObject invokee, Cal

try {
// Do the invocation.
cr.staticInfo.mh.invokeExact(tc);
cr.staticInfo.mh.invokeExact(tc, csd);
}
catch (UnwindException e) {
throw e;
Expand Down
26 changes: 13 additions & 13 deletions src/org/perl6/nqp/sixmodel/KnowHOWMethods.java
Expand Up @@ -15,7 +15,7 @@
* for code reference like things.
*/
public class KnowHOWMethods extends CompilationUnit {
public void new_type(ThreadContext tc) {
public void new_type(ThreadContext tc, CallSiteDescriptor csd) {
/* Get arguments. */
Ops.checkarity(tc.curFrame, 1, 1);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);
Expand Down Expand Up @@ -51,7 +51,7 @@ public void new_type(ThreadContext tc) {
tc.curFrame.leave();
}

public void add_method(ThreadContext tc) {
public void add_method(ThreadContext tc, CallSiteDescriptor csd) {
Ops.checkarity(tc.curFrame, 4, 4);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);
String name = Ops.posparam_s(tc.curFrame, 2);
Expand All @@ -66,7 +66,7 @@ public void add_method(ThreadContext tc) {
tc.curFrame.leave();
}

public void add_attribute(ThreadContext tc) {
public void add_attribute(ThreadContext tc, CallSiteDescriptor csd) {
Ops.checkarity(tc.curFrame, 3, 3);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);
SixModelObject attribute = Ops.posparam_o(tc.curFrame, 2);
Expand All @@ -82,7 +82,7 @@ public void add_attribute(ThreadContext tc) {
tc.curFrame.leave();
}

public void compose(ThreadContext tc) {
public void compose(ThreadContext tc, CallSiteDescriptor csd) {
Ops.checkarity(tc.curFrame, 2, 2);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);
SixModelObject type_obj = Ops.posparam_o(tc.curFrame, 1);
Expand Down Expand Up @@ -148,7 +148,7 @@ public void compose(ThreadContext tc) {
tc.curFrame.leave();
}

public void attributes(ThreadContext tc) {
public void attributes(ThreadContext tc, CallSiteDescriptor csd) {
Ops.checkarity(tc.curFrame, 2, 2);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);

Expand All @@ -167,7 +167,7 @@ public void attributes(ThreadContext tc) {
tc.curFrame.leave();
}

public void methods(ThreadContext tc) {
public void methods(ThreadContext tc, CallSiteDescriptor csd) {
Ops.checkarity(tc.curFrame, 2, 2);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);

Expand All @@ -186,7 +186,7 @@ public void methods(ThreadContext tc) {
tc.curFrame.leave();
}

public void name(ThreadContext tc) {
public void name(ThreadContext tc, CallSiteDescriptor csd) {
Ops.checkarity(tc.curFrame, 2, 2);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);

Expand All @@ -197,7 +197,7 @@ public void name(ThreadContext tc) {
tc.curFrame.leave();
}

public void attr_new(ThreadContext tc) {
public void attr_new(ThreadContext tc, CallSiteDescriptor csd) {
/* Process arguments. */
Ops.checkarity(tc.curFrame, 1, 1);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);
Expand All @@ -220,28 +220,28 @@ public void attr_new(ThreadContext tc) {
tc.curFrame.leave();
}

public void attr_compose(ThreadContext tc) {
public void attr_compose(ThreadContext tc, CallSiteDescriptor csd) {
Ops.checkarity(tc.curFrame, 1, 1);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);
Ops.return_o(self, tc.curFrame);
tc.curFrame.leave();
}

public void attr_name(ThreadContext tc) {
public void attr_name(ThreadContext tc, CallSiteDescriptor csd) {
Ops.checkarity(tc.curFrame, 1, 1);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);
Ops.return_s(((KnowHOWAttributeInstance)self).name, tc.curFrame);
tc.curFrame.leave();
}

public void attr_type(ThreadContext tc) {
public void attr_type(ThreadContext tc, CallSiteDescriptor csd) {
Ops.checkarity(tc.curFrame, 1, 1);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);
Ops.return_o(((KnowHOWAttributeInstance)self).type, tc.curFrame);
tc.curFrame.leave();
}

public void attr_box_target(ThreadContext tc) {
public void attr_box_target(ThreadContext tc, CallSiteDescriptor csd) {
Ops.checkarity(tc.curFrame, 1, 1);
SixModelObject self = Ops.posparam_o(tc.curFrame, 0);
Ops.return_i(((KnowHOWAttributeInstance)self).box_target, tc.curFrame);
Expand All @@ -253,7 +253,7 @@ public CodeRef[] getCodeRefs() {
String[] snull = null;
long[][] hnull = new long[0][];
short zero = 0;
MethodType mt = MethodType.methodType(void.class, ThreadContext.class);
MethodType mt = MethodType.methodType(void.class, ThreadContext.class, CallSiteDescriptor.class);
Lookup l = MethodHandles.lookup();
try {
refs[0] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "new_type", mt).bindTo(this),
Expand Down

0 comments on commit da4616f

Please sign in to comment.