[meta] Auto generate MIR, LIR, and WarpCacheIRTranspiler boilerplate
Categories
(Core :: JavaScript Engine: JIT, enhancement, P3)
Tracking
()
People
(Reporter: caroline, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: meta)
Attachments
(23 files, 10 obsolete files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
Much of MIR class definition, LIR code, and WarpCacheIRTranspiler is very mechanical and can be generated similarly to what was done for auto generating CacheIR code.
Reporter | ||
Comment 1•4 years ago
|
||
Reporter | ||
Comment 2•4 years ago
|
||
Depends on D111043
Reporter | ||
Comment 3•4 years ago
|
||
Depends on D111044
Reporter | ||
Comment 4•4 years ago
|
||
Depends on D111045
Reporter | ||
Comment 5•4 years ago
|
||
Depends on D111046
Reporter | ||
Comment 6•4 years ago
|
||
Depends on D111047
Reporter | ||
Comment 7•4 years ago
|
||
Depends on D111048
Reporter | ||
Comment 8•4 years ago
|
||
Depends on D111049
Reporter | ||
Comment 9•4 years ago
|
||
Depends on D111050
Comment 10•4 years ago
|
||
The obvious question for me is, "does this reduce essential complexity?", and the answer is imo not obviously "yes". Looking at a few of the patches here, I see that generally the YAML is about as long (lines of code) as the C++ it replaces. Add to that that the YAML has ad-hoc semantics, is untyped and indentation-structured, and is processed by a dynamically typed program, and I have a hard time seeing the upside compared to, say, further macroization of the MIR. I agree that the MIR boilerplate is annoying, but does this patch set address anything deep or open up for other important work in the future?
Is there a backgrounder for this work somewhere, a design doc or notes from a discussion?
Re the implementation of the idea, why barely-structured YAML and not well-structured JSON? Why untyped Python and not TypeScript or Go?
(Sorry to come across as negative; I'm only looking for enlightenment.)
Comment 11•4 years ago
•
|
||
The main background for this work is that we are currently using a very similar system for supporting CacheIR (see CacheIROps.yaml and GenerateCacheIRFiles.py), and it has been an overwhelming success. Adding a new CacheIR op in baseline is very smooth: you define it in the yaml file, you use it in CacheIR.cpp
, and you implement it in CacheIRCompiler.cpp
. We previously had a macro-based system for handling CacheIR boilerplate, but it was already creaking under its own weight, and we had several new features to add. Switching to a code generator was an unambiguous improvement.
Transpiling a new CacheIR op in Warp is less nice: if you add a new MIR op, you need to write somewhat finicky code in at least five places, most of which is boilerplate. The purpose of this project is to explore whether we can get similar benefits when auto-generating MIR that we saw from CacheIR. In a perfect world, we could add new functionality -- say, supporting a new inlineable native function -- while only touching the yaml files (to define boilerplate), CacheIR.cpp
(to decide when to use the new op), CacheIRCompiler.cpp
(to generate IC code), and CodeGenerator.cpp
(to generate Warp/Ion code). We might not be able to get there, but it seems valuable to at least try writing a prototype and see how it feels. (Note that the current patches are just Caroline's first draft being put up for feedback. There will likely be significant changes. If it turns out that, even after polishing, some of the boilerplate we're hoping to remove was better without the code generator, we won't land those parts.)
One other benefit of auto-generation is that it makes it easier to experiment with different MIR implementations: for example, devirtualizing MIR in favour of auto-generated switch statements.
In terms of implementation choices: Python is nice because it's already well-supported in our build system. YAML over JSON was pretty arbitrary: YAML is a little nicer to write by hand, and JSON doesn't support comments. Neither choice has had any issues in the CacheIR implementation, It's certainly possible that we could run into problems in the future, but this code runs as part of the build process and produces the same output every time, so there's not a lot of room for bugs to slip in.
Comment 12•4 years ago
|
||
Thanks for the backgrounder / perspective. I'll be interested in following this work and see where it goes. Clearly the amount of boilerplate in Ion is smaller these days than it used to be but is still annoyingly large, and I have no arguments against generating code where we can.
(I admit to strong negative biases re untyped languages, untyped data, and indentation-based structuring; that said, I don't really think justifying them with "it's what we've done in the past" is all that great either. A discussion for another day. "JSON doesn't support comments" seems highly relevant, though.)
Updated•4 years ago
|
Updated•4 years ago
|
Reporter | ||
Comment 13•4 years ago
|
||
Depends on D111051
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Comment 14•4 years ago
|
||
Comment 15•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/bbce3487d14f
https://hg.mozilla.org/mozilla-central/rev/bf6f19cc2331
https://hg.mozilla.org/mozilla-central/rev/2cb147cc9ae2
https://hg.mozilla.org/mozilla-central/rev/9ce262e1f44b
https://hg.mozilla.org/mozilla-central/rev/ed0d74615437
https://hg.mozilla.org/mozilla-central/rev/5f6a27d7e131
https://hg.mozilla.org/mozilla-central/rev/566c2b19754e
https://hg.mozilla.org/mozilla-central/rev/822533d1632f
https://hg.mozilla.org/mozilla-central/rev/b13552f6d81e
https://hg.mozilla.org/mozilla-central/rev/cbebfcacd934
Reporter | ||
Comment 16•4 years ago
|
||
Reporter | ||
Comment 17•4 years ago
|
||
Depends on D116775
Reporter | ||
Comment 18•4 years ago
|
||
Depends on D116775
Reporter | ||
Comment 19•4 years ago
|
||
Depends on D117120
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Comment 20•4 years ago
|
||
Comment 21•4 years ago
|
||
bugherder |
Reporter | ||
Comment 22•4 years ago
|
||
Comment 23•4 years ago
|
||
Comment 24•4 years ago
|
||
bugherder |
Reporter | ||
Comment 25•4 years ago
|
||
Reporter | ||
Comment 26•4 years ago
|
||
Depends on D119720
Reporter | ||
Comment 27•4 years ago
|
||
Depends on D119721
Reporter | ||
Comment 28•4 years ago
|
||
Depends on D119722
Reporter | ||
Comment 29•4 years ago
|
||
Depends on D119723
Reporter | ||
Comment 30•4 years ago
|
||
Depends on D119724
Reporter | ||
Comment 31•4 years ago
|
||
Depends on D119725
Reporter | ||
Comment 32•4 years ago
|
||
Depends on D119726
Reporter | ||
Comment 33•4 years ago
|
||
Depends on D119727
Reporter | ||
Comment 34•4 years ago
|
||
Reporter | ||
Comment 35•4 years ago
|
||
Depends on D120277
Reporter | ||
Comment 36•4 years ago
|
||
Depends on D120278
Reporter | ||
Comment 37•4 years ago
|
||
Depends on D120279
Reporter | ||
Comment 38•4 years ago
|
||
Depends on D120280
Reporter | ||
Comment 39•4 years ago
|
||
Depends on D120282
Reporter | ||
Comment 40•4 years ago
|
||
Depends on D120283
Reporter | ||
Comment 41•4 years ago
|
||
Depends on D120284
Reporter | ||
Comment 42•4 years ago
|
||
Depends on D120285
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Comment 43•3 years ago
|
||
Comment 44•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/98e70cb9f81a
https://hg.mozilla.org/mozilla-central/rev/59114f24f348
https://hg.mozilla.org/mozilla-central/rev/9c17091087a8
https://hg.mozilla.org/mozilla-central/rev/778ead7a44ba
https://hg.mozilla.org/mozilla-central/rev/e25df64152c2
https://hg.mozilla.org/mozilla-central/rev/66491995508e
https://hg.mozilla.org/mozilla-central/rev/898028ee73ec
https://hg.mozilla.org/mozilla-central/rev/54c739cc8d2f
https://hg.mozilla.org/mozilla-central/rev/1053a0c611ba
Updated•3 years ago
|
Comment 45•3 years ago
|
||
The bug assignee is inactive on Bugzilla, so the assignee is being reset.
Comment 46•2 years ago
|
||
The meta keyword is there, the bug doesn't depend on other bugs and there is no activity for 12 months.
:willyelm, maybe it's time to close this bug?
Comment 47•2 years ago
|
||
Hi Jan, do you have additional information about this bug?
Comment 48•2 years ago
|
||
Patches landed in this bug so let's close it. We can file a new bug for other work in this area.
Updated•2 years ago
|
Description
•