Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async arrow parse #1066

Closed
wants to merge 17 commits into from
Closed

Async arrow parse #1066

wants to merge 17 commits into from

Conversation

Lan2u
Copy link

@Lan2u Lan2u commented Jan 12, 2021

This Pull Request finishes the lex/parsing part of #818.

It changes the following:

  • Adds async arrow function parsing

@github-actions
Copy link

github-actions bot commented Jan 12, 2021

Test262 conformance changes:

Test result master count PR count difference
Total 78,497 78,497 0
Passed 24,805 24,787 -18
Ignored 15,587 15,587 0
Failed 38,105 38,123 +18
Panics 26 26 0
Conformance 31.60 31.58 -0.02%

@codecov
Copy link

codecov bot commented Jan 12, 2021

Codecov Report

Merging #1066 (565fdd9) into master (5a5061c) will decrease coverage by 0.00%.
The diff coverage is 70.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1066      +/-   ##
==========================================
- Coverage   58.70%   58.70%   -0.01%     
==========================================
  Files         176      180       +4     
  Lines       12391    12468      +77     
==========================================
+ Hits         7274     7319      +45     
- Misses       5117     5149      +32     
Impacted Files Coverage Δ
.../node/declaration/async_arrow_function_decl/mod.rs 27.77% <27.77%> (ø)
boa/src/syntax/parser/expression/primary/mod.rs 71.42% <42.85%> (-1.46%) ⬇️
boa/src/syntax/parser/statement/mod.rs 52.73% <42.85%> (-1.55%) ⬇️
boa/src/syntax/ast/node/mod.rs 46.37% <50.00%> (-0.69%) ⬇️
boa/src/syntax/parser/expression/assignment/mod.rs 49.48% <63.63%> (-0.52%) ⬇️
...parser/expression/assignment/arrow_function/mod.rs 85.00% <66.66%> (ø)
boa/src/syntax/parser/function/mod.rs 64.38% <83.33%> (+1.14%) ⬆️
...yntax/parser/expression/assignment/concise_body.rs 86.66% <86.66%> (ø)
.../expression/assignment/async_arrow_function/mod.rs 90.90% <90.90%> (ø)
boa/src/syntax/lexer/mod.rs 67.82% <100.00%> (+0.56%) ⬆️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a5061c...565fdd9. Read the comment docs.

@github-actions
Copy link

Benchmark for 73c9795

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 362.5±0.46ns 363.1±0.22ns -0.17%
Arithmetic operations (Full) 232.8±1.55µs 231.6±1.72µs +0.52%
Array access (Execution) 6.3±0.02µs 6.3±0.02µs 0.00%
Array access (Full) 254.0±0.51µs 254.6±0.42µs -0.24%
Array creation (Execution) 3.1±0.00ms 3.1±0.00ms 0.00%
Array creation (Full) 3.2±0.01ms 3.3±0.00ms -3.03%
Array pop (Execution) 978.8±2.88µs 990.9±3.57µs -1.22%
Array pop (Full) 1397.7±1.29µs 1413.9±1.74µs -1.15%
Boolean Object Access (Execution) 5.2±0.01µs 5.4±0.02µs -3.70%
Boolean Object Access (Full) 250.0±0.41µs 252.7±0.52µs -1.07%
Clean js (Execution) 693.0±3.01µs 689.4±2.98µs +0.52%
Clean js (Full) 981.3±5.68µs 977.7±4.86µs +0.37%
Clean js (Parser) 40.0±0.04µs 40.5±0.28µs -1.23%
Create Realm 501.7±6.09ns 513.0±1.15ns -2.20%
Dynamic Object Property Access (Execution) 5.1±0.01µs 5.1±0.02µs 0.00%
Dynamic Object Property Access (Full) 250.6±0.47µs 252.1±0.51µs -0.60%
Expression (Parser) 7.1±0.01µs 7.0±0.01µs +1.43%
Fibonacci (Execution) 849.8±2.27µs 851.3±0.49µs -0.18%
Fibonacci (Full) 1138.0±1.49µs 1143.4±2.71µs -0.47%
For loop (Execution) 23.3±0.07µs 23.2±0.08µs +0.43%
For loop (Full) 273.9±0.56µs 273.3±0.40µs +0.22%
For loop (Parser) 19.3±0.02µs 19.6±0.02µs -1.53%
Goal Symbols (Parser) 13.5±0.21µs 13.8±0.02µs -2.17%
Hello World (Parser) 3.7±0.02µs 3.7±0.01µs 0.00%
Long file (Parser) 803.9±1.20ns 799.9±0.91ns +0.50%
Mini js (Execution) 614.5±3.66µs 614.4±4.11µs +0.02%
Mini js (Full) 887.7±3.42µs 886.9±2.87µs +0.09%
Mini js (Parser) 35.5±0.05µs 35.7±0.03µs -0.56%
Number Object Access (Execution) 4.1±0.01µs 4.2±0.01µs -2.38%
Number Object Access (Full) 245.4±0.36µs 245.7±0.32µs -0.12%
Object Creation (Execution) 4.4±0.01µs 4.4±0.07µs 0.00%
Object Creation (Full) 246.3±3.39µs 245.9±0.54µs +0.16%
RegExp (Execution) 9.8±0.03µs 9.7±0.04µs +1.03%
RegExp (Full) 260.2±0.58µs 258.8±0.52µs +0.54%
RegExp Literal (Execution) 11.2±0.03µs 11.1±0.03µs +0.90%
RegExp Literal (Full) 261.0±0.59µs 256.6±0.58µs +1.71%
RegExp Literal Creation (Execution) 9.8±0.04µs 9.6±0.03µs +2.08%
RegExp Literal Creation (Full) 252.0±0.47µs 249.8±0.43µs +0.88%
Static Object Property Access (Execution) 4.6±0.02µs 4.6±0.02µs 0.00%
Static Object Property Access (Full) 247.6±0.36µs 246.7±0.36µs +0.36%
String Object Access (Execution) 7.2±0.10µs 7.5±0.02µs -4.00%
String Object Access (Full) 254.7±4.95µs 252.1±0.43µs +1.03%
String comparison (Execution) 6.6±0.02µs 6.6±0.03µs 0.00%
String comparison (Full) 252.5±0.35µs 251.5±0.39µs +0.40%
String concatenation (Execution) 5.2±0.01µs 5.4±0.02µs -3.70%
String concatenation (Full) 244.4±0.33µs 244.2±0.51µs +0.08%
String copy (Execution) 4.0±0.01µs 4.1±0.01µs -2.44%
String copy (Full) 241.9±0.53µs 241.4±2.16µs +0.21%
Symbols (Execution) 3.4±0.01µs 3.4±0.01µs 0.00%
Symbols (Full) 236.9±2.43µs 234.6±0.61µs +0.98%

@github-actions
Copy link

Benchmark for 97327de

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 327.6±10.63ns 331.5±14.56ns -1.18%
Arithmetic operations (Full) 289.1±64.06µs 245.2±14.70µs +17.90%
Array access (Execution) 6.4±0.27µs 6.4±0.48µs 0.00%
Array access (Full) 817.4±183.94µs 262.1±60.19µs +211.87%
Array creation (Execution) 2.6±0.10ms 2.7±0.14ms -3.70%
Array creation (Full) 2.9±0.13ms 2.9±0.12ms 0.00%
Array pop (Execution) 867.1±46.05µs 855.6±26.05µs +1.34%
Array pop (Full) 5.0±2.17ms 1266.8±36.87µs +294.70%
Boolean Object Access (Execution) 5.1±0.21µs 5.2±0.22µs -1.92%
Boolean Object Access (Full) 493.4±80.45µs 253.7±29.51µs +94.48%
Clean js (Execution) 671.5±39.21µs 648.1±28.86µs +3.61%
Clean js (Full) 1791.6±426.53µs 923.6±43.27µs +93.98%
Clean js (Parser) 314.5±87.29µs 40.3±2.94µs +680.40%
Create Realm 491.9±34.27ns 455.6±35.49ns +7.97%
Dynamic Object Property Access (Execution) 5.1±0.19µs 5.1±0.22µs 0.00%
Dynamic Object Property Access (Full) 478.5±73.50µs 249.3±9.96µs +91.94%
Expression (Parser) 29.9±8.85µs 6.5±0.25µs +360.00%
Fibonacci (Execution) 896.6±35.30µs 894.5±37.85µs +0.23%
Fibonacci (Full) 1196.6±52.75µs 1126.9±42.10µs +6.19%
For loop (Execution) 23.1±1.33µs 22.8±0.72µs +1.32%
For loop (Full) 872.3±149.14µs 270.2±10.71µs +222.83%
For loop (Parser) 146.5±36.89µs 18.8±0.98µs +679.26%
Goal Symbols (Parser) 92.4±28.49µs 13.2±0.44µs +600.00%
Hello World (Parser) 28.5±7.52µs 3.5±0.12µs +714.29%
Long file (Parser) 747.2±35.92ns 731.7±52.03ns +2.12%
Mini js (Execution) 574.3±23.41µs 576.4±30.32µs -0.36%
Mini js (Full) 1249.9±379.78µs 829.5±24.98µs +50.68%
Mini js (Parser) 238.9±56.00µs 35.5±2.36µs +572.96%
Number Object Access (Execution) 4.0±0.23µs 4.0±0.15µs 0.00%
Number Object Access (Full) 435.7±62.55µs 242.9±10.36µs +79.37%
Object Creation (Execution) 4.4±0.28µs 4.3±0.18µs +2.33%
Object Creation (Full) 600.1±145.05µs 250.5±17.52µs +139.56%
RegExp (Execution) 9.5±0.98µs 9.2±0.50µs +3.26%
RegExp (Full) 535.6±77.76µs 258.3±9.52µs +107.36%
RegExp Literal (Execution) 10.7±0.64µs 10.7±0.40µs 0.00%
RegExp Literal (Full) 362.6±69.33µs 262.3±13.00µs +38.24%
RegExp Literal Creation (Execution) 9.1±0.40µs 9.1±0.30µs 0.00%
RegExp Literal Creation (Full) 387.0±59.97µs 250.0±9.76µs +54.80%
Static Object Property Access (Execution) 5.0±0.21µs 4.6±0.18µs +8.70%
Static Object Property Access (Full) 591.7±142.20µs 245.6±7.98µs +140.92%
String Object Access (Execution) 6.9±0.33µs 7.1±0.28µs -2.82%
String Object Access (Full) 409.9±97.03µs 261.9±28.24µs +56.51%
String comparison (Execution) 6.4±0.31µs 6.1±0.27µs +4.92%
String comparison (Full) 614.2±141.53µs 251.9±13.07µs +143.83%
String concatenation (Execution) 5.2±0.22µs 5.1±0.22µs +1.96%
String concatenation (Full) 416.3±60.95µs 245.3±15.79µs +69.71%
String copy (Execution) 3.9±0.28µs 3.9±0.28µs 0.00%
String copy (Full) 345.7±69.85µs 237.1±7.63µs +45.80%
Symbols (Execution) 3.6±0.14µs 3.6±0.17µs 0.00%
Symbols (Full) 310.9±24.07µs 232.6±9.70µs +33.66%

@github-actions
Copy link

Benchmark for a2d334f

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 358.4±2.69ns 361.2±3.80ns -0.78%
Arithmetic operations (Full) 261.1±24.45µs 233.0±3.00µs +12.06%
Array access (Execution) 6.0±0.11µs 6.3±0.10µs -4.76%
Array access (Full) 610.5±188.13µs 245.7±5.20µs +148.47%
Array creation (Execution) 3.0±0.04ms 3.1±0.03ms -3.23%
Array creation (Full) 3.3±0.04ms 3.2±0.05ms +3.13%
Array pop (Execution) 952.5±12.18µs 965.5±16.76µs -1.35%
Array pop (Full) 5.2±1.17ms 1403.0±13.81µs +270.63%
Boolean Object Access (Execution) 5.2±0.02µs 5.3±0.05µs -1.89%
Boolean Object Access (Full) 334.9±78.09µs 246.5±3.34µs +35.86%
Clean js (Execution) 683.6±6.63µs 664.5±9.84µs +2.87%
Clean js (Full) 1649.3±247.28µs 966.1±12.67µs +70.72%
Clean js (Parser) 293.8±97.97µs 39.6±0.54µs +641.92%
Create Realm 486.7±10.28ns 488.3±6.29ns -0.33%
Dynamic Object Property Access (Execution) 5.0±0.07µs 5.2±0.06µs -3.85%
Dynamic Object Property Access (Full) 558.8±45.38µs 243.6±3.73µs +129.39%
Expression (Parser) 23.7±5.55µs 6.9±0.11µs +243.48%
Fibonacci (Execution) 811.8±9.99µs 841.4±9.78µs -3.52%
Fibonacci (Full) 1198.9±48.17µs 1115.4±16.94µs +7.49%
For loop (Execution) 22.4±0.38µs 22.7±0.30µs -1.32%
For loop (Full) 789.7±192.00µs 270.5±3.17µs +191.94%
For loop (Parser) 122.6±26.69µs 19.1±0.29µs +541.88%
Goal Symbols (Parser) 83.6±15.26µs 13.2±0.19µs +533.33%
Hello World (Parser) 31.0±11.40µs 3.6±0.07µs +761.11%
Long file (Parser) 814.1±45.34ns 785.3±11.02ns +3.67%
Mini js (Execution) 612.9±5.89µs 600.6±8.84µs +2.05%
Mini js (Full) 1550.4±292.73µs 873.6±10.93µs +77.47%
Mini js (Parser) 207.3±37.54µs 35.0±0.55µs +492.29%
Number Object Access (Execution) 4.2±0.03µs 4.1±0.05µs +2.44%
Number Object Access (Full) 473.2±104.35µs 242.9±1.97µs +94.81%
Object Creation (Execution) 4.2±0.07µs 4.3±0.06µs -2.33%
Object Creation (Full) 455.4±129.45µs 240.9±3.70µs +89.04%
RegExp (Execution) 9.5±0.16µs 9.5±0.12µs 0.00%
RegExp (Full) 437.9±100.50µs 254.2±4.04µs +72.27%
RegExp Literal (Execution) 11.0±0.15µs 10.8±0.16µs +1.85%
RegExp Literal (Full) 478.9±65.41µs 254.4±2.83µs +88.25%
RegExp Literal Creation (Execution) 9.5±0.13µs 9.4±0.14µs +1.06%
RegExp Literal Creation (Full) 378.6±24.81µs 243.4±3.60µs +55.55%
Static Object Property Access (Execution) 4.5±0.07µs 4.6±0.09µs -2.17%
Static Object Property Access (Full) 489.4±99.33µs 247.8±2.08µs +97.50%
String Object Access (Execution) 7.1±0.05µs 7.2±0.13µs -1.39%
String Object Access (Full) 515.5±132.25µs 250.3±3.92µs +105.95%
String comparison (Execution) 6.6±0.06µs 6.6±0.09µs 0.00%
String comparison (Full) 607.2±257.65µs 246.6±4.24µs +146.23%
String concatenation (Execution) 5.1±0.08µs 5.2±0.07µs -1.92%
String concatenation (Full) 496.0±115.79µs 240.7±4.02µs +106.07%
String copy (Execution) 3.9±0.03µs 3.9±0.07µs 0.00%
String copy (Full) 370.9±54.91µs 236.4±3.78µs +56.90%
Symbols (Execution) 3.3±0.05µs 3.4±0.05µs -2.94%
Symbols (Full) 322.7±33.56µs 232.0±3.49µs +39.09%

@Razican
Copy link
Member

Razican commented Jan 13, 2021

Looking good!

A couple of things:

  • I don't think this fully closes the Implement async / await #818 issue, since there is no execution implemented
  • I would use a Parse::unimplemented() error instead of a panic for unimplemented things, that should maintain the panics to a minimum.

I will do a proper review later this week.

@Razican Razican added the parser Issues surrounding the parser label Jan 13, 2021
@Razican Razican added this to the v0.12.0 milestone Jan 13, 2021
@Lan2u
Copy link
Author

Lan2u commented Jan 13, 2021

Looking good!

A couple of things:

  • I don't think this fully closes the Implement async / await #818 issue, since there is no execution implemented
  • I would use a Parse::unimplemented() error instead of a panic for unimplemented things, that should maintain the panics to a minimum.

I will do a proper review later this week.

I put a comment on the #818 issue that it might make sense to split into multiple issues rather than one big issue but either/or is good with me.

Since this is still draft: I've left the todo!() since I plan to implement them before marking this ready

@Lan2u Lan2u marked this pull request as ready for review January 13, 2021 20:46
@github-actions
Copy link

Benchmark for 2cfa3bf

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 301.8±0.80ns 304.8±0.16ns -0.98%
Arithmetic operations (Full) 283.3±24.36µs 193.9±0.42µs +46.11%
Array access (Execution) 5.3±0.02µs 5.3±0.02µs 0.00%
Array access (Full) 424.8±71.68µs 213.0±0.35µs +99.44%
Array creation (Execution) 2.4±0.00ms 2.6±0.00ms -7.69%
Array creation (Full) 2.7±0.01ms 2.7±0.01ms 0.00%
Array pop (Execution) 775.8±2.63µs 824.2±2.74µs -5.87%
Array pop (Full) 2.9±1.45ms 1183.1±2.62µs +145.12%
Boolean Object Access (Execution) 4.5±0.01µs 4.5±0.01µs 0.00%
Boolean Object Access (Full) 451.7±102.84µs 209.9±0.32µs +115.20%
Clean js (Execution) 566.4±4.62µs 574.3±2.79µs -1.38%
Clean js (Full) 1447.7±240.96µs 824.3±4.19µs +75.63%
Clean js (Parser) 231.4±88.60µs 35.7±0.07µs +548.18%
Create Realm 417.5±2.72ns 422.0±2.78ns -1.07%
Dynamic Object Property Access (Execution) 4.3±0.01µs 4.3±0.02µs 0.00%
Dynamic Object Property Access (Full) 455.4±114.10µs 209.2±0.45µs +117.69%
Expression (Parser) 30.9±9.33µs 6.1±0.00µs +406.56%
Fibonacci (Execution) 712.7±0.38µs 718.7±1.17µs -0.83%
Fibonacci (Full) 993.7±19.05µs 950.1±0.92µs +4.59%
For loop (Execution) 19.6±0.05µs 19.3±0.05µs +1.55%
For loop (Full) 652.2±189.59µs 228.9±0.76µs +184.93%
For loop (Parser) 131.1±48.62µs 17.0±0.02µs +671.18%
Goal Symbols (Parser) 64.7±17.15µs 11.8±0.08µs +448.31%
Hello World (Parser) 17.0±3.01µs 3.2±0.00µs +431.25%
Long file (Parser) 704.2±42.26ns 692.8±0.61ns +1.65%
Mini js (Execution) 505.6±2.86µs 512.7±4.15µs -1.38%
Mini js (Full) 1424.0±441.03µs 744.5±2.81µs +91.27%
Mini js (Parser) 236.1±62.79µs 31.3±0.04µs +654.31%
Number Object Access (Execution) 3.5±0.00µs 3.5±0.00µs 0.00%
Number Object Access (Full) 284.8±34.18µs 207.8±2.20µs +37.05%
Object Creation (Execution) 3.7±0.01µs 3.7±0.02µs 0.00%
Object Creation (Full) 498.1±145.96µs 206.4±0.62µs +141.33%
RegExp (Execution) 8.2±0.03µs 8.1±0.04µs +1.23%
RegExp (Full) 560.0±132.33µs 217.7±0.52µs +157.23%
RegExp Literal (Execution) 9.3±0.03µs 9.4±0.03µs -1.06%
RegExp Literal (Full) 401.0±60.26µs 217.7±0.86µs +84.20%
RegExp Literal Creation (Execution) 8.2±0.04µs 8.1±0.03µs +1.23%
RegExp Literal Creation (Full) 325.5±21.76µs 209.6±0.29µs +55.30%
Static Object Property Access (Execution) 3.9±0.01µs 3.9±0.01µs 0.00%
Static Object Property Access (Full) 399.9±38.37µs 207.3±0.51µs +92.91%
String Object Access (Execution) 6.1±0.01µs 6.2±0.01µs -1.61%
String Object Access (Full) 429.0±67.50µs 212.1±0.56µs +102.26%
String comparison (Execution) 5.6±0.02µs 5.5±0.02µs +1.82%
String comparison (Full) 558.8±128.18µs 211.4±0.53µs +164.33%
String concatenation (Execution) 4.5±0.01µs 4.5±0.02µs 0.00%
String concatenation (Full) 336.2±46.15µs 205.5±0.25µs +63.60%
String copy (Execution) 3.4±0.01µs 3.3±0.01µs +3.03%
String copy (Full) 355.5±42.91µs 200.8±0.63µs +77.04%
Symbols (Execution) 2.8±0.01µs 2.9±0.02µs -3.45%
Symbols (Full) 277.0±18.21µs 196.3±0.64µs +41.11%

