On Oct-26, Melvin Smith wrote: > At 06:25 PM 10/26/2003 -0800, Steve Fink wrote: > > .pcc_sub _main prototyped > > .pcc_begin_return > > .return 10 > > .return 20 > > .pcc_end_return > > .end > > It is still the same issue. This code explicitly mixes 2 call conventions. > _main is declared as prototyped so it will return 1 in I0 which signals that > it is returning its values in registers in prototyped convention. Your > call explicitly calls in non_prototyped mode which does not generate any > code to check the return convention since you are saying by your code > that you _know_ what the call convention is.
Oops, I meant to leave the "prototyped" off of the _main sub. This behaves indistinguishably from declaring it prototyped; it seg faults if called non_prototyped. I believe it's supposed to work when called with either style. Sorry for the bad example. Likewise, if I declare the .pcc_sub to be non_prototyped (so that both the call and declaration are non_prototyped), I get the same error: .sub _main .local Sub myfunc myfunc = newsub _myfunc .pcc_begin non_prototyped .pcc_call myfunc ret: .result $I0 .result $I1 .pcc_end print "Returned " print $I0 print "," print $I1 print "\n" end .end .pcc_sub _myfunc non_prototyped .pcc_begin_return .return 10 .return 20 .pcc_end_return .end % ./perl6 -Rt mini.imc . . . PC=60; OP=38 (invoke_p); ARGS=(P1=RetContinuation=PMC(0x40c04998)) PC=21; OP=1003 (restoretop) PC=22; OP=801 (shift_i_p); ARGS=(I17=0, P3=NULL) Error: '/home/sfink/parrot/parrot -t -r mini.imc ' failed died with signal 11 (SIGSEGV) > However, I see your point. To be orthogonal would suggest that we > implement the same feature for .pcc_call that we do for the .pcc_sub > declaration. If you left off the calling convention to .pcc_call it > would generate code to check for either. Although this would really > bloat the code, it might be wise to support the feature for some > instances. No, sorry, my bad example obscured the issue. I was not asking for a .pcc_begin that works in either case; I just want it to be possible to call a subroutine without a prototype and have it successfully return values. True, I would also like to be able to call the same subroutine *with* a prototype in another call site, but that is already implemented. I don't think allowing people to leave off the {non_,}prototyped declaration from .pcc_begin provides anything but superficial syntactic orthogonality; a call site really ought to know whether it can see the prototype of what it's calling or not! (Well... except I sometimes call non_prototyped even when I know the prototype, because pdd03 calling convention prototypes don't handle everything in a Perl6 prototype. But that's irrelevant here.) My brain doesn't seem to be working all that well this weekend... I'll throw in one more thing just because I know a certain Mr. P. Cawley dearly loves people to pile unrelated things into a single thread: could there be a way to expose which continuation to invoke when returning from a routine? In a regex, I'd really like a rule to be invoked with a "success" continuation and a "fail, so backtrack" continuation. And possibly with some more extreme failure continuations for cuts and commits and things. But right now the return continuation in P1 is hidden inside the PCC mechanism. (I guess I could just manually overwrite P1, but that seems like it's working against imcc rather than with it.) I'm faking it for now by returning a boolean status code, but that doesn't really feel like the "right" solution.