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

Unified Diff: runtime/vm/object.cc

Issue 2992013002: [vm] Change TypedData_getUint64 native method to silently cast values (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
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index c5faed86ee98228f863825674ed14900e357236c..4adab80466650414cd4a3fb8ca61ac947c87fa51 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -18155,15 +18155,19 @@ RawInteger* Integer::New(int64_t value, Heap::Space space) {
}
RawInteger* Integer::NewFromUint64(uint64_t value, Heap::Space space) {
- if (value > static_cast<uint64_t>(Mint::kMaxValue)) {
- if (FLAG_limit_ints_to_64_bits) {
- // Out of range.
- return Integer::null();
- } else {
- return Bigint::NewFromUint64(value, space);
- }
+ if (!FLAG_limit_ints_to_64_bits &&
+ (value > static_cast<uint64_t>(Mint::kMaxValue))) {
+ return Bigint::NewFromUint64(value, space);
} else {
zra 2017/07/28 21:47:46 The else is unnecessary.
alexmarkov 2017/07/28 23:09:29 Done.
- return Integer::New(value, space);
+ return Integer::New(static_cast<int64_t>(value), space);
+ }
+}
+
+bool Integer::IsValidUint64(uint64_t value) {
+ if (FLAG_limit_ints_to_64_bits) {
+ return (value <= static_cast<uint64_t>(Mint::kMaxValue));
+ } else {
zra 2017/07/28 21:47:46 ditto
alexmarkov 2017/07/28 23:09:29 In this particular case I think 'else' adds readab
+ return true;
}
}
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698