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

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

Issue 2395133002: Revert of [wasm] Refactor import handling for 0xC. (Closed)
Patch Set: 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/wasm/wasm-module-builder.h ('k') | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module-builder.cc
diff --git a/src/wasm/wasm-module-builder.cc b/src/wasm/wasm-module-builder.cc
index 941a0736c3272a53488121a3e3309619e4d90646..084f5a0c1a08185d4c0021c86adc93957a93a9a1 100644
--- a/src/wasm/wasm-module-builder.cc
+++ b/src/wasm/wasm-module-builder.cc
@@ -255,9 +255,8 @@
}
uint32_t WasmModuleBuilder::AddGlobal(LocalType type, bool exported,
- bool mutability,
- const WasmInitExpr& init) {
- globals_.push_back({type, exported, mutability, init});
+ bool mutability) {
+ globals_.push_back({type, exported, mutability});
return static_cast<uint32_t>(globals_.size() - 1);
}
@@ -345,64 +344,29 @@
for (auto global : globals_) {
buffer.write_u8(WasmOpcodes::LocalTypeCodeFor(global.type));
buffer.write_u8(global.mutability ? 1 : 0);
- switch (global.init.kind) {
- case WasmInitExpr::kI32Const: {
- DCHECK_EQ(kAstI32, global.type);
- const byte code[] = {WASM_I32V_5(global.init.val.i32_const)};
+ switch (global.type) {
+ case kAstI32: {
+ static const byte code[] = {WASM_I32V_1(0)};
buffer.write(code, sizeof(code));
break;
}
- case WasmInitExpr::kI64Const: {
- DCHECK_EQ(kAstI64, global.type);
- const byte code[] = {WASM_I64V_10(global.init.val.i64_const)};
+ case kAstF32: {
+ static const byte code[] = {WASM_F32(0)};
buffer.write(code, sizeof(code));
break;
}
- case WasmInitExpr::kF32Const: {
- DCHECK_EQ(kAstF32, global.type);
- const byte code[] = {WASM_F32(global.init.val.f32_const)};
+ case kAstI64: {
+ static const byte code[] = {WASM_I64V_1(0)};
buffer.write(code, sizeof(code));
break;
}
- case WasmInitExpr::kF64Const: {
- DCHECK_EQ(kAstF64, global.type);
- const byte code[] = {WASM_F64(global.init.val.f64_const)};
+ case kAstF64: {
+ static const byte code[] = {WASM_F64(0.0)};
buffer.write(code, sizeof(code));
break;
}
- case WasmInitExpr::kGlobalIndex: {
- const byte code[] = {kExprGetGlobal,
- U32V_5(global.init.val.global_index)};
- buffer.write(code, sizeof(code));
- break;
- }
- default: {
- // No initializer, emit a default value.
- switch (global.type) {
- case kAstI32: {
- const byte code[] = {WASM_I32V_1(0)};
- buffer.write(code, sizeof(code));
- break;
- }
- case kAstI64: {
- const byte code[] = {WASM_I64V_1(0)};
- buffer.write(code, sizeof(code));
- break;
- }
- case kAstF32: {
- const byte code[] = {WASM_F32(0.0)};
- buffer.write(code, sizeof(code));
- break;
- }
- case kAstF64: {
- const byte code[] = {WASM_F64(0.0)};
- buffer.write(code, sizeof(code));
- break;
- }
- default:
- UNREACHABLE();
- }
- }
+ default:
+ UNREACHABLE();
}
buffer.write_u8(kExprEnd);
}
« no previous file with comments | « src/wasm/wasm-module-builder.h ('k') | test/cctest/wasm/test-run-wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698