| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. |
| 6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
| 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 15 matching lines...) Expand all Loading... |
| 26 // The R5, R4 registers can be destroyed only if there is no slow-path, i.e. | 26 // The R5, R4 registers can be destroyed only if there is no slow-path, i.e. |
| 27 // if the intrinsified method always executes a return. | 27 // if the intrinsified method always executes a return. |
| 28 // The FP register should not be modified, because it is used by the profiler. | 28 // The FP register should not be modified, because it is used by the profiler. |
| 29 | 29 |
| 30 #define __ assembler-> | 30 #define __ assembler-> |
| 31 | 31 |
| 32 | 32 |
| 33 intptr_t Intrinsifier::ParameterSlotFromSp() { return -1; } | 33 intptr_t Intrinsifier::ParameterSlotFromSp() { return -1; } |
| 34 | 34 |
| 35 | 35 |
| 36 static intptr_t ComputeObjectArrayTypeArgumentsOffset() { | |
| 37 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | |
| 38 const Class& cls = Class::Handle( | |
| 39 core_lib.LookupClassAllowPrivate(Symbols::_List())); | |
| 40 ASSERT(!cls.IsNull()); | |
| 41 ASSERT(cls.NumTypeArguments() == 1); | |
| 42 const intptr_t field_offset = cls.type_arguments_field_offset(); | |
| 43 ASSERT(field_offset != Class::kNoTypeArguments); | |
| 44 return field_offset; | |
| 45 } | |
| 46 | |
| 47 | |
| 48 // Intrinsify only for Smi value and index. Non-smi values need a store buffer | 36 // Intrinsify only for Smi value and index. Non-smi values need a store buffer |
| 49 // update. Array length is always a Smi. | 37 // update. Array length is always a Smi. |
| 50 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) { | 38 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) { |
| 39 if (Isolate::Current()->flags().type_checks()) { |
| 40 return; |
| 41 } |
| 42 |
| 51 Label fall_through; | 43 Label fall_through; |
| 52 | |
| 53 if (Isolate::Current()->flags().type_checks()) { | |
| 54 const intptr_t type_args_field_offset = | |
| 55 ComputeObjectArrayTypeArgumentsOffset(); | |
| 56 // Inline simple tests (Smi, null), fallthrough if not positive. | |
| 57 Label checked_ok; | |
| 58 __ ldr(R2, Address(SP, 0 * kWordSize)); // Value. | |
| 59 | |
| 60 // Null value is valid for any type. | |
| 61 __ CompareObject(R2, Object::null_object()); | |
| 62 __ b(&checked_ok, EQ); | |
| 63 | |
| 64 __ ldr(R1, Address(SP, 2 * kWordSize)); // Array. | |
| 65 __ ldr(R1, FieldAddress(R1, type_args_field_offset)); | |
| 66 | |
| 67 // R1: Type arguments of array. | |
| 68 __ CompareObject(R1, Object::null_object()); | |
| 69 __ b(&checked_ok, EQ); | |
| 70 | |
| 71 // Check if it's dynamic. | |
| 72 // Get type at index 0. | |
| 73 __ ldr(R0, FieldAddress(R1, TypeArguments::type_at_offset(0))); | |
| 74 __ CompareObject(R0, Type::ZoneHandle(Type::DynamicType())); | |
| 75 __ b(&checked_ok, EQ); | |
| 76 | |
| 77 // Check for int and num. | |
| 78 __ tsti(R2, Immediate(Immediate(kSmiTagMask))); // Value is Smi? | |
| 79 __ b(&fall_through, NE); // Non-smi value. | |
| 80 __ CompareObject(R0, Type::ZoneHandle(Type::IntType())); | |
| 81 __ b(&checked_ok, EQ); | |
| 82 __ CompareObject(R0, Type::ZoneHandle(Type::Number())); | |
| 83 __ b(&fall_through, NE); | |
| 84 __ Bind(&checked_ok); | |
| 85 } | |
| 86 __ ldr(R1, Address(SP, 1 * kWordSize)); // Index. | 44 __ ldr(R1, Address(SP, 1 * kWordSize)); // Index. |
| 87 __ tsti(R1, Immediate(kSmiTagMask)); | 45 __ tsti(R1, Immediate(kSmiTagMask)); |
| 88 // Index not Smi. | 46 // Index not Smi. |
| 89 __ b(&fall_through, NE); | 47 __ b(&fall_through, NE); |
| 90 __ ldr(R0, Address(SP, 2 * kWordSize)); // Array. | 48 __ ldr(R0, Address(SP, 2 * kWordSize)); // Array. |
| 91 | 49 |
| 92 // Range check. | 50 // Range check. |
| 93 __ ldr(R3, FieldAddress(R0, Array::length_offset())); // Array length. | 51 __ ldr(R3, FieldAddress(R0, Array::length_offset())); // Array length. |
| 94 __ cmp(R1, Operand(R3)); | 52 __ cmp(R1, Operand(R3)); |
| 95 // Runtime throws exception. | 53 // Runtime throws exception. |
| (...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2127 | 2085 |
| 2128 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) { | 2086 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) { |
| 2129 __ LoadIsolate(R0); | 2087 __ LoadIsolate(R0); |
| 2130 __ ldr(R0, Address(R0, Isolate::current_tag_offset())); | 2088 __ ldr(R0, Address(R0, Isolate::current_tag_offset())); |
| 2131 __ ret(); | 2089 __ ret(); |
| 2132 } | 2090 } |
| 2133 | 2091 |
| 2134 } // namespace dart | 2092 } // namespace dart |
| 2135 | 2093 |
| 2136 #endif // defined TARGET_ARCH_ARM64 | 2094 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |