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:
Andreas Kling 2025-04-20 13:08:56 +02:00 committed by Andreas Kling
commit 5290dcf650
Notes: github-actions[bot] 2025-04-20 16:44:46 +00:00
4 changed files with 13 additions and 15 deletions

View file

@ -77,7 +77,7 @@ public:
Wasm::FunctionAddress exported_address() const { return m_exported_address; }
protected:
ExportedWasmFunction(FlyString name, GC::Ptr<GC::Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)>>, Wasm::FunctionAddress, Object& prototype);
ExportedWasmFunction(FlyString name, AK::Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)>, Wasm::FunctionAddress, Object& prototype);
private:
Wasm::FunctionAddress m_exported_address;