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

LibJS: Emit bytecode for function declaration instantiation #24272

Merged
merged 5 commits into from May 11, 2024

Conversation

kalenikaliaksandr
Copy link
Contributor

By doing that all instructions required for instantiation are emitted once in compilation and then reused for subsequent calls, instead of running generic instantiation process for each call.

@kalenikaliaksandr kalenikaliaksandr marked this pull request as draft May 9, 2024 17:57
@github-actions github-actions bot added 👀 pr-needs-review PR needs review from a maintainer or community member and removed 👀 pr-needs-review PR needs review from a maintainer or community member labels May 9, 2024
@kalenikaliaksandr kalenikaliaksandr force-pushed the fdi-bytecode branch 3 times, most recently from a769892 to 7fe07b3 Compare May 10, 2024 17:27
@kalenikaliaksandr kalenikaliaksandr marked this pull request as ready for review May 10, 2024 17:27
@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label May 10, 2024
@kalenikaliaksandr kalenikaliaksandr force-pushed the fdi-bytecode branch 2 times, most recently from 1810cc2 to 9d285a8 Compare May 10, 2024 18:14
@kalenikaliaksandr kalenikaliaksandr marked this pull request as draft May 10, 2024 18:29
@github-actions github-actions bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label May 10, 2024
@kalenikaliaksandr kalenikaliaksandr marked this pull request as ready for review May 10, 2024 21:20
@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label May 10, 2024
@kalenikaliaksandr
Copy link
Contributor Author

Benchmark results are mostly not affected by this change, but it moves us closer to some more useful Call optimizations by fixing following things:

  • Default parameters are no longer need separate executables which means we are closer to having 1:1 relationship between executables and execution contexts.
  • Getting rid of VM::binding_initialization() removes some execute_ast_node() calls (leftover from AST interpreter)
Suite       Test                                   Speedup  Old (Mean ± Range)        New (Mean ± Range)
----------  -----------------------------------  ---------  ------------------------  ------------------------
Kraken      ai-astar.js                              1.014  1.875 ± 1.870 … 1.880     1.850 ± 1.810 … 1.890
Kraken      audio-beat-detection.js                  0.975  1.350 ± 1.340 … 1.360     1.385 ± 1.380 … 1.390
Kraken      audio-dft.js                             1.037  1.115 ± 1.100 … 1.130     1.075 ± 1.060 … 1.090
Kraken      audio-fft.js                             1.004  1.235 ± 1.230 … 1.240     1.230 ± 1.230 … 1.230
Kraken      audio-oscillator.js                      0.979  1.370 ± 1.330 … 1.410     1.400 ± 1.390 … 1.410
Kraken      imaging-darkroom.js                      0.941  1.820 ± 1.820 … 1.820     1.935 ± 1.740 … 2.130
Kraken      imaging-desaturate.js                    0.991  1.700 ± 1.700 … 1.700     1.715 ± 1.710 … 1.720
Kraken      imaging-gaussian-blur.js                 1.051  8.045 ± 7.820 … 8.270     7.655 ± 7.460 … 7.850
Kraken      json-parse-financial.js                  1      0.115 ± 0.110 … 0.120     0.115 ± 0.110 … 0.120
Kraken      json-stringify-tinderbox.js              1.02   0.255 ± 0.250 … 0.260     0.250 ± 0.250 … 0.250
Kraken      stanford-crypto-aes.js                   0.983  0.585 ± 0.580 … 0.590     0.595 ± 0.590 … 0.600
Kraken      stanford-crypto-ccm.js                   1.021  0.480 ± 0.480 … 0.480     0.470 ± 0.470 … 0.470
Kraken      stanford-crypto-pbkdf2.js                1.016  0.935 ± 0.930 … 0.940     0.920 ± 0.900 … 0.940
Kraken      stanford-crypto-sha256-iterative.js      1      0.380 ± 0.380 … 0.380     0.380 ± 0.380 … 0.380
Octane      box2d.js                                 0.858  2.145 ± 2.140 … 2.150     2.500 ± 2.490 … 2.510
Octane      code-load.js                             1.016  2.175 ± 2.170 … 2.180     2.140 ± 2.140 … 2.140
Octane      crypto.js                                0.988  6.120 ± 6.020 … 6.220     6.195 ± 6.130 … 6.260
Octane      deltablue.js                             0.995  2.020 ± 2.010 … 2.030     2.030 ± 2.030 … 2.030
Octane      earley-boyer.js                          1.063  15.645 ± 15.510 … 15.780  14.715 ± 14.690 … 14.740
Octane      gbemu.js                                 1.002  2.540 ± 2.540 … 2.540     2.535 ± 2.510 … 2.560
Octane      mandreel.js                              1.019  11.840 ± 11.840 … 11.840  11.620 ± 11.480 … 11.760
Octane      navier-stokes.js                         0.99   3.115 ± 3.090 … 3.140     3.145 ± 3.060 … 3.230
Octane      pdfjs.js                                 1.008  2.580 ± 2.580 … 2.580     2.560 ± 2.550 … 2.570
Octane      raytrace.js                              1.093  6.115 ± 6.100 … 6.130     5.595 ± 5.540 … 5.650
Octane      regexp.js                                0.999  18.485 ± 18.400 … 18.570  18.505 ± 18.400 … 18.610
Octane      richards.js                              1      2.010 ± 2.010 … 2.010     2.010 ± 2.010 … 2.010
Octane      splay.js                                 1.004  2.680 ± 2.670 … 2.690     2.670 ± 2.660 … 2.680
Octane      typescript.js                            1.031  31.195 ± 31.140 … 31.250  30.245 ± 30.190 … 30.300
Octane      zlib.js                                  1.012  85.765 ± 85.590 … 85.940  84.710 ± 84.580 … 84.840
Kraken      Total                                    1.014  21.260                    20.975
Octane      Total                                    1.017  194.430                   191.175
All Suites  Total                                    1.017  215.690                   212.150

Preparation for upcoming function where binding pattern will have to be
used outside of ASTCodegen.cpp
Preparation for upcoming changes where NewFunction will have to be used
with FunctionDeclaration node.
By doing that all instructions required for instantiation are emitted
once in compilation and then reused for subsequent calls, instead of
running generic instantiation process for each call.
If the minimal amount of required bindings is known in advance, it could
be used to ensure capacity to avoid resizing the internal vector that
holds bindings.
This function was used for function params initialization but no longer
used after it got replaced by emitting bytecode.
@awesomekling awesomekling merged commit 1e361db into SerenityOS:master May 11, 2024
10 of 11 checks passed
@github-actions github-actions bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants