Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Unified Diff: runtime/lib/bigint.dart

Issue 2983633002: Avoid Bigint literals in Dart core library (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/typed_data_patch.dart » ('j') | runtime/lib/typed_data_patch.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/bigint.dart
diff --git a/runtime/lib/bigint.dart b/runtime/lib/bigint.dart
index af03ea41fd62394b676623b0b59d6b2126c524e9..217b6ed027913af46acc604126dda38121701ef3 100644
--- a/runtime/lib/bigint.dart
+++ b/runtime/lib/bigint.dart
@@ -57,6 +57,10 @@ class _Bigint extends _IntegerImplementation implements int {
static const int _DIGIT2_BITS = _DIGIT_BITS >> 1;
static const int _DIGIT2_MASK = (1 << _DIGIT2_BITS) - 1;
+ // Bits per 2 digits
+ static const int _TWO_DIGITS_BITS = _DIGIT_BITS << 1;
+ static const int _TWO_DIGITS_MASK = (1 << _TWO_DIGITS_BITS) - 1;
regis 2017/07/17 16:45:31 How is this supposed to work? Do you avoid the cre
alexmarkov 2017/07/17 20:21:28 Done.
+
// Min and max of non bigint values.
static const int _MIN_INT64 = (-1) << 63;
static const int _MAX_INT64 = 0x7fffffffffffffff;
@@ -1932,7 +1936,8 @@ class _Montgomery implements _Reduction {
0xffff; // y == 1/x mod 2^16
y = (y * (2 - ((xl * y) & 0xffffffff))) & 0xffffffff; // y == 1/x mod 2^32
var x = (args[_X_HI] << _Bigint._DIGIT_BITS) | xl;
- y = (y * (2 - ((x * y) & 0xffffffffffffffff))) & 0xffffffffffffffff;
+ y = (y * (2 - ((x * y) & _Bigint._TWO_DIGITS_MASK))) &
+ _Bigint._TWO_DIGITS_MASK;
// y == 1/x mod _DIGIT_BASE^2
y = -y; // We really want the negative inverse.
args[_RHO] = y & _Bigint._DIGIT_MASK;
« no previous file with comments | « no previous file | runtime/lib/typed_data_patch.dart » ('j') | runtime/lib/typed_data_patch.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698