| 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_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 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 S5, S4 registers can be destroyed only if there is no slow-path, i.e. | 26 // The S5, S4 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 __ lw(T2, Address(SP, 0 * kWordSize)); // Value. | |
| 59 | |
| 60 // Null value is valid for any type. | |
| 61 __ LoadObject(T7, Object::null_object()); | |
| 62 __ beq(T2, T7, &checked_ok); | |
| 63 | |
| 64 __ lw(T1, Address(SP, 2 * kWordSize)); // Array. | |
| 65 __ lw(T1, FieldAddress(T1, type_args_field_offset)); | |
| 66 | |
| 67 // T1: Type arguments of array. | |
| 68 __ beq(T1, T7, &checked_ok); | |
| 69 | |
| 70 // Check if it's dynamic. | |
| 71 // Get type at index 0. | |
| 72 __ lw(T0, FieldAddress(T1, TypeArguments::type_at_offset(0))); | |
| 73 __ BranchEqual(T0, Type::ZoneHandle(Type::DynamicType()), &checked_ok); | |
| 74 | |
| 75 // Check for int and num. | |
| 76 __ andi(CMPRES1, T2, Immediate(kSmiTagMask)); | |
| 77 __ bne(CMPRES1, ZR, &fall_through); // Non-smi value. | |
| 78 | |
| 79 __ BranchEqual(T0, Type::ZoneHandle(Type::IntType()), &checked_ok); | |
| 80 __ BranchNotEqual(T0, Type::ZoneHandle(Type::Number()), &fall_through); | |
| 81 __ Bind(&checked_ok); | |
| 82 } | |
| 83 __ lw(T1, Address(SP, 1 * kWordSize)); // Index. | 44 __ lw(T1, Address(SP, 1 * kWordSize)); // Index. |
| 84 __ andi(CMPRES1, T1, Immediate(kSmiTagMask)); | 45 __ andi(CMPRES1, T1, Immediate(kSmiTagMask)); |
| 85 // Index not Smi. | 46 // Index not Smi. |
| 86 __ bne(CMPRES1, ZR, &fall_through); | 47 __ bne(CMPRES1, ZR, &fall_through); |
| 87 | 48 |
| 88 __ lw(T0, Address(SP, 2 * kWordSize)); // Array. | 49 __ lw(T0, Address(SP, 2 * kWordSize)); // Array. |
| 89 // Range check. | 50 // Range check. |
| 90 __ lw(T3, FieldAddress(T0, Array::length_offset())); // Array length. | 51 __ lw(T3, FieldAddress(T0, Array::length_offset())); // Array length. |
| 91 // Runtime throws exception. | 52 // Runtime throws exception. |
| 92 __ BranchUnsignedGreaterEqual(T1, T3, &fall_through); | 53 __ BranchUnsignedGreaterEqual(T1, T3, &fall_through); |
| (...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2159 | 2120 |
| 2160 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) { | 2121 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) { |
| 2161 __ LoadIsolate(V0); | 2122 __ LoadIsolate(V0); |
| 2162 __ Ret(); | 2123 __ Ret(); |
| 2163 __ delay_slot()->lw(V0, Address(V0, Isolate::current_tag_offset())); | 2124 __ delay_slot()->lw(V0, Address(V0, Isolate::current_tag_offset())); |
| 2164 } | 2125 } |
| 2165 | 2126 |
| 2166 } // namespace dart | 2127 } // namespace dart |
| 2167 | 2128 |
| 2168 #endif // defined TARGET_ARCH_MIPS | 2129 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |