Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: src/wasm/wasm-text.cc

Issue 2540133002: [wasm] Remove raw byte pointers from WasmModule (Closed)
Patch Set: Address comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-text.h ('k') | src/zone/zone-containers.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « src/wasm/wasm-text.h ('k') | src/zone/zone-containers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698