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

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

Issue 1913663002: vm: Generate 'and' instruction for Smi values. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: xxx Created 4 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
« no previous file with comments | « runtime/lib/bigint.dart ('k') | runtime/lib/integers.dart » ('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/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // Overflow in shift, use Bigints 278 // Overflow in shift, use Bigints
279 return Integer::null(); 279 return Integer::null();
280 } 280 }
281 } else { 281 } else {
282 ASSERT(value.IsBigint()); 282 ASSERT(value.IsBigint());
283 } 283 }
284 return Integer::null(); 284 return Integer::null();
285 } 285 }
286 286
287 287
288 DEFINE_NATIVE_ENTRY(Smi_bitAndFromSmi, 2) {
289 const Smi& left = Smi::CheckedHandle(arguments->NativeArgAt(0));
290 GET_NON_NULL_NATIVE_ARGUMENT(Smi, right, arguments->NativeArgAt(1));
291 if (FLAG_trace_intrinsified_natives) {
292 OS::Print("Smi_bitAndFromSmi %s & %s\n",
293 left.ToCString(), right.ToCString());
294 }
295 const Smi& left_value = Smi::Cast(left);
296 const Smi& right_value = Smi::Cast(right);
297 return Smi::New(left_value.Value() & right_value.Value());
298 }
299
300
288 DEFINE_NATIVE_ENTRY(Smi_shrFromInt, 2) { 301 DEFINE_NATIVE_ENTRY(Smi_shrFromInt, 2) {
289 const Smi& amount = Smi::CheckedHandle(arguments->NativeArgAt(0)); 302 const Smi& amount = Smi::CheckedHandle(arguments->NativeArgAt(0));
290 GET_NON_NULL_NATIVE_ARGUMENT(Integer, value, arguments->NativeArgAt(1)); 303 GET_NON_NULL_NATIVE_ARGUMENT(Integer, value, arguments->NativeArgAt(1));
291 ASSERT(CheckInteger(amount)); 304 ASSERT(CheckInteger(amount));
292 ASSERT(CheckInteger(value)); 305 ASSERT(CheckInteger(value));
293 const Integer& result = Integer::Handle( 306 const Integer& result = Integer::Handle(
294 ShiftOperationHelper(Token::kSHR, value, amount)); 307 ShiftOperationHelper(Token::kSHR, value, amount));
295 // A null result indicates that a bigint operation is required. 308 // A null result indicates that a bigint operation is required.
296 return result.IsNull() ? result.raw() : result.AsValidInteger(); 309 return result.IsNull() ? result.raw() : result.AsValidInteger();
297 } 310 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 DEFINE_NATIVE_ENTRY(Bigint_allocate, 4) { 410 DEFINE_NATIVE_ENTRY(Bigint_allocate, 4) {
398 // First arg is null type arguments, since class Bigint is not parameterized. 411 // First arg is null type arguments, since class Bigint is not parameterized.
399 const Bool& neg = Bool::CheckedHandle(arguments->NativeArgAt(1)); 412 const Bool& neg = Bool::CheckedHandle(arguments->NativeArgAt(1));
400 const Smi& used = Smi::CheckedHandle(arguments->NativeArgAt(2)); 413 const Smi& used = Smi::CheckedHandle(arguments->NativeArgAt(2));
401 const TypedData& digits = TypedData::CheckedHandle(arguments->NativeArgAt(3)); 414 const TypedData& digits = TypedData::CheckedHandle(arguments->NativeArgAt(3));
402 ASSERT(!digits.IsNull()); 415 ASSERT(!digits.IsNull());
403 return Bigint::New(neg.value(), used.Value(), digits); 416 return Bigint::New(neg.value(), used.Value(), digits);
404 } 417 }
405 418
406 } // namespace dart 419 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/bigint.dart ('k') | runtime/lib/integers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698