Closed Bug 1690943 Opened 3 years ago Closed 3 years ago

Synthesize all missing class constructors in the JS Parser

Categories

(Core :: JavaScript Engine, task, P1)

task

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: tcampbell, Assigned: tcampbell)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

Currently, we use the JSOP::ClassConstructor opcode for missing constructors of classes with no fields, but synthesize one with the parser if there are fields. The ClassConstructor opcode relies on some ugly self-hosted bytecode cloning hacks which we'd like to remove. Instead, we can always synthesize the missing constructors.

In order for this to be useful, we must also support syntax parsing these constructors. Using script-flags we can handle this case in a straightforward way.

The ClassConstructor opcode would synthesize a private copy of a BaseScript with roughly the same bytecode, so there isn't new overhead here.

Introduce ParseNodeKind::DefaultConstructor to represent synthesized class
constructors in the parse AST. Use this for synthesized constructors and then
hide them from Reflect.parse. This brings consistency with the default class
constructors used for classes without fields. In future, all missing
constructors will be synthesized by Parser instead of special opcodes.

The Parser currently synthesizes missing constructors for classes that have
fields and this extends that to missing constructors of any class. We also
need to add lazy parsing support here to make this practical.

Depends on D104137

These are no longer needed now that we synthesize missing constructors in the
parser.

Depends on D104138

Attachment #9201302 - Attachment description: Bug 1690943 - Hide synthesized constructors from Reflect.parse → Bug 1690943 - Hide synthesized constructors from Reflect.parse. r?arai!
Attachment #9201303 - Attachment description: Bug 1690943 - Use synthesized functions for all default class constructors → Bug 1690943 - Use synthesized functions for all default class constructors. r?arai!
Attachment #9201304 - Attachment description: Bug 1690943 - Remove {Class,Derived}Constructor Opcodes → Bug 1690943 - Remove {Class,Derived}Constructor Opcodes. r?arai!
Pushed by tcampbell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/60ba53c75cfb
Hide synthesized constructors from Reflect.parse. r=arai
https://hg.mozilla.org/integration/autoland/rev/d81dbae6505c
Use synthesized functions for all default class constructors. r=arai
https://hg.mozilla.org/integration/autoland/rev/ed71dfbcad90
Remove {Class,Derived}Constructor Opcodes. r=arai
Blocks: 1688759
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: