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

Unified Diff: src/asmjs/asm-wasm-builder.cc

Issue 2692943002: [wasm] Introduce EmitVarInt and EmitWithVarInt (Closed)
Patch Set: Use bit_cast instead of static_cast Created 3 years, 10 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 | « no previous file | src/wasm/wasm-module-builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/asmjs/asm-wasm-builder.cc
diff --git a/src/asmjs/asm-wasm-builder.cc b/src/asmjs/asm-wasm-builder.cc
index 73a3d33765ce6dce44634f2b407e5ee0ef7c12f3..8a2c0bdb81af2d70603e7d00525ae9a567c94157 100644
--- a/src/asmjs/asm-wasm-builder.cc
+++ b/src/asmjs/asm-wasm-builder.cc
@@ -683,35 +683,26 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
if (type->IsA(AsmType::Signed())) {
int32_t i = 0;
- if (!value->ToInt32(&i)) {
- UNREACHABLE();
- }
- byte code[] = {WASM_I32V(i)};
- current_function_builder_->EmitCode(code, sizeof(code));
+ CHECK(value->ToInt32(&i));
+ current_function_builder_->EmitI32Const(i);
} else if (type->IsA(AsmType::Unsigned()) || type->IsA(AsmType::FixNum())) {
uint32_t u = 0;
- if (!value->ToUint32(&u)) {
- UNREACHABLE();
- }
- int32_t i = static_cast<int32_t>(u);
- byte code[] = {WASM_I32V(i)};
- current_function_builder_->EmitCode(code, sizeof(code));
+ CHECK(value->ToUint32(&u));
+ current_function_builder_->EmitI32Const(bit_cast<int32_t>(u));
} else if (type->IsA(AsmType::Int())) {
// The parser can collapse !0, !1 etc to true / false.
// Allow these as int literals.
if (expr->raw_value()->IsTrue()) {
- byte code[] = {WASM_I32V(1)};
+ byte code[] = {WASM_ONE};
current_function_builder_->EmitCode(code, sizeof(code));
} else if (expr->raw_value()->IsFalse()) {
- byte code[] = {WASM_I32V(0)};
+ byte code[] = {WASM_ZERO};
current_function_builder_->EmitCode(code, sizeof(code));
} else if (expr->raw_value()->IsNumber()) {
// This can happen when -x becomes x * -1 (due to the parser).
int32_t i = 0;
- if (!value->ToInt32(&i) || i != -1) {
- UNREACHABLE();
- }
- byte code[] = {WASM_I32V(i)};
+ CHECK(value->ToInt32(&i) && i == -1);
+ byte code[] = {WASM_I32V_1(-1)};
current_function_builder_->EmitCode(code, sizeof(code));
} else {
UNREACHABLE();
« no previous file with comments | « no previous file | src/wasm/wasm-module-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698