diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-12-14 19:31:37 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-12-14 19:31:44 -0800 |
commit | 2ce78b61261357ce1c9391e318ed87e992a02587 (patch) | |
tree | 08b061093da13e50d2c8c170d5e529d53145b3a6 | |
parent | bd3a35d28606220000b160cbd4494242542d0502 (diff) | |
download | binaryen-2ce78b61261357ce1c9391e318ed87e992a02587.tar.gz binaryen-2ce78b61261357ce1c9391e318ed87e992a02587.tar.bz2 binaryen-2ce78b61261357ce1c9391e318ed87e992a02587.zip |
fix asm const arg
-rw-r--r-- | src/s2wasm.h | 6 | ||||
-rw-r--r-- | test/dot_s/asm_const.wast | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h index f7597b460..20cdce0c4 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -882,15 +882,19 @@ public: auto arg = curr->operands[0]->cast<Const>(); size_t segmentIndex = parent->addressSegments[arg->value.geti32()]; std::string code = escape(parent->wasm.memory.segments[segmentIndex].data); + int32_t id; if (ids.count(code) == 0) { - size_t id = ids.size(); + id = ids.size(); ids[code] = id; + } else { + id = ids[code]; } std::string sig = getSig(curr); sigsForCode[code].insert(sig); std::string fixedTarget = EMSCRIPTEN_ASM_CONST.str; fixedTarget += '_' + sig; curr->target = cashew::IString(fixedTarget.c_str(), false); + arg->value = Literal(id); } } diff --git a/test/dot_s/asm_const.wast b/test/dot_s/asm_const.wast index 55665533c..cdfd6f1c2 100644 --- a/test/dot_s/asm_const.wast +++ b/test/dot_s/asm_const.wast @@ -6,7 +6,7 @@ (block $fake_return_waka123 (block (call_import $emscripten_asm_const_vi - (i32.const 16) + (i32.const 0) ) (br $fake_return_waka123 (i32.const 0) |