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

Redesign bytecode virtual machine #1361

Merged
merged 1 commit into from
Jul 5, 2021
Merged

Redesign bytecode virtual machine #1361

merged 1 commit into from
Jul 5, 2021

Conversation

HalidOdat
Copy link
Member

@HalidOdat HalidOdat commented Jun 24, 2021

The previous virtual machine was not really a bytecode vm, since did not interpret bytecode, rather it interpreted and array of fat enums, while this is easier to implement is has bad space efficiency (also bad performance), one instruction was 32 bytes (on 64-bit machine) and consequently all other instructions where 32 bytes.
So for this code:

PushOne
pop

It would take 64 bytes. But now with an actual bytecode vm we only need 2 bytes.

Also implemented some other stuff:

  • Jumping opcodes
  • If-else
  • while
  • do-while
  • break
  • continue
  • labeled loops
  • short-circit operators (&&, ||, ??)
  • Variable assignment
  • Object property getting and setting
  • Binary assign operators
  • throwing
  • conditional operator (?:)
  • Array expression ([1, 2, 3, 4])
  • this
  • instanceof operator

@HalidOdat HalidOdat added enhancement New feature or request vm Issues and PRs related to the Boa Virtual Machine. labels Jun 24, 2021
@HalidOdat HalidOdat marked this pull request as draft June 24, 2021 18:11
@github-actions
Copy link

Benchmark for 247eb6d

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 366.6±11.45ns 360.4±10.61ns +1.72%
Arithmetic operations (Full) 280.3±4.75µs 264.1±7.10µs +6.13%
Array access (Execution) 6.1±0.21µs 6.3±0.22µs -3.17%
Array access (Full) 305.3±3.51µs 296.3±8.61µs +3.04%
Array creation (Execution) 2.6±0.07ms 2.6±0.08ms 0.00%
Array creation (Full) 3.1±0.02ms 3.0±0.09ms +3.33%
Array pop (Execution) 856.4±26.28µs 852.2±20.36µs +0.49%
Array pop (Full) 1413.0±10.99µs 1312.9±39.65µs +7.62%
Boolean Object Access (Execution) 5.1±0.16µs 5.2±0.15µs -1.92%
Boolean Object Access (Full) 294.4±7.19µs 281.1±9.52µs +4.73%
Clean js (Execution) 616.7±15.45µs 605.2±16.51µs +1.90%
Clean js (Full) 982.2±6.38µs 932.6±27.03µs +5.32%
Clean js (Parser) 40.0±0.49µs 38.2±1.13µs +4.71%
Create Realm 428.9±6.80ns 430.1±6.30ns -0.28%
Dynamic Object Property Access (Execution) 5.2±0.14µs 5.1±0.19µs +1.96%
Dynamic Object Property Access (Full) 307.0±1.85µs 280.9±8.97µs +9.29%
Expression (Parser) 7.1±0.08µs 6.7±0.27µs +5.97%
Fibonacci (Execution) 742.6±20.03µs 770.4±7.57µs -3.61%
Fibonacci (Full) 1117.1±11.27µs 1031.4±33.92µs +8.31%
For loop (Execution) 22.0±0.26µs 22.1±0.15µs -0.45%
For loop (Full) 316.9±2.59µs 297.6±8.94µs +6.49%
For loop (Parser) 19.4±0.20µs 18.6±0.55µs +4.30%
Goal Symbols (Parser) 14.3±0.08µs 13.8±0.41µs +3.62%
Hello World (Parser) 3.9±0.03µs 3.8±0.13µs +2.63%
Long file (Parser) 786.1±11.24ns 746.3±23.52ns +5.33%
Mini js (Execution) 578.6±5.93µs 560.8±17.85µs +3.17%
Mini js (Full) 903.6±12.70µs 861.0±24.73µs +4.95%
Mini js (Parser) 35.1±0.18µs 33.5±0.89µs +4.78%
Number Object Access (Execution) 4.0±0.12µs 4.1±0.11µs -2.44%
Number Object Access (Full) 275.2±8.61µs 273.4±9.86µs +0.66%
Object Creation (Execution) 4.3±0.16µs 4.4±0.09µs -2.27%
Object Creation (Full) 300.3±1.73µs 285.9±8.71µs +5.04%
RegExp (Execution) 11.3±0.46µs 11.0±0.45µs +2.73%
RegExp (Full) 314.0±3.02µs 298.7±10.15µs +5.12%
RegExp Literal (Execution) 11.1±0.45µs 11.6±0.30µs -4.31%
RegExp Literal (Full) 308.5±2.31µs 296.4±8.51µs +4.08%
RegExp Literal Creation (Execution) 9.7±0.30µs 9.6±0.31µs +1.04%
RegExp Literal Creation (Full) 306.3±4.14µs 286.5±8.59µs +6.91%
Static Object Property Access (Execution) 4.7±0.15µs 4.6±0.13µs +2.17%
Static Object Property Access (Full) 298.6±2.28µs 282.5±9.35µs +5.70%
String Object Access (Execution) 7.1±0.24µs 7.1±0.21µs 0.00%
String Object Access (Full) 300.5±3.06µs 287.5±11.10µs +4.52%
String comparison (Execution) 6.3±0.20µs 6.2±0.21µs +1.61%
String comparison (Full) 302.9±3.37µs 285.6±8.41µs +6.06%
String concatenation (Execution) 5.0±0.14µs 4.9±0.17µs +2.04%
String concatenation (Full) 297.9±1.96µs 274.8±9.32µs +8.41%
String copy (Execution) 3.9±0.13µs 3.9±0.12µs 0.00%
String copy (Full) 280.5±8.62µs 276.4±8.34µs +1.48%
Symbols (Execution) 3.5±0.05µs 3.5±0.04µs 0.00%
Symbols (Full) 279.2±3.03µs 261.2±8.58µs +6.89%

@github-actions
Copy link

Benchmark for 54fb08e

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 357.7±13.66ns 372.2±9.74ns -3.90%
Arithmetic operations (Full) 270.0±7.78µs 260.7±11.33µs +3.57%
Array access (Execution) 5.8±0.28µs 6.5±0.19µs -10.77%
Array access (Full) 301.1±7.50µs 291.4±11.14µs +3.33%
Array creation (Execution) 2.6±0.13ms 2.7±0.08ms -3.70%
Array creation (Full) 3.0±0.06ms 2.9±0.13ms +3.45%
Array pop (Execution) 881.7±26.74µs 814.0±37.11µs +8.32%
Array pop (Full) 1335.8±32.54µs 1405.2±28.75µs -4.94%
Boolean Object Access (Execution) 5.3±0.18µs 5.0±0.25µs +6.00%
Boolean Object Access (Full) 291.6±6.96µs 293.9±4.67µs -0.78%
Clean js (Execution) 634.7±10.36µs 632.3±16.60µs +0.38%
Clean js (Full) 932.0±24.85µs 946.6±44.32µs -1.54%
Clean js (Parser) 40.1±0.88µs 38.0±1.93µs +5.53%
Create Realm 406.0±21.13ns 417.6±12.43ns -2.78%
Dynamic Object Property Access (Execution) 5.2±0.12µs 5.2±0.06µs 0.00%
Dynamic Object Property Access (Full) 297.5±7.83µs 292.6±7.02µs +1.67%
Expression (Parser) 7.0±0.17µs 6.9±0.27µs +1.45%
Fibonacci (Execution) 742.6±29.63µs 763.0±11.80µs -2.67%
Fibonacci (Full) 1095.7±17.71µs 1096.6±25.11µs -0.08%
For loop (Execution) 21.3±0.79µs 21.7±0.52µs -1.84%
For loop (Full) 301.4±7.68µs 312.0±4.19µs -3.40%
For loop (Parser) 19.0±0.51µs 19.4±0.39µs -2.06%
Goal Symbols (Parser) 14.4±0.16µs 13.7±0.46µs +5.11%
Hello World (Parser) 3.8±0.09µs 3.8±0.13µs 0.00%
Long file (Parser) 791.5±2.26ns 777.1±25.60ns +1.85%
Mini js (Execution) 574.0±11.35µs 564.9±13.73µs +1.61%
Mini js (Full) 906.0±10.35µs 869.7±37.06µs +4.17%
Mini js (Parser) 33.7±0.83µs 35.1±0.38µs -3.99%
Number Object Access (Execution) 4.3±0.13µs 4.2±0.08µs +2.38%
Number Object Access (Full) 264.4±12.11µs 291.5±3.67µs -9.30%
Object Creation (Execution) 4.4±0.12µs 4.2±0.16µs +4.76%
Object Creation (Full) 294.7±4.78µs 285.2±9.87µs +3.33%
RegExp (Execution) 11.8±0.37µs 11.8±0.32µs 0.00%
RegExp (Full) 299.4±7.57µs 299.1±8.22µs +0.10%
RegExp Literal (Execution) 11.3±0.60µs 12.0±0.13µs -5.83%
RegExp Literal (Full) 289.0±10.53µs 280.1±13.74µs +3.18%
RegExp Literal Creation (Execution) 10.3±0.17µs 9.4±0.47µs +9.57%
RegExp Literal Creation (Full) 295.9±4.39µs 298.1±4.49µs -0.74%
Static Object Property Access (Execution) 4.6±0.13µs 4.7±0.13µs -2.13%
Static Object Property Access (Full) 289.6±6.43µs 282.5±10.87µs +2.51%
String Object Access (Execution) 7.2±0.27µs 6.7±0.33µs +7.46%
String Object Access (Full) 301.7±2.71µs 276.0±17.90µs +9.31%
String comparison (Execution) 6.2±0.33µs 6.1±0.27µs +1.64%
String comparison (Full) 300.2±7.24µs 297.7±4.32µs +0.84%
String concatenation (Execution) 5.3±0.10µs 4.8±0.28µs +10.42%
String concatenation (Full) 293.1±3.65µs 284.6±9.71µs +2.99%
String copy (Execution) 3.6±0.16µs 4.0±0.12µs -10.00%
String copy (Full) 276.5±9.78µs 285.0±0.36µs -2.98%
Symbols (Execution) 3.4±0.14µs 3.5±0.08µs -2.86%
Symbols (Full) 264.4±11.12µs 264.2±8.40µs +0.08%

@jasonwilliams
Copy link
Member

Looks good so far, and yes i was hoping to reduce the bytecodes down to actual codes rather than fat enums. Thanks for refactoring this.

@github-actions
Copy link

Benchmark for 725a2c8

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 367.5±5.39ns 368.1±5.11ns -0.16%
Arithmetic operations (Full) 268.9±3.10µs 267.7±4.52µs +0.45%
Array access (Execution) 6.4±0.10µs 6.5±0.10µs -1.54%
Array access (Full) 296.9±5.40µs 292.8±4.33µs +1.40%
Array creation (Execution) 2.6±0.04ms 2.7±0.05ms -3.70%
Array creation (Full) 3.1±0.03ms 3.0±0.05ms +3.33%
Array pop (Execution) 868.4±13.47µs 872.5±10.08µs -0.47%
Array pop (Full) 1380.6±20.51µs 1354.8±31.53µs +1.90%
Boolean Object Access (Execution) 5.3±0.08µs 5.3±0.07µs 0.00%
Boolean Object Access (Full) 294.8±4.42µs 285.0±4.38µs +3.44%
Clean js (Execution) 638.2±8.27µs 616.0±10.80µs +3.60%
Clean js (Full) 953.8±12.94µs 937.5±15.46µs +1.74%
Clean js (Parser) 39.3±0.56µs 38.6±0.49µs +1.81%
Create Realm 418.8±8.37ns 431.3±6.08ns -2.90%
Dynamic Object Property Access (Execution) 5.1±0.08µs 5.4±0.10µs -5.56%
Dynamic Object Property Access (Full) 294.1±4.49µs 287.3±5.51µs +2.37%
Expression (Parser) 7.0±0.12µs 6.9±0.11µs +1.45%
Fibonacci (Execution) 755.7±12.56µs 750.6±10.51µs +0.68%
Fibonacci (Full) 1077.4±16.70µs 1070.5±20.47µs +0.64%
For loop (Execution) 21.4±0.36µs 21.8±0.32µs -1.83%
For loop (Full) 308.1±4.39µs 300.4±3.26µs +2.56%
For loop (Parser) 19.1±0.31µs 18.9±0.36µs +1.06%
Goal Symbols (Parser) 14.0±0.24µs 13.6±0.30µs +2.94%
Hello World (Parser) 3.9±0.05µs 3.8±0.06µs +2.63%
Long file (Parser) 771.5±13.81ns 762.4±12.37ns +1.19%
Mini js (Execution) 566.7±8.41µs 549.0±7.22µs +3.22%
Mini js (Full) 881.9±13.16µs 879.5±15.94µs +0.27%
Mini js (Parser) 34.4±0.55µs 33.7±0.77µs +2.08%
Number Object Access (Execution) 4.2±0.07µs 4.2±0.08µs 0.00%
Number Object Access (Full) 289.1±4.52µs 281.4±5.40µs +2.74%
Object Creation (Execution) 4.4±0.12µs 4.6±0.07µs -4.35%
Object Creation (Full) 286.1±4.64µs 286.8±6.09µs -0.24%
RegExp (Execution) 11.2±0.19µs 11.7±0.21µs -4.27%
RegExp (Full) 298.5±4.70µs 288.2±9.15µs +3.57%
RegExp Literal (Execution) 11.1±0.17µs 11.9±0.18µs -6.72%
RegExp Literal (Full) 301.5±4.29µs 298.8±5.83µs +0.90%
RegExp Literal Creation (Execution) 9.4±0.13µs 10.0±0.18µs -6.00%
RegExp Literal Creation (Full) 285.1±5.57µs 296.0±4.84µs -3.68%
Static Object Property Access (Execution) 4.6±0.07µs 4.8±0.08µs -4.17%
Static Object Property Access (Full) 286.8±5.50µs 288.6±5.48µs -0.62%
String Object Access (Execution) 7.4±0.10µs 7.4±0.12µs 0.00%
String Object Access (Full) 294.6±4.21µs 292.6±4.32µs +0.68%
String comparison (Execution) 6.5±0.11µs 6.6±0.12µs -1.52%
String comparison (Full) 291.0±3.73µs 285.8±4.73µs +1.82%
String concatenation (Execution) 5.1±0.08µs 5.3±0.08µs -3.77%
String concatenation (Full) 288.6±3.98µs 284.1±4.66µs +1.58%
String copy (Execution) 4.0±0.06µs 3.9±0.05µs +2.56%
String copy (Full) 278.7±4.06µs 272.9±3.27µs +2.13%
Symbols (Execution) 3.4±0.06µs 3.5±0.06µs -2.86%
Symbols (Full) 273.9±4.24µs 269.3±5.53µs +1.71%

@Razican Razican changed the title Redesign bytecode vritual machine Redesign bytecode virtual machine Jun 25, 2021
@github-actions
Copy link

Benchmark for 5d799fa

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 355.1±16.22ns 351.2±15.17ns +1.11%
Arithmetic operations (Full) 264.4±12.74µs 270.1±10.97µs -2.11%
Array access (Execution) 6.1±0.30µs 6.2±0.33µs -1.61%
Array access (Full) 285.5±18.03µs 288.1±15.14µs -0.90%
Array creation (Execution) 2.7±0.18ms 2.5±0.16ms +8.00%
Array creation (Full) 2.9±0.16ms 2.9±0.13ms 0.00%
Array pop (Execution) 861.2±49.40µs 855.5±27.67µs +0.67%
Array pop (Full) 1349.1±87.24µs 1373.3±28.41µs -1.76%
Boolean Object Access (Execution) 5.1±0.26µs 5.1±0.29µs 0.00%
Boolean Object Access (Full) 283.0±9.66µs 290.2±15.89µs -2.48%
Clean js (Execution) 601.9±26.55µs 592.2±30.88µs +1.64%
Clean js (Full) 927.8±34.41µs 927.0±34.19µs +0.09%
Clean js (Parser) 39.6±1.01µs 38.1±1.60µs +3.94%
Create Realm 416.7±21.79ns 416.0±23.35ns +0.17%
Dynamic Object Property Access (Execution) 5.1±0.19µs 5.0±0.25µs +2.00%
Dynamic Object Property Access (Full) 284.1±11.58µs 281.4±13.05µs +0.96%
Expression (Parser) 7.0±0.12µs 6.9±0.25µs +1.45%
Fibonacci (Execution) 725.4±31.80µs 711.0±31.45µs +2.03%
Fibonacci (Full) 1013.0±50.36µs 1047.6±73.41µs -3.30%
For loop (Execution) 20.8±0.88µs 21.0±0.90µs -0.95%
For loop (Full) 296.8±9.70µs 301.9±9.62µs -1.69%
For loop (Parser) 18.9±0.85µs 18.0±0.94µs +5.00%
Goal Symbols (Parser) 13.5±0.56µs 13.5±0.65µs 0.00%
Hello World (Parser) 3.8±0.14µs 3.6±0.16µs +5.56%
Long file (Parser) 772.8±22.89ns 751.8±29.99ns +2.79%
Mini js (Execution) 551.9±28.55µs 531.6±26.65µs +3.82%
Mini js (Full) 855.1±35.33µs 861.5±28.08µs -0.74%
Mini js (Parser) 33.9±1.27µs 33.7±1.79µs +0.59%
Number Object Access (Execution) 4.0±0.18µs 4.1±0.15µs -2.44%
Number Object Access (Full) 276.8±12.58µs 278.8±9.96µs -0.72%
Object Creation (Execution) 4.3±0.18µs 4.4±0.19µs -2.27%
Object Creation (Full) 278.2±17.34µs 295.1±13.32µs -5.73%
RegExp (Execution) 11.0±0.37µs 11.2±0.32µs -1.79%
RegExp (Full) 294.0±10.81µs 302.4±7.40µs -2.78%
RegExp Literal (Execution) 11.2±0.26µs 11.8±0.27µs -5.08%
RegExp Literal (Full) 288.7±11.60µs 305.7±6.73µs -5.56%
RegExp Literal Creation (Execution) 9.7±0.25µs 9.8±0.31µs -1.02%
RegExp Literal Creation (Full) 280.8±11.91µs 289.7±9.37µs -3.07%
Static Object Property Access (Execution) 4.6±0.16µs 4.6±0.22µs 0.00%
Static Object Property Access (Full) 275.3±12.42µs 293.9±5.63µs -6.33%
String Object Access (Execution) 7.0±0.28µs 7.1±0.27µs -1.41%
String Object Access (Full) 284.3±11.90µs 278.4±13.13µs +2.12%
String comparison (Execution) 6.3±0.26µs 6.5±0.24µs -3.08%
String comparison (Full) 283.0±13.70µs 285.6±11.24µs -0.91%
String concatenation (Execution) 5.2±0.21µs 5.3±0.15µs -1.89%
String concatenation (Full) 272.1±12.93µs 287.1±5.93µs -5.22%
String copy (Execution) 3.9±0.20µs 3.9±0.14µs 0.00%
String copy (Full) 273.1±10.90µs 283.0±7.36µs -3.50%
Symbols (Execution) 3.4±0.13µs 3.3±0.16µs +3.03%
Symbols (Full) 256.0±12.60µs 262.1±13.83µs -2.33%

@HalidOdat HalidOdat added this to the v0.13.0 milestone Jun 28, 2021
@HalidOdat HalidOdat marked this pull request as ready for review June 28, 2021 20:46
@github-actions
Copy link

Test262 conformance changes:

Test result master count PR count difference
Total 78,897 78,897 0
Passed 26,974 26,974 0
Ignored 15,616 15,616 0
Failed 36,307 36,307 0
Panics 0 0 0
Conformance 34.19% 34.19% 0.00%

@HalidOdat
Copy link
Member Author

This is ready to review/merge :)

I wanted to add more stuff like function/calls and catching error (both require a lot of change to the current execution scheme, call frames and stack unwinding). But I already added a lot in this PR, so I will leave this for separate PRs after this gets merged.

Hopefully in the near future we will completely replace the AST walker executor.

@github-actions
Copy link

Benchmark for 62e7ae6

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 374.8±22.21ns 358.9±23.17ns +4.43%
Arithmetic operations (Full) 300.7±23.82µs 297.4±18.78µs +1.11%
Array access (Execution) 7.0±0.37µs 7.2±0.37µs -2.78%
Array access (Full) 325.5±19.28µs 334.8±18.32µs -2.78%
Array creation (Execution) 2.7±0.19ms 2.7±0.15ms 0.00%
Array creation (Full) 3.0±0.16ms 3.0±0.19ms 0.00%
Array pop (Execution) 868.5±58.13µs 848.6±34.73µs +2.35%
Array pop (Full) 1402.6±82.77µs 1373.9±80.12µs +2.09%
Boolean Object Access (Execution) 5.6±0.28µs 5.8±0.31µs -3.45%
Boolean Object Access (Full) 314.7±12.16µs 324.6±21.47µs -3.05%
Clean js (Execution) 630.0±25.92µs 655.2±37.10µs -3.85%
Clean js (Full) 991.5±49.01µs 1063.1±71.46µs -6.74%
Clean js (Parser) 42.4±5.79µs 43.3±2.24µs -2.08%
Create Realm 442.2±23.54ns 440.3±23.83ns +0.43%
Dynamic Object Property Access (Execution) 5.7±0.33µs 6.1±0.78µs -6.56%
Dynamic Object Property Access (Full) 320.9±21.71µs 325.3±15.54µs -1.35%
Expression (Parser) 7.1±0.46µs 7.1±0.34µs 0.00%
Fibonacci (Execution) 870.4±35.86µs 891.8±38.91µs -2.40%
Fibonacci (Full) 1189.0±66.84µs 1226.6±58.54µs -3.07%
For loop (Execution) 22.6±1.30µs 23.6±1.07µs -4.24%
For loop (Full) 328.1±15.18µs 335.9±25.24µs -2.32%
For loop (Parser) 19.9±1.23µs 20.8±1.13µs -4.33%
Goal Symbols (Parser) 14.1±1.17µs 15.0±1.11µs -6.00%
Hello World (Parser) 3.9±0.27µs 4.2±0.59µs -7.14%
Long file (Parser) 800.7±59.33ns 849.0±55.38ns -5.69%
Mini js (Execution) 560.8±35.02µs 584.6±30.68µs -4.07%
Mini js (Full) 919.1±43.52µs 957.0±47.55µs -3.96%
Mini js (Parser) 36.3±2.67µs 37.8±2.58µs -3.97%
Number Object Access (Execution) 4.4±0.24µs 4.5±0.26µs -2.22%
Number Object Access (Full) 327.0±16.56µs 313.5±15.72µs +4.31%
Object Creation (Execution) 5.0±0.25µs 5.0±0.26µs 0.00%
Object Creation (Full) 315.5±13.26µs 327.3±21.69µs -3.61%
RegExp (Execution) 11.9±0.84µs 12.1±0.64µs -1.65%
RegExp (Full) 335.7±22.02µs 325.6±15.00µs +3.10%
RegExp Literal (Execution) 12.0±0.63µs 12.0±0.74µs 0.00%
RegExp Literal (Full) 335.1±16.10µs 332.1±18.11µs +0.90%
RegExp Literal Creation (Execution) 9.9±0.81µs 10.4±0.51µs -4.81%
RegExp Literal Creation (Full) 332.2±24.32µs 320.6±18.07µs +3.62%
Static Object Property Access (Execution) 5.3±0.27µs 5.2±0.35µs +1.92%
Static Object Property Access (Full) 337.8±23.82µs 319.0±19.32µs +5.89%
String Object Access (Execution) 8.3±0.59µs 7.9±0.46µs +5.06%
String Object Access (Full) 315.7±12.96µs 321.8±15.53µs -1.90%
String comparison (Execution) 7.2±0.34µs 7.1±0.46µs +1.41%
String comparison (Full) 325.7±18.47µs 327.0±22.89µs -0.40%
String concatenation (Execution) 5.7±0.25µs 5.9±0.30µs -3.39%
String concatenation (Full) 319.1±26.01µs 317.8±12.53µs +0.41%
String copy (Execution) 4.5±0.28µs 4.4±0.29µs +2.27%
String copy (Full) 313.2±18.52µs 303.9±15.05µs +3.06%
Symbols (Execution) 3.9±0.20µs 4.0±0.23µs -2.50%
Symbols (Full) 297.4±18.88µs 296.9±17.69µs +0.17%

@github-actions
Copy link

Benchmark for 9f20035

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 374.0±0.30ns 373.7±0.20ns +0.08%
Arithmetic operations (Full) 280.4±1.45µs 283.1±0.40µs -0.95%
Array access (Execution) 6.6±0.02µs 6.5±0.04µs +1.54%
Array access (Full) 304.5±1.71µs 304.2±0.55µs +0.10%
Array creation (Execution) 2.8±0.01ms 2.7±0.00ms +3.70%
Array creation (Full) 3.1±0.02ms 3.1±0.02ms 0.00%
Array pop (Execution) 901.8±3.31µs 901.4±2.68µs +0.04%
Array pop (Full) 1414.9±1.62µs 1411.5±3.70µs +0.24%
Boolean Object Access (Execution) 5.5±0.02µs 5.5±0.02µs 0.00%
Boolean Object Access (Full) 297.4±0.73µs 297.1±0.75µs +0.10%
Clean js (Execution) 643.8±3.03µs 646.7±3.87µs -0.45%
Clean js (Full) 976.9±3.58µs 985.0±5.72µs -0.82%
Clean js (Parser) 40.5±0.08µs 40.7±0.05µs -0.49%
Create Realm 435.6±0.69ns 438.2±1.88ns -0.59%
Dynamic Object Property Access (Execution) 5.4±0.02µs 5.2±0.01µs +3.85%
Dynamic Object Property Access (Full) 300.7±3.83µs 301.7±0.54µs -0.33%
Expression (Parser) 7.2±0.01µs 7.2±0.01µs 0.00%
Fibonacci (Execution) 771.3±2.63µs 769.5±1.34µs +0.23%
Fibonacci (Full) 1099.5±3.56µs 1105.5±2.21µs -0.54%
For loop (Execution) 22.2±0.06µs 22.2±0.07µs 0.00%
For loop (Full) 313.5±0.68µs 316.2±0.56µs -0.85%
For loop (Parser) 19.8±0.03µs 19.7±0.04µs +0.51%
Goal Symbols (Parser) 14.2±0.02µs 14.2±0.02µs 0.00%
Hello World (Parser) 3.9±0.00µs 3.9±0.01µs 0.00%
Long file (Parser) 803.1±1.03ns 806.0±1.47ns -0.36%
Mini js (Execution) 581.8±3.34µs 584.6±3.65µs -0.48%
Mini js (Full) 909.5±3.30µs 917.5±4.44µs -0.87%
Mini js (Parser) 35.4±0.06µs 35.2±0.04µs +0.57%
Number Object Access (Execution) 4.3±0.01µs 4.3±0.01µs 0.00%
Number Object Access (Full) 289.8±0.41µs 294.5±0.48µs -1.60%
Object Creation (Execution) 4.6±0.03µs 4.5±0.01µs +2.22%
Object Creation (Full) 295.0±0.70µs 298.9±0.76µs -1.30%
RegExp (Execution) 11.6±0.19µs 12.0±0.08µs -3.33%
RegExp (Full) 308.4±1.11µs 313.3±0.40µs -1.56%
RegExp Literal (Execution) 11.5±0.05µs 12.0±0.09µs -4.17%
RegExp Literal (Full) 311.6±4.73µs 311.4±0.75µs +0.06%
RegExp Literal Creation (Execution) 9.9±0.03µs 10.3±0.03µs -3.88%
RegExp Literal Creation (Full) 300.7±0.79µs 304.2±2.44µs -1.15%
Static Object Property Access (Execution) 4.8±0.01µs 4.8±0.01µs 0.00%
Static Object Property Access (Full) 297.8±0.70µs 299.9±1.13µs -0.70%
String Object Access (Execution) 7.5±0.04µs 7.5±0.03µs 0.00%
String Object Access (Full) 299.9±5.95µs 303.2±0.71µs -1.09%
String comparison (Execution) 6.8±0.12µs 6.5±0.02µs +4.62%
String comparison (Full) 302.8±0.35µs 299.7±0.48µs +1.03%
String concatenation (Execution) 5.4±0.02µs 5.4±0.01µs 0.00%
String concatenation (Full) 291.9±0.86µs 292.7±0.48µs -0.27%
String copy (Execution) 4.0±0.01µs 4.1±0.01µs -2.44%
String copy (Full) 289.3±0.52µs 287.2±2.72µs +0.73%
Symbols (Execution) 3.5±0.01µs 3.5±0.02µs 0.00%
Symbols (Full) 276.5±0.82µs 279.8±0.82µs -1.18%

@github-actions
Copy link

Benchmark for b1df807

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 274.8±0.13ns 274.6±0.14ns +0.07%
Arithmetic operations (Full) 205.2±1.60µs 234.1±0.75µs -12.35%
Array access (Execution) 4.8±0.02µs 4.9±0.02µs -2.04%
Array access (Full) 258.5±0.57µs 225.7±0.34µs +14.53%
Array creation (Execution) 2.3±0.00ms 2.0±0.00ms +15.00%
Array creation (Full) 2.3±0.00ms 2.6±0.00ms -11.54%
Array pop (Execution) 751.3±4.95µs 660.8±2.29µs +13.70%
Array pop (Full) 1037.8±1.94µs 1180.2±1.67µs -12.07%
Boolean Object Access (Execution) 4.6±0.01µs 4.6±0.01µs 0.00%
Boolean Object Access (Full) 220.8±0.45µs 247.8±0.68µs -10.90%
Clean js (Execution) 537.9±3.75µs 534.6±4.34µs +0.62%
Clean js (Full) 722.6±5.25µs 727.0±3.20µs -0.61%
Clean js (Parser) 31.4±0.03µs 31.4±0.03µs 0.00%
Create Realm 322.9±2.07ns 317.2±3.28ns +1.80%
Dynamic Object Property Access (Execution) 4.5±0.01µs 3.9±0.01µs +15.38%
Dynamic Object Property Access (Full) 223.1±0.38µs 221.0±0.23µs +0.95%
Expression (Parser) 5.3±0.07µs 5.4±0.01µs -1.85%
Fibonacci (Execution) 576.7±1.35µs 650.2±1.44µs -11.30%
Fibonacci (Full) 929.6±1.10µs 820.0±2.07µs +13.37%
For loop (Execution) 16.4±0.03µs 18.5±0.07µs -11.35%
For loop (Full) 265.4±0.61µs 267.4±0.66µs -0.75%
For loop (Parser) 15.0±0.17µs 17.2±0.03µs -12.79%
Goal Symbols (Parser) 10.9±0.07µs 10.9±0.01µs 0.00%
Hello World (Parser) 2.9±0.03µs 3.0±0.00µs -3.33%
Long file (Parser) 626.7±5.35ns 632.3±12.04ns -0.89%
Mini js (Execution) 483.3±3.24µs 482.9±3.58µs +0.08%
Mini js (Full) 663.4±8.08µs 672.1±2.49µs -1.29%
Mini js (Parser) 27.2±0.03µs 27.4±0.10µs -0.73%
Number Object Access (Execution) 3.6±0.01µs 3.2±0.01µs +12.50%
Number Object Access (Full) 215.6±0.43µs 215.7±0.41µs -0.05%
Object Creation (Execution) 3.8±0.01µs 3.4±0.01µs +11.76%
Object Creation (Full) 217.8±0.68µs 249.1±1.14µs -12.57%
RegExp (Execution) 9.6±0.03µs 10.1±0.09µs -4.95%
RegExp (Full) 230.8±1.25µs 230.7±0.29µs +0.04%
RegExp Literal (Execution) 9.6±0.04µs 10.0±0.03µs -4.00%
RegExp Literal (Full) 256.3±0.46µs 228.1±0.51µs +12.36%
RegExp Literal Creation (Execution) 8.3±0.04µs 7.5±0.02µs +10.67%
RegExp Literal Creation (Full) 222.6±1.65µs 253.4±0.40µs -12.15%
Static Object Property Access (Execution) 4.0±0.01µs 3.6±0.02µs +11.11%
Static Object Property Access (Full) 223.1±0.33µs 249.1±0.35µs -10.44%
String Object Access (Execution) 6.3±0.03µs 5.5±0.04µs +14.55%
String Object Access (Full) 222.1±0.79µs 251.6±0.36µs -11.72%
String comparison (Execution) 5.6±0.03µs 4.9±0.01µs +14.29%
String comparison (Full) 220.9±0.22µs 221.4±0.76µs -0.23%
String concatenation (Execution) 4.5±0.02µs 3.9±0.01µs +15.38%
String concatenation (Full) 217.4±0.37µs 216.2±0.29µs +0.56%
String copy (Execution) 3.4±0.01µs 3.0±0.01µs +13.33%
String copy (Full) 213.6±0.28µs 214.6±1.15µs -0.47%
Symbols (Execution) 3.0±0.00µs 2.6±0.00µs +15.38%
Symbols (Full) 232.8±0.56µs 233.2±0.48µs -0.17%

@github-actions
Copy link

Benchmark for bea70aa

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 367.4±14.36ns 367.8±15.54ns -0.11%
Arithmetic operations (Full) 299.6±15.95µs 300.0±12.59µs -0.13%
Array access (Execution) 7.5±0.43µs 7.1±0.34µs +5.63%
Array access (Full) 322.8±14.60µs 328.6±14.06µs -1.77%
Array creation (Execution) 2.8±0.09ms 2.8±0.09ms 0.00%
Array creation (Full) 3.1±0.17ms 3.1±0.11ms 0.00%
Array pop (Execution) 905.2±57.11µs 868.1±51.06µs +4.27%
Array pop (Full) 1356.9±73.40µs 1407.0±52.19µs -3.56%
Boolean Object Access (Execution) 5.9±0.28µs 5.9±0.32µs 0.00%
Boolean Object Access (Full) 347.2±35.98µs 321.4±13.07µs +8.03%
Clean js (Execution) 668.0±23.33µs 675.2±30.81µs -1.07%
Clean js (Full) 1033.4±54.50µs 999.9±42.37µs +3.35%
Clean js (Parser) 41.4±2.44µs 43.1±2.43µs -3.94%
Create Realm 442.4±16.00ns 453.1±29.30ns -2.36%
Dynamic Object Property Access (Execution) 6.0±0.25µs 5.7±0.33µs +5.26%
Dynamic Object Property Access (Full) 326.5±15.84µs 333.4±14.97µs -2.07%
Expression (Parser) 8.1±0.43µs 7.7±0.36µs +5.19%
Fibonacci (Execution) 914.4±44.36µs 854.9±33.95µs +6.96%
Fibonacci (Full) 1250.7±70.16µs 1219.7±66.69µs +2.54%
For loop (Execution) 24.1±1.75µs 23.8±2.62µs +1.26%
For loop (Full) 358.2±39.97µs 335.1±14.85µs +6.89%
For loop (Parser) 21.2±1.79µs 20.7±0.95µs +2.42%
Goal Symbols (Parser) 14.9±0.79µs 14.6±0.55µs +2.05%
Hello World (Parser) 4.1±0.18µs 4.0±0.25µs +2.50%
Long file (Parser) 837.8±58.55ns 811.3±41.11ns +3.27%
Mini js (Execution) 604.1±35.10µs 599.3±27.25µs +0.80%
Mini js (Full) 961.0±29.04µs 939.4±29.39µs +2.30%
Mini js (Parser) 35.9±2.08µs 37.8±1.91µs -5.03%
Number Object Access (Execution) 4.7±0.46µs 4.6±0.16µs +2.17%
Number Object Access (Full) 317.5±17.47µs 318.0±14.49µs -0.16%
Object Creation (Execution) 5.2±0.37µs 5.4±0.31µs -3.70%
Object Creation (Full) 337.0±24.82µs 321.2±12.89µs +4.92%
RegExp (Execution) 12.4±0.53µs 12.0±0.63µs +3.33%
RegExp (Full) 333.1±17.67µs 335.3±14.07µs -0.66%
RegExp Literal (Execution) 12.5±0.75µs 11.8±0.62µs +5.93%
RegExp Literal (Full) 326.9±14.98µs 341.2±15.37µs -4.19%
RegExp Literal Creation (Execution) 10.7±0.48µs 10.3±0.42µs +3.88%
RegExp Literal Creation (Full) 326.7±27.22µs 334.0±35.73µs -2.19%
Static Object Property Access (Execution) 5.8±0.98µs 5.4±0.26µs +7.41%
Static Object Property Access (Full) 333.8±48.10µs 328.4±33.20µs +1.64%
String Object Access (Execution) 8.1±0.34µs 8.2±0.60µs -1.22%
String Object Access (Full) 321.9±15.25µs 326.5±12.37µs -1.41%
String comparison (Execution) 6.9±0.27µs 7.3±0.36µs -5.48%
String comparison (Full) 325.5±14.64µs 327.6±15.74µs -0.64%
String concatenation (Execution) 5.7±0.54µs 5.9±0.24µs -3.39%
String concatenation (Full) 311.8±18.39µs 324.5±13.23µs -3.91%
String copy (Execution) 4.4±0.15µs 4.4±0.17µs 0.00%
String copy (Full) 318.7±10.56µs 316.1±11.59µs +0.82%
Symbols (Execution) 3.9±0.11µs 3.9±0.20µs 0.00%
Symbols (Full) 303.7±21.58µs 305.0±12.32µs -0.43%

boa/src/syntax/ast/node/mod.rs Show resolved Hide resolved
docs/vm.md Outdated Show resolved Hide resolved
boa/src/vm/opcode.rs Outdated Show resolved Hide resolved
boa/src/vm/opcode.rs Outdated Show resolved Hide resolved
boa/src/vm/opcode.rs Show resolved Hide resolved
@github-actions
Copy link

Benchmark for 8598a21

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 362.7±17.51ns 358.2±17.38ns +1.26%
Arithmetic operations (Full) 260.4±12.77µs 267.1±12.58µs -2.51%
Array access (Execution) 6.2±0.56µs 6.3±0.28µs -1.59%
Array access (Full) 277.2±18.39µs 291.2±18.96µs -4.81%
Array creation (Execution) 2.4±0.19ms 2.6±0.10ms -7.69%
Array creation (Full) 2.8±0.17ms 3.1±0.14ms -9.68%
Array pop (Execution) 849.8±46.64µs 861.1±50.29µs -1.31%
Array pop (Full) 1334.5±66.83µs 1345.6±54.46µs -0.82%
Boolean Object Access (Execution) 5.0±0.36µs 5.2±0.22µs -3.85%
Boolean Object Access (Full) 282.8±13.78µs 286.4±14.86µs -1.26%
Clean js (Execution) 586.6±40.33µs 614.4±25.60µs -4.52%
Clean js (Full) 927.8±31.41µs 932.2±31.58µs -0.47%
Clean js (Parser) 37.8±1.60µs 39.6±1.49µs -4.55%
Create Realm 438.1±24.36ns 407.8±17.70ns +7.43%
Dynamic Object Property Access (Execution) 4.7±0.44µs 5.0±0.25µs -6.00%
Dynamic Object Property Access (Full) 285.2±13.04µs 296.1±21.28µs -3.68%
Expression (Parser) 6.8±0.26µs 6.8±0.62µs 0.00%
Fibonacci (Execution) 747.9±24.48µs 743.3±36.45µs +0.62%
Fibonacci (Full) 1059.4±67.41µs 1078.4±67.06µs -1.76%
For loop (Execution) 21.2±1.12µs 20.9±1.04µs +1.44%
For loop (Full) 292.9±19.88µs 302.1±15.15µs -3.05%
For loop (Parser) 18.9±0.80µs 18.7±0.75µs +1.07%
Goal Symbols (Parser) 13.8±0.70µs 13.6±0.70µs +1.47%
Hello World (Parser) 3.7±0.14µs 3.8±0.16µs -2.63%
Long file (Parser) 766.8±34.68ns 804.4±63.57ns -4.67%
Mini js (Execution) 537.8±31.45µs 544.7±28.10µs -1.27%
Mini js (Full) 854.3±30.89µs 881.6±43.56µs -3.10%
Mini js (Parser) 33.6±1.76µs 33.5±2.37µs +0.30%
Number Object Access (Execution) 3.7±0.27µs 4.0±0.18µs -7.50%
Number Object Access (Full) 276.7±13.27µs 284.6±31.03µs -2.78%
Object Creation (Execution) 4.3±0.27µs 4.3±0.17µs 0.00%
Object Creation (Full) 295.3±22.29µs 285.1±11.39µs +3.58%
RegExp (Execution) 10.9±1.35µs 11.5±0.49µs -5.22%
RegExp (Full) 299.7±18.14µs 299.6±11.68µs +0.03%
RegExp Literal (Execution) 10.6±0.72µs 11.4±0.55µs -7.02%
RegExp Literal (Full) 293.8±13.40µs 303.6±32.02µs -3.23%
RegExp Literal Creation (Execution) 9.5±0.54µs 9.6±0.45µs -1.04%
RegExp Literal Creation (Full) 293.4±16.58µs 304.1±17.59µs -3.52%
Static Object Property Access (Execution) 4.6±0.24µs 4.5±0.20µs +2.22%
Static Object Property Access (Full) 286.3±11.64µs 285.3±15.41µs +0.35%
String Object Access (Execution) 7.2±0.85µs 7.1±0.47µs +1.41%
String Object Access (Full) 287.2±14.71µs 286.7±15.32µs +0.17%
String comparison (Execution) 6.8±0.33µs 6.4±0.28µs +6.25%
String comparison (Full) 296.0±14.13µs 287.1±16.08µs +3.10%
String concatenation (Execution) 5.5±0.42µs 5.0±0.25µs +10.00%
String concatenation (Full) 283.6±13.98µs 290.0±14.92µs -2.21%
String copy (Execution) 4.2±0.21µs 3.8±0.16µs +10.53%
String copy (Full) 279.6±16.80µs 279.3±17.17µs +0.11%
Symbols (Execution) 3.4±0.20µs 3.4±0.17µs 0.00%
Symbols (Full) 257.5±19.39µs 271.9±14.75µs -5.30%

@HalidOdat HalidOdat requested a review from Razican June 30, 2021 00:09
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.

Looks very good :) I think this will improve how we build the VM. Dividing statements, expressions and so on in Node should improve the big matches.

boa/src/bytecompiler.rs Show resolved Hide resolved
 - Implemented Jump and JumpIfFalse opcodes
 - Implemented If in vm
 - Implement assign to identifiers
 - Implement JumpIfTrue opcode
 - Implemented short circuit operators
 - Implement while loop
 - Implement do-while loop
 - Pop expressions
 - Split compilation for epression and statement
 - simplify boolean compilation
 - Implement loop break and continue with labels
 - Implement getting property from object
 - Implement setting object properties
 - Implement binary assign
 - Implement throw
 - Split variable names from literals
 - Implement conditional operator
 - Implement array expressions without spread
 - Implement some unary operators
 - Add accessor types
 - Implement this
 - Add opcode for pushing rationals
 - Implement instanceof operator
@github-actions
Copy link

Benchmark for 25179ca

Click to view benchmark
Test PR Benchmark Master Benchmark %
Arithmetic operations (Execution) 373.4±1.38ns 370.0±3.69ns +0.92%
Arithmetic operations (Full) 281.3±1.14µs 282.1±2.54µs -0.28%
Array access (Execution) 6.7±0.04µs 6.6±0.02µs +1.52%
Array access (Full) 309.3±0.75µs 314.1±3.15µs -1.53%
Array creation (Execution) 3.1±0.00ms 3.1±0.00ms 0.00%
Array creation (Full) 3.4±0.01ms 3.5±0.02ms -2.86%
Array pop (Execution) 990.9±5.29µs 993.4±3.90µs -0.25%
Array pop (Full) 1495.2±5.71µs 1494.0±16.83µs +0.08%
Boolean Object Access (Execution) 5.5±0.02µs 5.5±0.02µs 0.00%
Boolean Object Access (Full) 302.6±0.60µs 302.4±2.37µs +0.07%
Clean js (Execution) 657.0±3.70µs 653.2±6.42µs +0.58%
Clean js (Full) 990.4±5.22µs 1003.1±6.23µs -1.27%
Clean js (Parser) 41.2±0.06µs 41.2±0.20µs 0.00%
Create Realm 429.0±1.24ns 453.5±0.64ns -5.40%
Dynamic Object Property Access (Execution) 5.2±0.07µs 5.3±0.03µs -1.89%
Dynamic Object Property Access (Full) 302.4±0.56µs 308.8±2.79µs -2.07%
Expression (Parser) 7.3±0.03µs 7.2±0.03µs +1.39%
Fibonacci (Execution) 776.3±1.85µs 775.6±1.02µs +0.09%
Fibonacci (Full) 1102.5±2.67µs 1101.1±11.03µs +0.13%
For loop (Execution) 22.3±0.12µs 22.6±0.10µs -1.33%
For loop (Full) 315.8±0.97µs 324.3±0.58µs -2.62%
For loop (Parser) 19.8±0.13µs 19.9±0.15µs -0.50%
Goal Symbols (Parser) 14.4±0.03µs 14.5±0.03µs -0.69%
Hello World (Parser) 3.9±0.02µs 3.9±0.02µs 0.00%
Long file (Parser) 803.3±8.87ns 790.9±0.96ns +1.57%
Mini js (Execution) 594.7±4.01µs 593.8±7.94µs +0.15%
Mini js (Full) 925.7±4.30µs 933.6±3.48µs -0.85%
Mini js (Parser) 35.8±0.09µs 35.8±0.12µs 0.00%
Number Object Access (Execution) 4.3±0.01µs 4.3±0.02µs 0.00%
Number Object Access (Full) 294.4±1.60µs 296.9±2.98µs -0.84%
Object Creation (Execution) 4.6±0.01µs 4.5±0.06µs +2.22%
Object Creation (Full) 302.2±0.95µs 305.4±1.12µs -1.05%
RegExp (Execution) 11.4±0.11µs 11.8±0.12µs -3.39%
RegExp (Full) 307.0±1.23µs 313.9±4.05µs -2.20%
RegExp Literal (Execution) 11.5±0.07µs 11.8±0.10µs -2.54%
RegExp Literal (Full) 310.7±1.65µs 315.6±1.74µs -1.55%
RegExp Literal Creation (Execution) 9.9±0.03µs 10.4±0.04µs -4.81%
RegExp Literal Creation (Full) 305.1±1.33µs 306.6±3.13µs -0.49%
Static Object Property Access (Execution) 4.8±0.03µs 4.8±0.04µs 0.00%
Static Object Property Access (Full) 305.3±0.55µs 306.7±1.01µs -0.46%
String Object Access (Execution) 7.4±0.17µs 7.5±0.03µs -1.33%
String Object Access (Full) 303.8±0.68µs 307.0±0.69µs -1.04%
String comparison (Execution) 6.6±0.05µs 6.7±0.09µs -1.49%
String comparison (Full) 303.2±1.74µs 310.7±2.21µs -2.41%
String concatenation (Execution) 5.4±0.05µs 5.4±0.07µs 0.00%
String concatenation (Full) 297.7±1.11µs 302.3±1.26µs -1.52%
String copy (Execution) 4.0±0.03µs 4.1±0.03µs -2.44%
String copy (Full) 287.9±2.76µs 293.9±1.39µs -2.04%
Symbols (Execution) 3.5±0.02µs 3.5±0.01µs 0.00%
Symbols (Full) 283.5±0.51µs 287.1±0.86µs -1.25%

@jasonwilliams
Copy link
Member

Will take a look today/tomorrow hopefully

@HalidOdat
Copy link
Member Author

Lets merge this, so other features are not blocked :)

@HalidOdat HalidOdat merged commit f33dbcc into master Jul 5, 2021
@HalidOdat HalidOdat deleted the bytecode-vm branch July 5, 2021 14:30
@jasonwilliams jasonwilliams mentioned this pull request Sep 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vm Issues and PRs related to the Boa Virtual Machine.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants