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