summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/wasm.js62
-rwxr-xr-xcheck.py22
-rw-r--r--src/wasm-binary.h16
3 files changed, 55 insertions, 45 deletions
diff --git a/bin/wasm.js b/bin/wasm.js
index 8ae44a3dc..45a2264b3 100644
--- a/bin/wasm.js
+++ b/bin/wasm.js
@@ -55575,7 +55575,7 @@ function __ZN4wasm17WasmBinaryBuilder11visitSwitchEPNS_6SwitchE(i11, i10) {
i5 = i10 + 8 | 0;
i7 = 0;
while (1) {
- i1 = __ZN4wasm17WasmBinaryBuilder12getBreakNameEi(i11, (__ZN4wasm17WasmBinaryBuilder8getInt16Ev(i11) | 0) & 65535) | 0;
+ i1 = __ZN4wasm17WasmBinaryBuilder12getBreakNameEi(i11, __ZN4wasm17WasmBinaryBuilder8getInt32Ev(i11) | 0) | 0;
if ((i7 | 0) >= (i2 | 0)) break;
HEAP32[i8 >> 2] = i1;
i6 = HEAP32[i3 >> 2] | 0;
@@ -62469,36 +62469,6 @@ function __ZNSt3__16vectorIN4wasm8NameTypeENS_9allocatorIS2_EEE24__emplace_back_
return;
}
-function __ZN4wasm17WasmBinaryBuilder10visitBreakEPNS_5BreakEh(i4, i3, i2) {
- i4 = i4 | 0;
- i3 = i3 | 0;
- i2 = i2 | 0;
- var i1 = 0, i5 = 0, i6 = 0, i7 = 0;
- i5 = STACKTOP;
- STACKTOP = STACKTOP + 16 | 0;
- i1 = i5;
- if (HEAP8[i4 + 12 >> 0] | 0) {
- i6 = __ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc(43432, 18483) | 0;
- i7 = __ZNKSt3__18ios_base6getlocEv(i6 + (HEAP32[(HEAP32[i6 >> 2] | 0) + -12 >> 2] | 0) | 0) | 0;
- HEAP32[i1 >> 2] = i7;
- i7 = __ZNKSt3__16locale9use_facetERNS0_2idE(i1, 44308) | 0;
- i7 = FUNCTION_TABLE_iii[HEAP32[(HEAP32[i7 >> 2] | 0) + 28 >> 2] & 31](i7, 10) | 0;
- __ZNSt3__16localeD2Ev(i1);
- __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE3putEc(i6, i7) | 0;
- __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv(i6) | 0;
- }
- i7 = __ZN4wasm17WasmBinaryBuilder12getBreakNameEi(i4, (__ZN4wasm17WasmBinaryBuilder7getInt8Ev(i4) | 0) & 255) | 0;
- HEAP32[i3 + 8 >> 2] = i7;
- if (i2 << 24 >> 24 == 7) {
- i7 = __ZN4wasm17WasmBinaryBuilder13popExpressionEv(i4) | 0;
- HEAP32[i3 + 16 >> 2] = i7;
- }
- i7 = __ZN4wasm17WasmBinaryBuilder13popExpressionEv(i4) | 0;
- HEAP32[i3 + 12 >> 2] = i7;
- STACKTOP = i5;
- return;
-}
-
function ___cxx_global_array_dtor(i1) {
i1 = i1 | 0;
__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev(44536);
@@ -62615,6 +62585,36 @@ function __ZNSt3__16vectorIN4wasm8NameTypeENS_9allocatorIS2_EEE24__emplace_back_
return;
}
+function __ZN4wasm17WasmBinaryBuilder10visitBreakEPNS_5BreakEh(i4, i3, i2) {
+ i4 = i4 | 0;
+ i3 = i3 | 0;
+ i2 = i2 | 0;
+ var i1 = 0, i5 = 0, i6 = 0, i7 = 0;
+ i5 = STACKTOP;
+ STACKTOP = STACKTOP + 16 | 0;
+ i1 = i5;
+ if (HEAP8[i4 + 12 >> 0] | 0) {
+ i6 = __ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc(43432, 18483) | 0;
+ i7 = __ZNKSt3__18ios_base6getlocEv(i6 + (HEAP32[(HEAP32[i6 >> 2] | 0) + -12 >> 2] | 0) | 0) | 0;
+ HEAP32[i1 >> 2] = i7;
+ i7 = __ZNKSt3__16locale9use_facetERNS0_2idE(i1, 44308) | 0;
+ i7 = FUNCTION_TABLE_iii[HEAP32[(HEAP32[i7 >> 2] | 0) + 28 >> 2] & 31](i7, 10) | 0;
+ __ZNSt3__16localeD2Ev(i1);
+ __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE3putEc(i6, i7) | 0;
+ __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv(i6) | 0;
+ }
+ i7 = __ZN4wasm17WasmBinaryBuilder12getBreakNameEi(i4, __ZN4wasm17WasmBinaryBuilder8getInt32Ev(i4) | 0) | 0;
+ HEAP32[i3 + 8 >> 2] = i7;
+ if (i2 << 24 >> 24 == 7) {
+ i7 = __ZN4wasm17WasmBinaryBuilder13popExpressionEv(i4) | 0;
+ HEAP32[i3 + 16 >> 2] = i7;
+ }
+ i7 = __ZN4wasm17WasmBinaryBuilder13popExpressionEv(i4) | 0;
+ HEAP32[i3 + 12 >> 2] = i7;
+ STACKTOP = i5;
+ return;
+}
+
function __ZNSt3__113unordered_mapIN6cashew7IStringEN7AsmData5LocalENS_4hashIS2_EENS_8equal_toIS2_EENS_9allocatorINS_4pairIKS2_S4_EEEEEixERSB_(i5, i4) {
i5 = i5 | 0;
i4 = i4 | 0;
diff --git a/check.py b/check.py
index e42bae2a4..34f3f4e4c 100755
--- a/check.py
+++ b/check.py
@@ -672,12 +672,22 @@ if has_emcc:
except:
args = []
print ' (no args)'
- if has_node:
- proc = subprocess.Popen([has_node, 'a.' + which + '.js'] + args, stdout=subprocess.PIPE)
- out, err = proc.communicate()
- assert proc.returncode == 0
- if out.strip() != expected.strip():
- fail(out, expected)
+
+ def execute():
+ if has_node:
+ proc = subprocess.Popen([has_node, 'a.' + which + '.js'] + args, stdout=subprocess.PIPE)
+ out, err = proc.communicate()
+ assert proc.returncode == 0
+ if out.strip() != expected.strip():
+ fail(out, expected)
+
+ execute()
+
+ # binary and back
+ shutil.copyfile('a.wasm.wast', 'a.wasm.original.wast')
+ recreated = binary_format_check('a.wasm.wast', verify_final_result=False)
+ shutil.copyfile(recreated, 'a.wasm.wast')
+ execute()
print '\n[ success! ]'
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index f772be353..5d25323de 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -650,7 +650,7 @@ public:
o << int8_t(BinaryConsts::EndMarker);
}
- int getBreakIndex(Name name) { // -1 if not found
+ int32_t getBreakIndex(Name name) { // -1 if not found
for (int i = breakStack.size() - 1; i >= 0; i--) {
if (breakStack[i] == name) {
return breakStack.size() - 1 - i;
@@ -669,15 +669,15 @@ public:
}
if (curr->condition) recurse(curr->condition);
o << int8_t(curr->condition ? BinaryConsts::BrIf : BinaryConsts::Br)
- << int8_t(getBreakIndex(curr->name));
+ << int32_t(getBreakIndex(curr->name));
}
void visitSwitch(Switch *curr) {
if (debug) std::cerr << "zz node: Switch" << std::endl;
o << int8_t(BinaryConsts::TableSwitch) << int16_t(curr->targets.size() + 1) << int8_t(curr->value != nullptr);
for (auto target : curr->targets) {
- o << (int16_t)getBreakIndex(target);
+ o << (int32_t)getBreakIndex(target);
}
- o << (int16_t)getBreakIndex(curr->default_);
+ o << (int32_t)getBreakIndex(curr->default_);
recurse(curr->condition);
o << int8_t(BinaryConsts::EndMarker);
if (curr->value) {
@@ -1405,14 +1405,14 @@ public:
curr->finalize();
}
- Name getBreakName(int offset) {
+ Name getBreakName(int32_t offset) {
assert(breakStack.size() - 1 - offset < breakStack.size());
return breakStack[breakStack.size() - 1 - offset];
}
void visitBreak(Break *curr, uint8_t code) {
if (debug) std::cerr << "zz node: Break" << std::endl;
- curr->name = getBreakName(getInt8());
+ curr->name = getBreakName(getInt32());
if (code == BinaryConsts::BrIf) curr->condition = popExpression();
curr->value = popExpression();
}
@@ -1421,9 +1421,9 @@ public:
auto numTargets = getInt16();
auto hasValue = getInt8();
for (auto i = 0; i < numTargets - 1; i++) {
- curr->targets.push_back(getBreakName(getInt16()));
+ curr->targets.push_back(getBreakName(getInt32()));
}
- curr->default_ = getBreakName(getInt16());
+ curr->default_ = getBreakName(getInt32());
processExpressions();
curr->condition = popExpression();
if (hasValue) {