Closed
Bug 607555
Opened 16 years ago
Closed 16 years ago
TM: fix interleaving of bytecode and LIR with TMFLAGS=recorder
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: n.nethercote, Assigned: n.nethercote)
Details
(Whiteboard: fixed-in-nanojit, fixed-in-tracemonkey, fixed-in-tamarin)
Attachments
(2 files)
|
2.80 KB,
patch
|
edwsmith
:
review+
|
Details | Diff | Splinter Review |
|
2.14 KB,
patch
|
dmandelin
:
review+
|
Details | Diff | Splinter Review |
The current interlaving of bytecode and LIR with TMFLAGS=recorder is totally
bogus. Here's an example:
start
ebx = parami 0 ebx
esi = parami 1 esi
edi = parami 2 edi
state = parami 0 ecx
------------------------------ # begin-loop
label1:
sp = ldi.state state[8]
rp = ldi.state state[24]
cx = ldi.state state[0]
eos = ldi.state state[12]
eor = ldi.state state[28]
strict = immi 0
------------------------------ # begin-interruptFlags-check
(void *) &JS_THREAD_DATA(cx)->interruptFlags = immi 0x8c7e818
ldi1 = ldi.all/v (void *) &JS_THREAD_DATA(cx)->interruptFlags/*0x8c7e818*/[0]
eqi1 = eqi ldi1, strict/*0*/
xf1: xf eqi1 -> pc=0x8ce229e imacpc=(nil) sp+0 rp+0 (GuardID=001)
00166: 86 trace 1
00169: 86 getlocal 0
00172: 86 getlocal 2
00175: 86 getlocal 0
00178: 86 getlocal 2
00181: 86 getelem
------------------------------ # end-interruptFlags-check
$stack7 = ldi.sp sp[-32]
sti.sp sp[0] = $stack7
ldi2 = ldi.sp sp[-16]
$stack9 = i2d ldi2
sti.sp sp[8] = ldi2
sti.sp sp[16] = $stack7
sti.sp sp[24] = ldi2
------------------------------ # begin-getelem(dense-array)
ldi3 = ldi.objclasp $stack7[4]
clasp = immi 0x83afae0
guard(class is Array) = eqi ldi3, clasp/*0x83afae0*/
xf2: xf guard(class is Array) -> pc=0x8ce22ad imacpc=(nil) sp+32 rp+0 (GuardID=002)
capacity = ldi.objcapacity $stack7[32]
ltui1 = ltui ldi2, capacity
xf3: xf ltui1 -> pc=0x8ce22ad imacpc=(nil) sp+32 rp+0 (GuardID=003)
ltui1 = ltui ldi2, capacity
xf3: xf ltui1 -> pc=0x8ce22ad imacpc=(nil) sp+32 rp+0 (GuardID=003)
immi1 = immi 3
lshi1 = lshi ldi2, immi1/*3*/
slots = ldi.objslots $stack7[36]
addi1 = addi slots, lshi1
ldi4 = ldi.slots addi1[4]
JSVAL_TAG_CLEAR = immi 0xffff0000
ltui2 = ltui ldi4, JSVAL_TAG_CLEAR/*0xffff0000*/
xf4: xf ltui2 -> pc=0x8ce22ad imacpc=(nil) sp+32 rp+0 (GuardID=004)
00182: 86 getlocal 3
00185: 86 div
00186: 86 setelem
ldd1 = ldd.slots addi1[0]
------------------------------ # end-getelem(dense-array)
It's just awful, and it makes it really hard to see what LIR resulted from
each bytecode.
The attached patch improves things greatly. New output:
start
ebx = parami 0 ebx
esi = parami 1 esi
edi = parami 2 edi
state = parami 0 ecx
------------------------------ # begin-loop
label1:
------------------------------ # begin-setup
sp = ldi.state state[8]
rp = ldi.state state[24]
cx = ldi.state state[0]
eos = ldi.state state[12]
eor = ldi.state state[28]
strict = immi 0
------------------------------ # begin-interruptFlags-check
(void *) &JS_THREAD_DATA(cx)->interruptFlags = immi 0x9d99818
ldi1 = ldi.all/v (void *) &JS_THREAD_DATA(cx)->interruptFlags/*0x9d99818*/[0]
eqi1 = eqi ldi1, strict/*0*/
xf1: xf eqi1 -> pc=0x9dfd29e imacpc=(nil) sp+0 rp+0 (GuardID=001)
------------------------------ # end-interruptFlags-check
------------------------------ # end-setup
00166: 86 trace 1
00169: 86 getlocal 0
$stack7 = ldi.sp sp[-32]
sti.sp sp[0] = $stack7
00172: 86 getlocal 2
ldi2 = ldi.sp sp[-16]
$stack9 = i2d ldi2
sti.sp sp[8] = ldi2
00175: 86 getlocal 0
sti.sp sp[16] = $stack7
00178: 86 getlocal 2
sti.sp sp[24] = ldi2
00181: 86 getelem
------------------------------ # begin-getelem(dense-array)
ldi3 = ldi.objclasp $stack7[4]
clasp = immi 0x83afae0
guard(class is Array) = eqi ldi3, clasp/*0x83afae0*/
xf2: xf guard(class is Array) -> pc=0x9dfd2ad imacpc=(nil) sp+32 rp+0 (GuardID=002)
capacity = ldi.objcapacity $stack7[32]
ltui1 = ltui ldi2, capacity
xf3: xf ltui1 -> pc=0x9dfd2ad imacpc=(nil) sp+32 rp+0 (GuardID=003)
immi1 = immi 3
lshi1 = lshi ldi2, immi1/*3*/
slots = ldi.objslots $stack7[36]
addi1 = addi slots, lshi1
ldi4 = ldi.slots addi1[4]
JSVAL_TAG_CLEAR = immi 0xffff0000
ltui2 = ltui ldi4, JSVAL_TAG_CLEAR/*0xffff0000*/
xf4: xf ltui2 -> pc=0x9dfd2ad imacpc=(nil) sp+32 rp+0 (GuardID=004)
ldd1 = ldd.slots addi1[0]
------------------------------ # end-getelem(dense-array)
std.sp sp[16] = ldd1
00182: 86 getlocal 3
ldi5 = ldi.sp sp[-8]
$stack10 = i2d ldi5
sti.sp sp[24] = ldi5
00185: 86 div
divd1 = divd ldd1, $stack10
std.sp sp[16] = divd1
Changes:
- Bytecode/LIR interleaving is much more correct (see below for more).
- The blank line shown after guards and labels is no longer there.
- A blank line before each bytecode is added.
Oh, god, it's so much prettier I want to cry.
Now, the reason it was so bad in the first place was that VerboseWriter has
this strange behaviour -- it clumps LIR instructions into groups, and will
only flush the group when it hits certain kinds of instructions, eg. guards.
The reason for this is that if you print/flush immediately, you don't get
the nice names from addName(), because addName() will be called after the
instruction is printed/flushed.
So what the patch does is just flush after more kinds of instructions. Most
notably, after stores and comments, neither of which are ever likely to be
given names (they're not expressions). This works great for TM because just
about every bytecode's LIR ends with either a store or a comment. The patch
also removes the flushing that currently happens after addxov/addjov-type
instructions, because they are expressions and so might be given a name. I
added the "begin-setup"/"end-setup" comments in jstracer.cpp because that
ensured that the LIR generated before the first bytecode was printed before
the first bytecode itself was printed (because we flush on comments).
Anyway, one remaining question: what effect does this have on Tamarin's LIR
dumps? I have no idea if the changes I have made will cause problems for
it. Ed?
Attachment #486283 -
Flags: review?(edwsmith)
| Assignee | ||
Comment 1•16 years ago
|
||
Attachment #486284 -
Flags: review?(dmandelin)
Comment 2•16 years ago
|
||
I am holding a parade in your honor in my head.
Comment 3•16 years ago
|
||
Looks nice. This doesn't seem to do anything bad to TR, and its a nice improvement. I looked at CodegenLIR; we were already calling flush() explicitly after each opcode, and our output also interleaves the JIT's state vector for variable types (indented), which acheived a blank line between each bytecode.
here's a snippet that is the first 4 bytecodes of some random loop:
B36: [Object~[A] String[S] *~[A] *~[A] *[A] *[A]] {} ()
loop label notnull = 0 2 3
merged label notnull = 0 2 3
36:label
B36:
[Object~[A] String[S] *~[A] *~[A] *[A] *[A]] {} ()
37:getlocal3
ldi10 = ldi.v vars[24]
sti.v vars[48] = ldi10
immi11 = immi 0
sti2c.t tags[6] = immi11/*0*/
[Object~[A] String[S] *~[A] *~[A] *[A] *[A]] {} (*~[A])
38:getlocal 4
ldi11 = ldi.v vars[32]
sti.v vars[56] = ldi11
sti2c.t tags[7] = immi11/*0*/
[Object~[A] String[S] *~[A] *~[A] *[A] *[A]] {} ...
40:lessthan
compare1 = calli.all #compare ( immi1/*0xb76b8028 core*/ ldi10 ldi11 )
immi12 = immi 8
xori1 = xori compare1, immi12/*8*/
lti1 = lti xori1, immi12/*8*/
sti.v vars[48] = lti1
immi13 = immi 6
sti2c.t tags[6] = immi13/*6*/
[Object~[A] String[S] *~[A] *~[A] *[A] *[A]] {} ...
41:iffalse 87
sti.v vars[48] = lti1
sti2c.t tags[6] = immi13/*6*/
eqi2 = eqi lti1, immi11/*0*/
jf lti1 -> unpatched
[Object~[A] String[S] *~[A] *~[A] *[A] *[A]] {} ()
I've been looking at interleaved output for years, and while my brain is trained, i keep wishing I'd spent the time to write something to generate simple multi-column output. Maybe simple buffering library so you can printf into multiple columns, and tell it where the "table" rows are, or maybe some prefix for each line that a post-processor could use. Heck, just injecting some html tags (<table>, tr, tb) might make verbose output readable in a browser, or give enough clues to a perl script to produce navigable output. (a table per function maybe?...)
Updated•16 years ago
|
Attachment #486283 -
Flags: review?(edwsmith) → review+
Updated•16 years ago
|
Attachment #486284 -
Flags: review?(dmandelin) → review+
| Assignee | ||
Comment 4•16 years ago
|
||
http://hg.mozilla.org/projects/nanojit-central/rev/53c69eca7d94
http://hg.mozilla.org/tracemonkey/rev/3eb40ab1f61f
http://hg.mozilla.org/tracemonkey/rev/6b9f7d6cd601
Whiteboard: fixed-in-nanojit, fixed-in-tracemonkey
Comment 5•16 years ago
|
||
Whiteboard: fixed-in-nanojit, fixed-in-tracemonkey → fixed-in-nanojit, fixed-in-tracemonkey, fixed-in-tamarin
Comment 6•16 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•