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

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

Issue 2390113003: [wasm] Refactor import handling for 0xC. (Closed)
Patch Set: Fix gc stress failure Created 4 years, 2 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
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/module-decoder.cc
diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc
index 90065616d93db85ef9dbe817302f6b8a06028f86..865d481bed89a42552db5465e57155b849fdfab1 100644
--- a/src/wasm/module-decoder.cc
+++ b/src/wasm/module-decoder.cc
@@ -318,7 +318,7 @@ class ModuleDecoder : public Decoder {
// ===== Imported global =========================================
import->index = static_cast<uint32_t>(module->globals.size());
module->globals.push_back(
- {kAstStmt, false, NO_INIT, 0, true, false});
+ {kAstStmt, false, WasmInitExpr(), 0, true, false});
WasmGlobal* global = &module->globals.back();
global->type = consume_value_type();
global->mutability = consume_u8("mutability") != 0;
@@ -399,7 +399,8 @@ class ModuleDecoder : public Decoder {
TRACE("DecodeGlobal[%d] module+%d\n", i,
static_cast<int>(pc_ - start_));
// Add an uninitialized global and pass a pointer to it.
- module->globals.push_back({kAstStmt, false, NO_INIT, 0, false, false});
+ module->globals.push_back(
+ {kAstStmt, false, WasmInitExpr(), 0, false, false});
WasmGlobal* global = &module->globals.back();
DecodeGlobalInModule(module, i, global);
}
@@ -545,9 +546,9 @@ class ModuleDecoder : public Decoder {
TRACE("DecodeDataSegment[%d] module+%d\n", i,
static_cast<int>(pc_ - start_));
module->data_segments.push_back({
- NO_INIT, // dest_addr
- 0, // source_offset
- 0 // source_size
+ WasmInitExpr(), // dest_addr
+ 0, // source_offset
+ 0 // source_size
});
WasmDataSegment* segment = &module->data_segments.back();
DecodeDataSegmentInModule(module, segment);
@@ -647,13 +648,19 @@ class ModuleDecoder : public Decoder {
const byte* pos = pc();
global->init = consume_init_expr(module, kAstStmt);
switch (global->init.kind) {
- case WasmInitExpr::kGlobalIndex:
- if (global->init.val.global_index >= index) {
+ case WasmInitExpr::kGlobalIndex: {
+ uint32_t other_index = global->init.val.global_index;
+ if (other_index >= index) {
error("invalid global index in init expression");
- } else if (module->globals[index].type != global->type) {
- error("type mismatch in global initialization");
+ } else if (module->globals[other_index].type != global->type) {
+ error(pos, pos,
+ "type mismatch in global initialization "
+ "(from global #%u), expected %s, got %s",
+ other_index, WasmOpcodes::TypeName(global->type),
+ WasmOpcodes::TypeName(module->globals[other_index].type));
}
break;
+ }
default:
if (global->type != TypeOf(module, global->init)) {
error(pos, pos,
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698