| 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/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" |
| 11 #include "vm/instructions.h" | 11 #include "vm/instructions.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 DECLARE_FLAG(bool, enable_type_checks); | 15 DECLARE_FLAG(bool, enable_type_checks); |
| 16 | 16 |
| 17 // When entering intrinsics code: | 17 // When entering intrinsics code: |
| 18 // RBX: IC Data | 18 // RBX: IC Data |
| 19 // R10: Arguments descriptor | 19 // R10: Arguments descriptor |
| 20 // TOS: Return address | 20 // TOS: Return address |
| 21 // The RBX, R10 registers can be destroyed only if there is no slow-path (i.e., |
| 22 // the methods returns true). |
| 21 | 23 |
| 22 #define __ assembler-> | 24 #define __ assembler-> |
| 23 | 25 |
| 24 bool Intrinsifier::ObjectArray_Allocate(Assembler* assembler) { | 26 bool Intrinsifier::ObjectArray_Allocate(Assembler* assembler) { |
| 25 return false; | 27 return false; |
| 26 } | 28 } |
| 27 | 29 |
| 28 | 30 |
| 29 bool Intrinsifier::Array_getLength(Assembler* assembler) { | 31 bool Intrinsifier::Array_getLength(Assembler* assembler) { |
| 30 __ movq(RAX, Address(RSP, + 1 * kWordSize)); | 32 __ movq(RAX, Address(RSP, + 1 * kWordSize)); |
| 31 __ movq(RAX, FieldAddress(RAX, Array::length_offset())); | 33 __ movq(RAX, FieldAddress(RAX, Array::length_offset())); |
| 32 __ ret(); | 34 __ ret(); |
| 33 return true; | 35 return true; |
| 34 } | 36 } |
| 35 | 37 |
| 36 | 38 |
| 37 bool Intrinsifier::ImmutableArray_getLength(Assembler* assembler) { | 39 bool Intrinsifier::ImmutableArray_getLength(Assembler* assembler) { |
| 38 return Array_getLength(assembler); | 40 return Array_getLength(assembler); |
| 39 } | 41 } |
| 40 | 42 |
| 41 | 43 |
| 42 bool Intrinsifier::Array_getIndexed(Assembler* assembler) { | 44 bool Intrinsifier::Array_getIndexed(Assembler* assembler) { |
| 45 Label fall_through; |
| 46 __ movq(RCX, Address(RSP, + 1 * kWordSize)); // Index. |
| 47 __ movq(RAX, Address(RSP, + 2 * kWordSize)); // Array. |
| 48 __ testq(RCX, Immediate(kSmiTagMask)); |
| 49 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. |
| 50 // Range check. |
| 51 __ cmpq(RCX, FieldAddress(RAX, Array::length_offset())); |
| 52 // Runtime throws exception. |
| 53 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); |
| 54 // Note that RBX is Smi, i.e, times 2. |
| 55 ASSERT(kSmiTagShift == 1); |
| 56 __ movq(RAX, FieldAddress(RAX, RCX, TIMES_4, sizeof(RawArray))); |
| 57 __ ret(); |
| 58 __ Bind(&fall_through); |
| 43 return false; | 59 return false; |
| 44 } | 60 } |
| 45 | 61 |
| 46 | 62 |
| 47 bool Intrinsifier::ImmutableArray_getIndexed(Assembler* assembler) { | 63 bool Intrinsifier::ImmutableArray_getIndexed(Assembler* assembler) { |
| 48 return Array_getIndexed(assembler); | 64 return Array_getIndexed(assembler); |
| 49 } | 65 } |
| 50 | 66 |
| 51 | 67 |
| 52 bool Intrinsifier::Array_setIndexed(Assembler* assembler) { | 68 bool Intrinsifier::Array_setIndexed(Assembler* assembler) { |
| 69 if (FLAG_enable_type_checks) { |
| 70 return false; |
| 71 } |
| 72 __ movq(RDX, Address(RSP, + 1 * kWordSize)); // Value. |
| 73 __ movq(RCX, Address(RSP, + 2 * kWordSize)); // Index. |
| 74 __ movq(RAX, Address(RSP, + 3 * kWordSize)); // Array. |
| 75 Label fall_through; |
| 76 __ testq(RCX, Immediate(kSmiTagMask)); |
| 77 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); |
| 78 // Range check. |
| 79 __ cmpq(RCX, FieldAddress(RAX, Array::length_offset())); |
| 80 // Runtime throws exception. |
| 81 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); |
| 82 // Note that RBX is Smi, i.e, times 2. |
| 83 ASSERT(kSmiTagShift == 1); |
| 84 // Destroy RCX as we will not continue in the function. |
| 85 __ StoreIntoObject(RAX, |
| 86 FieldAddress(RAX, RCX, TIMES_4, sizeof(RawArray)), |
| 87 RDX); |
| 88 // Caller is responsible of preserving the value if necessary. |
| 89 __ ret(); |
| 90 __ Bind(&fall_through); |
| 53 return false; | 91 return false; |
| 54 } | 92 } |
| 55 | 93 |
| 56 | 94 |
| 57 bool Intrinsifier::GArray_Allocate(Assembler* assembler) { | 95 bool Intrinsifier::GArray_Allocate(Assembler* assembler) { |
| 58 return false; | 96 return false; |
| 59 } | 97 } |
| 60 | 98 |
| 61 | 99 |
| 62 // Get length of growable object array. | 100 // Get length of growable object array. |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 404 |
| 367 bool Intrinsifier::String_isEmpty(Assembler* assembler) { | 405 bool Intrinsifier::String_isEmpty(Assembler* assembler) { |
| 368 return false; | 406 return false; |
| 369 } | 407 } |
| 370 | 408 |
| 371 #undef __ | 409 #undef __ |
| 372 | 410 |
| 373 } // namespace dart | 411 } // namespace dart |
| 374 | 412 |
| 375 #endif // defined TARGET_ARCH_X64 | 413 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |