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

Side by Side Diff: runtime/vm/bigint_operations.cc

Issue 326183002: Pass around the current isolate in exception handling code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | « runtime/lib/integers.cc ('k') | runtime/vm/code_generator.cc » ('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/assert.h" 5 #include "platform/assert.h"
6 #include "platform/utils.h" 6 #include "platform/utils.h"
7 7
8 #include "vm/double_internals.h" 8 #include "vm/double_internals.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 const intptr_t kMaxAllowedDigitLength = 351 const intptr_t kMaxAllowedDigitLength =
352 (kIntptrMax - 10) / kLog2Dividend / kDigitBitSize * kLog2Divisor; 352 (kIntptrMax - 10) / kLog2Dividend / kDigitBitSize * kLog2Divisor;
353 353
354 const intptr_t length = bigint.Length(); 354 const intptr_t length = bigint.Length();
355 Isolate* isolate = Isolate::Current(); 355 Isolate* isolate = Isolate::Current();
356 if (length >= kMaxAllowedDigitLength) { 356 if (length >= kMaxAllowedDigitLength) {
357 // Use the preallocated out of memory exception to avoid calling 357 // Use the preallocated out of memory exception to avoid calling
358 // into dart code or allocating any code. 358 // into dart code or allocating any code.
359 const Instance& exception = 359 const Instance& exception =
360 Instance::Handle(isolate->object_store()->out_of_memory()); 360 Instance::Handle(isolate->object_store()->out_of_memory());
361 Exceptions::Throw(exception); 361 Exceptions::Throw(isolate, exception);
362 UNREACHABLE(); 362 UNREACHABLE();
363 } 363 }
364 364
365 // Approximate the size of the resulting string. We prefer overestimating 365 // Approximate the size of the resulting string. We prefer overestimating
366 // to not allocating enough. 366 // to not allocating enough.
367 int64_t bit_length = length * kDigitBitSize; 367 int64_t bit_length = length * kDigitBitSize;
368 ASSERT(bit_length > length || length == 0); 368 ASSERT(bit_length > length || length == 0);
369 int64_t decimal_length = (bit_length * kLog2Dividend / kLog2Divisor) + 1; 369 int64_t decimal_length = (bit_length * kLog2Dividend / kLog2Divisor) + 1;
370 // Add one byte for the trailing \0 character. 370 // Add one byte for the trailing \0 character.
371 int64_t required_size = decimal_length + 1; 371 int64_t required_size = decimal_length + 1;
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 intptr_t BigintOperations::CountBits(Chunk digit) { 1858 intptr_t BigintOperations::CountBits(Chunk digit) {
1859 intptr_t result = 0; 1859 intptr_t result = 0;
1860 while (digit != 0) { 1860 while (digit != 0) {
1861 digit >>= 1; 1861 digit >>= 1;
1862 result++; 1862 result++;
1863 } 1863 }
1864 return result; 1864 return result;
1865 } 1865 }
1866 1866
1867 } // namespace dart 1867 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/code_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698