Closed Bug 1518391 Opened 10 months ago Closed 9 months ago

Add dedicate ParseNode subclasses for function/module, and do not use JSOp

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla67
Tracking Status
firefox66 --- wontfix
firefox67 --- fixed

People

(Reporter: arai, Assigned: arai)

References

Details

Attachments

(4 files)

CodeNode uses several kind of JSOp to express multiple kind of function/method in multiple kind of situation.

https://searchfox.org/mozilla-central/rev/76fe4bb385348d3f45bbebcf69ba8c7283dfcec7/js/src/frontend/ParseNode.h#1499-1505

We should create dedicated enum class and use it instead to simplicify and clarity.
which should also make bug 1473796 simpler.

See Also: → 1520996

turns out that most cases are just obsolete.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=563d7534cd8ff4a1bff24038c94b4e29702f020e

https://hg.mozilla.org/try/rev/0d4b1c79c0d0b2b23b3799b41a0ab9bdf28c82e1#l2.12

   bool functionIsHoisted() const {
     MOZ_ASSERT(isKind(ParseNodeKind::Function));
-    MOZ_ASSERT(
-        isOp(JSOP_LAMBDA) ||        // lambda
-        isOp(JSOP_LAMBDA_ARROW) ||  // arrow function
-        isOp(JSOP_DEFFUN) ||        // non-body-level function statement
-        isOp(JSOP_NOP) ||           // body-level function stmt in global code
-        isOp(JSOP_GETLOCAL) ||      // body-level function stmt in function code
-        isOp(JSOP_GETARG) ||        // body-level function redeclaring formal
-        isOp(JSOP_INITLEXICAL));    // block-level function stmt
-    return !isOp(JSOP_LAMBDA) && !isOp(JSOP_LAMBDA_ARROW) && !isOp(JSOP_DEFFUN);
+    return isOp(JSOP_NOP);
   }
Summary: Do not use JSOp in CodeNode → Add dedicate ParseNode subclasses for function/module, and do not use JSOp
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED

pn_op for CodeNode can only be JSOP_NOP, JSOP_LAMBDA, and JSOP_LAMBDA_ARROW.
Removed other cases.
Also removed the override with JSOP_FUNWITHPROTO given the field is never read
after the function.

CodeNode was shared between ParseNodeKind::Function and ParseNodeKind::Module,
but Module only uses pn_u.code.body.
Separated them for further refactoring for function part.

Depends on D18325

This is a replacement for pn_op that is used in BytecodeEmitter.
This patch just adds the field, but keeps using pn_op.
Part 4 removes the usage of pn_op for FunctionNode.

Depends on D18327

You need to log in before you can comment on or make changes to this bug.