mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 20:16:02 +00:00
LibJS: Optimize Function.prototype.apply()
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macOS, macos-15, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macOS, macOS-arm64, macos-15) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, Linux, Linux-x86_64, blacksmith-8vcpu-ubuntu-2404) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macOS, macos-15, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macOS, macOS-arm64, macos-15) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, Linux, Linux-x86_64, blacksmith-8vcpu-ubuntu-2404) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
...by avoiding `CreateListFromArrayLike` in cases when we could directly use elements of underlying object's indexed properties storage. Makes this program go 2.1x faster: ```js function target(a, b, c) { return a + b + c; } const args = [1, 2, 3]; let result = 0; (function() { for (let i = 0; i < 10_000_000; i++) { result += target.apply(null, args); } })(); ```
This commit is contained in:
parent
3f7c4dd5f6
commit
1274f4e2f7
Notes:
github-actions[bot]
2025-06-03 15:17:07 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 1274f4e2f7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4967
2 changed files with 26 additions and 0 deletions
|
@ -50,6 +50,16 @@ test("basic functionality", () => {
|
|||
expect((() => this).apply("foo")).toBe(globalThis);
|
||||
});
|
||||
|
||||
test("array with holes", () => {
|
||||
function target(a, b, c) {
|
||||
return a + b + c;
|
||||
}
|
||||
|
||||
const args = [1, , 3];
|
||||
const result = target.apply(null, args);
|
||||
expect(result).toBe(NaN);
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("does not accept non-function values", () => {
|
||||
expect(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue