Improve vm/Opcodes.h comments
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
People
(Reporter: jorendorff, Assigned: jorendorff)
Details
Attachments
(24 files, 3 obsolete files)
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
I'm documenting some of the bytecode invariants, as part of trying to make a safer BytecodeEmitter.
Updated•5 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
Updated•5 years ago
|
Assignee | ||
Comment 2•5 years ago
|
||
The baseline jit's OPCODE_LIST macro is removed at the same time, rather than
try to keep it in sync with Opcodes.h. This touches a bit more code than
expected because OPCODE_LIST treated JSOP_FORCEINTERPRETER as special. Happily
it turns out to be easy to work around that.
Depends on D57517
Assignee | ||
Comment 3•5 years ago
|
||
I initially used a script to do this. I checked that sort(1) gives the same
output on the before and after versions of the file.
This does not follow the existing categorization exactly. The plan is to
re-categorize the opcodes in a later patch in this stack.
Depends on D57521
Assignee | ||
Comment 4•5 years ago
|
||
make_opcode_doc.py allows groups of related opcodes, but checks that they share
all relevant details (stack budget, etc). If they don't match, the script bails
out with an error. Rearranging the bytecodes had the side effect of breaking up
some of these groups, so this changeset simply copies a couple of existing
comments.
(I placed JSOP_INC and JSOP_DEC with JSOP_ADD and JSOP_SUB because they are
optimized versions of the same operation. They don't increment or decrement
variables. inc
is always equivalent to one; add
. The other group that was
broken up included both JSOP_EQ/NE and JSOP_LT/GT/LE/GE. The new ordering is
the ordering in the standard.)
Depends on D57522
Assignee | ||
Comment 5•5 years ago
|
||
Depends on D57523
Assignee | ||
Comment 6•5 years ago
|
||
A few words on generally what I'm trying to do with these edits:
-
I want to know what counts as valid bytecode, because I want to make
a safe BytecodeEmitter type that, when used via its public methods,
can't produce invalid bytecode that would lead to crashes.Therefore, I'm documenting all (!) the rules I an think of, using
the word "must" to mark them as rules.Often the rules are unclear, because it's been pretty informal. This
exercise therefore involves some judgment calls and other places
where I still use the word "must" but on a deliberately vague
requirement ("All paths into the span must establish that
invariant.") -
I try to let the
Stack:
line do its job, and not spend prose words
telling the story of what all values an instruction pushes or pops.Generally, I want to spend more words on why things are like this,
and less words minutely describing stack traffic. -
I'm changing the verbs in the first sentence or two of each comment
to the imperative: "Pushes" -> "Push". This amounts to a personal
preference. I like the directness of "Push null." They are
instructions, after all.There is a limit; I'll keep saying "This instruction never throws",
not "Don't throw." -
The comments in later patches say "binding" a lot. That's because
it's shorter than "local or global variable, function argument,
function
,class
,import
,export
, or random other thing I
forgot, or that has been added to the language in the thirty seconds
since I wrote this".
Depends on D57524
Assignee | ||
Comment 7•5 years ago
|
||
Depends on D57525
Assignee | ||
Comment 8•5 years ago
|
||
Depends on D57526
Assignee | ||
Comment 9•5 years ago
|
||
Depends on D57527
Assignee | ||
Comment 10•5 years ago
|
||
Depends on D57528
Assignee | ||
Comment 11•5 years ago
|
||
Depends on D57529
Assignee | ||
Comment 12•5 years ago
|
||
Depends on D57530
Assignee | ||
Comment 13•5 years ago
|
||
Depends on D57531
Assignee | ||
Comment 14•5 years ago
|
||
Depends on D57532
Assignee | ||
Comment 15•5 years ago
|
||
Depends on D57534
Assignee | ||
Comment 16•5 years ago
|
||
Depends on D57535
Assignee | ||
Comment 17•5 years ago
|
||
Depends on D57536
Assignee | ||
Comment 18•5 years ago
|
||
Depends on D57538
Assignee | ||
Comment 19•5 years ago
|
||
filter()
returned a list in Python 2 and returns an iterator in Python 3.
Depends on D57539
Assignee | ||
Comment 20•5 years ago
|
||
Depends on D57540
Assignee | ||
Comment 21•5 years ago
|
||
Now that they're in a reasonable order in Opcodes.h, it's better to keep that
order for the docs.
Depends on D57541
Comment 22•5 years ago
|
||
Comment 23•5 years ago
|
||
Backed out 9 changesets (bug 1602530) for SM bustage at /gdb-tests.cpp on a CLOSED TREE.
Backout link: https://hg.mozilla.org/integration/autoland/rev/aa8ef4f721768ae09143dc6cfb932f1f67c6476e
Push with failures: https://treeherder.mozilla.org/#/jobs?repo=autoland&resultStatus=testfailed%2Cbusted%2Cexception&revision=f128305cb5c0ab61124a142ee1a1a654edf290d9&selectedJob=282416675
Log link: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=282416675&repo=autoland&lineNumber=7141
Log snippet:
[task 2019-12-23T18:06:32.338Z] SpiderMonkey unwinder is disabled by default, to enable it type:
[task 2019-12-23T18:06:32.338Z] enable unwinder .* SpiderMonkey
[task 2019-12-23T18:06:32.338Z] Breakpoint 1: file /builds/worker/workspace/build/src/js/src/gdb/gdb-tests.cpp, line 53.
[task 2019-12-23T18:06:32.338Z] [Thread debugging using libthread_db enabled]
[task 2019-12-23T18:06:32.338Z] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[task 2019-12-23T18:06:32.338Z] [New Thread 0x7ffff6a71700 (LWP 7722)]
[task 2019-12-23T18:06:32.338Z] [Thread 0x7ffff6a71700 (LWP 7722) exited]
[task 2019-12-23T18:06:32.338Z] [New Thread 0x7ffff5eff700 (LWP 7723)]
[task 2019-12-23T18:06:32.338Z] [New Thread 0x7ffff5d01700 (LWP 7724)]
[task 2019-12-23T18:06:32.338Z] [New Thread 0x7ffff5b03700 (LWP 7725)]
[task 2019-12-23T18:06:32.338Z] [New Thread 0x7ffff5905700 (LWP 7726)]
[task 2019-12-23T18:06:32.338Z] [New Thread 0x7ffff5707700 (LWP 7727)]
[task 2019-12-23T18:06:32.338Z] [New Thread 0x7ffff5509700 (LWP 7728)]
[task 2019-12-23T18:06:32.338Z] [New Thread 0x7ffff530b700 (LWP 7729)]
[task 2019-12-23T18:06:32.338Z] [New Thread 0x7ffff510d700 (LWP 7730)]
[task 2019-12-23T18:06:32.338Z]
[task 2019-12-23T18:06:32.338Z] Thread 1 "gdb-tests" hit Breakpoint 1, breakpoint () at /builds/worker/workspace/build/src/js/src/gdb/gdb-tests.cpp:53
[task 2019-12-23T18:06:32.338Z] 53 fprintf(stderr, "Called " FILE ":breakpoint\n");
[task 2019-12-23T18:06:32.338Z] #1 Fragment_typedef_printers_one::run (this=<Fragment_typedef_printers_one::singleton>, cx=, argv=) at /builds/worker/workspace/build/src/js/src/gdb/tests/typedef-printers.cpp:8
[task 2019-12-23T18:06:32.338Z] 8 breakpoint();
[task 2019-12-23T18:06:32.338Z] (gdb) quit
[task 2019-12-23T18:06:32.338Z]
[task 2019-12-23T18:06:32.338Z] tests failed:
[task 2019-12-23T18:06:32.339Z] test-Interpreter.py
[task 2019-12-23T18:06:32.354Z] + BUILD_STATUS=2
Comment 24•5 years ago
|
||
The relevant portion of log is:
[task 2019-12-23T18:04:53.952Z] Unexpected result:
[task 2019-12-23T18:04:53.952Z] expected: '{ fp_ = , sp = fp_.slots() + 2, pc = (JSOP_IFEQ) }'
[task 2019-12-23T18:04:53.952Z] actual: '{ fp_ = , sp = fp_.slots() + 2, pc = (-105) }'
Part 3 reordered opcodes and we hit a signed-vs-unsigned issue in the GDB tests.
If I can find a simple fix, I'll reland this, otherwise we can wait until Jason is back. This work isn't urgent.
Comment 25•5 years ago
|
||
Once we re-order the opcodes, a gdb-test fails because JSOP_IFEQ is now >
128. This works around that problem by changing the test to look for a
different opcode.
Comment 26•5 years ago
|
||
Tweaked the testcase. Will check on try and then push Jason's patches.
Comment 27•5 years ago
|
||
Assignee | ||
Comment 28•5 years ago
|
||
Thanks.
Comment 29•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/a88c006da5fc
https://hg.mozilla.org/mozilla-central/rev/9585633a4e58
https://hg.mozilla.org/mozilla-central/rev/d28fd3e593c7
https://hg.mozilla.org/mozilla-central/rev/275f83010d64
https://hg.mozilla.org/mozilla-central/rev/aa0fdb572be9
https://hg.mozilla.org/mozilla-central/rev/752cb5e796ba
https://hg.mozilla.org/mozilla-central/rev/cfbe639af441
https://hg.mozilla.org/mozilla-central/rev/6be587fe00dc
https://hg.mozilla.org/mozilla-central/rev/c2077ae6552a
https://hg.mozilla.org/mozilla-central/rev/b57384d314f4
Comment 30•5 years ago
|
||
Comment 31•5 years ago
|
||
Updated•5 years ago
|
Comment 32•5 years ago
|
||
Comment 33•5 years ago
|
||
Comment 34•5 years ago
|
||
Comment 35•5 years ago
|
||
Depends on D59061
Updated•5 years ago
|
Updated•5 years ago
|
Comment 36•5 years ago
|
||
Comment 37•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/cf4a4a4e82ba
https://hg.mozilla.org/mozilla-central/rev/e3335a38dc67
https://hg.mozilla.org/mozilla-central/rev/12cf8297599d
https://hg.mozilla.org/mozilla-central/rev/0ea55d6ffa02
https://hg.mozilla.org/mozilla-central/rev/2093d0d74df8
https://hg.mozilla.org/mozilla-central/rev/623b2526fb4a
https://hg.mozilla.org/mozilla-central/rev/0202261dc26f
https://hg.mozilla.org/mozilla-central/rev/01562cd62979
https://hg.mozilla.org/mozilla-central/rev/8a218ed395e5
https://hg.mozilla.org/mozilla-central/rev/1b3122a089d1
https://hg.mozilla.org/mozilla-central/rev/ff59ddb49234
https://hg.mozilla.org/mozilla-central/rev/d25bcced29f6
https://hg.mozilla.org/mozilla-central/rev/1cfad5c14c54
https://hg.mozilla.org/mozilla-central/rev/d31d6754fce8
Comment 38•4 years ago
|
||
The leave-open keyword is there and there is no activity for 6 months.
:jorendorff, maybe it's time to close this bug?
Assignee | ||
Updated•4 years ago
|
Updated•4 years ago
|
Description
•