Commit 5d8eefe9 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Add getter for shared_ptr to NativeModule

This was done via {managed_native_module()->get()}. Add a simple getter
for that.

R=ahaas@chromium.org

Bug: v8:8562
Change-Id: I8e461a8e16b618abdb772098fad3a6b721d54902
Reviewed-on: https://chromium-review.googlesource.com/c/1371564Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58156}
parent 3eb3529d
......@@ -7390,7 +7390,7 @@ WasmModuleObject::GetTransferrableModule() {
if (i::FLAG_wasm_shared_code) {
i::Handle<i::WasmModuleObject> obj =
i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this));
return TransferrableModule(obj->managed_native_module()->get());
return TransferrableModule(obj->shared_native_module());
} else {
CompiledWasmModule compiled_module = GetCompiledModule();
OwnedBuffer serialized_module = compiled_module.Serialize();
......@@ -7407,7 +7407,7 @@ WasmModuleObject::GetTransferrableModule() {
CompiledWasmModule WasmModuleObject::GetCompiledModule() {
i::Handle<i::WasmModuleObject> obj =
i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this));
return Utils::Convert(obj->managed_native_module()->get());
return Utils::Convert(obj->shared_native_module());
}
MaybeLocal<WasmModuleObject> WasmModuleObject::FromTransferrableModule(
......
......@@ -237,7 +237,7 @@ bool WasmEngine::CompileFunction(Isolate* isolate, NativeModule* native_module,
std::shared_ptr<NativeModule> WasmEngine::ExportNativeModule(
Handle<WasmModuleObject> module_object) {
return module_object->managed_native_module()->get();
return module_object->shared_native_module();
}
Handle<WasmModuleObject> WasmEngine::ImportNativeModule(
......
......@@ -65,8 +65,7 @@ class WasmStreaming::WasmStreamingImpl {
// Local<WasmModuleObject> here.
streaming_decoder_->SetModuleCompiledCallback(
[callback, data](i::Handle<i::WasmModuleObject> module_object) {
callback(data, Utils::Convert(
module_object->managed_native_module()->get()));
callback(data, Utils::Convert(module_object->shared_native_module()));
});
}
......
......@@ -80,6 +80,10 @@ OPTIONAL_ACCESSORS2(WasmModuleObject, breakpoint_infos, FixedArray,
wasm::NativeModule* WasmModuleObject::native_module() const {
return managed_native_module()->raw();
}
std::shared_ptr<wasm::NativeModule> WasmModuleObject::shared_native_module()
const {
return managed_native_module()->get();
}
const wasm::WasmModule* WasmModuleObject::module() const {
// TODO(clemensh): Remove this helper (inline in callers).
return native_module()->module();
......
......@@ -117,6 +117,7 @@ class WasmModuleObject : public JSObject {
DECL_OPTIONAL_ACCESSORS2(asm_js_offset_table, ByteArray)
DECL_OPTIONAL_ACCESSORS2(breakpoint_infos, FixedArray)
inline wasm::NativeModule* native_module() const;
inline std::shared_ptr<wasm::NativeModule> shared_native_module() const;
inline const wasm::WasmModule* module() const;
inline void reset_breakpoint_infos();
......
......@@ -101,7 +101,7 @@ class TestResolver : public CompilationResultResolver {
void OnCompilationSucceeded(i::Handle<i::WasmModuleObject> module) override {
*state_ = CompilationState::kFinished;
if (!module.is_null()) {
*native_module_ = module->managed_native_module()->get();
*native_module_ = module->shared_native_module();
}
}
......
......@@ -305,7 +305,7 @@ void TestTransferrableWasmModules(bool should_share) {
v8::Local<v8::WasmModuleObject>::Cast(
v8::Utils::ToLocal(Handle<JSObject>::cast(module_object)));
store.push_back(v8_module->GetTransferrableModule());
original_native_module = module_object->managed_native_module()->get();
original_native_module = module_object->shared_native_module();
}
{
......@@ -320,7 +320,7 @@ void TestTransferrableWasmModules(bool should_share) {
Handle<WasmModuleObject> module_object = Handle<WasmModuleObject>::cast(
v8::Utils::OpenHandle(*transferred_module.ToLocalChecked()));
std::shared_ptr<NativeModule> transferred_native_module =
module_object->managed_native_module()->get();
module_object->shared_native_module();
bool is_sharing = (original_native_module == transferred_native_module);
CHECK_EQ(should_share, is_sharing);
}
......
......@@ -94,7 +94,7 @@ class SharedEngineIsolate {
}
SharedModule ExportInstance(Handle<WasmInstanceObject> instance) {
return instance->module_object()->managed_native_module()->get();
return instance->module_object()->shared_native_module();
}
int32_t Run(Handle<WasmInstanceObject> instance) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment