Jeff Clites <[EMAIL PROTECTED]> wrote:
On Jan 5, 2004, at 5:32 AM, Leopold Toetsch wrote:
The return value is only returned, when I3 != 0. For your example that
shouldn't be the case (I3 is unused aka zero). So there isn't any
return
value passed back.
Yep, the second time through I find REG_INT(3) (that is, interpreter->int_reg.registers[3]) set to 1 in thread_func().
Wherever that comes from, just insert a line
set I3, 0
before you invoke the return continutation. That's the official way, to inidicate a void return value.
I tracked down how I3 was getting set, even though from the pasm it looks like nothing should be changing it. It turns out to be a side effect of the use of NCI in the threading implementation; the problem wasn't showing up for you since you have CAN_BUILD_CALL_FRAMES defined (but I don't). So I have a patch below which avoids setting I3 to 1 if the return value (in P5) is null--the generated NCI stubs were setting I3 to 1 for functions whose signatures indicate that they return PMCs, even if there was no PMC returned. (With this patch, the script I posted works, and the nci.t tests continue to pass.)
Also, looking at the i386 Parrot_jit_build_call_func() code I noticed that in the case of a "P" return type, it was setting a PMC register but incrementing the int register count. I have a patch below to fix this also; I don't have a way to test it, though.
JEff
Index: build_tools/build_nativecall.pl
===================================================================
RCS file: /cvs/public/parrot/build_tools/build_nativecall.pl,v
retrieving revision 1.35
diff -u -r1.35 build_nativecall.pl
--- build_tools/build_nativecall.pl 3 Jan 2004 20:03:38 -0000 1.35
+++ build_tools/build_nativecall.pl 6 Jan 2004 08:35:33 -0000
@@ -314,8 +314,14 @@
sub set_return_count {
my ($stack, $int, $string, $pmc, $num) = @_;
+
+ my $pmc_string;
+
+ if( $pmc ) { $pmc_string = "return_data ? $pmc : 0" }
+ else { $pmc_string = 0 }
+
print NCI <<FOOTER;
- set_return_val(interpreter, $stack, $int, $string, $pmc, $num);
+ set_return_val(interpreter, $stack, $int, $string, $pmc_string, $num);
return;
}
Index: jit/i386/jit_emit.h =================================================================== RCS file: /cvs/public/parrot/jit/i386/jit_emit.h,v retrieving revision 1.99 diff -u -r1.99 jit_emit.h --- jit/i386/jit_emit.h 3 Jan 2004 13:22:45 -0000 1.99 +++ jit/i386/jit_emit.h 6 Jan 2004 08:37:22 -0000 @@ -3050,7 +3050,7 @@ case 'v': /* void - do nothing */ break; case 'P': - jit_emit_mov_mr_i(pc, &PMC_REG(next_i++), emit_EAX); + jit_emit_mov_mr_i(pc, &PMC_REG(next_p++), emit_EAX); break; case 'p': /* make a new unmanaged struct */ /* save return value on stack */