Index: src/wasm/wasm-text.cc |
diff --git a/src/wasm/wasm-text.cc b/src/wasm/wasm-text.cc |
index f26663227ac99eb43d63edc2e7e0e383bbcdf38b..8ce329a3153ec5afd23df4aa89e2b5e433744280 100644 |
--- a/src/wasm/wasm-text.cc |
+++ b/src/wasm/wasm-text.cc |
@@ -128,7 +128,8 @@ bool IsValidFunctionName(const Vector<const char> &name) { |
} // namespace |
void wasm::PrintWasmText( |
- const WasmModule *module, uint32_t func_index, std::ostream &os, |
+ const WasmModule *module, const ModuleWireBytes &wire_bytes, |
+ uint32_t func_index, std::ostream &os, |
std::vector<std::tuple<uint32_t, int, int>> *offset_table) { |
DCHECK_NOT_NULL(module); |
DCHECK_GT(module->functions.size(), func_index); |
@@ -141,9 +142,7 @@ void wasm::PrintWasmText( |
// Print the function signature. |
os << "func"; |
- Vector<const char> fun_name( |
- reinterpret_cast<const char *>(module->module_start + fun->name_offset), |
- fun->name_length); |
+ WasmName fun_name = wire_bytes.GetNameOrNull(fun); |
if (IsValidFunctionName(fun_name)) { |
os << " $"; |
os.write(fun_name.start(), fun_name.length()); |
@@ -167,10 +166,10 @@ void wasm::PrintWasmText( |
// Print the local declarations. |
AstLocalDecls decls(&zone); |
- const byte *code_start = module->module_start + fun->code_start_offset; |
- const byte *code_end = module->module_start + fun->code_end_offset; |
- BytecodeIterator i(code_start, code_end, &decls); |
- DCHECK_LT(code_start, i.pc()); |
+ Vector<const byte> func_bytes = wire_bytes.module_bytes.SubVector( |
+ fun->code_start_offset, fun->code_end_offset); |
+ BytecodeIterator i(func_bytes.begin(), func_bytes.end(), &decls); |
+ DCHECK_LT(func_bytes.begin(), i.pc()); |
if (!decls.local_types.empty()) { |
os << "(local"; |
for (auto p : decls.local_types) { |