| 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 21 matching lines...) Expand all Loading... |
| 32 // and the newly allocated object is returned in RAX. | 32 // and the newly allocated object is returned in RAX. |
| 33 const intptr_t kTypeArgumentsOffset = 2 * kWordSize; | 33 const intptr_t kTypeArgumentsOffset = 2 * kWordSize; |
| 34 const intptr_t kArrayLengthOffset = 1 * kWordSize; | 34 const intptr_t kArrayLengthOffset = 1 * kWordSize; |
| 35 Label fall_through; | 35 Label fall_through; |
| 36 | 36 |
| 37 // Compute the size to be allocated, it is based on the array length | 37 // Compute the size to be allocated, it is based on the array length |
| 38 // and is computed as: | 38 // and is computed as: |
| 39 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). | 39 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). |
| 40 __ movq(RDI, Address(RSP, kArrayLengthOffset)); // Array Length. | 40 __ movq(RDI, Address(RSP, kArrayLengthOffset)); // Array Length. |
| 41 // Check that length is a positive Smi. | 41 // Check that length is a positive Smi. |
| 42 __ testq(RDI, Immediate(kSmiTagSize)); | 42 __ testq(RDI, Immediate(kSmiTagMask)); |
| 43 __ j(NOT_ZERO, &fall_through); | 43 __ j(NOT_ZERO, &fall_through); |
| 44 __ cmpq(RDI, Immediate(0)); | 44 __ cmpq(RDI, Immediate(0)); |
| 45 __ j(LESS, &fall_through); | 45 __ j(LESS, &fall_through); |
| 46 // Check for maximum allowed length. | 46 // Check for maximum allowed length. |
| 47 const Immediate& max_len = | 47 const Immediate& max_len = |
| 48 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements))); | 48 Immediate(reinterpret_cast<int64_t>(Smi::New(Array::kMaxElements))); |
| 49 __ cmpq(RDI, max_len); | 49 __ cmpq(RDI, max_len); |
| 50 __ j(GREATER, &fall_through); | 50 __ j(GREATER, &fall_through); |
| 51 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; | 51 const intptr_t fixed_size = sizeof(RawArray) + kObjectAlignment - 1; |
| 52 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi. | 52 __ leaq(RDI, Address(RDI, TIMES_4, fixed_size)); // RDI is a Smi. |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 return false; | 410 return false; |
| 411 } | 411 } |
| 412 | 412 |
| 413 | 413 |
| 414 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_factor) \ | 414 #define TYPED_ARRAY_ALLOCATION(type_name, cid, max_len, scale_factor) \ |
| 415 Label fall_through; \ | 415 Label fall_through; \ |
| 416 const intptr_t kArrayLengthStackOffset = 1 * kWordSize; \ | 416 const intptr_t kArrayLengthStackOffset = 1 * kWordSize; \ |
| 417 __ movq(RDI, Address(RSP, kArrayLengthStackOffset)); /* Array length. */ \ | 417 __ movq(RDI, Address(RSP, kArrayLengthStackOffset)); /* Array length. */ \ |
| 418 /* Check that length is a positive Smi. */ \ | 418 /* Check that length is a positive Smi. */ \ |
| 419 /* RDI: requested array length argument. */ \ | 419 /* RDI: requested array length argument. */ \ |
| 420 __ testq(RDI, Immediate(kSmiTagSize)); \ | 420 __ testq(RDI, Immediate(kSmiTagMask)); \ |
| 421 __ j(NOT_ZERO, &fall_through); \ | 421 __ j(NOT_ZERO, &fall_through); \ |
| 422 __ cmpq(RDI, Immediate(0)); \ | 422 __ cmpq(RDI, Immediate(0)); \ |
| 423 __ j(LESS, &fall_through); \ | 423 __ j(LESS, &fall_through); \ |
| 424 __ SmiUntag(RDI); \ | 424 __ SmiUntag(RDI); \ |
| 425 /* Check for maximum allowed length. */ \ | 425 /* Check for maximum allowed length. */ \ |
| 426 /* RDI: untagged array length. */ \ | 426 /* RDI: untagged array length. */ \ |
| 427 __ cmpq(RDI, Immediate(max_len)); \ | 427 __ cmpq(RDI, Immediate(max_len)); \ |
| 428 __ j(GREATER, &fall_through); \ | 428 __ j(GREATER, &fall_through); \ |
| 429 /* Special case for scaling by 16. */ \ | 429 /* Special case for scaling by 16. */ \ |
| 430 if (scale_factor == TIMES_16) { \ | 430 if (scale_factor == TIMES_16) { \ |
| (...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 __ Bind(&fall_through); | 1531 __ Bind(&fall_through); |
| 1532 return false; | 1532 return false; |
| 1533 } | 1533 } |
| 1534 | 1534 |
| 1535 | 1535 |
| 1536 #undef __ | 1536 #undef __ |
| 1537 | 1537 |
| 1538 } // namespace dart | 1538 } // namespace dart |
| 1539 | 1539 |
| 1540 #endif // defined TARGET_ARCH_X64 | 1540 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |