.sub main @MAIN
$P1 = whee()
print $P1
.end
.sub whee
$P2 = new PerlString
$P2 = "leo\n"
.return ($P2)
.end
We get a trace like:
0 set P16, PMC_C[2] - P16=PMCNULL,
3 set I0, 1 - I0=0,
6 set I1, 0 - I1=0,
9 set I2, 0 - I2=0,
12 set I3, 0 - I3=1,
15 set I4, 0 - I4=0,
18 set P0, P16 - P0=PMCNULL, P16=Sub=PMC(0xf90a98 Adr:0x190b580)
21 invokecc
# Calling sub 'whee'
# in file '(unknown file)' near line -1
28 new P30, 34 - P30=PMCNULL,
31 set P30, "leo\n" - P30=PerlString=PMC(0xf90a38 Str:"(null)"),
34 set P5, P30 - P5=PMCNULL, P30=PerlString=PMC(0xf90a38 Str:"leo\n")
37 set I0, 1 - I0=1,
40 set I1, 0 - I1=0,
43 set I2, 0 - I2=0,
46 set I3, 1 - I3=0,
49 set I4, 0 - I4=0,
52 returncc
22 set P30, P5 - P30=PMCNULL, P5=PerlString=PMC(0xf90a38 Str:"leo\n")
25 print P30 - P30=PerlString=PMC(0xf90a38 Str:"leo\n")
leo
27 end
Is it worth trying to optimize the mapping of $P2 to P5 there to avoid the extra assignment? possible?
> Is it worth trying to optimize the mapping of $P2 to P5 there to avoid
> the extra assignment? possible?
"parrot -Oc" did that until a few days ago. It was broken. The problem
arises with code like:
foo(a,b) # P5, P6
foo(b,a) # P6, P5 different mapping in the caller
.sub foo
.param pmc x
.param pmc y
.return (y,x) # different mapping in sub
At some point the (new) register allocator will use hints for simple
cases along with register renaming.
leo