Closed
Bug 632020
Opened 14 years ago
Closed 7 years ago
Module pattern can inhibit bytecode-level constant-folding and dead code elimination
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla64
Tracking | Status | |
---|---|---|
firefox64 | --- | fixed |
People
(Reporter: jorendorff, Assigned: jandem)
References
Details
Attachments
(1 file)
Bug 632020 - Allow constant folding to see inside functions when using the module pattern. r?jwalden
46 bytes,
text/x-phabricator-request
|
Waldo
:
review+
|
Details | Review |
Paste this into a debug shell:
dis(); (function () { return 3 * 4; }()); // constant-folding
dis(); (function () { return 3 * 4; })(); // no constant-folding
Likewise:
dis(); (function () { if (0) f(); }()); // DCE
dis(); (function () { if (0) f(); })(); // no DCE
I don't know that it matters much, since both JITs do their own
optimizations. If we're stuck in the interpreter, you can of course observe
the difference.
$ ./js # note: no -m, no -j
js> var t = Date.now(); (function () { for (var i = 0; i < 10*10*10*10*10*10; i++);}()); print(Date.now()-t);
290
js> var t = Date.now(); (function () { for (var i = 0; i < 10*10*10*10*10*10; i++);})(); print(Date.now()-t);
1107
Updated•11 years ago
|
Assignee: general → nobody
Comment 2•10 years ago
|
||
Neither `(function(){ ... })()` nor `(function(){ ... }())` is currently constant folded.
`(function(){ ... })()` is ignored in FoldCall because the callable component is parenthesized: https://dxr.mozilla.org/mozilla-central/rev/1f4cf75c894862cf3634d6014d8de9c807a054a7/js/src/frontend/FoldConstants.cpp#1585
The function in `(function(){ ... }())` is marked as parenthesized and then ignored in FoldCall just like the other one: https://dxr.mozilla.org/mozilla-central/rev/1f4cf75c894862cf3634d6014d8de9c807a054a7/js/src/frontend/FullParseHandler.h#799
Assignee | ||
Comment 4•7 years ago
|
||
Assignee | ||
Updated•7 years ago
|
Assignee: nobody → jdemooij
Status: NEW → ASSIGNED
Comment 5•7 years ago
|
||
Comment on attachment 9012141 [details]
Bug 632020 - Allow constant folding to see inside functions when using the module pattern. r?jwalden
Jeff Walden [:Waldo] has approved the revision.
Attachment #9012141 -
Flags: review+
Pushed by jandemooij@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/abd419a57735
Allow constant folding to see inside functions when using the module pattern. r=jwalden
Comment 7•7 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox64:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in
before you can comment on or make changes to this bug.
Description
•