thanks very much for your answer.
For my first question:
in my opinion, the sidetrace was a branch code path of the corresponding trace. and with your
explanation, i see the snapshot:
1.sidetrace was created from snapshot;
(the snapshot here means it was taken before the code path of a trace was branched, right?)
2.the registers should be changed according to the snapshot when the LuaJIT fell back to
interpreter from compiler;
(but a trace can contain many snapshots, so the registers will be changed according to all the
snapshots in a trace, right?)
3.there was a guard instruction next to each snapshot, and in case of failure, the LuaJIT will be
instructed to restore the previous snapshot.
(the failure here meas the LuaJIT fell back to interpreter from compiler? ulteriorly, a trace jump
to another trace(sidetrace) must fall back to interpreter from compiler? if so, does it contradicts
point 2 which pointed out the registers will be changed according to all the snapshots in a trace
when fallback?)
For the second question:
here is the minimal code:
1 local random = math.random
2 local split = require("ngx.re").split
3 local v = require("jit.v")
4 v.on("testTrace.log")
5
6 local function f(path)
7 local m, err = split(path, "/", "jo")
8 if err then
9 error(err)
10 end
11
12 return #m
13 end
14
15 local pathList = {
16 "/test1/test2/test3/test4/test5",
17 "/test1/test2/test3/test4",
18 "/test1/test2/test3",
19 "/test1/test2",
20 "/test1"
21 }
22
23 local max, len = 10e1, #pathList
24 for _ = 1, max do
25 f(pathList[random(1, len)])
26 end
and it's trace log:
[TRACE 1 lrucache.lua:76 loop]
[TRACE 2 re.lua:209 loop]
[TRACE 3 (2/13) re.lua:229 -> 2]
[TRACE --- t.lua:24 -- inner loop in root trace at re.lua:210]
[TRACE 4 (2/1) re.lua:59 -> 2]
[TRACE 5 (2/28) re.lua:229 -> 2]
[TRACE 6 (3/0) re.lua:229 -> 2]
[TRACE 7 (2/18) re.lua:59 -> 2]
[TRACE 8 (4/4) re.lua:264 -> 2]
how do i analyze [TRACE --- t.lua:24 -- inner loop in root trace at re.lua:210]?
and thank you again!
Tweyseo