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 // The intrinsic code below is executed before a method has built its frame. | 5 // The intrinsic code below is executed before a method has built its frame. |
6 // The return address is on the stack and the arguments below it. | 6 // The return address is on the stack and the arguments below it. |
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. | 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. |
8 // Each intrinsification method returns true if the corresponding | 8 // Each intrinsification method returns true if the corresponding |
9 // Dart method was intrinsified. | 9 // Dart method was intrinsified. |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 DECLARE_FLAG(bool, enable_type_checks); | 27 DECLARE_FLAG(bool, enable_type_checks); |
28 | 28 |
29 | 29 |
30 #define __ assembler-> | 30 #define __ assembler-> |
31 | 31 |
32 | 32 |
33 intptr_t Intrinsifier::ParameterSlotFromSp() { return 0; } | 33 intptr_t Intrinsifier::ParameterSlotFromSp() { return 0; } |
34 | 34 |
35 | 35 |
| 36 static bool TypeChecksEnabled() { |
| 37 return FLAG_enable_type_checks || Isolate::Current()->checked_mode(); |
| 38 } |
| 39 |
| 40 |
36 static intptr_t ComputeObjectArrayTypeArgumentsOffset() { | 41 static intptr_t ComputeObjectArrayTypeArgumentsOffset() { |
37 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 42 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
38 const Class& cls = Class::Handle( | 43 const Class& cls = Class::Handle( |
39 core_lib.LookupClassAllowPrivate(Symbols::_List())); | 44 core_lib.LookupClassAllowPrivate(Symbols::_List())); |
40 ASSERT(!cls.IsNull()); | 45 ASSERT(!cls.IsNull()); |
41 ASSERT(cls.NumTypeArguments() == 1); | 46 ASSERT(cls.NumTypeArguments() == 1); |
42 const intptr_t field_offset = cls.type_arguments_field_offset(); | 47 const intptr_t field_offset = cls.type_arguments_field_offset(); |
43 ASSERT(field_offset != Class::kNoTypeArguments); | 48 ASSERT(field_offset != Class::kNoTypeArguments); |
44 return field_offset; | 49 return field_offset; |
45 } | 50 } |
46 | 51 |
47 | 52 |
48 // Intrinsify only for Smi value and index. Non-smi values need a store buffer | 53 // Intrinsify only for Smi value and index. Non-smi values need a store buffer |
49 // update. Array length is always a Smi. | 54 // update. Array length is always a Smi. |
50 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) { | 55 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) { |
51 Label fall_through; | 56 Label fall_through; |
52 if (FLAG_enable_type_checks) { | 57 if (TypeChecksEnabled()) { |
53 const intptr_t type_args_field_offset = | 58 const intptr_t type_args_field_offset = |
54 ComputeObjectArrayTypeArgumentsOffset(); | 59 ComputeObjectArrayTypeArgumentsOffset(); |
55 // Inline simple tests (Smi, null), fallthrough if not positive. | 60 // Inline simple tests (Smi, null), fallthrough if not positive. |
56 const Immediate& raw_null = | 61 const Immediate& raw_null = |
57 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 62 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
58 Label checked_ok; | 63 Label checked_ok; |
59 __ movl(EDI, Address(ESP, + 1 * kWordSize)); // Value. | 64 __ movl(EDI, Address(ESP, + 1 * kWordSize)); // Value. |
60 // Null value is valid for any type. | 65 // Null value is valid for any type. |
61 __ cmpl(EDI, raw_null); | 66 __ cmpl(EDI, raw_null); |
62 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | 67 __ j(EQUAL, &checked_ok, Assembler::kNearJump); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 148 |
144 __ Bind(&fall_through); | 149 __ Bind(&fall_through); |
145 } | 150 } |
146 | 151 |
147 | 152 |
148 // Add an element to growable array if it doesn't need to grow, otherwise | 153 // Add an element to growable array if it doesn't need to grow, otherwise |
149 // call into regular code. | 154 // call into regular code. |
150 // On stack: growable array (+2), value (+1), return-address (+0). | 155 // On stack: growable array (+2), value (+1), return-address (+0). |
151 void Intrinsifier::GrowableArray_add(Assembler* assembler) { | 156 void Intrinsifier::GrowableArray_add(Assembler* assembler) { |
152 // In checked mode we need to type-check the incoming argument. | 157 // In checked mode we need to type-check the incoming argument. |
153 if (FLAG_enable_type_checks) return; | 158 if (TypeChecksEnabled()) return; |
154 | 159 |
155 Label fall_through; | 160 Label fall_through; |
156 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Array. | 161 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Array. |
157 __ movl(EBX, FieldAddress(EAX, GrowableObjectArray::length_offset())); | 162 __ movl(EBX, FieldAddress(EAX, GrowableObjectArray::length_offset())); |
158 // EBX: length. | 163 // EBX: length. |
159 __ movl(EDI, FieldAddress(EAX, GrowableObjectArray::data_offset())); | 164 __ movl(EDI, FieldAddress(EAX, GrowableObjectArray::data_offset())); |
160 // EDI: data. | 165 // EDI: data. |
161 // Compare length with capacity. | 166 // Compare length with capacity. |
162 __ cmpl(EBX, FieldAddress(EDI, Array::length_offset())); | 167 __ cmpl(EBX, FieldAddress(EDI, Array::length_offset())); |
163 __ j(EQUAL, &fall_through); // Must grow data. | 168 __ j(EQUAL, &fall_through); // Must grow data. |
(...skipping 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 Isolate::current_tag_offset()); | 2058 Isolate::current_tag_offset()); |
2054 // Set return value to Isolate::current_tag_. | 2059 // Set return value to Isolate::current_tag_. |
2055 __ movl(EAX, current_tag_addr); | 2060 __ movl(EAX, current_tag_addr); |
2056 __ ret(); | 2061 __ ret(); |
2057 } | 2062 } |
2058 | 2063 |
2059 #undef __ | 2064 #undef __ |
2060 } // namespace dart | 2065 } // namespace dart |
2061 | 2066 |
2062 #endif // defined TARGET_ARCH_IA32 | 2067 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |