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

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

Issue 2982823002: Option to truncate integers to 64 bits, part 2 (Closed)
Patch Set: Fixes for review comments Created 3 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
« no previous file with comments | « no previous file | runtime/lib/isolate.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/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
11 #include "vm/isolate.h" 11 #include "vm/isolate.h"
12 #include "vm/native_entry.h" 12 #include "vm/native_entry.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/symbols.h" 15 #include "vm/symbols.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 DEFINE_FLAG(bool, 19 DEFINE_FLAG(bool,
20 trace_intrinsified_natives, 20 trace_intrinsified_natives,
21 false, 21 false,
22 "Report if any of the intrinsified natives are called"); 22 "Report if any of the intrinsified natives are called");
23 23
24 // Smi natives. 24 // Smi natives.
25 25
26 // Returns false if integer is in wrong representation, e.g., as is a Bigint 26 // Returns false if integer is in wrong representation, e.g., as is a Bigint
27 // when it could have been a Smi. 27 // when it could have been a Smi.
28 static bool CheckInteger(const Integer& i) { 28 static bool CheckInteger(const Integer& i) {
29 if (i.IsBigint()) { 29 if (i.IsBigint()) {
30 ASSERT(!FLAG_limit_ints_to_64_bits); 30 ASSERT(!Bigint::IsDisabled());
31 const Bigint& bigint = Bigint::Cast(i); 31 const Bigint& bigint = Bigint::Cast(i);
32 return !bigint.FitsIntoSmi() && !bigint.FitsIntoInt64(); 32 return !bigint.FitsIntoSmi() && !bigint.FitsIntoInt64();
33 } 33 }
siva 2017/07/14 20:53:29 When --limit-ints-to-64-bits mode is specified i.I
34 if (i.IsMint()) { 34 if (i.IsMint()) {
35 const Mint& mint = Mint::Cast(i); 35 const Mint& mint = Mint::Cast(i);
36 return !Smi::IsValid(mint.value()); 36 return !Smi::IsValid(mint.value());
37 } 37 }
38 return true; 38 return true;
39 } 39 }
40 40
41 DEFINE_NATIVE_ENTRY(Integer_bitAndFromInteger, 2) { 41 DEFINE_NATIVE_ENTRY(Integer_bitAndFromInteger, 2) {
42 const Integer& right = Integer::CheckedHandle(arguments->NativeArgAt(0)); 42 const Integer& right = Integer::CheckedHandle(arguments->NativeArgAt(0));
43 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); 43 GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1));
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 265 }
266 case Token::kSHR: 266 case Token::kSHR:
267 shift_count = Utils::Minimum(shift_count, Mint::kBits); 267 shift_count = Utils::Minimum(shift_count, Mint::kBits);
268 return Integer::New(mint_value >> shift_count, Heap::kNew); 268 return Integer::New(mint_value >> shift_count, Heap::kNew);
269 default: 269 default:
270 UNIMPLEMENTED(); 270 UNIMPLEMENTED();
271 } 271 }
272 } else { 272 } else {
273 ASSERT(value.IsBigint()); 273 ASSERT(value.IsBigint());
274 } 274 }
275 ASSERT(!FLAG_limit_ints_to_64_bits); 275 ASSERT(!Bigint::IsDisabled());
276 return Integer::null(); 276 return Integer::null();
277 } 277 }
278 278
279 DEFINE_NATIVE_ENTRY(Smi_bitAndFromSmi, 2) { 279 DEFINE_NATIVE_ENTRY(Smi_bitAndFromSmi, 2) {
280 const Smi& left = Smi::CheckedHandle(arguments->NativeArgAt(0)); 280 const Smi& left = Smi::CheckedHandle(arguments->NativeArgAt(0));
281 GET_NON_NULL_NATIVE_ARGUMENT(Smi, right, arguments->NativeArgAt(1)); 281 GET_NON_NULL_NATIVE_ARGUMENT(Smi, right, arguments->NativeArgAt(1));
282 if (FLAG_trace_intrinsified_natives) { 282 if (FLAG_trace_intrinsified_natives) {
283 OS::Print("Smi_bitAndFromSmi %s & %s\n", left.ToCString(), 283 OS::Print("Smi_bitAndFromSmi %s & %s\n", left.ToCString(),
284 right.ToCString()); 284 right.ToCString());
285 } 285 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 const Bigint& bigint = Bigint::CheckedHandle(arguments->NativeArgAt(0)); 380 const Bigint& bigint = Bigint::CheckedHandle(arguments->NativeArgAt(0));
381 return bigint.used(); 381 return bigint.used();
382 } 382 }
383 383
384 DEFINE_NATIVE_ENTRY(Bigint_getDigits, 1) { 384 DEFINE_NATIVE_ENTRY(Bigint_getDigits, 1) {
385 const Bigint& bigint = Bigint::CheckedHandle(arguments->NativeArgAt(0)); 385 const Bigint& bigint = Bigint::CheckedHandle(arguments->NativeArgAt(0));
386 return bigint.digits(); 386 return bigint.digits();
387 } 387 }
388 388
389 DEFINE_NATIVE_ENTRY(Bigint_allocate, 4) { 389 DEFINE_NATIVE_ENTRY(Bigint_allocate, 4) {
390 // TODO(alexmarkov): Revise this assertion if this native method can be used 390 ASSERT(!Bigint::IsDisabled());
391 // to explicitly allocate Bigint objects in --limit-ints-to-64-bits mode.
392 ASSERT(!FLAG_limit_ints_to_64_bits);
393 // First arg is null type arguments, since class Bigint is not parameterized. 391 // First arg is null type arguments, since class Bigint is not parameterized.
394 const Bool& neg = Bool::CheckedHandle(arguments->NativeArgAt(1)); 392 const Bool& neg = Bool::CheckedHandle(arguments->NativeArgAt(1));
395 const Smi& used = Smi::CheckedHandle(arguments->NativeArgAt(2)); 393 const Smi& used = Smi::CheckedHandle(arguments->NativeArgAt(2));
396 const TypedData& digits = TypedData::CheckedHandle(arguments->NativeArgAt(3)); 394 const TypedData& digits = TypedData::CheckedHandle(arguments->NativeArgAt(3));
397 ASSERT(!digits.IsNull()); 395 ASSERT(!digits.IsNull());
398 return Bigint::New(neg.value(), used.Value(), digits); 396 return Bigint::New(neg.value(), used.Value(), digits);
399 } 397 }
400 398
401 } // namespace dart 399 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698