Commit ffc4ba74 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Remove redirecting accessor methods

We had a number of accessors defined on {WasmCompiledModule}, which
redirected to {WasmSharedModuleData}. This is uncommon in the code base
and hides where information is really stored.
This CL removes them and accesses information directly from the
{WasmSharedModuleData} instead.

R=ahaas@chromium.org

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: I54fce75dbf7dcb2f16dcf13e4634b5618225a429
Reviewed-on: https://chromium-review.googlesource.com/831510Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50157}
parent 9c858492
...@@ -7777,8 +7777,8 @@ Local<String> WasmCompiledModule::GetWasmWireBytes() { ...@@ -7777,8 +7777,8 @@ Local<String> WasmCompiledModule::GetWasmWireBytes() {
i::Handle<i::WasmModuleObject> obj = i::Handle<i::WasmModuleObject> obj =
i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this)); i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this));
i::Handle<i::WasmCompiledModule> compiled_part = i::Handle<i::WasmCompiledModule> compiled_part =
i::handle(i::WasmCompiledModule::cast(obj->compiled_module())); i::handle(obj->compiled_module());
i::Handle<i::String> wire_bytes(compiled_part->module_bytes()); i::Handle<i::String> wire_bytes(compiled_part->shared()->module_bytes());
return Local<String>::Cast(Utils::ToLocal(wire_bytes)); return Local<String>::Cast(Utils::ToLocal(wire_bytes));
} }
...@@ -9824,8 +9824,9 @@ int debug::WasmScript::NumFunctions() const { ...@@ -9824,8 +9824,9 @@ int debug::WasmScript::NumFunctions() const {
DCHECK_EQ(i::Script::TYPE_WASM, script->type()); DCHECK_EQ(i::Script::TYPE_WASM, script->type());
i::WasmCompiledModule* compiled_module = i::WasmCompiledModule* compiled_module =
i::WasmCompiledModule::cast(script->wasm_compiled_module()); i::WasmCompiledModule::cast(script->wasm_compiled_module());
DCHECK_GE(i::kMaxInt, compiled_module->module()->functions.size()); i::wasm::WasmModule* module = compiled_module->shared()->module();
return static_cast<int>(compiled_module->module()->functions.size()); DCHECK_GE(i::kMaxInt, module->functions.size());
return static_cast<int>(module->functions.size());
} }
int debug::WasmScript::NumImportedFunctions() const { int debug::WasmScript::NumImportedFunctions() const {
...@@ -9834,8 +9835,9 @@ int debug::WasmScript::NumImportedFunctions() const { ...@@ -9834,8 +9835,9 @@ int debug::WasmScript::NumImportedFunctions() const {
DCHECK_EQ(i::Script::TYPE_WASM, script->type()); DCHECK_EQ(i::Script::TYPE_WASM, script->type());
i::WasmCompiledModule* compiled_module = i::WasmCompiledModule* compiled_module =
i::WasmCompiledModule::cast(script->wasm_compiled_module()); i::WasmCompiledModule::cast(script->wasm_compiled_module());
DCHECK_GE(i::kMaxInt, compiled_module->module()->num_imported_functions); i::wasm::WasmModule* module = compiled_module->shared()->module();
return static_cast<int>(compiled_module->module()->num_imported_functions); DCHECK_GE(i::kMaxInt, module->num_imported_functions);
return static_cast<int>(module->num_imported_functions);
} }
std::pair<int, int> debug::WasmScript::GetFunctionRange( std::pair<int, int> debug::WasmScript::GetFunctionRange(
...@@ -9845,10 +9847,10 @@ std::pair<int, int> debug::WasmScript::GetFunctionRange( ...@@ -9845,10 +9847,10 @@ std::pair<int, int> debug::WasmScript::GetFunctionRange(
DCHECK_EQ(i::Script::TYPE_WASM, script->type()); DCHECK_EQ(i::Script::TYPE_WASM, script->type());
i::WasmCompiledModule* compiled_module = i::WasmCompiledModule* compiled_module =
i::WasmCompiledModule::cast(script->wasm_compiled_module()); i::WasmCompiledModule::cast(script->wasm_compiled_module());
i::wasm::WasmModule* module = compiled_module->shared()->module();
DCHECK_LE(0, function_index); DCHECK_LE(0, function_index);
DCHECK_GT(compiled_module->module()->functions.size(), function_index); DCHECK_GT(module->functions.size(), function_index);
i::wasm::WasmFunction& func = i::wasm::WasmFunction& func = module->functions[function_index];
compiled_module->module()->functions[function_index];
DCHECK_GE(i::kMaxInt, func.code.offset()); DCHECK_GE(i::kMaxInt, func.code.offset());
DCHECK_GE(i::kMaxInt, func.code.end_offset()); DCHECK_GE(i::kMaxInt, func.code.end_offset());
return std::make_pair(static_cast<int>(func.code.offset()), return std::make_pair(static_cast<int>(func.code.offset()),
......
...@@ -1244,7 +1244,7 @@ int FrameSummary::WasmFrameSummary::SourcePosition() const { ...@@ -1244,7 +1244,7 @@ int FrameSummary::WasmFrameSummary::SourcePosition() const {
} }
Handle<Script> FrameSummary::WasmFrameSummary::script() const { Handle<Script> FrameSummary::WasmFrameSummary::script() const {
return handle(wasm_instance()->compiled_module()->script()); return handle(wasm_instance()->compiled_module()->shared()->script());
} }
Handle<String> FrameSummary::WasmFrameSummary::FunctionName() const { Handle<String> FrameSummary::WasmFrameSummary::FunctionName() const {
...@@ -1743,7 +1743,7 @@ uint32_t WasmCompiledFrame::function_index() const { ...@@ -1743,7 +1743,7 @@ uint32_t WasmCompiledFrame::function_index() const {
} }
Script* WasmCompiledFrame::script() const { Script* WasmCompiledFrame::script() const {
return wasm_instance()->compiled_module()->script(); return wasm_instance()->compiled_module()->shared()->script();
} }
int WasmCompiledFrame::position() const { int WasmCompiledFrame::position() const {
...@@ -1874,7 +1874,7 @@ WasmInstanceObject* WasmInterpreterEntryFrame::wasm_instance() const { ...@@ -1874,7 +1874,7 @@ WasmInstanceObject* WasmInterpreterEntryFrame::wasm_instance() const {
} }
Script* WasmInterpreterEntryFrame::script() const { Script* WasmInterpreterEntryFrame::script() const {
return wasm_instance()->compiled_module()->script(); return wasm_instance()->compiled_module()->shared()->script();
} }
int WasmInterpreterEntryFrame::position() const { int WasmInterpreterEntryFrame::position() const {
......
...@@ -437,7 +437,7 @@ class FrameArrayBuilder { ...@@ -437,7 +437,7 @@ class FrameArrayBuilder {
} }
Handle<WasmInstanceObject> instance = summary.wasm_instance(); Handle<WasmInstanceObject> instance = summary.wasm_instance();
int flags = 0; int flags = 0;
if (instance->compiled_module()->is_asm_js()) { if (instance->compiled_module()->shared()->is_asm_js()) {
flags |= FrameArray::kIsAsmJsWasmFrame; flags |= FrameArray::kIsAsmJsWasmFrame;
if (WasmCompiledFrame::cast(frame)->at_to_number_conversion()) { if (WasmCompiledFrame::cast(frame)->at_to_number_conversion()) {
flags |= FrameArray::kAsmJsAtNumberConversion; flags |= FrameArray::kAsmJsAtNumberConversion;
...@@ -456,7 +456,7 @@ class FrameArrayBuilder { ...@@ -456,7 +456,7 @@ class FrameArrayBuilder {
const auto& summary = summ.AsWasmInterpreted(); const auto& summary = summ.AsWasmInterpreted();
Handle<WasmInstanceObject> instance = summary.wasm_instance(); Handle<WasmInstanceObject> instance = summary.wasm_instance();
int flags = FrameArray::kIsWasmInterpretedFrame; int flags = FrameArray::kIsWasmInterpretedFrame;
DCHECK(!instance->compiled_module()->is_asm_js()); DCHECK(!instance->compiled_module()->shared()->is_asm_js());
elements_ = FrameArray::AppendWasmFrame(elements_, instance, elements_ = FrameArray::AppendWasmFrame(elements_, instance,
summary.function_index(), {}, summary.function_index(), {},
summary.byte_offset(), flags); summary.byte_offset(), flags);
......
...@@ -737,7 +737,8 @@ Handle<Object> WasmStackFrame::Null() const { ...@@ -737,7 +737,8 @@ Handle<Object> WasmStackFrame::Null() const {
bool WasmStackFrame::HasScript() const { return true; } bool WasmStackFrame::HasScript() const { return true; }
Handle<Script> WasmStackFrame::GetScript() const { Handle<Script> WasmStackFrame::GetScript() const {
return handle(wasm_instance_->compiled_module()->script(), isolate_); return handle(wasm_instance_->compiled_module()->shared()->script(),
isolate_);
} }
AsmJsWasmStackFrame::AsmJsWasmStackFrame() {} AsmJsWasmStackFrame::AsmJsWasmStackFrame() {}
...@@ -761,13 +762,15 @@ Handle<Object> AsmJsWasmStackFrame::GetFunction() const { ...@@ -761,13 +762,15 @@ Handle<Object> AsmJsWasmStackFrame::GetFunction() const {
} }
Handle<Object> AsmJsWasmStackFrame::GetFileName() { Handle<Object> AsmJsWasmStackFrame::GetFileName() {
Handle<Script> script(wasm_instance_->compiled_module()->script(), isolate_); Handle<Script> script(wasm_instance_->compiled_module()->shared()->script(),
isolate_);
DCHECK(script->IsUserJavaScript()); DCHECK(script->IsUserJavaScript());
return handle(script->name(), isolate_); return handle(script->name(), isolate_);
} }
Handle<Object> AsmJsWasmStackFrame::GetScriptNameOrSourceUrl() { Handle<Object> AsmJsWasmStackFrame::GetScriptNameOrSourceUrl() {
Handle<Script> script(wasm_instance_->compiled_module()->script(), isolate_); Handle<Script> script(wasm_instance_->compiled_module()->shared()->script(),
isolate_);
DCHECK_EQ(Script::TYPE_NORMAL, script->type()); DCHECK_EQ(Script::TYPE_NORMAL, script->type());
return ScriptNameOrSourceUrl(script, isolate_); return ScriptNameOrSourceUrl(script, isolate_);
} }
...@@ -789,14 +792,16 @@ int AsmJsWasmStackFrame::GetPosition() const { ...@@ -789,14 +792,16 @@ int AsmJsWasmStackFrame::GetPosition() const {
int AsmJsWasmStackFrame::GetLineNumber() { int AsmJsWasmStackFrame::GetLineNumber() {
DCHECK_LE(0, GetPosition()); DCHECK_LE(0, GetPosition());
Handle<Script> script(wasm_instance_->compiled_module()->script(), isolate_); Handle<Script> script(wasm_instance_->compiled_module()->shared()->script(),
isolate_);
DCHECK(script->IsUserJavaScript()); DCHECK(script->IsUserJavaScript());
return Script::GetLineNumber(script, GetPosition()) + 1; return Script::GetLineNumber(script, GetPosition()) + 1;
} }
int AsmJsWasmStackFrame::GetColumnNumber() { int AsmJsWasmStackFrame::GetColumnNumber() {
DCHECK_LE(0, GetPosition()); DCHECK_LE(0, GetPosition());
Handle<Script> script(wasm_instance_->compiled_module()->script(), isolate_); Handle<Script> script(wasm_instance_->compiled_module()->shared()->script(),
isolate_);
DCHECK(script->IsUserJavaScript()); DCHECK(script->IsUserJavaScript());
return Script::GetColumnNumber(script, GetPosition()) + 1; return Script::GetColumnNumber(script, GetPosition()) + 1;
} }
......
...@@ -251,8 +251,9 @@ std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule( ...@@ -251,8 +251,9 @@ std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule(
Isolate* isolate, Handle<FixedArray> input) { Isolate* isolate, Handle<FixedArray> input) {
Handle<WasmCompiledModule> compiled_module = Handle<WasmCompiledModule> compiled_module =
Handle<WasmCompiledModule>::cast(input); Handle<WasmCompiledModule>::cast(input);
WasmCompiledModuleSerializer wasm_cs(isolate, 0, isolate->native_context(), WasmCompiledModuleSerializer wasm_cs(
handle(compiled_module->module_bytes())); isolate, 0, isolate->native_context(),
handle(compiled_module->shared()->module_bytes()));
ScriptData* data = wasm_cs.Serialize(compiled_module); ScriptData* data = wasm_cs.Serialize(compiled_module);
return std::unique_ptr<ScriptData>(data); return std::unique_ptr<ScriptData>(data);
} }
......
...@@ -848,7 +848,7 @@ Maybe<bool> ValueSerializer::WriteWasmModule(Handle<WasmModuleObject> object) { ...@@ -848,7 +848,7 @@ Maybe<bool> ValueSerializer::WriteWasmModule(Handle<WasmModuleObject> object) {
WriteTag(SerializationTag::kWasmModule); WriteTag(SerializationTag::kWasmModule);
WriteRawBytes(&encoding_tag, sizeof(encoding_tag)); WriteRawBytes(&encoding_tag, sizeof(encoding_tag));
Handle<String> wire_bytes(compiled_part->module_bytes(), isolate_); Handle<String> wire_bytes(compiled_part->shared()->module_bytes(), isolate_);
int wire_bytes_length = wire_bytes->length(); int wire_bytes_length = wire_bytes->length();
WriteVarint<uint32_t>(wire_bytes_length); WriteVarint<uint32_t>(wire_bytes_length);
uint8_t* destination; uint8_t* destination;
......
...@@ -875,7 +875,7 @@ Address CompileLazy(Isolate* isolate) { ...@@ -875,7 +875,7 @@ Address CompileLazy(Isolate* isolate) {
compiler::ModuleEnv CreateModuleEnvFromCompiledModule( compiler::ModuleEnv CreateModuleEnvFromCompiledModule(
Isolate* isolate, Handle<WasmCompiledModule> compiled_module) { Isolate* isolate, Handle<WasmCompiledModule> compiled_module) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
WasmModule* module = compiled_module->module(); WasmModule* module = compiled_module->shared()->module();
std::vector<Handle<Code>> empty_code; std::vector<Handle<Code>> empty_code;
if (FLAG_wasm_jit_to_native) { if (FLAG_wasm_jit_to_native) {
NativeModule* native_module = compiled_module->GetNativeModule(); NativeModule* native_module = compiled_module->GetNativeModule();
...@@ -1129,9 +1129,10 @@ Handle<Code> LazyCompilationOrchestrator::CompileLazyOnGCHeap( ...@@ -1129,9 +1129,10 @@ Handle<Code> LazyCompilationOrchestrator::CompileLazyOnGCHeap(
Handle<WasmCompiledModule> caller_module( Handle<WasmCompiledModule> caller_module(
caller_func_info.instance.ToHandleChecked()->compiled_module(), caller_func_info.instance.ToHandleChecked()->compiled_module(),
isolate); isolate);
SeqOneByteString* module_bytes = caller_module->module_bytes(); SeqOneByteString* module_bytes = caller_module->shared()->module_bytes();
const byte* func_bytes = const byte* func_bytes =
module_bytes->GetChars() + caller_module->module() module_bytes->GetChars() + caller_module->shared()
->module()
->functions[caller_func_info.func_index] ->functions[caller_func_info.func_index]
.code.offset(); .code.offset();
Code* lazy_callee = nullptr; Code* lazy_callee = nullptr;
...@@ -1311,15 +1312,17 @@ const wasm::WasmCode* LazyCompilationOrchestrator::CompileDirectCall( ...@@ -1311,15 +1312,17 @@ const wasm::WasmCode* LazyCompilationOrchestrator::CompileDirectCall(
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
Handle<WasmCompiledModule> caller_module( Handle<WasmCompiledModule> caller_module(
wasm_caller->owner()->compiled_module(), isolate); wasm_caller->owner()->compiled_module(), isolate);
SeqOneByteString* module_bytes = caller_module->module_bytes(); SeqOneByteString* module_bytes = caller_module->shared()->module_bytes();
uint32_t caller_func_index = wasm_caller->index(); uint32_t caller_func_index = wasm_caller->index();
SourcePositionTableIterator source_pos_iterator( SourcePositionTableIterator source_pos_iterator(
Handle<ByteArray>(ByteArray::cast( Handle<ByteArray>(ByteArray::cast(
caller_module->source_positions()->get(caller_func_index)))); caller_module->source_positions()->get(caller_func_index))));
const byte* func_bytes = const byte* func_bytes =
module_bytes->GetChars() + module_bytes->GetChars() + caller_module->shared()
caller_module->module()->functions[caller_func_index].code.offset(); ->module()
->functions[caller_func_index]
.code.offset();
for (RelocIterator it(wasm_caller->instructions(), for (RelocIterator it(wasm_caller->instructions(),
wasm_caller->reloc_info(), wasm_caller->reloc_info(),
wasm_caller->constant_pool(), wasm_caller->constant_pool(),
...@@ -2217,7 +2220,7 @@ InstanceBuilder::InstanceBuilder( ...@@ -2217,7 +2220,7 @@ InstanceBuilder::InstanceBuilder(
MaybeHandle<JSArrayBuffer> memory, MaybeHandle<JSArrayBuffer> memory,
WeakCallbackInfo<void>::Callback instance_finalizer_callback) WeakCallbackInfo<void>::Callback instance_finalizer_callback)
: isolate_(isolate), : isolate_(isolate),
module_(module_object->compiled_module()->module()), module_(module_object->compiled_module()->shared()->module()),
async_counters_(isolate->async_counters()), async_counters_(isolate->async_counters()),
thrower_(thrower), thrower_(thrower),
module_object_(module_object), module_object_(module_object),
...@@ -2760,8 +2763,8 @@ uint32_t InstanceBuilder::EvalUint32InitExpr(const WasmInitExpr& expr) { ...@@ -2760,8 +2763,8 @@ uint32_t InstanceBuilder::EvalUint32InitExpr(const WasmInitExpr& expr) {
// Load data segments into the memory. // Load data segments into the memory.
void InstanceBuilder::LoadDataSegments(WasmContext* wasm_context) { void InstanceBuilder::LoadDataSegments(WasmContext* wasm_context) {
Handle<SeqOneByteString> module_bytes(compiled_module_->module_bytes(), Handle<SeqOneByteString> module_bytes(
isolate_); compiled_module_->shared()->module_bytes(), isolate_);
for (const WasmDataSegment& segment : module_->data_segments) { for (const WasmDataSegment& segment : module_->data_segments) {
uint32_t source_size = segment.source.length(); uint32_t source_size = segment.source.length();
// Segments of size == 0 are just nops. // Segments of size == 0 are just nops.
...@@ -2802,7 +2805,7 @@ void InstanceBuilder::WriteGlobalValue(WasmGlobal& global, ...@@ -2802,7 +2805,7 @@ void InstanceBuilder::WriteGlobalValue(WasmGlobal& global,
void InstanceBuilder::SanitizeImports() { void InstanceBuilder::SanitizeImports() {
Handle<SeqOneByteString> module_bytes( Handle<SeqOneByteString> module_bytes(
module_object_->compiled_module()->module_bytes()); module_object_->compiled_module()->shared()->module_bytes());
for (size_t index = 0; index < module_->import_table.size(); ++index) { for (size_t index = 0; index < module_->import_table.size(); ++index) {
WasmImport& import = module_->import_table[index]; WasmImport& import = module_->import_table[index];
...@@ -4133,7 +4136,7 @@ class AsyncCompileJob::FinishCompile : public CompileStep { ...@@ -4133,7 +4136,7 @@ class AsyncCompileJob::FinishCompile : public CompileStep {
// Finish the wasm script now and make it public to the debugger. // Finish the wasm script now and make it public to the debugger.
job_->isolate_->debug()->OnAfterCompile( job_->isolate_->debug()->OnAfterCompile(
handle(job_->compiled_module_->script())); handle(job_->compiled_module_->shared()->script()));
// TODO(wasm): compiling wrappers should be made async as well. // TODO(wasm): compiling wrappers should be made async as well.
job_->DoSync<CompileWrappers>(); job_->DoSync<CompileWrappers>();
...@@ -4354,13 +4357,13 @@ void CompileJsToWasmWrappers(Isolate* isolate, ...@@ -4354,13 +4357,13 @@ void CompileJsToWasmWrappers(Isolate* isolate,
int wrapper_index = 0; int wrapper_index = 0;
Handle<FixedArray> export_wrappers = compiled_module->export_wrappers(); Handle<FixedArray> export_wrappers = compiled_module->export_wrappers();
NativeModule* native_module = compiled_module->GetNativeModule(); NativeModule* native_module = compiled_module->GetNativeModule();
for (auto exp : compiled_module->module()->export_table) { for (auto exp : compiled_module->shared()->module()->export_table) {
if (exp.kind != kExternalFunction) continue; if (exp.kind != kExternalFunction) continue;
WasmCodeWrapper wasm_code = EnsureExportedLazyDeoptData( WasmCodeWrapper wasm_code = EnsureExportedLazyDeoptData(
isolate, Handle<WasmInstanceObject>::null(), isolate, Handle<WasmInstanceObject>::null(),
compiled_module->code_table(), native_module, exp.index); compiled_module->code_table(), native_module, exp.index);
Handle<Code> wrapper_code = js_to_wasm_cache.CloneOrCompileJSToWasmWrapper( Handle<Code> wrapper_code = js_to_wasm_cache.CloneOrCompileJSToWasmWrapper(
isolate, compiled_module->module(), wasm_code, exp.index, isolate, compiled_module->shared()->module(), wasm_code, exp.index,
compiled_module->use_trap_handler()); compiled_module->use_trap_handler());
export_wrappers->set(wrapper_index, *wrapper_code); export_wrappers->set(wrapper_index, *wrapper_code);
RecordStats(*wrapper_code, counters); RecordStats(*wrapper_code, counters);
......
...@@ -51,18 +51,19 @@ class PatchDirectCallsHelper { ...@@ -51,18 +51,19 @@ class PatchDirectCallsHelper {
decoder(nullptr, nullptr) { decoder(nullptr, nullptr) {
uint32_t func_index = code->index(); uint32_t func_index = code->index();
WasmCompiledModule* comp_mod = instance->compiled_module(); WasmCompiledModule* comp_mod = instance->compiled_module();
func_bytes = comp_mod->module_bytes()->GetChars() + func_bytes =
comp_mod->module()->functions[func_index].code.offset(); comp_mod->shared()->module_bytes()->GetChars() +
comp_mod->shared()->module()->functions[func_index].code.offset();
} }
PatchDirectCallsHelper(WasmInstanceObject* instance, Code* code) PatchDirectCallsHelper(WasmInstanceObject* instance, Code* code)
: source_pos_it(code->SourcePositionTable()), decoder(nullptr, nullptr) { : source_pos_it(code->SourcePositionTable()), decoder(nullptr, nullptr) {
FixedArray* deopt_data = code->deoptimization_data(); FixedArray* deopt_data = code->deoptimization_data();
DCHECK_EQ(2, deopt_data->length()); DCHECK_EQ(2, deopt_data->length());
WasmCompiledModule* comp_mod = instance->compiled_module(); WasmSharedModuleData* shared = instance->compiled_module()->ptr_to_shared();
int func_index = Smi::ToInt(deopt_data->get(1)); int func_index = Smi::ToInt(deopt_data->get(1));
func_bytes = comp_mod->module_bytes()->GetChars() + func_bytes = shared->module_bytes()->GetChars() +
comp_mod->module()->functions[func_index].code.offset(); shared->module()->functions[func_index].code.offset();
} }
SourcePositionTableIterator source_pos_it; SourcePositionTableIterator source_pos_it;
...@@ -117,11 +118,11 @@ bool CodeSpecialization::ApplyToWholeInstance( ...@@ -117,11 +118,11 @@ bool CodeSpecialization::ApplyToWholeInstance(
WasmCompiledModule* compiled_module = instance->compiled_module(); WasmCompiledModule* compiled_module = instance->compiled_module();
NativeModule* native_module = compiled_module->GetNativeModule(); NativeModule* native_module = compiled_module->GetNativeModule();
FixedArray* code_table = compiled_module->ptr_to_code_table(); FixedArray* code_table = compiled_module->ptr_to_code_table();
WasmModule* module = compiled_module->module(); WasmSharedModuleData* shared = compiled_module->ptr_to_shared();
std::vector<WasmFunction>* wasm_functions = WasmModule* module = shared->module();
&compiled_module->module()->functions; std::vector<WasmFunction>* wasm_functions = &shared->module()->functions;
DCHECK_EQ(compiled_module->export_wrappers()->length(), DCHECK_EQ(compiled_module->export_wrappers()->length(),
compiled_module->module()->num_exported_functions); shared->module()->num_exported_functions);
bool changed = false; bool changed = false;
int func_index = module->num_imported_functions; int func_index = module->num_imported_functions;
......
...@@ -132,15 +132,18 @@ class InterpreterHandle { ...@@ -132,15 +132,18 @@ class InterpreterHandle {
static Vector<const byte> GetBytes(WasmDebugInfo* debug_info) { static Vector<const byte> GetBytes(WasmDebugInfo* debug_info) {
// Return raw pointer into heap. The WasmInterpreter will make its own copy // Return raw pointer into heap. The WasmInterpreter will make its own copy
// of this data anyway, and there is no heap allocation in-between. // of this data anyway, and there is no heap allocation in-between.
SeqOneByteString* bytes_str = SeqOneByteString* bytes_str = debug_info->wasm_instance()
debug_info->wasm_instance()->compiled_module()->module_bytes(); ->compiled_module()
->shared()
->module_bytes();
return {bytes_str->GetChars(), static_cast<size_t>(bytes_str->length())}; return {bytes_str->GetChars(), static_cast<size_t>(bytes_str->length())};
} }
public: public:
InterpreterHandle(Isolate* isolate, WasmDebugInfo* debug_info) InterpreterHandle(Isolate* isolate, WasmDebugInfo* debug_info)
: isolate_(isolate), : isolate_(isolate),
module_(debug_info->wasm_instance()->compiled_module()->module()), module_(
debug_info->wasm_instance()->compiled_module()->shared()->module()),
interpreter_(isolate, module_, GetBytes(debug_info), interpreter_(isolate, module_, GetBytes(debug_info),
debug_info->wasm_instance()->wasm_context()->get()) {} debug_info->wasm_instance()->wasm_context()->get()) {}
...@@ -559,7 +562,7 @@ wasm::InterpreterHandle* GetInterpreterHandleOrNull(WasmDebugInfo* debug_info) { ...@@ -559,7 +562,7 @@ wasm::InterpreterHandle* GetInterpreterHandleOrNull(WasmDebugInfo* debug_info) {
int GetNumFunctions(WasmInstanceObject* instance) { int GetNumFunctions(WasmInstanceObject* instance) {
size_t num_functions = size_t num_functions =
instance->compiled_module()->module()->functions.size(); instance->compiled_module()->shared()->module()->functions.size();
DCHECK_GE(kMaxInt, num_functions); DCHECK_GE(kMaxInt, num_functions);
return static_cast<int>(num_functions); return static_cast<int>(num_functions);
} }
...@@ -725,6 +728,7 @@ void WasmDebugInfo::RedirectToInterpreter(Handle<WasmDebugInfo> debug_info, ...@@ -725,6 +728,7 @@ void WasmDebugInfo::RedirectToInterpreter(Handle<WasmDebugInfo> debug_info,
Handle<WasmInstanceObject> instance(debug_info->wasm_instance(), isolate); Handle<WasmInstanceObject> instance(debug_info->wasm_instance(), isolate);
wasm::NativeModule* native_module = wasm::NativeModule* native_module =
instance->compiled_module()->GetNativeModule(); instance->compiled_module()->GetNativeModule();
wasm::WasmModule* module = instance->module();
CodeRelocationMap code_to_relocate; CodeRelocationMap code_to_relocate;
Handle<FixedArray> code_table = instance->compiled_module()->code_table(); Handle<FixedArray> code_table = instance->compiled_module()->code_table();
...@@ -737,14 +741,11 @@ void WasmDebugInfo::RedirectToInterpreter(Handle<WasmDebugInfo> debug_info, ...@@ -737,14 +741,11 @@ void WasmDebugInfo::RedirectToInterpreter(Handle<WasmDebugInfo> debug_info,
for (int func_index : func_indexes) { for (int func_index : func_indexes) {
DCHECK_LE(0, func_index); DCHECK_LE(0, func_index);
DCHECK_GT(debug_info->wasm_instance()->module()->functions.size(), DCHECK_GT(module->functions.size(), func_index);
func_index);
if (!interpreted_functions->get(func_index)->IsUndefined(isolate)) continue; if (!interpreted_functions->get(func_index)->IsUndefined(isolate)) continue;
Handle<Code> new_code = compiler::CompileWasmInterpreterEntry( Handle<Code> new_code = compiler::CompileWasmInterpreterEntry(
isolate, func_index, isolate, func_index, module->functions[func_index].sig, instance);
instance->compiled_module()->module()->functions[func_index].sig,
instance);
if (FLAG_wasm_jit_to_native) { if (FLAG_wasm_jit_to_native) {
const wasm::WasmCode* wasm_new_code = const wasm::WasmCode* wasm_new_code =
native_module->AddInterpreterWrapper(new_code, func_index); native_module->AddInterpreterWrapper(new_code, func_index);
......
...@@ -81,14 +81,6 @@ OPTIONAL_ACCESSORS(WasmDebugInfo, c_wasm_entry_map, Managed<wasm::SignatureMap>, ...@@ -81,14 +81,6 @@ OPTIONAL_ACCESSORS(WasmDebugInfo, c_wasm_entry_map, Managed<wasm::SignatureMap>,
#undef OPTIONAL_ACCESSORS #undef OPTIONAL_ACCESSORS
#define FORWARD_SHARED(type, name) \
type WasmCompiledModule::name() { return shared()->name(); }
FORWARD_SHARED(SeqOneByteString*, module_bytes)
FORWARD_SHARED(wasm::WasmModule*, module)
FORWARD_SHARED(Script*, script)
FORWARD_SHARED(bool, is_asm_js)
#undef FORWARD_SHARED
#define WCM_OBJECT_OR_WEAK(TYPE, NAME, ID, TYPE_CHECK, SETTER_MODIFIER) \ #define WCM_OBJECT_OR_WEAK(TYPE, NAME, ID, TYPE_CHECK, SETTER_MODIFIER) \
Handle<TYPE> WasmCompiledModule::NAME() const { \ Handle<TYPE> WasmCompiledModule::NAME() const { \
return handle(ptr_to_##NAME()); \ return handle(ptr_to_##NAME()); \
......
...@@ -133,14 +133,14 @@ iterate_compiled_module_instance_chain( ...@@ -133,14 +133,14 @@ iterate_compiled_module_instance_chain(
} }
#ifdef DEBUG #ifdef DEBUG
bool IsBreakablePosition(Handle<WasmCompiledModule> compiled_module, bool IsBreakablePosition(WasmSharedModuleData* shared, int func_index,
int func_index, int offset_in_func) { int offset_in_func) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
AccountingAllocator alloc; AccountingAllocator alloc;
Zone tmp(&alloc, ZONE_NAME); Zone tmp(&alloc, ZONE_NAME);
wasm::BodyLocalDecls locals(&tmp); wasm::BodyLocalDecls locals(&tmp);
const byte* module_start = compiled_module->module_bytes()->GetChars(); const byte* module_start = shared->module_bytes()->GetChars();
WasmFunction& func = compiled_module->module()->functions[func_index]; WasmFunction& func = shared->module()->functions[func_index];
wasm::BytecodeIterator iterator(module_start + func.code.offset(), wasm::BytecodeIterator iterator(module_start + func.code.offset(),
module_start + func.code.end_offset(), module_start + func.code.end_offset(),
&locals); &locals);
...@@ -542,7 +542,9 @@ WasmModuleObject* WasmInstanceObject::module_object() { ...@@ -542,7 +542,9 @@ WasmModuleObject* WasmInstanceObject::module_object() {
return *compiled_module()->wasm_module(); return *compiled_module()->wasm_module();
} }
WasmModule* WasmInstanceObject::module() { return compiled_module()->module(); } WasmModule* WasmInstanceObject::module() {
return compiled_module()->shared()->module();
}
Handle<WasmDebugInfo> WasmInstanceObject::GetOrCreateDebugInfo( Handle<WasmDebugInfo> WasmInstanceObject::GetOrCreateDebugInfo(
Handle<WasmInstanceObject> instance) { Handle<WasmInstanceObject> instance) {
...@@ -595,12 +597,13 @@ uint32_t WasmInstanceObject::GetMaxMemoryPages() { ...@@ -595,12 +597,13 @@ uint32_t WasmInstanceObject::GetMaxMemoryPages() {
if (maximum < FLAG_wasm_max_mem_pages) return maximum; if (maximum < FLAG_wasm_max_mem_pages) return maximum;
} }
} }
uint32_t compiled_maximum_pages = compiled_module()->module()->maximum_pages; uint32_t module_maximum_pages =
compiled_module()->shared()->module()->maximum_pages;
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
assert(compiled_module()->module()->is_wasm()); DCHECK(compiled_module()->shared()->module()->is_wasm());
isolate->counters()->wasm_wasm_max_mem_pages_count()->AddSample( isolate->counters()->wasm_wasm_max_mem_pages_count()->AddSample(
compiled_maximum_pages); module_maximum_pages);
if (compiled_maximum_pages != 0) return compiled_maximum_pages; if (module_maximum_pages != 0) return module_maximum_pages;
return FLAG_wasm_max_mem_pages; return FLAG_wasm_max_mem_pages;
} }
...@@ -1666,7 +1669,7 @@ void WasmCompiledModule::ReinitializeAfterDeserialization( ...@@ -1666,7 +1669,7 @@ void WasmCompiledModule::ReinitializeAfterDeserialization(
WasmSharedModuleData::ReinitializeAfterDeserialization(isolate, shared); WasmSharedModuleData::ReinitializeAfterDeserialization(isolate, shared);
} }
size_t function_table_count = size_t function_table_count =
compiled_module->module()->function_tables.size(); compiled_module->shared()->module()->function_tables.size();
wasm::NativeModule* native_module = compiled_module->GetNativeModule(); wasm::NativeModule* native_module = compiled_module->GetNativeModule();
if (function_table_count > 0) { if (function_table_count > 0) {
...@@ -1802,20 +1805,20 @@ bool WasmCompiledModule::SetBreakPoint( ...@@ -1802,20 +1805,20 @@ bool WasmCompiledModule::SetBreakPoint(
Handle<WasmCompiledModule> compiled_module, int* position, Handle<WasmCompiledModule> compiled_module, int* position,
Handle<Object> break_point_object) { Handle<Object> break_point_object) {
Isolate* isolate = compiled_module->GetIsolate(); Isolate* isolate = compiled_module->GetIsolate();
Handle<WasmSharedModuleData> shared = compiled_module->shared();
// Find the function for this breakpoint. // Find the function for this breakpoint.
int func_index = compiled_module->shared()->GetContainingFunction(*position); int func_index = shared->GetContainingFunction(*position);
if (func_index < 0) return false; if (func_index < 0) return false;
WasmFunction& func = compiled_module->module()->functions[func_index]; WasmFunction& func = shared->module()->functions[func_index];
int offset_in_func = *position - func.code.offset(); int offset_in_func = *position - func.code.offset();
// According to the current design, we should only be called with valid // According to the current design, we should only be called with valid
// breakable positions. // breakable positions.
DCHECK(IsBreakablePosition(compiled_module, func_index, offset_in_func)); DCHECK(IsBreakablePosition(*shared, func_index, offset_in_func));
// Insert new break point into break_positions of shared module data. // Insert new break point into break_positions of shared module data.
WasmSharedModuleData::AddBreakpoint(compiled_module->shared(), *position, WasmSharedModuleData::AddBreakpoint(shared, *position, break_point_object);
break_point_object);
// Iterate over all instances of this module and tell them to set this new // Iterate over all instances of this module and tell them to set this new
// breakpoint. // breakpoint.
......
...@@ -534,14 +534,6 @@ class WasmCompiledModule : public FixedArray { ...@@ -534,14 +534,6 @@ class WasmCompiledModule : public FixedArray {
#undef DECLARATION #undef DECLARATION
public: public:
// Allow to call method on WasmSharedModuleData also on this object.
#define FORWARD_SHARED(type, name) inline type name();
FORWARD_SHARED(SeqOneByteString*, module_bytes)
FORWARD_SHARED(wasm::WasmModule*, module)
FORWARD_SHARED(Script*, script)
FORWARD_SHARED(bool, is_asm_js)
#undef FORWARD_SHARED
static bool IsWasmCompiledModule(Object* obj); static bool IsWasmCompiledModule(Object* obj);
void PrintInstancesChain(); void PrintInstancesChain();
......
...@@ -277,7 +277,8 @@ class WasmSerializationTest { ...@@ -277,7 +277,8 @@ class WasmSerializationTest {
DisallowHeapAllocation assume_no_gc; DisallowHeapAllocation assume_no_gc;
Handle<WasmCompiledModule> compiled_part(module_object->compiled_module(), Handle<WasmCompiledModule> compiled_part(module_object->compiled_module(),
current_isolate()); current_isolate());
CHECK_EQ(memcmp(compiled_part->module_bytes()->GetCharsAddress(), CHECK_EQ(
memcmp(compiled_part->shared()->module_bytes()->GetCharsAddress(),
wire_bytes().first, wire_bytes().second), wire_bytes().first, wire_bytes().second),
0); 0);
} }
......
...@@ -193,8 +193,9 @@ void TestingModuleBuilder::PopulateIndirectFunctionTable() { ...@@ -193,8 +193,9 @@ void TestingModuleBuilder::PopulateIndirectFunctionTable() {
} }
uint32_t TestingModuleBuilder::AddBytes(Vector<const byte> bytes) { uint32_t TestingModuleBuilder::AddBytes(Vector<const byte> bytes) {
Handle<SeqOneByteString> old_bytes( Handle<WasmSharedModuleData> shared =
instance_object_->compiled_module()->module_bytes(), isolate_); instance_object_->compiled_module()->shared();
Handle<SeqOneByteString> old_bytes(shared->module_bytes(), isolate_);
uint32_t old_size = static_cast<uint32_t>(old_bytes->length()); uint32_t old_size = static_cast<uint32_t>(old_bytes->length());
// Avoid placing strings at offset 0, this might be interpreted as "not // Avoid placing strings at offset 0, this might be interpreted as "not
// set", e.g. for function names. // set", e.g. for function names.
...@@ -204,8 +205,7 @@ uint32_t TestingModuleBuilder::AddBytes(Vector<const byte> bytes) { ...@@ -204,8 +205,7 @@ uint32_t TestingModuleBuilder::AddBytes(Vector<const byte> bytes) {
memcpy(new_bytes.start() + bytes_offset, bytes.start(), bytes.length()); memcpy(new_bytes.start() + bytes_offset, bytes.start(), bytes.length());
Handle<SeqOneByteString> new_bytes_str = Handle<SeqOneByteString>::cast( Handle<SeqOneByteString> new_bytes_str = Handle<SeqOneByteString>::cast(
isolate_->factory()->NewStringFromOneByte(new_bytes).ToHandleChecked()); isolate_->factory()->NewStringFromOneByte(new_bytes).ToHandleChecked());
instance_object_->compiled_module()->shared()->set_module_bytes( shared->set_module_bytes(*new_bytes_str);
*new_bytes_str);
return bytes_offset; return bytes_offset;
} }
...@@ -442,7 +442,7 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) { ...@@ -442,7 +442,7 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) {
if (FLAG_wasm_jit_to_native) { if (FLAG_wasm_jit_to_native) {
native_module->ResizeCodeTableForTest(function_->func_index); native_module->ResizeCodeTableForTest(function_->func_index);
} }
Handle<SeqOneByteString> wire_bytes(compiled_module->module_bytes(), Handle<SeqOneByteString> wire_bytes(compiled_module->shared()->module_bytes(),
isolate()); isolate());
compiler::ModuleEnv module_env = builder_->CreateModuleEnv(); compiler::ModuleEnv module_env = builder_->CreateModuleEnv();
......
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