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

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

Issue 381543002: Tweaks for speed in integer arithmetic runtime. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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/platform/utils.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 Exceptions::ThrowArgumentError(amount); 275 Exceptions::ThrowArgumentError(amount);
276 } 276 }
277 if (value.IsSmi()) { 277 if (value.IsSmi()) {
278 const Smi& smi_value = Smi::Cast(value); 278 const Smi& smi_value = Smi::Cast(value);
279 return smi_value.ShiftOp(kind, amount, silent); 279 return smi_value.ShiftOp(kind, amount, silent);
280 } 280 }
281 Bigint& big_value = Bigint::Handle(); 281 Bigint& big_value = Bigint::Handle();
282 if (value.IsMint()) { 282 if (value.IsMint()) {
283 const int64_t mint_value = value.AsInt64Value(); 283 const int64_t mint_value = value.AsInt64Value();
284 const int count = Utils::HighestBit(mint_value); 284 const int count = Utils::HighestBit(mint_value);
285 if ((count + amount.Value()) < Mint::kBits) { 285 int shift_count = amount.Value();
286 if (kind == Token::kSHR) {
287 shift_count = -shift_count;
288 }
srdjan 2014/07/09 17:05:16 s/int/intptr_t/
regis 2014/07/09 17:15:51 Done.
289 if ((count + shift_count) < Mint::kBits) {
286 switch (kind) { 290 switch (kind) {
287 case Token::kSHL: 291 case Token::kSHL:
288 return Integer::New(mint_value << amount.Value(), Heap::kNew, silent); 292 return Integer::New(mint_value << shift_count, Heap::kNew, silent);
289 case Token::kSHR: 293 case Token::kSHR:
290 return Integer::New(mint_value >> amount.Value(), Heap::kNew, silent); 294 return Integer::New(mint_value >> -shift_count, Heap::kNew, silent);
291 default: 295 default:
292 UNIMPLEMENTED(); 296 UNIMPLEMENTED();
293 } 297 }
294 } else { 298 } else {
295 // Overflow in shift, use Bigints 299 // Overflow in shift, use Bigints
296 big_value = BigintOperations::NewFromInt64(mint_value); 300 big_value = BigintOperations::NewFromInt64(mint_value);
297 } 301 }
298 } else { 302 } else {
299 ASSERT(value.IsBigint()); 303 ASSERT(value.IsBigint());
300 big_value = Bigint::Cast(value).raw(); 304 big_value = Bigint::Cast(value).raw();
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // Use the preallocated out of memory exception to avoid calling 445 // Use the preallocated out of memory exception to avoid calling
442 // into dart code or allocating any code. 446 // into dart code or allocating any code.
443 const Instance& exception = 447 const Instance& exception =
444 Instance::Handle(isolate->object_store()->out_of_memory()); 448 Instance::Handle(isolate->object_store()->out_of_memory());
445 Exceptions::Throw(isolate, exception); 449 Exceptions::Throw(isolate, exception);
446 UNREACHABLE(); 450 UNREACHABLE();
447 return 0; 451 return 0;
448 } 452 }
449 453
450 } // namespace dart 454 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/platform/utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698