boa icon indicating copy to clipboard operation
boa copied to clipboard

Implement control flow graph construction

Open HalidOdat opened this issue 1 year ago • 5 comments

This PR is a WIP implementation of control flow graph construction from bytecode, that will be used for many optimizations, like dead-code-elimination.

TODO

  • [ ] Add instruction information like length, does it push/pop, is it a jump, etc
  • [x] Remove BasicBlock and redirect it's references
  • [ ] Insert BasicBlock and redirect it's references
  • [ ] Clean-up
  • [ ] Document

HalidOdat avatar Jun 13 '23 00:06 HalidOdat

Nice! This'll also be really useful when we eventually implement JIT compilation

jedel1043 avatar Jun 13 '23 02:06 jedel1043

Test262 conformance changes

Test result main count PR count difference
Total 95,960 95,960 0
Passed 76,534 76,534 0
Ignored 18,477 18,477 0
Failed 949 949 0
Panics 0 0 0
Conformance 79.76% 79.76% 0.00%

github-actions[bot] avatar Jun 15 '23 17:06 github-actions[bot]

Codecov Report

Attention: 68 lines in your changes are missing coverage. Please review.

Comparison is base (0f82312) 48.88% compared to head (126367f) 49.34%.

Files Patch % Lines
...ore/engine/src/optimizer/control_flow_graph/mod.rs 90.15% 25 Missing :warning:
cli/src/debug/optimizer.rs 0.00% 21 Missing :warning:
...ne/src/optimizer/control_flow_graph/basic_block.rs 60.60% 13 Missing :warning:
core/engine/src/vm/opcode/mod.rs 36.36% 7 Missing :warning:
core/engine/src/vm/code_block.rs 0.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3037      +/-   ##
==========================================
+ Coverage   48.88%   49.34%   +0.46%     
==========================================
  Files         471      473       +2     
  Lines       48492    48814     +322     
==========================================
+ Hits        23705    24088     +383     
+ Misses      24787    24726      -61     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 15 '23 17:06 codecov[bot]

Coincidentally, I found this crate that could simplify the optimizer logic: https://docs.rs/egg/0.9.5/egg

jedel1043 avatar Jul 15 '23 18:07 jedel1043

Coincidentally, I found this crate that could simplify the optimizer logic: https://docs.rs/egg/0.9.5/egg

Looks interesting! But I think it would be better to create our own, because JS semantics are complex and it would be easier to extend.

I postponed this PR until #3059 is fully complete (currently refactoring generators, which are the remaining test262 failing tests).

HalidOdat avatar Jul 16 '23 16:07 HalidOdat