Commit a17083ee authored by Ben L. Titzer's avatar Ben L. Titzer Committed by Commit Bot

[wasm] Rename WasmModuleWrapper to Managed<WasmModule>

R=ahaas@chromium.org

Bug: v8:7570
Change-Id: I5327d1b8e2f2bf4c1538f565442305a0e1f05b65
Reviewed-on: https://chromium-review.googlesource.com/1032550Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52835}
parent ff571867
......@@ -1535,8 +1535,8 @@ void WasmDebugInfo::WasmDebugInfoVerify() {
void WasmSharedModuleData::WasmSharedModuleDataVerify() {
CHECK(IsWasmSharedModuleData());
VerifyObjectField(kModuleWrapperOffset);
CHECK(module_wrapper()->IsForeign());
VerifyObjectField(kManagedModuleOffset);
CHECK(managed_module()->IsForeign());
VerifyObjectField(kModuleBytesOffset);
VerifyObjectField(kScriptOffset);
VerifyObjectField(kAsmJsOffsetTableOffset);
......
......@@ -1375,10 +1375,10 @@ MaybeHandle<WasmModuleObject> CompileToModuleObjectInternal(
.ToHandleChecked();
DCHECK(module_bytes->IsSeqOneByteString());
// The {module_wrapper} will take ownership of the {WasmModule} object,
// The {managed_module} will take ownership of the {WasmModule} object,
// and it will be destroyed when the GC reclaims the wrapper object.
Handle<WasmModuleWrapper> module_wrapper =
WasmModuleWrapper::FromUniquePtr(isolate, std::move(module));
Handle<Managed<WasmModule>> managed_module =
Managed<WasmModule>::FromUniquePtr(isolate, std::move(module));
// Create the shared module data.
// TODO(clemensh): For the same module (same bytes / same hash), we should
......@@ -1386,7 +1386,7 @@ MaybeHandle<WasmModuleObject> CompileToModuleObjectInternal(
// breakpoints on a (potentially empty) subset of the instances.
Handle<WasmSharedModuleData> shared = WasmSharedModuleData::New(
isolate, module_wrapper, Handle<SeqOneByteString>::cast(module_bytes),
isolate, managed_module, Handle<SeqOneByteString>::cast(module_bytes),
script, asm_js_offset_table);
int export_wrappers_size =
......@@ -2875,9 +2875,9 @@ void AsyncCompileJob::FinishCompile() {
.ToHandleChecked();
DCHECK(module_bytes->IsSeqOneByteString());
// The {module_wrapper} will take ownership of the {WasmModule} object,
// The {managed_module} will take ownership of the {WasmModule} object,
// and it will be destroyed when the GC reclaims the wrapper object.
Handle<Managed<WasmModule>> module_wrapper =
Handle<Managed<WasmModule>> managed_module =
Managed<WasmModule>::FromUniquePtr(isolate_, std::move(module_));
// Create the shared module data.
......@@ -2885,7 +2885,7 @@ void AsyncCompileJob::FinishCompile() {
// only have one WasmSharedModuleData. Otherwise, we might only set
// breakpoints on a (potentially empty) subset of the instances.
Handle<WasmSharedModuleData> shared = WasmSharedModuleData::New(
isolate_, module_wrapper, Handle<SeqOneByteString>::cast(module_bytes),
isolate_, managed_module, Handle<SeqOneByteString>::cast(module_bytes),
script, asm_js_offset_table);
compiled_module_->set_shared(*shared);
script->set_wasm_compiled_module(*compiled_module_);
......
......@@ -27,7 +27,7 @@ MaybeHandle<WasmModuleObject> WasmEngine::SyncCompileTranslatedAsmJs(
bytes.end(), false, kAsmJsOrigin);
CHECK(!result.failed());
// Transfer ownership of the WasmModule to the {WasmModuleWrapper} generated
// Transfer ownership of the WasmModule to the {Managed<WasmModule>} generated
// in {CompileToModuleObject}.
return CompileToModuleObject(isolate, thrower, std::move(result.val), bytes,
asm_js_script, asm_js_offset_table_bytes);
......@@ -42,7 +42,7 @@ MaybeHandle<WasmModuleObject> WasmEngine::SyncCompile(
return {};
}
// Transfer ownership of the WasmModule to the {WasmModuleWrapper} generated
// Transfer ownership of the WasmModule to the {Managed<WasmModule>} generated
// in {CompileToModuleObject}.
return CompileToModuleObject(isolate, thrower, std::move(result.val), bytes,
Handle<Script>(), Vector<const byte>());
......
......@@ -185,8 +185,6 @@ struct V8_EXPORT_PRIVATE WasmModule {
mutable std::unique_ptr<std::unordered_map<uint32_t, WireBytesRef>> names_;
};
typedef Managed<WasmModule> WasmModuleWrapper;
// Interface to the storage (wire bytes) of a wasm module.
// It is illegal for anyone receiving a ModuleWireBytes to store pointers based
// on module_bytes, as this storage is only guaranteed to be alive as long as
......
......@@ -168,7 +168,7 @@ ImportedFunctionEntry::ImportedFunctionEntry(WasmInstanceObject* instance,
}
// WasmSharedModuleData
ACCESSORS(WasmSharedModuleData, module_wrapper, Object, kModuleWrapperOffset)
ACCESSORS(WasmSharedModuleData, managed_module, Object, kManagedModuleOffset)
ACCESSORS(WasmSharedModuleData, module_bytes, SeqOneByteString,
kModuleBytesOffset)
ACCESSORS(WasmSharedModuleData, script, Script, kScriptOffset)
......
......@@ -974,16 +974,16 @@ wasm::WasmCode* WasmExportedFunction::GetWasmCode() {
}
WasmModule* WasmSharedModuleData::module() const {
return Managed<WasmModule>::cast(module_wrapper())->raw();
return Managed<WasmModule>::cast(managed_module())->raw();
}
Handle<WasmSharedModuleData> WasmSharedModuleData::New(
Isolate* isolate, Handle<Foreign> module_wrapper,
Isolate* isolate, Handle<Foreign> managed_module,
Handle<SeqOneByteString> module_bytes, Handle<Script> script,
Handle<ByteArray> asm_js_offset_table) {
Handle<WasmSharedModuleData> data = Handle<WasmSharedModuleData>::cast(
isolate->factory()->NewStruct(WASM_SHARED_MODULE_DATA_TYPE, TENURED));
data->set_module_wrapper(*module_wrapper);
data->set_managed_module(*managed_module);
if (!module_bytes.is_null()) {
data->set_module_bytes(*module_bytes);
}
......
......@@ -368,7 +368,7 @@ class WasmExportedFunction : public JSFunction {
// Information shared by all WasmCompiledModule objects for the same module.
class WasmSharedModuleData : public Struct {
public:
DECL_ACCESSORS(module_wrapper, Object)
DECL_ACCESSORS(managed_module, Object)
wasm::WasmModule* module() const;
DECL_ACCESSORS(module_bytes, SeqOneByteString)
DECL_ACCESSORS(script, Script)
......@@ -383,12 +383,12 @@ class WasmSharedModuleData : public Struct {
DECL_VERIFIER(WasmSharedModuleData)
// Layout description.
#define WASM_SHARED_MODULE_DATA_FIELDS(V) \
V(kModuleWrapperOffset, kPointerSize) \
V(kModuleBytesOffset, kPointerSize) \
V(kScriptOffset, kPointerSize) \
V(kAsmJsOffsetTableOffset, kPointerSize) \
V(kBreakPointInfosOffset, kPointerSize) \
#define WASM_SHARED_MODULE_DATA_FIELDS(V) \
V(kManagedModuleOffset, kPointerSize) \
V(kModuleBytesOffset, kPointerSize) \
V(kScriptOffset, kPointerSize) \
V(kAsmJsOffsetTableOffset, kPointerSize) \
V(kBreakPointInfosOffset, kPointerSize) \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
......@@ -405,7 +405,7 @@ class WasmSharedModuleData : public Struct {
Handle<WasmInstanceObject>);
static Handle<WasmSharedModuleData> New(
Isolate* isolate, Handle<Foreign> module_wrapper,
Isolate* isolate, Handle<Foreign> managed_module,
Handle<SeqOneByteString> module_bytes, Handle<Script> script,
Handle<ByteArray> asm_js_offset_table);
......
......@@ -690,13 +690,13 @@ MaybeHandle<WasmCompiledModule> DeserializeNativeModule(
TENURED)
.ToHandleChecked();
DCHECK(module_bytes->IsSeqOneByteString());
// The {module_wrapper} will take ownership of the {WasmModule} object,
// The {managed_module} will take ownership of the {WasmModule} object,
// and it will be destroyed when the GC reclaims the wrapper object.
Handle<WasmModuleWrapper> module_wrapper =
WasmModuleWrapper::FromUniquePtr(isolate, std::move(decode_result.val));
Handle<Managed<WasmModule>> managed_module =
Managed<WasmModule>::FromUniquePtr(isolate, std::move(decode_result.val));
Handle<Script> script = CreateWasmScript(isolate, wire_bytes);
Handle<WasmSharedModuleData> shared = WasmSharedModuleData::New(
isolate, module_wrapper, Handle<SeqOneByteString>::cast(module_bytes),
isolate, managed_module, Handle<SeqOneByteString>::cast(module_bytes),
script, Handle<ByteArray>::null());
int export_wrappers_size =
static_cast<int>(shared->module()->num_exported_functions);
......
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