mirror of https://github.com/boa-dev/boa.git
Browse Source
Most of the time that we have a `ByValue` ( `[ value ]` syntax ) it is for arrays and the value is usually an index. This PR adds a fast path to the instructions (without calling `.borrow()` on the object to check if its an array) For example, this code: ```js let a = [1, 2, 3] for (let i = 0 ; i < 10000000; ++i) { a[i % 3] += a[ (i + 1) % 3 ] } ``` Using `hyperfine`, it ran `1.38` times faster on this PR. ```bash Benchmark 1: ./boa_main test.js Time (mean ± σ): 16.504 s ± 0.192 s [User: 16.440 s, System: 0.020 s] Range (min … max): 16.328 s … 16.938 s 10 runs Benchmark 2: ./boa_direct_array_access test.js Time (mean ± σ): 11.982 s ± 0.038 s [User: 11.939 s, System: 0.013 s] Range (min … max): 11.914 s … 12.035 s 10 runs Summary './boa_direct_array_access test.js' ran 1.38 ± 0.02 times faster than './boa_main test.js' ```pull/2723/head
Haled Odat
2 years ago
5 changed files with 120 additions and 7 deletions
Loading…
Reference in new issue