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

Unified Diff: runtime/lib/double.cc

Issue 2974633003: Option to truncate integers to 64 bits, part 1 (core VM changes) (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/integers.cc » ('j') | runtime/platform/utils.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/double.cc
diff --git a/runtime/lib/double.cc b/runtime/lib/double.cc
index 813002445b1cb00c566f19e418bc429e9691e81d..8a8c23797339cc81494141ebbd9f9fa029cc6768 100644
--- a/runtime/lib/double.cc
+++ b/runtime/lib/double.cc
@@ -79,6 +79,19 @@ static RawInteger* DoubleToInteger(double val, const char* error_msg) {
args.SetAt(0, String::Handle(String::New(error_msg)));
Exceptions::ThrowByType(Exceptions::kUnsupported, args);
}
+ if (FLAG_truncate_ints_to_64_bits) {
+ // TODO(alexmarkov): decide on the double-to-integer conversion semantics
+ // in truncating mode.
regis 2017/07/07 20:10:29 Something to discuss with the API people. You coul
alexmarkov 2017/07/07 20:46:38 Acknowledged.
+ int64_t ival = 0;
+ if (val <= static_cast<double>(kMinInt64)) {
+ ival = kMinInt64;
+ } else if (val >= static_cast<double>(kMaxInt64)) {
+ ival = kMaxInt64;
+ } else { // representable in int64_t
regis 2017/07/07 20:10:29 The convention is to use a capital letter and a pe
alexmarkov 2017/07/07 20:46:38 Done.
+ ival = static_cast<int64_t>(val);
+ }
+ return Integer::New(ival);
+ }
if ((-1.0 < val) && (val < 1.0)) {
return Smi::New(0);
}
« no previous file with comments | « no previous file | runtime/lib/integers.cc » ('j') | runtime/platform/utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698