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

Side by Side Diff: runtime/lib/double.cc

Issue 15743017: Adds a flag to the standalone vm to throw an exception on 53-bit integer overflow. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/exceptions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <math.h> 5 #include <math.h>
6 6
7 #include "vm/bootstrap_natives.h" 7 #include "vm/bootstrap_natives.h"
8 8
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_generator.h" // DartModulo. 10 #include "vm/code_generator.h" // DartModulo.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 static RawInteger* DoubleToInteger(double val, const char* error_msg) { 76 static RawInteger* DoubleToInteger(double val, const char* error_msg) {
77 if (isinf(val) || isnan(val)) { 77 if (isinf(val) || isnan(val)) {
78 const Array& args = Array::Handle(Array::New(1)); 78 const Array& args = Array::Handle(Array::New(1));
79 args.SetAt(0, String::Handle(String::New(error_msg))); 79 args.SetAt(0, String::Handle(String::New(error_msg)));
80 Exceptions::ThrowByType(Exceptions::kUnsupported, args); 80 Exceptions::ThrowByType(Exceptions::kUnsupported, args);
81 } 81 }
82 const Bigint& big = Bigint::Handle(BigintOperations::NewFromDouble(val)); 82 const Bigint& big = Bigint::Handle(BigintOperations::NewFromDouble(val));
83 return big.AsValidInteger(); 83 return big.AsValidInteger();
84 } 84 }
85 85
86
86 DEFINE_NATIVE_ENTRY(Double_trunc_div, 2) { 87 DEFINE_NATIVE_ENTRY(Double_trunc_div, 2) {
87 double left = Double::CheckedHandle(arguments->NativeArgAt(0)).value(); 88 double left = Double::CheckedHandle(arguments->NativeArgAt(0)).value();
88 GET_NON_NULL_NATIVE_ARGUMENT(Double, right_object, arguments->NativeArgAt(1)); 89 GET_NON_NULL_NATIVE_ARGUMENT(Double, right_object, arguments->NativeArgAt(1));
89 double right = right_object.value(); 90 double right = right_object.value();
90 if (FLAG_trace_intrinsified_natives) { 91 if (FLAG_trace_intrinsified_natives) {
91 OS::Print("Double_trunc_div %f ~/ %f\n", left, right); 92 OS::Print("Double_trunc_div %f ~/ %f\n", left, right);
92 } 93 }
93 return DoubleToInteger(trunc(left / right), 94 return DoubleToInteger(trunc(left / right),
94 "Result of truncating division is Infinity or NaN"); 95 "Result of truncating division is Infinity or NaN");
95 } 96 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 287
287 DEFINE_NATIVE_ENTRY(Double_getIsNegative, 1) { 288 DEFINE_NATIVE_ENTRY(Double_getIsNegative, 1) {
288 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0)); 289 const Double& arg = Double::CheckedHandle(arguments->NativeArgAt(0));
289 // Include negative zero, infinity. 290 // Include negative zero, infinity.
290 return Bool::Get(signbit(arg.value()) && !isnan(arg.value())); 291 return Bool::Get(signbit(arg.value()) && !isnan(arg.value()));
291 } 292 }
292 293
293 // Add here only functions using/referring to old-style casts. 294 // Add here only functions using/referring to old-style casts.
294 295
295 } // namespace dart 296 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/exceptions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698