mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 21:12:08 +02:00
LibJS: Separate raw and capturing native functions
NativeFunction previously stored an AK::Function for every builtin, even when the callable was just a plain C++ entry point. That mixed together two different representations, made simple builtins carry capture storage they did not need, and forced the GC to treat every native function as if it might contain captured JS values. Introduce RawNativeFunction for plain NativeFunctionPointer callees and keep AK::Function-backed callables on a CapturingNativeFunction subclass. Update the straightforward native registrations in LibJS and LibWeb to use the raw representation, while leaving exported Wasm functions on the capturing path because they still capture state. Wrap UniversalGlobalScope's byte-length strategy lambda in Function<...> explicitly so it keeps selecting the capturing NativeFunction::create overload.
This commit is contained in:
committed by
Andreas Kling
parent
fadea53343
commit
8a9d5ee1a1
Notes:
github-actions[bot]
2026-04-15 13:59:08 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/8a9d5ee1a12 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8922 Reviewed-by: https://github.com/shannonbooth
@@ -94,10 +94,15 @@ public:
|
||||
|
||||
Wasm::FunctionAddress exported_address() const { return m_exported_address; }
|
||||
|
||||
virtual JS::ThrowCompletionOr<JS::Value> call() override;
|
||||
|
||||
protected:
|
||||
ExportedWasmFunction(Utf16FlyString name, AK::Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)>, Wasm::FunctionAddress, Object& prototype);
|
||||
|
||||
private:
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
AK::Function<JS::ThrowCompletionOr<JS::Value>(JS::VM&)> m_behavior;
|
||||
Wasm::FunctionAddress m_exported_address;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user