@Lan2u
Copy link
Author

Lan2u commented Jan 13, 2021

I'm unsure why the test262 failures have gone up, I'd guess its to do with the lack of execution implementation but will need to look into it - implementing unique formal params has reduced the failure count, perhaps implementing async without returning a Promise has caused enough failures to offset anything which is now passing

@Lan2u Lan2u requested a review from Razican January 13, 2021 21:33
@github-actions
Copy link

Benchmark for afafedc

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 357.6±3.29ns 359.8±0.53ns -0.61%
Arithmetic operations (Full) 233.0±3.46µs 232.6±0.53µs +0.17%
Array access (Execution) 6.2±0.08µs 6.3±0.03µs -1.59%
Array access (Full) 258.1±2.42µs 253.7±0.94µs +1.73%
Array creation (Execution) 3.0±0.07ms 3.1±0.00ms -3.23%
Array creation (Full) 3.5±0.14ms 3.2±0.01ms +9.38%
Array pop (Execution) 956.9±7.50µs 987.8±3.44µs -3.13%
Array pop (Full) 1438.4±12.67µs 1411.4±1.76µs +1.91%
Boolean Object Access (Execution) 5.1±0.06µs 5.3±0.01µs -3.77%
Boolean Object Access (Full) 254.0±1.52µs 252.9±0.78µs +0.43%
Clean js (Execution) 669.1±7.12µs 684.1±3.38µs -2.19%
Clean js (Full) 973.0±10.72µs 977.7±8.01µs -0.48%
Clean js (Parser) 40.5±0.07µs 40.4±0.11µs +0.25%
Create Realm 478.7±5.68ns 492.4±1.18ns -2.78%
Dynamic Object Property Access (Execution) 5.2±0.22µs 5.2±0.03µs 0.00%
Dynamic Object Property Access (Full) 264.1±21.49µs 254.1±1.09µs +3.94%
Expression (Parser) 7.2±0.57µs 7.1±0.02µs +1.41%
Fibonacci (Execution) 846.6±6.92µs 849.3±0.78µs -0.32%
Fibonacci (Full) 1126.3±12.14µs 1131.5±5.06µs -0.46%
For loop (Execution) 22.9±0.31µs 23.0±0.07µs -0.43%
For loop (Full) 279.2±2.94µs 274.0±0.58µs +1.90%
For loop (Parser) 19.3±0.12µs 19.6±0.04µs -1.53%
Goal Symbols (Parser) 13.7±0.09µs 13.6±0.04µs +0.74%
Hello World (Parser) 3.6±0.02µs 3.7±0.00µs -2.70%
Long file (Parser) 801.4±5.50ns 799.9±1.38ns +0.19%
Mini js (Execution) 599.0±6.30µs 612.4±3.42µs -2.19%
Mini js (Full) 879.7±9.06µs 887.3±3.56µs -0.86%
Mini js (Parser) 35.9±0.08µs 35.8±0.07µs +0.28%
Number Object Access (Execution) 4.0±0.04µs 4.3±0.20µs -6.98%
Number Object Access (Full) 249.1±1.27µs 244.1±1.29µs +2.05%
Object Creation (Execution) 4.3±0.04µs 4.4±0.04µs -2.27%
Object Creation (Full) 247.3±2.33µs 246.8±0.96µs +0.20%
RegExp (Execution) 9.6±0.12µs 9.6±0.03µs 0.00%
RegExp (Full) 264.5±4.71µs 260.6±0.51µs +1.50%
RegExp Literal (Execution) 10.9±0.15µs 11.0±0.06µs -0.91%
RegExp Literal (Full) 258.9±3.24µs 256.3±1.20µs +1.01%
RegExp Literal Creation (Execution) 9.6±0.11µs 9.5±0.03µs +1.05%
RegExp Literal Creation (Full) 253.9±2.80µs 249.9±0.67µs +1.60%
Static Object Property Access (Execution) 4.6±0.05µs 4.7±0.02µs -2.13%
Static Object Property Access (Full) 251.8±2.85µs 247.6±0.75µs +1.70%
String Object Access (Execution) 7.0±0.10µs 7.3±0.02µs -4.11%
String Object Access (Full) 254.1±3.19µs 256.8±0.58µs -1.05%
String comparison (Execution) 6.6±0.05µs 6.6±0.02µs 0.00%
String comparison (Full) 260.1±10.75µs 254.8±0.49µs +2.08%
String concatenation (Execution) 5.2±0.07µs 5.3±0.02µs -1.89%
String concatenation (Full) 248.4±1.59µs 244.6±0.54µs +1.55%
String copy (Execution) 4.1±0.17µs 4.0±0.01µs +2.50%
String copy (Full) 243.5±1.36µs 238.9±0.76µs +1.93%
Symbols (Execution) 3.3±0.03µs 3.4±0.02µs -2.94%
Symbols (Full) 239.7±2.64µs 235.6±0.57µs +1.74%

@Lan2u
Copy link
Author

Lan2u commented Jan 14, 2021

I've started looking at the execution stuff in the async_exec branch - I'm much less familiar with the execution side of boa so I have a lot of learning to do

@github-actions
Copy link

Benchmark for 1976cb4

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 324.5±18.50ns 363.7±0.36ns -10.78%
Arithmetic operations (Full) 213.3±14.52µs 208.9±11.85µs +2.11%
Array access (Execution) 5.6±0.47µs 6.1±0.20µs -8.20%
Array access (Full) 233.9±18.66µs 239.0±8.27µs -2.13%
Array creation (Execution) 3.0±0.11ms 2.6±0.11ms +15.38%
Array creation (Full) 3.1±0.11ms 3.1±0.11ms 0.00%
Array pop (Execution) 984.5±10.57µs 831.4±51.19µs +18.41%
Array pop (Full) 1348.3±89.10µs 1459.1±1.49µs -7.59%
Boolean Object Access (Execution) 4.7±0.26µs 4.9±0.48µs -4.08%
Boolean Object Access (Full) 227.0±11.77µs 235.7±15.01µs -3.69%
Clean js (Execution) 684.9±12.10µs 677.0±6.28µs +1.17%
Clean js (Full) 907.5±33.43µs 862.6±33.81µs +5.21%
Clean js (Parser) 37.1±2.50µs 37.4±2.98µs -0.80%
Create Realm 394.3±21.29ns 473.3±21.11ns -16.69%
Dynamic Object Property Access (Execution) 4.8±0.22µs 4.5±0.22µs +6.67%
Dynamic Object Property Access (Full) 248.8±3.79µs 270.7±41.45µs -8.09%
Expression (Parser) 6.6±0.23µs 6.2±0.76µs +6.45%
Fibonacci (Execution) 809.0±41.60µs 873.5±41.16µs -7.38%
Fibonacci (Full) 1060.5±53.99µs 1092.9±42.23µs -2.96%
For loop (Execution) 22.1±1.74µs 23.2±0.05µs -4.74%
For loop (Full) 258.4±16.50µs 265.4±8.34µs -2.64%
For loop (Parser) 18.1±0.91µs 18.1±1.10µs 0.00%
Goal Symbols (Parser) 12.8±0.67µs 12.4±0.59µs +3.23%
Hello World (Parser) 3.4±0.16µs 3.3±0.22µs +3.03%
Long file (Parser) 809.7±0.71ns 801.6±26.71ns +1.01%
Mini js (Execution) 566.7±40.61µs 557.3±25.17µs +1.69%
Mini js (Full) 817.4±37.64µs 780.6±84.72µs +4.71%
Mini js (Parser) 32.2±2.14µs 32.9±1.74µs -2.13%
Number Object Access (Execution) 3.6±0.14µs 3.7±0.32µs -2.70%
Number Object Access (Full) 231.9±11.63µs 238.2±11.04µs -2.64%
Object Creation (Execution) 4.2±0.17µs 3.6±0.27µs +16.67%
Object Creation (Full) 243.8±4.57µs 223.4±9.56µs +9.13%
RegExp (Execution) 9.5±0.15µs 9.0±0.47µs +5.56%
RegExp (Full) 260.9±3.52µs 232.4±13.72µs +12.26%
RegExp Literal (Execution) 11.0±0.13µs 10.1±0.55µs +8.91%
RegExp Literal (Full) 252.1±8.04µs 237.0±15.39µs +6.37%
RegExp Literal Creation (Execution) 9.7±0.04µs 9.4±0.17µs +3.19%
RegExp Literal Creation (Full) 252.4±2.71µs 264.2±11.43µs -4.47%
Static Object Property Access (Execution) 4.4±0.18µs 4.6±0.01µs -4.35%
Static Object Property Access (Full) 245.5±4.91µs 254.0±1.67µs -3.35%
String Object Access (Execution) 6.9±0.42µs 7.2±0.28µs -4.17%
String Object Access (Full) 232.2±10.92µs 240.2±16.95µs -3.33%
String comparison (Execution) 5.9±0.35µs 5.4±0.35µs +9.26%
String comparison (Full) 231.0±13.12µs 232.2±9.60µs -0.52%
String concatenation (Execution) 5.1±0.21µs 4.5±0.35µs +13.33%
String concatenation (Full) 234.9±7.95µs 225.2±9.64µs +4.31%
String copy (Execution) 3.7±0.18µs 3.9±0.00µs -5.13%
String copy (Full) 233.3±7.52µs 227.8±8.91µs +2.41%
Symbols (Execution) 3.1±0.13µs 3.3±0.09µs -6.06%
Symbols (Full) 215.6±13.00µs 216.5±9.58µs -0.42%

@github-actions
Copy link

Benchmark for c82081c

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 365.6±0.20ns 366.7±0.41ns -0.30%
Arithmetic operations (Full) 234.2±1.45µs 245.1±12.53µs -4.45%
Array access (Execution) 6.3±0.02µs 6.3±0.02µs 0.00%
Array access (Full) 264.5±7.61µs 267.9±40.08µs -1.27%
Array creation (Execution) 3.0±0.11ms 3.0±0.08ms 0.00%
Array creation (Full) 3.3±0.08ms 3.2±0.00ms +3.13%
Array pop (Execution) 966.9±24.03µs 970.2±20.08µs -0.34%
Array pop (Full) 1441.7±3.04µs 1408.9±4.14µs +2.33%
Boolean Object Access (Execution) 5.4±0.22µs 5.2±0.02µs +3.85%
Boolean Object Access (Full) 253.6±0.42µs 252.3±0.67µs +0.52%
Clean js (Execution) 712.2±22.01µs 688.4±3.70µs +3.46%
Clean js (Full) 987.5±5.41µs 991.6±7.45µs -0.41%
Clean js (Parser) 40.0±0.07µs 40.1±0.08µs -0.25%
Create Realm 456.5±12.80ns 452.2±0.31ns +0.95%
Dynamic Object Property Access (Execution) 5.4±0.40µs 5.3±0.18µs +1.89%
Dynamic Object Property Access (Full) 260.8±15.12µs 259.8±6.54µs +0.38%
Expression (Parser) 7.1±0.32µs 7.0±0.03µs +1.43%
Fibonacci (Execution) 858.7±0.90µs 844.7±1.06µs +1.66%
Fibonacci (Full) 1136.1±1.76µs 1131.1±3.16µs +0.44%
For loop (Execution) 23.4±0.28µs 23.8±0.10µs -1.68%
For loop (Full) 276.0±0.44µs 276.6±0.44µs -0.22%
For loop (Parser) 19.2±0.02µs 19.4±0.02µs -1.03%
Goal Symbols (Parser) 14.1±0.71µs 13.6±0.03µs +3.68%
Hello World (Parser) 3.6±0.05µs 3.6±0.01µs 0.00%
Long file (Parser) 809.5±1.23ns 807.3±1.34ns +0.27%
Mini js (Execution) 631.8±18.21µs 613.5±5.61µs +2.98%
Mini js (Full) 893.6±3.43µs 887.4±3.73µs +0.70%
Mini js (Parser) 35.5±0.05µs 35.6±0.04µs -0.28%
Number Object Access (Execution) 4.2±0.19µs 4.0±0.01µs +5.00%
Number Object Access (Full) 246.8±0.46µs 248.7±0.82µs -0.76%
Object Creation (Execution) 4.5±0.18µs 4.4±0.01µs +2.27%
Object Creation (Full) 245.5±0.36µs 248.8±0.55µs -1.33%
RegExp (Execution) 10.0±0.37µs 9.5±0.05µs +5.26%
RegExp (Full) 260.4±0.90µs 262.5±0.75µs -0.80%
RegExp Literal (Execution) 11.7±0.48µs 11.1±0.21µs +5.41%
RegExp Literal (Full) 268.7±10.01µs 262.2±0.79µs +2.48%
RegExp Literal Creation (Execution) 10.1±0.44µs 9.5±0.09µs +6.32%
RegExp Literal Creation (Full) 258.0±6.18µs 255.2±0.95µs +1.10%
Static Object Property Access (Execution) 4.8±0.20µs 4.8±0.26µs 0.00%
Static Object Property Access (Full) 249.9±0.40µs 249.6±0.70µs +0.12%
String Object Access (Execution) 7.2±0.27µs 7.2±0.02µs 0.00%
String Object Access (Full) 258.2±0.42µs 257.0±4.83µs +0.47%
String comparison (Execution) 6.9±0.38µs 6.7±0.04µs +2.99%
String comparison (Full) 257.4±0.54µs 255.0±0.42µs +0.94%
String concatenation (Execution) 5.5±0.33µs 5.3±0.02µs +3.77%
String concatenation (Full) 247.3±0.35µs 250.2±0.69µs -1.16%
String copy (Execution) 4.1±0.17µs 4.0±0.01µs +2.50%
String copy (Full) 245.8±10.75µs 243.7±0.69µs +0.86%
Symbols (Execution) 3.4±0.01µs 3.4±0.01µs 0.00%
Symbols (Full) 245.0±12.27µs 244.3±9.22µs +0.29%

Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good, just needs a rebase.

Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, sorry for my delay reviewing this. I saw some things that could be improved, though.

///
/// More information:
/// - [ECMAScript reference][spec]
/// - [MDN documentation][mdn]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this link is broken.

//! Async Arrow function parsing.
//!
//! More information:
//! - [MDN documentation][mdn]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation link seems broken.

/// Arrow function parsing.
///
/// More information:
/// - [MDN documentation][mdn]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation link seems broken.

/// - [ECMAScript specification][spec]
///
/// Async More information:
/// - [MDN documentation][async-mdn]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link seems broken.

/// As these are effectively the same we just use a flag to reduce code duplication.
///
/// More information:
/// - [MDN documentation][mdn]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link seems broken.

Ok(body)
}
_ => Ok(StatementList::from(vec![Return::new(
ExpressionBody::new(self.allow_in, self.is_async).parse(cursor)?,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it seems that this depends on this self.is_async parameter, but the spec doesn't say so.

match cursor.peek(0)?.ok_or(ParseError::AbruptEnd)?.kind() {
TokenKind::Punctuator(Punctuator::OpenBlock) => {
let _ = cursor.next();
let body = FunctionBody::new(false, self.is_async).parse(cursor)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the spec correctly, both options here should be false.

Comment on lines +30 to +33
/// UniqueFormalParameters / FormalParameters parsing.
///
/// Due to the similarity between these productions we use a unique flag rather than
/// duplicating the code.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I would prefer having the former FormalParameters, and then having another UniqueFormalParameters structure that would basically call FormalParameters::parse(), and would then do a check on the generated parameter list before returning the result.

Comment on lines +94 to +100
if self.unique && params.iter().any(|v| v.name() == next_param.name()) {
// https://tc39.es/ecma262/#prod-UniqueFormalParameters
return Err(ParseError::lex(LexError::Syntax(
"Invalid duplicate formal parameter name".into(),
pos,
)));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be a lexing error. It's a normal parsing error, the lexing was correct, but in this context, it's a syntax error, so a parsing error.

Comment on lines -82 to -369
fn check_arrow_assignment_2arg() {
check_parser(
"let foo = (a, b) => { return a };",
vec![LetDeclList::from(vec![LetDecl::new::<_, Option<Node>>(
Identifier::from("foo"),
Some(
ArrowFunctionDecl::new(
vec![
FormalParameter::new("a", None, false),
FormalParameter::new("b", None, false),
],
vec![Return::new::<Node, Option<_>, Option<_>>(
Some(Identifier::from("a").into()),
None,
)
.into()],
)
.into(),
),
)])
.into()],
);
}

#[test]
fn check_arrow_assignment_2arg_nobrackets() {
check_parser(
"let foo = (a, b) => a;",
vec![LetDeclList::from(vec![LetDecl::new::<_, Option<Node>>(
Identifier::from("foo"),
Some(
ArrowFunctionDecl::new(
vec![
FormalParameter::new("a", None, false),
FormalParameter::new("b", None, false),
],
vec![Return::new::<Node, Option<_>, Option<_>>(
Some(Identifier::from("a").into()),
None,
)
.into()],
)
.into(),
),
)])
.into()],
);
}

#[test]
fn check_arrow_assignment_3arg() {
check_parser(
"let foo = (a, b, c) => { return a };",
vec![LetDeclList::from(vec![LetDecl::new::<_, Option<Node>>(
Identifier::from("foo"),
Some(
ArrowFunctionDecl::new(
vec![
FormalParameter::new("a", None, false),
FormalParameter::new("b", None, false),
FormalParameter::new("c", None, false),
],
vec![Return::new::<Node, Option<_>, Option<_>>(
Some(Identifier::from("a").into()),
None,
)
.into()],
)
.into(),
),
)])
.into()],
);
}

#[test]
fn check_arrow_assignment_3arg_nobrackets() {
check_parser(
"let foo = (a, b, c) => a;",
vec![LetDeclList::from(vec![LetDecl::new::<_, Option<Node>>(
Identifier::from("foo"),
Some(
ArrowFunctionDecl::new(
vec![
FormalParameter::new("a", None, false),
FormalParameter::new("b", None, false),
FormalParameter::new("c", None, false),
],
vec![Return::new::<Node, Option<_>, Option<_>>(
Some(Identifier::from("a").into()),
None,
)
.into()],
)
.into(),
),
)])
.into()],
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were those tests moved?

@Razican Razican modified the milestones: v0.12.0, v0.13.0 May 22, 2021
@raskad raskad modified the milestones: v0.13.0, v0.14.0 Sep 25, 2021
@jasonwilliams
Copy link
Member

@Lan2u do you think you'll be coming back to this PR?

@Lan2u
Copy link
Author

Lan2u commented Oct 13, 2021

@Lan2u do you think you'll be coming back to this PR?

Unfortunately probably not, I haven't had much time over the last year.

@Razican
Copy link
Member

Razican commented Jan 29, 2022

I'm closing this PR, as this is now very outdated. I will create issues in order to be able to re-do this again.

@Razican Razican closed this Jan 29, 2022
@RageKnify RageKnify deleted the async_arrow_parse branch January 29, 2022 16:21
@lastmjs
Copy link
Contributor

lastmjs commented Feb 15, 2022

Do you think this code is relevant to implementing #1805? I'm new to the codebase and just gathering info

@Razican
Copy link
Member

Razican commented Feb 16, 2022

Do you think this code is relevant to implementing #1805? I'm new to the codebase and just gathering info

Things have changed a bit, but the general idea should still be valid :) so I think it can be useful to check the diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Issues surrounding the parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants