Chromium Code Reviews| 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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/exceptions.h" | 9 #include "vm/exceptions.h" |
| 10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 } | 249 } |
| 250 } else { | 250 } else { |
| 251 // Overflow in shift, use Bigints | 251 // Overflow in shift, use Bigints |
| 252 big_value = BigintOperations::NewFromInt64(mint_value); | 252 big_value = BigintOperations::NewFromInt64(mint_value); |
| 253 } | 253 } |
| 254 } else { | 254 } else { |
| 255 ASSERT(value.IsBigint()); | 255 ASSERT(value.IsBigint()); |
| 256 big_value = Bigint::Cast(value).raw(); | 256 big_value = Bigint::Cast(value).raw(); |
| 257 } | 257 } |
| 258 switch (kind) { | 258 switch (kind) { |
| 259 case Token::kSHL: | 259 case Token::kSHL: { |
| 260 return BigintOperations::ShiftLeft(big_value, amount.Value()); | 260 const Bigint& big = Bigint::Handle( |
| 261 case Token::kSHR: | 261 BigintOperations::ShiftLeft(big_value, amount.Value())); |
| 262 return BigintOperations::ShiftRight(big_value, amount.Value()); | 262 return big.AsValidInteger(); |
|
Ivan Posva
2013/05/23 21:37:54
Aren't these here redundant as the result will be
zra
2013/05/23 22:14:38
You're right. I've removed the changes here.
| |
| 263 } | |
| 264 case Token::kSHR: { | |
| 265 const Bigint& big = Bigint::Handle( | |
| 266 BigintOperations::ShiftRight(big_value, amount.Value())); | |
| 267 return big.AsValidInteger(); | |
| 268 } | |
| 263 default: | 269 default: |
| 264 UNIMPLEMENTED(); | 270 UNIMPLEMENTED(); |
| 265 } | 271 } |
| 266 return Integer::null(); | 272 return Integer::null(); |
| 267 } | 273 } |
| 268 | 274 |
| 269 | 275 |
| 270 DEFINE_NATIVE_ENTRY(Smi_shrFromInt, 2) { | 276 DEFINE_NATIVE_ENTRY(Smi_shrFromInt, 2) { |
| 271 const Smi& amount = Smi::CheckedHandle(arguments->NativeArgAt(0)); | 277 const Smi& amount = Smi::CheckedHandle(arguments->NativeArgAt(0)); |
| 272 GET_NON_NULL_NATIVE_ARGUMENT(Integer, value, arguments->NativeArgAt(1)); | 278 GET_NON_NULL_NATIVE_ARGUMENT(Integer, value, arguments->NativeArgAt(1)); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 297 DEFINE_NATIVE_ENTRY(Smi_bitNegate, 1) { | 303 DEFINE_NATIVE_ENTRY(Smi_bitNegate, 1) { |
| 298 const Smi& operand = Smi::CheckedHandle(arguments->NativeArgAt(0)); | 304 const Smi& operand = Smi::CheckedHandle(arguments->NativeArgAt(0)); |
| 299 if (FLAG_trace_intrinsified_natives) { | 305 if (FLAG_trace_intrinsified_natives) { |
| 300 OS::Print("Smi_bitNegate: %s\n", operand.ToCString()); | 306 OS::Print("Smi_bitNegate: %s\n", operand.ToCString()); |
| 301 } | 307 } |
| 302 intptr_t result = ~operand.Value(); | 308 intptr_t result = ~operand.Value(); |
| 303 ASSERT(Smi::IsValid(result)); | 309 ASSERT(Smi::IsValid(result)); |
| 304 return Smi::New(result); | 310 return Smi::New(result); |
| 305 } | 311 } |
| 306 | 312 |
| 313 | |
|
Ivan Posva
2013/05/23 21:37:54
Two lines!
zra
2013/05/23 22:14:38
There are two lines between the bottom of the func
| |
| 307 // Mint natives. | 314 // Mint natives. |
| 308 | 315 |
| 309 DEFINE_NATIVE_ENTRY(Mint_bitNegate, 1) { | 316 DEFINE_NATIVE_ENTRY(Mint_bitNegate, 1) { |
| 310 const Mint& operand = Mint::CheckedHandle(arguments->NativeArgAt(0)); | 317 const Mint& operand = Mint::CheckedHandle(arguments->NativeArgAt(0)); |
| 311 ASSERT(CheckInteger(operand)); | 318 ASSERT(CheckInteger(operand)); |
| 312 if (FLAG_trace_intrinsified_natives) { | 319 if (FLAG_trace_intrinsified_natives) { |
| 313 OS::Print("Mint_bitNegate: %s\n", operand.ToCString()); | 320 OS::Print("Mint_bitNegate: %s\n", operand.ToCString()); |
| 314 } | 321 } |
| 315 int64_t result = ~operand.value(); | 322 int64_t result = ~operand.value(); |
| 316 return Integer::New(result); | 323 return Integer::New(result); |
| 317 } | 324 } |
| 318 | 325 |
| 326 | |
| 319 // Bigint natives. | 327 // Bigint natives. |
| 320 | 328 |
| 321 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { | 329 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { |
| 322 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); | 330 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); |
| 323 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); | 331 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); |
| 324 ASSERT(CheckInteger(value)); | 332 ASSERT(CheckInteger(value)); |
| 325 ASSERT(CheckInteger(result)); | 333 ASSERT(CheckInteger(result)); |
| 326 return result.AsValidInteger(); | 334 return result.AsValidInteger(); |
| 327 } | 335 } |
| 328 | 336 |
| 329 } // namespace dart | 337 } // namespace dart |
| OLD | NEW |