| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // if the intrinsified method always executes a return. | 28 // if the intrinsified method always executes a return. |
| 29 // The FP register should not be modified, because it is used by the profiler. | 29 // The FP register should not be modified, because it is used by the profiler. |
| 30 // The THR register (see constants_arm.h) must be preserved. | 30 // The THR register (see constants_arm.h) must be preserved. |
| 31 | 31 |
| 32 #define __ assembler-> | 32 #define __ assembler-> |
| 33 | 33 |
| 34 | 34 |
| 35 intptr_t Intrinsifier::ParameterSlotFromSp() { return -1; } | 35 intptr_t Intrinsifier::ParameterSlotFromSp() { return -1; } |
| 36 | 36 |
| 37 | 37 |
| 38 static intptr_t ComputeObjectArrayTypeArgumentsOffset() { | |
| 39 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | |
| 40 const Class& cls = Class::Handle( | |
| 41 core_lib.LookupClassAllowPrivate(Symbols::_List())); | |
| 42 ASSERT(!cls.IsNull()); | |
| 43 ASSERT(cls.NumTypeArguments() == 1); | |
| 44 const intptr_t field_offset = cls.type_arguments_field_offset(); | |
| 45 ASSERT(field_offset != Class::kNoTypeArguments); | |
| 46 return field_offset; | |
| 47 } | |
| 48 | |
| 49 | |
| 50 // Intrinsify only for Smi value and index. Non-smi values need a store buffer | 38 // Intrinsify only for Smi value and index. Non-smi values need a store buffer |
| 51 // update. Array length is always a Smi. | 39 // update. Array length is always a Smi. |
| 52 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) { | 40 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) { |
| 41 if (Isolate::Current()->flags().type_checks()) { |
| 42 return; |
| 43 } |
| 44 |
| 53 Label fall_through; | 45 Label fall_through; |
| 54 | |
| 55 if (Isolate::Current()->flags().type_checks()) { | |
| 56 const intptr_t type_args_field_offset = | |
| 57 ComputeObjectArrayTypeArgumentsOffset(); | |
| 58 // Inline simple tests (Smi, null), fallthrough if not positive. | |
| 59 Label checked_ok; | |
| 60 __ ldr(R2, Address(SP, 0 * kWordSize)); // Value. | |
| 61 | |
| 62 // Null value is valid for any type. | |
| 63 __ CompareObject(R2, Object::null_object()); | |
| 64 __ b(&checked_ok, EQ); | |
| 65 | |
| 66 __ ldr(R1, Address(SP, 2 * kWordSize)); // Array. | |
| 67 __ ldr(R1, FieldAddress(R1, type_args_field_offset)); | |
| 68 | |
| 69 // R1: Type arguments of array. | |
| 70 __ CompareObject(R1, Object::null_object()); | |
| 71 __ b(&checked_ok, EQ); | |
| 72 | |
| 73 // Check if it's dynamic. | |
| 74 // Get type at index 0. | |
| 75 __ ldr(R0, FieldAddress(R1, TypeArguments::type_at_offset(0))); | |
| 76 __ CompareObject(R0, Type::ZoneHandle(Type::DynamicType())); | |
| 77 __ b(&checked_ok, EQ); | |
| 78 | |
| 79 // Check for int and num. | |
| 80 __ tst(R2, Operand(kSmiTagMask)); // Value is Smi? | |
| 81 __ b(&fall_through, NE); // Non-smi value. | |
| 82 __ CompareObject(R0, Type::ZoneHandle(Type::IntType())); | |
| 83 __ b(&checked_ok, EQ); | |
| 84 __ CompareObject(R0, Type::ZoneHandle(Type::Number())); | |
| 85 __ b(&fall_through, NE); | |
| 86 __ Bind(&checked_ok); | |
| 87 } | |
| 88 __ ldr(R1, Address(SP, 1 * kWordSize)); // Index. | 46 __ ldr(R1, Address(SP, 1 * kWordSize)); // Index. |
| 89 __ tst(R1, Operand(kSmiTagMask)); | 47 __ tst(R1, Operand(kSmiTagMask)); |
| 90 // Index not Smi. | 48 // Index not Smi. |
| 91 __ b(&fall_through, NE); | 49 __ b(&fall_through, NE); |
| 92 __ ldr(R0, Address(SP, 2 * kWordSize)); // Array. | 50 __ ldr(R0, Address(SP, 2 * kWordSize)); // Array. |
| 93 | 51 |
| 94 // Range check. | 52 // Range check. |
| 95 __ ldr(R3, FieldAddress(R0, Array::length_offset())); // Array length. | 53 __ ldr(R3, FieldAddress(R0, Array::length_offset())); // Array length. |
| 96 __ cmp(R1, Operand(R3)); | 54 __ cmp(R1, Operand(R3)); |
| 97 // Runtime throws exception. | 55 // Runtime throws exception. |
| (...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2046 | 2004 |
| 2047 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) { | 2005 void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler) { |
| 2048 __ LoadIsolate(R0); | 2006 __ LoadIsolate(R0); |
| 2049 __ ldr(R0, Address(R0, Isolate::current_tag_offset())); | 2007 __ ldr(R0, Address(R0, Isolate::current_tag_offset())); |
| 2050 __ Ret(); | 2008 __ Ret(); |
| 2051 } | 2009 } |
| 2052 | 2010 |
| 2053 } // namespace dart | 2011 } // namespace dart |
| 2054 | 2012 |
| 2055 #endif // defined TARGET_ARCH_ARM | 2013 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |