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

Unified Diff: runtime/lib/double.cc

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « runtime/lib/byte_array.dart ('k') | runtime/lib/double.dart » ('j') | no next file with comments »
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 7a15d5b28ac4f528f4caba7d85803b2be43d8f7f..b2c11f72783d902378a7acfe073b9a3a625b72a6 100644
--- a/runtime/lib/double.cc
+++ b/runtime/lib/double.cc
@@ -79,7 +79,20 @@ DEFINE_NATIVE_ENTRY(Double_trunc_div, 2) {
if (FLAG_trace_intrinsified_natives) {
OS::Print("Double_trunc_div %f ~/ %f\n", left, right);
}
- return Double::New(trunc(left / right));
+ double result = trunc(left / right);
+ if (isinf(result) || isnan(result)) {
+ const Array& args = Array::Handle(Array::New(1));
+ args.SetAt(0, String::Handle(String::New(
+ "Result of truncating division is Infinity or NaN")));
+ Exceptions::ThrowByType(Exceptions::kUnsupported, args);
+ }
+ if ((Smi::kMinValue <= result) && (result <= Smi::kMaxValue)) {
+ return Smi::New(static_cast<intptr_t>(result));
+ } else if ((Mint::kMinValue <= result) && (result <= Mint::kMaxValue)) {
+ return Mint::New(static_cast<int64_t>(result));
+ } else {
+ return BigintOperations::NewFromDouble(result);
+ }
}
@@ -191,7 +204,7 @@ DEFINE_NATIVE_ENTRY(Double_toInt, 1) {
if (isinf(arg.value()) || isnan(arg.value())) {
const Array& args = Array::Handle(Array::New(1));
args.SetAt(0, String::Handle(String::New("Infinity or NaN toInt")));
- Exceptions::ThrowByType(Exceptions::kFormat, args);
+ Exceptions::ThrowByType(Exceptions::kUnsupported, args);
}
double result = trunc(arg.value());
if ((Smi::kMinValue <= result) && (result <= Smi::kMaxValue)) {
« no previous file with comments | « runtime/lib/byte_array.dart ('k') | runtime/lib/double.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698