mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibJS: Make IteratorRecord inherit from Cell, not Object
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (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-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (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
This shaves its size down from 104 bytes to 48 bytes, cutting GC pressure caused by this type in more than half.
This commit is contained in:
parent
1d88c4529c
commit
5f12b2a05d
Notes:
github-actions[bot]
2025-03-22 22:00:36 +00:00
Author: https://github.com/awesomekling
Commit: 5f12b2a05d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4051
5 changed files with 18 additions and 25 deletions
|
@ -31,7 +31,7 @@ Iterator::Iterator(Object& prototype, GC::Ref<IteratorRecord> iterated)
|
|||
}
|
||||
|
||||
Iterator::Iterator(Object& prototype)
|
||||
: Iterator(prototype, prototype.shape().realm().create<IteratorRecord>(prototype.shape().realm(), nullptr, js_undefined(), false))
|
||||
: Iterator(prototype, prototype.heap().allocate<IteratorRecord>(nullptr, js_undefined(), false))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,7 @@ ThrowCompletionOr<GC::Ref<IteratorRecord>> get_iterator_direct(VM& vm, Object& o
|
|||
|
||||
// 2. Let iteratorRecord be Record { [[Iterator]]: obj, [[NextMethod]]: nextMethod, [[Done]]: false }.
|
||||
// 3. Return iteratorRecord.
|
||||
auto& realm = *vm.current_realm();
|
||||
return realm.create<IteratorRecord>(realm, object, next_method, false);
|
||||
return vm.heap().allocate<IteratorRecord>(object, next_method, false);
|
||||
}
|
||||
|
||||
// 7.4.3 GetIteratorFromMethod ( obj, method ), https://tc39.es/ecma262/#sec-getiteratorfrommethod
|
||||
|
@ -61,8 +60,7 @@ ThrowCompletionOr<GC::Ref<IteratorRecord>> get_iterator_from_method(VM& vm, Valu
|
|||
auto next_method = TRY(iterator.get(vm, vm.names.next));
|
||||
|
||||
// 4. Let iteratorRecord be the Iterator Record { [[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false }.
|
||||
auto& realm = *vm.current_realm();
|
||||
auto iterator_record = realm.create<IteratorRecord>(realm, iterator.as_object(), next_method, false);
|
||||
auto iterator_record = vm.heap().allocate<IteratorRecord>(iterator.as_object(), next_method, false);
|
||||
|
||||
// 5. Return iteratorRecord.
|
||||
return iterator_record;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue