The fixuptable may hold items of different types. I did define item
type "0" holding a segment nr and a branch offset.
Finally to have a non local return from the evaled code, I did split
the runops loop into two parts. The inner part handles resumes after
e.g. the trace opcode, the outer loop handles intersegment jumps,
marked with the resume_flag being 2.
To make this play with JIT too, I had to make the "invoke" opcode a
restartable opcode, which might be to expensive for the normal case.
So we might want to have an additional "invoke_cs" or "eval" opcode,
that might leave the current code segment.
Here is one test with trace, to better see what's goin on:
$ imcc -t t/syn/eval_3.imc
PC=0; OP=73 (set_i_ic); ARGS=(I1=0, 5)
PC=3; OP=87 (set_s_sc); ARGS=(S0=(null), ".sub _e\nif I1 == 6 g")
PC=6; OP=841 (compreg_p_sc); ARGS=(P2, "PIR")
PC=9; OP=838 (compile_p_p_s); ARGS=(P0, P2=Compiler=PMC(0x8183328), \
S0=".sub _e\nif I1 == 6 g")
PC=13; OP=322 (inc_i); ARGS=(I1=5)
PC=15; OP=837 (invoke)
*** invoking EVAL_1
PC=0; OP=158 (eq_i_ic_ic); ARGS=(I1=6, 6, 5)
PC=5; OP=739 (branch_cs_ic); ARGS=(0)
*** back from EVAL_1
*** Resume at seg 0 ofs 13
PC=13; OP=322 (inc_i); ARGS=(I1=6)
PC=15; OP=837 (invoke)
*** invoking EVAL_1
PC=0; OP=158 (eq_i_ic_ic); ARGS=(I1=7, 6, 5)
PC=4; OP=0 (end)
*** back from EVAL_1
PC=16; OP=21 (print_i); ARGS=(I1=7)
7PC=18; OP=26 (print_sc); ARGS=("\n")
PC=20; OP=0 (end)
Have fun,
leo
No, this isn't how we're doing intersegment branches. Plain jump will
work just fine for this, the only thing we'd potentially need is the
address of the routine to jump through, and that only if we're not
going to require sub PMCs for everything. (And, honestly, I am and
have been leaning this way)
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk
> At 4:53 PM +0100 1/22/03, Leopold Toetsch wrote:
>
>> This patch adds a new opcde for intersegment branches. I named it
>> "branch_cs". This takes one $I param, which is the entry in the
>> fixuptable.
>> Thanks to Jason Gloudon for hinting me, how to handle this beast.
>> (s thread "[perl #20315] [PATCH] eval - inter code segment branches")
>
>
> No, this isn't how we're doing intersegment branches. Plain jump will
> work just fine for this, the only thing we'd potentially need is the
> address of the routine to jump through, and that only if we're not going
> to require sub PMCs for everything. (And, honestly, I am and have been
> leaning this way)
IMHO plain jumps do not work:
- How to get out of JIT code?
- How to jump in not yet JItted code
- How to setup new bounds for current code segment?
- How to run a plain jump with CGoto or Prederef?
leo
Sure they do. They work as well as jumps within code, which also has
a not-insignificant potential for problems.
But the issues you raised are some of the reasons I'd prefer
inter-segment jumping to be done via sub dispatch.
> At 6:13 PM +0100 1/22/03, Leopold Toetsch wrote:
>> IMHO plain jumps do not work:
>
>
> Sure they do. They work as well as jumps within code, which also has a
> not-insignificant potential for problems.
>
> But the issues you raised are some of the reasons I'd prefer
> inter-segment jumping to be done via sub dispatch.
Ok then:
output_is(<<'CODE', <<'OUT', "intersegment branch");
# #!/usr/bin/perl -w
# my $i= 5;
# LAB:
# $i++;
# eval("goto LAB if ($i==6)");
# print "$i\n";
#
# 7
#####
.sub _test
I1 = 5
$S0 = ".sub _e\nif I1 == 6 goto LAB\nend\n.end\n"
compreg P2, "PIR"
compile P0, P2, $S0
LAB:
inc I1
invoke
print I1
print "\n"
end
.end
CODE
7
OUT