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

Unified Diff: src/wasm/module-decoder.cc

Issue 2014533003: [wasm] Refactor encoder.h to use a proper buffer and remove OldFunctions section. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months 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
Index: src/wasm/module-decoder.cc
diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc
index 417d71fbe71ab44db3deea0d1a6b67c4177fd774..b17d529ba3a70e2d31a24d8dbdfbdf7bb2a018e1 100644
--- a/src/wasm/module-decoder.cc
+++ b/src/wasm/module-decoder.cc
@@ -118,6 +118,10 @@ class ModuleDecoder : public Decoder {
break;
}
+ TRACE(" +%d section name : \"%.*s\"\n",
+ static_cast<int>(section_name_start - start_),
+ string_length < 20 ? string_length : 20, section_name_start);
+
WasmSection::Code section =
WasmSection::lookup(section_name_start, string_length);
@@ -171,8 +175,7 @@ class ModuleDecoder : public Decoder {
0, // name_offset
0, // name_length
0, // code_start_offset
- 0, // code_end_offset
- false}); // exported
+ 0}); // code_end_offset
WasmFunction* function = &module->functions.back();
function->sig_index = consume_sig_index(module, &function->sig);
}
@@ -204,44 +207,6 @@ class ModuleDecoder : public Decoder {
}
break;
}
- case WasmSection::Code::OldFunctions: {
- int length;
- uint32_t functions_count = consume_u32v(&length, "functions count");
- module->functions.reserve(SafeReserve(functions_count));
- // Set up module environment for verification.
- ModuleEnv menv;
- menv.module = module;
- menv.instance = nullptr;
- menv.origin = origin_;
- // Decode functions.
- for (uint32_t i = 0; i < functions_count; i++) {
- if (failed()) break;
- TRACE("DecodeFunction[%d] module+%d\n", i,
- static_cast<int>(pc_ - start_));
-
- module->functions.push_back({nullptr, // sig
- i, // func_index
- 0, // sig_index
- 0, // name_offset
- 0, // name_length
- 0, // code_start_offset
- 0, // code_end_offset
- false}); // exported
- WasmFunction* function = &module->functions.back();
- DecodeFunctionInModule(module, function, false);
- }
- if (ok() && verify_functions) {
- for (uint32_t i = 0; i < functions_count; i++) {
- if (failed()) break;
- WasmFunction* function = &module->functions[i];
- VerifyFunctionBody(i, &menv, function);
- if (result_.failed()) {
- error(result_.error_pc, result_.error_msg.get());
- }
- }
- }
- break;
- }
case WasmSection::Code::Names: {
int length;
const byte* pos = pc_;
@@ -464,7 +429,6 @@ class ModuleDecoder : public Decoder {
function->name_length = 0; // ---- name length
function->code_start_offset = off(pc_); // ---- code start
function->code_end_offset = off(limit_); // ---- code end
- function->exported = false; // ---- exported
if (ok()) VerifyFunctionBody(0, module_env, function);
@@ -498,46 +462,6 @@ class ModuleDecoder : public Decoder {
global->exported = consume_u8("exported") != 0;
}
- // Decodes a single function entry inside a module starting at {pc_}.
- // TODO(titzer): legacy function body; remove
- void DecodeFunctionInModule(WasmModule* module, WasmFunction* function,
- bool verify_body = true) {
- byte decl_bits = consume_u8("function decl");
-
- const byte* sigpos = pc_;
- function->sig_index = consume_u16("signature index");
-
- if (function->sig_index >= module->signatures.size()) {
- return error(sigpos, "invalid signature index");
- } else {
- function->sig = module->signatures[function->sig_index];
- }
-
- TRACE(" +%d <function attributes:%s%s>\n", static_cast<int>(pc_ - start_),
- decl_bits & kDeclFunctionName ? " name" : "",
- decl_bits & kDeclFunctionExport ? " exported" : "");
-
- function->exported = decl_bits & kDeclFunctionExport;
-
- if (decl_bits & kDeclFunctionName) {
- function->name_offset =
- consume_string(&function->name_length, function->exported);
- }
-
- uint16_t size = consume_u16("body size");
- if (ok()) {
- if ((pc_ + size) > limit_) {
- return error(pc_, limit_,
- "expected %d bytes for function body, fell off end", size);
- }
- function->code_start_offset = static_cast<uint32_t>(pc_ - start_);
- function->code_end_offset = function->code_start_offset + size;
- TRACE(" +%d %-20s: (%d bytes)\n", static_cast<int>(pc_ - start_),
- "function body", size);
- pc_ += size;
- }
- }
-
bool IsWithinLimit(uint32_t limit, uint32_t offset, uint32_t size) {
if (offset > limit) return false;
if ((offset + size) < offset) return false; // overflow

Powered by Google App Engine
This is Rietveld 408576698