mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the namespace change, we now have the following names: * JS::NonnullGCPtr -> GC::Ref * JS::GCPtr -> GC::Ptr * JS::HeapFunction -> GC::Function * JS::CellImpl -> GC::Cell * JS::Handle -> GC::Root
This commit is contained in:
parent
ce23efc5f6
commit
f87041bf3a
Notes:
github-actions[bot]
2024-11-15 13:50:17 +00:00
Author: https://github.com/shannonbooth
Commit: f87041bf3a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2345
1722 changed files with 9939 additions and 9906 deletions
|
@ -8,8 +8,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <LibGC/Root.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
#include <LibWasm/AbstractMachine/AbstractMachine.h>
|
||||
|
@ -21,13 +21,13 @@ namespace Web::WebAssembly {
|
|||
void visit_edges(JS::Object&, JS::Cell::Visitor&);
|
||||
void finalize(JS::Object&);
|
||||
|
||||
bool validate(JS::VM&, JS::Handle<WebIDL::BufferSource>& bytes);
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> compile(JS::VM&, JS::Handle<WebIDL::BufferSource>& bytes);
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> compile_streaming(JS::VM&, JS::Handle<WebIDL::Promise> source);
|
||||
bool validate(JS::VM&, GC::Root<WebIDL::BufferSource>& bytes);
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> compile(JS::VM&, GC::Root<WebIDL::BufferSource>& bytes);
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> compile_streaming(JS::VM&, GC::Root<WebIDL::Promise> source);
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> instantiate(JS::VM&, JS::Handle<WebIDL::BufferSource>& bytes, Optional<JS::Handle<JS::Object>>& import_object);
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> instantiate(JS::VM&, Module const& module_object, Optional<JS::Handle<JS::Object>>& import_object);
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> instantiate_streaming(JS::VM&, JS::Handle<WebIDL::Promise> source, Optional<JS::Handle<JS::Object>>& import_object);
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> instantiate(JS::VM&, GC::Root<WebIDL::BufferSource>& bytes, Optional<GC::Root<JS::Object>>& import_object);
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> instantiate(JS::VM&, Module const& module_object, Optional<GC::Root<JS::Object>>& import_object);
|
||||
WebIDL::ExceptionOr<GC::Ref<WebIDL::Promise>> instantiate_streaming(JS::VM&, GC::Root<WebIDL::Promise> source, Optional<GC::Root<JS::Object>>& import_object);
|
||||
|
||||
namespace Detail {
|
||||
struct CompiledWebAssemblyModule : public RefCounted<CompiledWebAssemblyModule> {
|
||||
|
@ -42,36 +42,36 @@ struct CompiledWebAssemblyModule : public RefCounted<CompiledWebAssemblyModule>
|
|||
class WebAssemblyCache {
|
||||
public:
|
||||
void add_compiled_module(NonnullRefPtr<CompiledWebAssemblyModule> module) { m_compiled_modules.append(module); }
|
||||
void add_function_instance(Wasm::FunctionAddress address, JS::GCPtr<JS::NativeFunction> function) { m_function_instances.set(address, function); }
|
||||
void add_imported_object(JS::GCPtr<JS::Object> object) { m_imported_objects.set(object); }
|
||||
void add_function_instance(Wasm::FunctionAddress address, GC::Ptr<JS::NativeFunction> function) { m_function_instances.set(address, function); }
|
||||
void add_imported_object(GC::Ptr<JS::Object> object) { m_imported_objects.set(object); }
|
||||
void add_extern_value(Wasm::ExternAddress address, JS::Value value) { m_extern_values.set(address, value); }
|
||||
|
||||
Optional<JS::GCPtr<JS::NativeFunction>> get_function_instance(Wasm::FunctionAddress address) { return m_function_instances.get(address); }
|
||||
Optional<GC::Ptr<JS::NativeFunction>> get_function_instance(Wasm::FunctionAddress address) { return m_function_instances.get(address); }
|
||||
Optional<JS::Value> get_extern_value(Wasm::ExternAddress address) { return m_extern_values.get(address); }
|
||||
|
||||
HashMap<Wasm::FunctionAddress, JS::GCPtr<JS::NativeFunction>> function_instances() const { return m_function_instances; }
|
||||
HashMap<Wasm::FunctionAddress, GC::Ptr<JS::NativeFunction>> function_instances() const { return m_function_instances; }
|
||||
HashMap<Wasm::ExternAddress, JS::Value> extern_values() const { return m_extern_values; }
|
||||
HashTable<JS::GCPtr<JS::Object>> imported_objects() const { return m_imported_objects; }
|
||||
HashTable<GC::Ptr<JS::Object>> imported_objects() const { return m_imported_objects; }
|
||||
Wasm::AbstractMachine& abstract_machine() { return m_abstract_machine; }
|
||||
|
||||
private:
|
||||
HashMap<Wasm::FunctionAddress, JS::GCPtr<JS::NativeFunction>> m_function_instances;
|
||||
HashMap<Wasm::FunctionAddress, GC::Ptr<JS::NativeFunction>> m_function_instances;
|
||||
HashMap<Wasm::ExternAddress, JS::Value> m_extern_values;
|
||||
Vector<NonnullRefPtr<CompiledWebAssemblyModule>> m_compiled_modules;
|
||||
HashTable<JS::GCPtr<JS::Object>> m_imported_objects;
|
||||
HashTable<GC::Ptr<JS::Object>> m_imported_objects;
|
||||
Wasm::AbstractMachine m_abstract_machine;
|
||||
};
|
||||
|
||||
WebAssemblyCache& get_cache(JS::Realm&);
|
||||
|
||||
JS::ThrowCompletionOr<NonnullOwnPtr<Wasm::ModuleInstance>> instantiate_module(JS::VM&, Wasm::Module const&, JS::GCPtr<JS::Object> import_object);
|
||||
JS::ThrowCompletionOr<NonnullOwnPtr<Wasm::ModuleInstance>> instantiate_module(JS::VM&, Wasm::Module const&, GC::Ptr<JS::Object> import_object);
|
||||
JS::ThrowCompletionOr<NonnullRefPtr<CompiledWebAssemblyModule>> compile_a_webassembly_module(JS::VM&, ByteBuffer);
|
||||
JS::NativeFunction* create_native_function(JS::VM&, Wasm::FunctionAddress address, ByteString const& name, Instance* instance = nullptr);
|
||||
JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::VM&, JS::Value value, Wasm::ValueType const& type);
|
||||
Wasm::Value default_webassembly_value(JS::VM&, Wasm::ValueType type);
|
||||
JS::Value to_js_value(JS::VM&, Wasm::Value& wasm_value, Wasm::ValueType type);
|
||||
|
||||
extern HashMap<JS::GCPtr<JS::Object>, WebAssemblyCache> s_caches;
|
||||
extern HashMap<GC::Ptr<JS::Object>, WebAssemblyCache> s_caches;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue