Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Arg re-ordering to simplify stack handling.
  • Loading branch information
jnthn committed Feb 21, 2013
1 parent da77c72 commit aa2d439
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions lib/QAST/JASTCompiler.nqp
Expand Up @@ -870,10 +870,10 @@ QAST::OperationsJAST.add_core_op('for', -> $qastcomp, $op {
}
my $cs_idx := $*CODEREFS.get_callsite_idx(@callsite, []);
if +@callsite > $*MAX_ARGS_O { $*MAX_ARGS_O := +@callsite }
$inv_il.append(JAST::Instruction.new( :op('aload_1') ));
$inv_il.append(JAST::Instruction.new( :op('aload'), $block_tmp ));
$inv_il.append(JAST::PushIndex.new( :value($cs_idx) ));
$inv_il.append(JAST::Instruction.new( :op('invokestatic'), $TYPE_OPS, 'invoke', 'Void', $TYPE_TC, $TYPE_SMO, 'Integer' ));
$inv_il.append(JAST::Instruction.new( :op('aload_1') ));
$inv_il.append(JAST::Instruction.new( :op('invokestatic'), $TYPE_OPS, 'invoke', 'Void', $TYPE_SMO, 'Integer', $TYPE_TC ));

# Load result onto the stack, unless in void context.
if $res {
Expand Down Expand Up @@ -1081,7 +1081,6 @@ sub process_args($qastcomp, $node, $il, $first, :$inv_temp) {
}
QAST::OperationsJAST.add_core_op('call', -> $qastcomp, $node {
my $il := JAST::InstructionList.new();
$il.append(JAST::Instruction.new( :op('aload_1') ));

# Get thing to call.
my $invokee;
Expand All @@ -1101,7 +1100,8 @@ QAST::OperationsJAST.add_core_op('call', -> $qastcomp, $node {
# Emit call.
$*STACK.obtain($invokee);
$il.append(JAST::PushIndex.new( :value($cs_idx) ));
$il.append(JAST::Instruction.new( :op('invokestatic'), $TYPE_OPS, 'invoke', 'Void', $TYPE_TC, $TYPE_SMO, 'Integer' ));
$il.append(JAST::Instruction.new( :op('aload_1') ));
$il.append(JAST::Instruction.new( :op('invokestatic'), $TYPE_OPS, 'invoke', 'Void', $TYPE_SMO, 'Integer', $TYPE_TC ));

# Load result onto the stack, unless in void context.
if $*WANT != $RT_VOID {
Expand Down Expand Up @@ -1144,7 +1144,6 @@ QAST::OperationsJAST.add_core_op('callmethod', -> $qastcomp, $node {

# Look up method.
$il.append(JAST::Instruction.new( :op('aload_1') ));
$il.append(JAST::Instruction.new( :op('dup') ));
$il.append(JAST::Instruction.new( :op('aload'), $inv_temp ));
if $name_tmp {
$il.append(JAST::Instruction.new( :op('aload'), $name_tmp ));
Expand All @@ -1156,7 +1155,8 @@ QAST::OperationsJAST.add_core_op('callmethod', -> $qastcomp, $node {

# Emit call.
$il.append(JAST::PushIndex.new( :value($cs_idx) ));
$il.append(JAST::Instruction.new( :op('invokestatic'), $TYPE_OPS, 'invoke', 'Void', $TYPE_TC, $TYPE_SMO, 'Integer' ));
$il.append(JAST::Instruction.new( :op('aload_1') ));
$il.append(JAST::Instruction.new( :op('invokestatic'), $TYPE_OPS, 'invoke', 'Void', $TYPE_SMO, 'Integer', $TYPE_TC ));

# Load result onto the stack, unless in void context.
if $*WANT != $RT_VOID {
Expand Down
6 changes: 3 additions & 3 deletions src/org/perl6/nqp/runtime/CompilationUnit.java
Expand Up @@ -40,7 +40,7 @@ public static void enterFromMain(Class<?> cuType, int entryCodeRefIdx, String[]
throws Exception {
ThreadContext tc = (new GlobalContext()).mainThread;
CompilationUnit cu = setupCompilationUnit(tc, cuType);
Ops.invoke(tc, cu.codeRefs[entryCodeRefIdx], -1);
Ops.invoke(cu.codeRefs[entryCodeRefIdx], -1, tc);
}

/**
Expand Down Expand Up @@ -82,7 +82,7 @@ public void initializeCompilationUnit(ThreadContext tc) {
int dIdx = deserializeIdx();
if (dIdx >= 0)
try {
Ops.invoke(tc, codeRefs[dIdx], -1);
Ops.invoke(codeRefs[dIdx], -1, tc);
}
catch (Exception e)
{
Expand All @@ -98,7 +98,7 @@ public void runLoadIfAvailable(ThreadContext tc) {
int lIdx = loadIdx();
if (lIdx >= 0)
try {
Ops.invoke(tc, codeRefs[lIdx], -1);
Ops.invoke(codeRefs[lIdx], -1, tc);
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -929,7 +929,7 @@ public static SixModelObject captureposarg(SixModelObject obj, long idx, ThreadC
/* Invocation. */
private static final CallSiteDescriptor emptyCallSite = new CallSiteDescriptor(new byte[0], null);
private static final CallSiteDescriptor invocantCallSite = new CallSiteDescriptor(new byte[] { CallSiteDescriptor.ARG_OBJ }, null);
public static void invoke(ThreadContext tc, SixModelObject invokee, int callsiteIndex) throws Exception {
public static void invoke(SixModelObject invokee, int callsiteIndex, ThreadContext tc) throws Exception {
// If it's lexotic, throw the exception right off.
if (invokee instanceof Lexotic) {
LexoticException throwee = tc.theLexotic;
Expand Down

0 comments on commit aa2d439

Please sign in to comment.