aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2013-04-23 22:16:20 +0300
committerJukka Jylänki <jujjyl@gmail.com>2013-04-23 22:19:12 +0300
commit332d1f86914b406af84f7e178379d144805a109f (patch)
treef7f176a676169cb23a0227aa8c65c6eb71b4266a
parentb43cbd876910598e1ca7aeaa58c8a41f5878a417 (diff)
Restore the overflow check to llvm_uadd_with_overflow_i64 to account for the case 0xFFFFFFFFFFFFFFFF + 0x0000000100000001 == 0x0000000100000000.
-rw-r--r--src/library.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js
index 5b58b47f..db84430e 100644
--- a/src/library.js
+++ b/src/library.js
@@ -7560,8 +7560,10 @@ LibraryManager.library = {
a = a|0; b = b|0; c = c|0; d = d|0;
var l = 0, h = 0, overflow = 0;
l = (a + c)>>>0;
- h = (((b + d)>>>0) + (((l>>>0) < (a>>>0))>>>0))>>>0; // Add carry from low word to high word on overflow.
- overflow = (((h>>>0) < (b>>>0))>>>0); // Return whether addition overflowed even the high word.
+ h = (b + d)>>>0;
+ overflow = ((h>>>0) < (b>>>0))>>>0; // Return whether addition overflowed even the high word.
+ h = h + (((l>>>0) < (a>>>0))>>>0)>>>0; // Add carry from low word to high word on overflow.
+ overflow = (overflow | ((h == 0)>>>0))>>>0; // Check again for overflow.
{{{ makeStructuralReturn(['l|0', 'h', 'overflow'], true) }}};
},