mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-14 14:21:56 +00:00
LibJS: Don't create a GC::Function for every JS::NativeFunction
Instead, let JS::NativeFunction store the AK::Function directly, and take care of conservatively marking its captured data. This avoids an extra GC allocation for every JS::NativeFunction.
This commit is contained in:
parent
4283c73d02
commit
5290dcf650
Notes:
github-actions[bot]
2025-04-20 16:44:46 +00:00
Author: https://github.com/awesomekling
Commit: 5290dcf650
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4408
4 changed files with 13 additions and 15 deletions
|
@ -375,16 +375,15 @@ GC_DEFINE_ALLOCATOR(ExportedWasmFunction);
|
|||
|
||||
GC::Ref<ExportedWasmFunction> ExportedWasmFunction::create(JS::Realm& realm, FlyString const& name, Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)> behavior, Wasm::FunctionAddress exported_address)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
auto prototype = realm.intrinsics().function_prototype();
|
||||
return realm.create<ExportedWasmFunction>(
|
||||
name,
|
||||
GC::create_function(vm.heap(), move(behavior)),
|
||||
move(behavior),
|
||||
exported_address,
|
||||
prototype);
|
||||
}
|
||||
|
||||
ExportedWasmFunction::ExportedWasmFunction(FlyString name, GC::Ptr<GC::Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)>> behavior, Wasm::FunctionAddress exported_address, JS::Object& prototype)
|
||||
ExportedWasmFunction::ExportedWasmFunction(FlyString name, AK::Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)> behavior, Wasm::FunctionAddress exported_address, JS::Object& prototype)
|
||||
: NativeFunction(move(name), move(behavior), prototype)
|
||||
, m_exported_address(exported_address)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue