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

Side by Side Diff: vm/bigint_operations.cc

Issue 11639007: Cleanup the exceptions create code to use Arrays instead GrowableArrays so (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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 | « lib/string.cc ('k') | vm/dart_entry.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 2012 Google Inc. All Rights Reserved. 1 // Copyright 2012 Google Inc. All Rights Reserved.
2 2
3 #include "vm/bigint_operations.h" 3 #include "vm/bigint_operations.h"
4 4
5 #include "platform/utils.h" 5 #include "platform/utils.h"
6 6
7 #include "vm/double_internals.h" 7 #include "vm/double_internals.h"
8 #include "vm/exceptions.h" 8 #include "vm/exceptions.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/zone.h" 10 #include "vm/zone.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 RawBigint* BigintOperations::NewFromDouble(double d, Heap::Space space) { 201 RawBigint* BigintOperations::NewFromDouble(double d, Heap::Space space) {
202 if ((-1.0 < d) && (d < 1.0)) { 202 if ((-1.0 < d) && (d < 1.0)) {
203 // Shortcut for small numbers. Also makes the right-shift below 203 // Shortcut for small numbers. Also makes the right-shift below
204 // well specified. 204 // well specified.
205 Smi& zero = Smi::Handle(Smi::New(0)); 205 Smi& zero = Smi::Handle(Smi::New(0));
206 return NewFromSmi(zero, space); 206 return NewFromSmi(zero, space);
207 } 207 }
208 DoubleInternals internals = DoubleInternals(d); 208 DoubleInternals internals = DoubleInternals(d);
209 if (internals.IsSpecial()) { 209 if (internals.IsSpecial()) {
210 GrowableArray<const Object*> exception_arguments; 210 const Array& exception_arguments = Array::Handle(Array::New(1));
211 exception_arguments.Add( 211 exception_arguments.SetAt(
212 &Object::ZoneHandle(String::New("BigintOperations::NewFromDouble"))); 212 0, Object::Handle(String::New("BigintOperations::NewFromDouble")));
213 Exceptions::ThrowByType(Exceptions::kInternalError, exception_arguments); 213 Exceptions::ThrowByType(Exceptions::kInternalError, exception_arguments);
214 } 214 }
215 uint64_t significand = internals.Significand(); 215 uint64_t significand = internals.Significand();
216 int exponent = internals.Exponent(); 216 int exponent = internals.Exponent();
217 int sign = internals.Sign(); 217 int sign = internals.Sign();
218 if (exponent <= 0) { 218 if (exponent <= 0) {
219 significand >>= -exponent; 219 significand >>= -exponent;
220 exponent = 0; 220 exponent = 0;
221 } else if (exponent <= 10) { 221 } else if (exponent <= 10) {
222 // A double significand has at most 53 bits. The following shift will 222 // A double significand has at most 53 bits. The following shift will
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 int BigintOperations::CountBits(Chunk digit) { 1662 int BigintOperations::CountBits(Chunk digit) {
1663 int result = 0; 1663 int result = 0;
1664 while (digit != 0) { 1664 while (digit != 0) {
1665 digit >>= 1; 1665 digit >>= 1;
1666 result++; 1666 result++;
1667 } 1667 }
1668 return result; 1668 return result;
1669 } 1669 }
1670 1670
1671 } // namespace dart 1671 } // namespace dart
OLDNEW
« no previous file with comments | « lib/string.cc ('k') | vm/dart_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698