Skip to content

Commit 3ba6b06

Browse files
Small fix to interpreter logic
1 parent 798b1b6 commit 3ba6b06

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
@@ -1802,34 +1802,32 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
18021802
VISIT(leftHigh, curr->leftHigh);
18031803
VISIT(rightLow, curr->rightLow);
18041804
VISIT(rightHigh, curr->rightHigh);
1805-
if (curr->op == AddInt128 || curr->op == SubInt128) {
1806-
uint64_t lowLHS = leftLow.getSingleValue().geti64();
1807-
uint64_t highLHS = leftHigh.getSingleValue().geti64();
1808-
uint64_t lowRHS = rightLow.getSingleValue().geti64();
1809-
uint64_t highRHS = rightHigh.getSingleValue().geti64();
18101805

1811-
uint64_t lowResult = 0;
1812-
uint64_t highResult = 0;
1806+
uint64_t lowLHS = leftLow.getSingleValue().geti64();
1807+
uint64_t highLHS = leftHigh.getSingleValue().geti64();
1808+
uint64_t lowRHS = rightLow.getSingleValue().geti64();
1809+
uint64_t highRHS = rightHigh.getSingleValue().geti64();
18131810

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

1827-
Literals results;
1828-
results.push_back(Literal(lowResult));
1829-
results.push_back(Literal(highResult));
1830-
return results;
1814+
switch (curr->op) {
1815+
case AddInt128: {
1816+
bool overflowed = std::ckd_add(&lowResult, lowLHS, lowRHS);
1817+
highResult = highLHS + highRHS + overflowed;
1818+
break;
1819+
}
1820+
case SubInt128: {
1821+
bool overflowed = std::ckd_sub(&lowResult, lowLHS, lowRHS);
1822+
highResult = highLHS - highRHS - overflowed;
1823+
break;
1824+
}
18311825
}
1832-
WASM_UNREACHABLE("invalid wide int binary op");
1826+
1827+
Literals results;
1828+
results.push_back(Literal(lowResult));
1829+
results.push_back(Literal(highResult));
1830+
return results;
18331831
}
18341832
Flow visitDrop(Drop* curr) {
18351833
VISIT(value, curr->value)

0 commit comments

Comments
 (0)