# New Ticket Created by Kenneth A Graves # Please include the string: [perl #23355] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=23355 >
As mentioned in another thread, I've found a couple of cases where parrot loses track of what it should be doing when dealing with packfiles. 1) I'm assuming a model where all external sub calls get translated into load_bytecode/$P0=global/.pcc_call $P0. If two functions in the same packfile are called, and the packfile is auto-generated from PIR, there is a segfault. It works for precompiled PBC packfiles, and for rearranged code that only calls C<load_bytecode "temp.imc"> once. 2) Changing all sub calls, including those internal to the current file, into the C<$P0 = global $S0> form would be easier for the compiler to generate. It works for precompiled PBC. It doesn't work for compile&run from PIR. Tests demonstrating both failures attached (as a patch to languages/imcc/t/syn/file.t). --kag -- attachment 1 ------------------------------------------------------ url: http://rt.perl.org/rt2/attach/62923/46322/a21b92/packfail.patch
--- t/syn/file.t.~1.6.~ 2003-08-16 19:00:09.000000000 -0400 +++ t/syn/file.t 2003-08-18 02:10:04.000000000 -0400 @@ -1,6 +1,6 @@ #!perl use strict; -use TestCompiler tests => 8; +use TestCompiler tests => 11; use lib '../../lib'; use Parrot::Config; @@ -262,6 +262,107 @@ back OUT +# write sub2 +open FOO, ">temp.imc" or die "Cant write temp.imc\n"; +print FOO <<'ENDF'; +.pcc_sub _sub2 prototyped + print "sub2\n" + .pcc_begin_return + .pcc_end_return + end +.end +ENDF +# compile it + +output_is(<<'CODE', <<'OUT', "twice call sub in external imc, return"); +.pcc_sub _sub1 prototyped + print "sub1\n" + load_bytecode "temp.imc" + print "loaded\n" + $P0 = global "_sub2" + .pcc_begin prototyped + .pcc_call $P0 + ret: + .pcc_end + print "back\n" + print "sub1 again\n" + load_bytecode "temp.imc" + print "loaded again\n" + $P0 = global "_sub2" + .pcc_begin prototyped + .pcc_call $P0 + ret_again: + .pcc_end + print "back again\n" + end +.end +CODE +sub1 +loaded +sub2 +back +sub1 again +loaded again +sub2 +back again +OUT + +output_is(<<'CODE', <<'OUT', "call internal sub like external"); +.pcc_sub _sub1 prototyped + print "sub1\n" + $P0 = global "_sub2" + .pcc_begin prototyped + .pcc_call $P0 + ret: + .pcc_end + print "back\n" + end +.end + +.pcc_sub _sub2 prototyped + print "sub2\n" + .pcc_begin_return + .pcc_end_return + end +.end +CODE +sub1 +sub2 +back +OUT + +# write subs +open FOO, ">temp.imc" or die "Cant write temp.imc\n"; +print FOO <<'ENDF'; +.pcc_sub _sub1 prototyped + print "sub1\n" + $P0 = global "_sub2" + .pcc_begin prototyped + .pcc_call $P0 + ret: + .pcc_end + print "back\n" + end +.end + +.pcc_sub _sub2 prototyped + print "sub2\n" + .pcc_begin_return + .pcc_end_return + end +.end +ENDF +# compile it + +system("imcc$PConfig{exe} -o temp.pbc temp.imc"); + +use Test::More; +is(`imcc$PConfig{exe} temp.pbc`, <<OUT, "call internal sub like external, precompiled"); +sub1 +sub2 +back +OUT + END { unlink $file; unlink "temp.imc";