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: Get this from execution context for non-arrow functions #24405

Merged

Conversation

kalenikaliaksandr
Copy link
Contributor

Allows to skip function environment allocation for non-arrow functions if the only reason it is needed is to hold this binding.

The parser is changed to do following:

  • If a function is an arrow function and uses this then all functions in a scope chain are marked to allocate function environment for this binding.
  • If a function uses new.target then all functions in a scope chain are marked to allocate function environment.

ordinary_call_bind_this() is changed to put this value in execution context when function environment allocation is skipped.

35% improvement in Octane/typescript.js
50% improvement in Octane/deltablue.js
19% improvement in Octane/raytrace.js

Suite       Test                                   Speedup  Old (Mean ± Range)        New (Mean ± Range)
----------  -----------------------------------  ---------  ------------------------  ------------------------
Kraken      ai-astar.js                              0.957  1.875 ± 1.870 … 1.880     1.960 ± 1.950 … 1.970
Kraken      audio-beat-detection.js                  0.986  1.410 ± 1.410 … 1.410     1.430 ± 1.430 … 1.430
Kraken      audio-dft.js                             1.017  1.205 ± 1.190 … 1.220     1.185 ± 1.170 … 1.200
Kraken      audio-fft.js                             1.004  1.320 ± 1.310 … 1.330     1.315 ± 1.310 … 1.320
Kraken      audio-oscillator.js                      0.993  1.445 ± 1.440 … 1.450     1.455 ± 1.450 … 1.460
Kraken      imaging-darkroom.js                      0.966  2.430 ± 2.400 … 2.460     2.515 ± 2.510 … 2.520
Kraken      imaging-desaturate.js                    0.985  2.010 ± 2.010 … 2.010     2.040 ± 2.040 … 2.040
Kraken      imaging-gaussian-blur.js                 0.991  7.515 ± 7.490 … 7.540     7.585 ± 7.560 … 7.610
Kraken      json-parse-financial.js                  0.778  0.140 ± 0.140 … 0.140     0.180 ± 0.160 … 0.200
Kraken      json-stringify-tinderbox.js              0.906  0.240 ± 0.240 … 0.240     0.265 ± 0.260 … 0.270
Kraken      stanford-crypto-aes.js                   1.045  0.690 ± 0.690 … 0.690     0.660 ± 0.650 … 0.670
Kraken      stanford-crypto-ccm.js                   1.072  0.595 ± 0.590 … 0.600     0.555 ± 0.550 … 0.560
Kraken      stanford-crypto-pbkdf2.js                1.059  1.175 ± 1.170 … 1.180     1.110 ± 1.100 … 1.120
Kraken      stanford-crypto-sha256-iterative.js      1.043  0.485 ± 0.480 … 0.490     0.465 ± 0.460 … 0.470
Octane      box2d.js                                 1.203  2.545 ± 2.540 … 2.550     2.115 ± 2.110 … 2.120
Octane      code-load.js                             0.993  2.070 ± 2.060 … 2.080     2.085 ± 2.080 … 2.090
Octane      crypto.js                                1.151  7.130 ± 7.110 … 7.150     6.195 ± 6.110 … 6.280
Octane      deltablue.js                             1.51   3.050 ± 3.050 … 3.050     2.020 ± 2.010 … 2.030
Octane      earley-boyer.js                          1.109  19.405 ± 19.280 … 19.530  17.490 ± 17.480 … 17.500
Octane      gbemu.js                                 1.06   3.175 ± 3.150 … 3.200     2.995 ± 2.980 … 3.010
Octane      mandreel.js                              1      13.955 ± 13.880 … 14.030  13.960 ± 13.830 … 14.090
Octane      navier-stokes.js                         1.005  3.185 ± 3.140 … 3.230     3.170 ± 3.160 … 3.180
Octane      pdfjs.js                                 1.062  3.085 ± 3.070 … 3.100     2.905 ± 2.900 … 2.910
Octane      raytrace.js                              1.188  6.625 ± 6.550 … 6.700     5.575 ± 5.570 … 5.580
Octane      regexp.js                                1.005  22.905 ± 22.760 … 23.050  22.795 ± 22.770 … 22.820
Octane      richards.js                              1.002  2.020 ± 2.020 … 2.020     2.015 ± 2.010 … 2.020
Octane      splay.js                                 1.026  2.715 ± 2.710 … 2.720     2.645 ± 2.620 … 2.670
Octane      typescript.js                            1.395  36.855 ± 36.360 … 37.350  26.415 ± 26.310 … 26.520
Octane      zlib.js                                  1.005  72.960 ± 72.530 … 73.390  72.565 ± 72.130 … 73.000
Kraken      Total                                    0.992  22.535                    22.720
Octane      Total                                    1.09   201.680                   184.945
All Suites  Total                                    1.08   224.215                   207.665

@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label May 21, 2024
@kalenikaliaksandr kalenikaliaksandr force-pushed the skip-more-fe-allocations branch 2 times, most recently from f80ae53 to c0ccbed Compare May 21, 2024 22:22
Allows to skip function environment allocation for non-arrow functions
if the only reason it is needed is to hold `this` binding.

The parser is changed to do following:
- If a function is an arrow function and uses `this` then all functions
  in a scope chain are marked to allocate function environment for
  `this` binding.
- If a function uses `new.target` then all functions in a scope chain
  are marked to allocate function environment.

`ordinary_call_bind_this()` is changed to put `this` value in execution
context when function environment allocation is skipped.

35% improvement in Octane/typescript.js
50% improvement in Octane/deltablue.js
19% improvement in Octane/raytrace.js
@awesomekling awesomekling merged commit ebb3d80 into SerenityOS:master May 22, 2024
11 checks passed
@github-actions github-actions bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label May 22, 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