| 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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
| 6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 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/cpu.h" | 11 #include "vm/cpu.h" |
| 12 #include "vm/dart_entry.h" | 12 #include "vm/dart_entry.h" |
| 13 #include "vm/flow_graph_compiler.h" | 13 #include "vm/flow_graph_compiler.h" |
| 14 #include "vm/object.h" | 14 #include "vm/object.h" |
| 15 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
| 16 #include "vm/regexp_assembler.h" | 16 #include "vm/regexp_assembler.h" |
| 17 #include "vm/symbols.h" | 17 #include "vm/symbols.h" |
| 18 | 18 |
| 19 namespace dart { | 19 namespace dart { |
| 20 | 20 |
| 21 DECLARE_FLAG(bool, enable_type_checks); | 21 DECLARE_FLAG(bool, enable_type_checks); |
| 22 | 22 |
| 23 | 23 |
| 24 #define __ assembler-> | 24 #define __ assembler-> |
| 25 | 25 |
| 26 | 26 |
| 27 intptr_t Intrinsifier::ParameterSlotFromSp() { return -1; } | 27 intptr_t Intrinsifier::ParameterSlotFromSp() { return -1; } |
| 28 | 28 |
| 29 | 29 |
| 30 static bool TypeChecksEnabled() { |
| 31 return FLAG_enable_type_checks || Isolate::Current()->checked_mode(); |
| 32 } |
| 33 |
| 34 |
| 30 static intptr_t ComputeObjectArrayTypeArgumentsOffset() { | 35 static intptr_t ComputeObjectArrayTypeArgumentsOffset() { |
| 31 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 36 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 32 const Class& cls = Class::Handle( | 37 const Class& cls = Class::Handle( |
| 33 core_lib.LookupClassAllowPrivate(Symbols::_List())); | 38 core_lib.LookupClassAllowPrivate(Symbols::_List())); |
| 34 ASSERT(!cls.IsNull()); | 39 ASSERT(!cls.IsNull()); |
| 35 ASSERT(cls.NumTypeArguments() == 1); | 40 ASSERT(cls.NumTypeArguments() == 1); |
| 36 const intptr_t field_offset = cls.type_arguments_field_offset(); | 41 const intptr_t field_offset = cls.type_arguments_field_offset(); |
| 37 ASSERT(field_offset != Class::kNoTypeArguments); | 42 ASSERT(field_offset != Class::kNoTypeArguments); |
| 38 return field_offset; | 43 return field_offset; |
| 39 } | 44 } |
| 40 | 45 |
| 41 | 46 |
| 42 // Intrinsify only for Smi value and index. Non-smi values need a store buffer | 47 // Intrinsify only for Smi value and index. Non-smi values need a store buffer |
| 43 // update. Array length is always a Smi. | 48 // update. Array length is always a Smi. |
| 44 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) { | 49 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) { |
| 45 Label fall_through; | 50 Label fall_through; |
| 46 | 51 |
| 47 if (FLAG_enable_type_checks) { | 52 if (TypeChecksEnabled()) { |
| 48 const intptr_t type_args_field_offset = | 53 const intptr_t type_args_field_offset = |
| 49 ComputeObjectArrayTypeArgumentsOffset(); | 54 ComputeObjectArrayTypeArgumentsOffset(); |
| 50 // Inline simple tests (Smi, null), fallthrough if not positive. | 55 // Inline simple tests (Smi, null), fallthrough if not positive. |
| 51 const int32_t raw_null = reinterpret_cast<intptr_t>(Object::null()); | 56 const int32_t raw_null = reinterpret_cast<intptr_t>(Object::null()); |
| 52 Label checked_ok; | 57 Label checked_ok; |
| 53 __ ldr(R2, Address(SP, 0 * kWordSize)); // Value. | 58 __ ldr(R2, Address(SP, 0 * kWordSize)); // Value. |
| 54 | 59 |
| 55 // Null value is valid for any type. | 60 // Null value is valid for any type. |
| 56 __ CompareImmediate(R2, raw_null); | 61 __ CompareImmediate(R2, raw_null); |
| 57 __ b(&checked_ok, EQ); | 62 __ b(&checked_ok, EQ); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 145 |
| 141 __ Bind(&fall_through); | 146 __ Bind(&fall_through); |
| 142 } | 147 } |
| 143 | 148 |
| 144 | 149 |
| 145 // Add an element to growable array if it doesn't need to grow, otherwise | 150 // Add an element to growable array if it doesn't need to grow, otherwise |
| 146 // call into regular code. | 151 // call into regular code. |
| 147 // On stack: growable array (+1), value (+0). | 152 // On stack: growable array (+1), value (+0). |
| 148 void Intrinsifier::GrowableArray_add(Assembler* assembler) { | 153 void Intrinsifier::GrowableArray_add(Assembler* assembler) { |
| 149 // In checked mode we need to type-check the incoming argument. | 154 // In checked mode we need to type-check the incoming argument. |
| 150 if (FLAG_enable_type_checks) { | 155 if (TypeChecksEnabled()) { |
| 151 return; | 156 return; |
| 152 } | 157 } |
| 153 Label fall_through; | 158 Label fall_through; |
| 154 // R0: Array. | 159 // R0: Array. |
| 155 __ ldr(R0, Address(SP, 1 * kWordSize)); | 160 __ ldr(R0, Address(SP, 1 * kWordSize)); |
| 156 // R1: length. | 161 // R1: length. |
| 157 __ ldr(R1, FieldAddress(R0, GrowableObjectArray::length_offset())); | 162 __ ldr(R1, FieldAddress(R0, GrowableObjectArray::length_offset())); |
| 158 // R2: data. | 163 // R2: data. |
| 159 __ ldr(R2, FieldAddress(R0, GrowableObjectArray::data_offset())); | 164 __ ldr(R2, FieldAddress(R0, GrowableObjectArray::data_offset())); |
| 160 // R3: capacity. | 165 // R3: capacity. |
| (...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1974 Isolate* isolate = Isolate::Current(); | 1979 Isolate* isolate = Isolate::Current(); |
| 1975 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate)); | 1980 __ LoadImmediate(R1, reinterpret_cast<uword>(isolate)); |
| 1976 // Set return value to Isolate::current_tag_. | 1981 // Set return value to Isolate::current_tag_. |
| 1977 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); | 1982 __ ldr(R0, Address(R1, Isolate::current_tag_offset())); |
| 1978 __ Ret(); | 1983 __ Ret(); |
| 1979 } | 1984 } |
| 1980 | 1985 |
| 1981 } // namespace dart | 1986 } // namespace dart |
| 1982 | 1987 |
| 1983 #endif // defined TARGET_ARCH_ARM | 1988 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |