| Index: runtime/lib/double.cc
|
| diff --git a/runtime/lib/double.cc b/runtime/lib/double.cc
|
| index 813002445b1cb00c566f19e418bc429e9691e81d..3bfba2a3e8de86de8f96f2df78c3f0e486065324 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.
|
| + 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.
|
| + ival = static_cast<int64_t>(val);
|
| + }
|
| + return Integer::New(ival);
|
| + }
|
| if ((-1.0 < val) && (val < 1.0)) {
|
| return Smi::New(0);
|
| }
|
|
|