OLD | NEW |
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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // Passing true for 'silent' prevents throwing JavascriptIntegerOverflow. | 254 // Passing true for 'silent' prevents throwing JavascriptIntegerOverflow. |
255 static RawInteger* ShiftOperationHelper(Token::Kind kind, | 255 static RawInteger* ShiftOperationHelper(Token::Kind kind, |
256 const Integer& value, | 256 const Integer& value, |
257 const Smi& amount, | 257 const Smi& amount, |
258 const bool silent = false) { | 258 const bool silent = false) { |
259 if (amount.Value() < 0) { | 259 if (amount.Value() < 0) { |
260 Exceptions::ThrowArgumentError(amount); | 260 Exceptions::ThrowArgumentError(amount); |
261 } | 261 } |
262 if (value.IsSmi()) { | 262 if (value.IsSmi()) { |
263 const Smi& smi_value = Smi::Cast(value); | 263 const Smi& smi_value = Smi::Cast(value); |
264 return smi_value.ShiftOp(kind, amount, silent); | 264 return smi_value.ShiftOp(kind, amount, Heap::kNew, silent); |
265 } | 265 } |
266 if (value.IsMint()) { | 266 if (value.IsMint()) { |
267 const int64_t mint_value = value.AsInt64Value(); | 267 const int64_t mint_value = value.AsInt64Value(); |
268 const int count = Utils::HighestBit(mint_value); | 268 const int count = Utils::HighestBit(mint_value); |
269 intptr_t shift_count = amount.Value(); | 269 intptr_t shift_count = amount.Value(); |
270 if (kind == Token::kSHR) { | 270 if (kind == Token::kSHR) { |
271 shift_count = -shift_count; | 271 shift_count = -shift_count; |
272 } | 272 } |
273 if ((count + shift_count) < Mint::kBits) { | 273 if ((count + shift_count) < Mint::kBits) { |
274 switch (kind) { | 274 switch (kind) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 DEFINE_NATIVE_ENTRY(Bigint_allocate, 4) { | 424 DEFINE_NATIVE_ENTRY(Bigint_allocate, 4) { |
425 // First arg is null type arguments, since class Bigint is not parameterized. | 425 // First arg is null type arguments, since class Bigint is not parameterized. |
426 const Bool& neg = Bool::CheckedHandle(arguments->NativeArgAt(1)); | 426 const Bool& neg = Bool::CheckedHandle(arguments->NativeArgAt(1)); |
427 const Smi& used = Smi::CheckedHandle(arguments->NativeArgAt(2)); | 427 const Smi& used = Smi::CheckedHandle(arguments->NativeArgAt(2)); |
428 const TypedData& digits = TypedData::CheckedHandle(arguments->NativeArgAt(3)); | 428 const TypedData& digits = TypedData::CheckedHandle(arguments->NativeArgAt(3)); |
429 ASSERT(!digits.IsNull()); | 429 ASSERT(!digits.IsNull()); |
430 return Bigint::New(neg.value(), used.Value(), digits); | 430 return Bigint::New(neg.value(), used.Value(), digits); |
431 } | 431 } |
432 | 432 |
433 } // namespace dart | 433 } // namespace dart |
OLD | NEW |