| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
| 9 | 9 |
| 10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 RAX); | 404 RAX); |
| 405 const Immediate& raw_null = | 405 const Immediate& raw_null = |
| 406 Immediate(reinterpret_cast<int64_t>(Object::null())); | 406 Immediate(reinterpret_cast<int64_t>(Object::null())); |
| 407 __ movq(RAX, raw_null); | 407 __ movq(RAX, raw_null); |
| 408 __ ret(); | 408 __ ret(); |
| 409 __ Bind(&fall_through); | 409 __ Bind(&fall_through); |
| 410 return false; | 410 return false; |
| 411 } | 411 } |
| 412 | 412 |
| 413 | 413 |
| 414 | |
| 415 // Tests if index is a valid length (Smi and within valid index range), | |
| 416 // jumps to fall_through if it is not. | |
| 417 // Returns index in R12, array in RAX. | |
| 418 // This should be used only on getIndexed intrinsics. | |
| 419 void TestByteArrayGetIndex(Assembler* assembler, Label* fall_through) { | |
| 420 __ movq(RAX, Address(RSP, + 2 * kWordSize)); // Array. | |
| 421 __ movq(R12, Address(RSP, + 1 * kWordSize)); // Index. | |
| 422 __ testq(R12, Immediate(kSmiTagMask)); | |
| 423 __ j(NOT_ZERO, fall_through, Assembler::kNearJump); // Non-smi index. | |
| 424 // Range check. | |
| 425 __ cmpq(R12, FieldAddress(RAX, ByteArray::length_offset())); | |
| 426 // Runtime throws exception. | |
| 427 __ j(ABOVE_EQUAL, fall_through, Assembler::kNearJump); | |
| 428 } | |
| 429 | |
| 430 | |
| 431 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_factor) \ | 414 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_factor) \ |
| 432 Label fall_through; \ | 415 Label fall_through; \ |
| 433 const intptr_t kArrayLengthStackOffset = 1 * kWordSize; \ | 416 const intptr_t kArrayLengthStackOffset = 1 * kWordSize; \ |
| 434 __ movq(RDI, Address(RSP, kArrayLengthStackOffset)); /* Array length. */ \ | 417 __ movq(RDI, Address(RSP, kArrayLengthStackOffset)); /* Array length. */ \ |
| 435 /* Check that length is a positive Smi. */ \ | 418 /* Check that length is a positive Smi. */ \ |
| 436 /* RDI: requested array length argument. */ \ | 419 /* RDI: requested array length argument. */ \ |
| 437 __ testq(RDI, Immediate(kSmiTagSize)); \ | 420 __ testq(RDI, Immediate(kSmiTagSize)); \ |
| 438 __ j(NOT_ZERO, &fall_through); \ | 421 __ j(NOT_ZERO, &fall_through); \ |
| 439 __ cmpq(RDI, Immediate(0)); \ | 422 __ cmpq(RDI, Immediate(0)); \ |
| 440 __ j(LESS, &fall_through); \ | 423 __ j(LESS, &fall_through); \ |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 __ ret(); | 1418 __ ret(); |
| 1436 return true; | 1419 return true; |
| 1437 } | 1420 } |
| 1438 | 1421 |
| 1439 | 1422 |
| 1440 #undef __ | 1423 #undef __ |
| 1441 | 1424 |
| 1442 } // namespace dart | 1425 } // namespace dart |
| 1443 | 1426 |
| 1444 #endif // defined TARGET_ARCH_X64 | 1427 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |