aboutsummaryrefslogtreecommitdiff
path: root/src/library.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-04-13 18:13:57 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-04-13 18:13:57 -0700
commit252ca4a148b0a210f2ba8ec817981aa9557c1ffe (patch)
tree0a0e23638f4dc1f54b73198035cd0ec0fc65d225 /src/library.js
parente216a8e3d7312b97e9d0822aaab27247a29d341d (diff)
fix overflow detection in i64 uadd, and add testcase
Diffstat (limited to 'src/library.js')
-rw-r--r--src/library.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js
index 2e0f3afb..f9864134 100644
--- a/src/library.js
+++ b/src/library.js
@@ -7482,9 +7482,10 @@ LibraryManager.library = {
var l = 0, h = 0, overflow = 0;
l = (a + c)>>>0;
h = (b + d)>>>0;
- if ((l>>>0) < (a>>>0)) { // iff we overflowed
+ if ((h>>>0) < (b>>>0)) overflow = 1;
+ if ((l>>>0) < (a>>>0)) {
h = (h+1)>>>0;
- overflow = 1;
+ if ((h>>>0) == 0) overflow = 1; // two possibilities to overflow here
}
{{{ makeStructuralReturn(['l|0', 'h', 'overflow'], true) }}};
},