Skip to content

Commit 80fe1b7

Browse files
Small fix to interpreter logic
1 parent 4eea2fa commit 80fe1b7

1 file changed

Lines changed: 22 additions & 24 deletions

File tree

src/wasm-interpreter.h

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,34 +1806,32 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
18061806
VISIT(leftHigh, curr->leftHigh);
18071807
VISIT(rightLow, curr->rightLow);
18081808
VISIT(rightHigh, curr->rightHigh);
1809-
if (curr->op == AddInt128 || curr->op == SubInt128) {
1810-
uint64_t lowLHS = leftLow.getSingleValue().geti64();
1811-
uint64_t highLHS = leftHigh.getSingleValue().geti64();
1812-
uint64_t lowRHS = rightLow.getSingleValue().geti64();
1813-
uint64_t highRHS = rightHigh.getSingleValue().geti64();
18141809

1815-
uint64_t lowResult = 0;
1816-
uint64_t highResult = 0;
1810+
uint64_t lowLHS = leftLow.getSingleValue().geti64();
1811+
uint64_t highLHS = leftHigh.getSingleValue().geti64();
1812+
uint64_t lowRHS = rightLow.getSingleValue().geti64();
1813+
uint64_t highRHS = rightHigh.getSingleValue().geti64();
18171814

1818-
switch (curr->op) {
1819-
case AddInt128: {
1820-
bool overflowed = std::ckd_add(&lowResult, lowLHS, lowRHS);
1821-
highResult = highLHS + highRHS + overflowed;
1822-
break;
1823-
}
1824-
case SubInt128: {
1825-
bool overflowed = std::ckd_sub(&lowResult, lowLHS, lowRHS);
1826-
highResult = highLHS - highRHS - overflowed;
1827-
break;
1828-
}
1829-
}
1815+
uint64_t lowResult = 0;
1816+
uint64_t highResult = 0;
18301817

1831-
Literals results;
1832-
results.push_back(Literal(lowResult));
1833-
results.push_back(Literal(highResult));
1834-
return results;
1818+
switch (curr->op) {
1819+
case AddInt128: {
1820+
bool overflowed = std::ckd_add(&lowResult, lowLHS, lowRHS);
1821+
highResult = highLHS + highRHS + overflowed;
1822+
break;
1823+
}
1824+
case SubInt128: {
1825+
bool overflowed = std::ckd_sub(&lowResult, lowLHS, lowRHS);
1826+
highResult = highLHS - highRHS - overflowed;
1827+
break;
1828+
}
18351829
}
1836-
WASM_UNREACHABLE("invalid wide int binary op");
1830+
1831+
Literals results;
1832+
results.push_back(Literal(lowResult));
1833+
results.push_back(Literal(highResult));
1834+
return results;
18371835
}
18381836
Flow visitDrop(Drop* curr) {
18391837
VISIT(value, curr->value)

0 commit comments

Comments
 (0)