diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-10-25 17:03:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-25 17:03:10 -0700 |
commit | ded69c16a2b3f27dd9b12b184d7045596d2a21d0 (patch) | |
tree | cbe2076c9d9d00ff149e24f6d5c04376f61a5547 /src/asm2wasm.h | |
parent | dc35ac6e83694fda26a78d8b11712c3210e30b36 (diff) | |
download | binaryen-ded69c16a2b3f27dd9b12b184d7045596d2a21d0.tar.gz binaryen-ded69c16a2b3f27dd9b12b184d7045596d2a21d0.tar.bz2 binaryen-ded69c16a2b3f27dd9b12b184d7045596d2a21d0.zip |
Optimize out bool & 1 (#804)
* asm.js corrections to unit.asm.js test
* optimize out bool&1
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 5bdb2a9bf..377b6b20b 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -954,9 +954,15 @@ void Asm2WasmBuilder::processAsm(Ref ast) { void visitCallIndirect(CallIndirect* curr) { // we already call into target = something + offset, where offset is a callImport with the name of the table. replace that with the table offset auto add = curr->target->cast<Binary>(); - auto offset = add->right->cast<CallImport>(); - auto tableName = offset->target; - add->right = parent->builder.makeConst(Literal((int32_t)parent->functionTableStarts[tableName])); + if (add->right->is<CallImport>()) { + auto offset = add->right->cast<CallImport>(); + auto tableName = offset->target; + add->right = parent->builder.makeConst(Literal((int32_t)parent->functionTableStarts[tableName])); + } else { + auto offset = add->left->cast<CallImport>(); + auto tableName = offset->target; + add->left = parent->builder.makeConst(Literal((int32_t)parent->functionTableStarts[tableName])); + } } }; |