mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 20:37:31 +09:00
Issue #2173 - Allow constant folding to see inside functions when using the module pattern
(function() { ... })() IIFE pattern should get its body const-folded. This won't make much
runtime difference on JIT, but can be significant in interpreted code (and saves time for
JIT codegen).
Based-on: m-c 632020
This commit is contained in:
parent
287a2ad2e4
commit
661b1c534c
1 changed files with 5 additions and 1 deletions
|
|
@ -1544,9 +1544,13 @@ FoldCall(ExclusiveContext* cx, BinaryNode* node, Parser<FullParseHandler>& parse
|
||||||
// assertEq((true ? obj.f : null)``, "global");
|
// assertEq((true ? obj.f : null)``, "global");
|
||||||
// assertEq(obj.f``, "obj");
|
// assertEq(obj.f``, "obj");
|
||||||
//
|
//
|
||||||
|
// As an exception to this, we do allow folding the function in
|
||||||
|
// `(function() { ... })()` (the module pattern), because that lets us
|
||||||
|
// constant fold code inside that function.
|
||||||
|
//
|
||||||
// See bug 537673 and bug 1182373.
|
// See bug 537673 and bug 1182373.
|
||||||
ParseNode* callee = node->left();
|
ParseNode* callee = node->left();
|
||||||
if (node->isKind(PNK_NEW) || !callee->isInParens()) {
|
if (node->isKind(PNK_NEW) || !callee->isInParens() || callee->is<FunctionNode>()) {
|
||||||
if (!Fold(cx, node->unsafeLeftReference(), parser, inGenexpLambda))
|
if (!Fold(cx, node->unsafeLeftReference(), parser, inGenexpLambda))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue