Closed Bug 1455548 Opened 7 years ago Closed 4 years ago

Refactor BytecodeEmitter to let us emit bytecode without a ParseNode

Categories

(Core :: JavaScript Engine, enhancement, P2)

enhancement

Tracking

()

RESOLVED INCOMPLETE
Tracking Status
firefox62 --- wontfix
firefox63 --- wontfix
firefox64 --- wontfix
firefox65 --- wontfix

People

(Reporter: Yoric, Assigned: arai)

References

(Depends on 1 open bug)

Details

Right now, we have a bunch of `BytecodeEmitter::emit*`, many of which take as argument a `ParseNode`. Ideally, we'd like to be able to emit bytecode without having a ParseNode. This means refactoring `BytecodeEmitter` as follows: - expose a bunch of APIs that are the building blocks for the `emit*` but don't need a ParseNode – with clear documentation on how to use them; - refactor the `emit*` methods as drivers for these APIs; - move the `emit*` methods to a subclass of `BytecodeEmitter`.
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Depends on: 1456006
Depends on: 1456039
Priority: -- → P1
Depends on: 1456404
Depends on: 1457365
another update. https://treeherder.mozilla.org/#/jobs?repo=try&revision=2259f80dff35ee8f5e703602924906c67bc0e54d&filter-searchStr=sm%20plain%20linux%20opt%2064 now the js shell can execute binjs file without creating ParseNode tree, with the following command: (where test.binjs is binary for `print(10);`) js --binast-direct -B js/src/jsapi-tests/binast/test.binjs still the number of supported syntax is very small, but I think this can be done incrementally.
Depends on: 1460126
Depends on: 1459845
In the WIP patch series, I implemented the consumer inside BytecodeEmitter.cpp, because helper classes and some BytecodeEmitter related classes are defined inside BytecodeEmitter.cpp. ultimately the consumer should be moved outside of BytecodeEmitter.cpp, that means those helper classes need to be exposed to BytecodeEmitter.h (or maybe separate file might be better, because current BytecodeEmitter consumers don't need those helpers)
Depends on: 1460154
Depends on: 1460489
update: https://treeherder.mozilla.org/#/jobs?repo=try&revision=8f2430413ee2ef9941edcdff80e45634705d1c2b Implemented call expression. compared to parser, we have to look more into child nodes inside single function while emitting, in order to determine what bytecode to emit before each child node. this might be troublesome, for example in destructuring, because of emitting order, and because single expression can contain function (that means, we should temporarily create AST for subtree, or support seek in tokenizer).
(In reply to Tooru Fujisawa [:arai] from comment #4) > compared to parser, we have to look more into child nodes inside single > function while emitting, > in order to determine what bytecode to emit before each child node. or, we should design the helper functions to defer receiving each parameter as much as possible, like, current IfEmitter (IfThenElseEmitter) expects that the existence of else-clause is known at the beginning, but with current BinAST structure it's unknown until we start parsing the else-clause. then, in IfEmitter's case, the expectation is based on the source note structure, (SRC_IF vs SRC_IF_ELSE) so, in some case it might require modifying bytecode or source note after emitting them.
Depends on: 1461888
Depends on: 1461896
Depends on: 1465999
Depends on: 1466000
Depends on: 1467384
Depends on: 1473796
Depends on: 1501576
Depends on: 1501577
Depends on: 1501578

Resolving BinAST bugs as Incomplete.

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.