| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 FieldAddress(EAX, GrowableObjectArray::type_arguments_offset()), | 138 FieldAddress(EAX, GrowableObjectArray::type_arguments_offset()), |
| 139 EBX); | 139 EBX); |
| 140 | 140 |
| 141 __ ZeroInitSmiField(FieldAddress(EAX, GrowableObjectArray::length_offset())); | 141 __ ZeroInitSmiField(FieldAddress(EAX, GrowableObjectArray::length_offset())); |
| 142 __ ret(); // returns the newly allocated object in EAX. | 142 __ ret(); // returns the newly allocated object in EAX. |
| 143 | 143 |
| 144 __ Bind(&fall_through); | 144 __ Bind(&fall_through); |
| 145 } | 145 } |
| 146 | 146 |
| 147 | 147 |
| 148 // Access growable object array at specified index. | |
| 149 // On stack: growable array (+2), index (+1), return-address (+0). | |
| 150 void Intrinsifier::GrowableArrayGetIndexed(Assembler* assembler) { | |
| 151 Label fall_through; | |
| 152 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index. | |
| 153 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // GrowableArray. | |
| 154 __ testl(EBX, Immediate(kSmiTagMask)); | |
| 155 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. | |
| 156 // Range check using _length field. | |
| 157 __ cmpl(EBX, FieldAddress(EAX, GrowableObjectArray::length_offset())); | |
| 158 // Runtime throws exception. | |
| 159 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); | |
| 160 __ movl(EAX, FieldAddress(EAX, GrowableObjectArray::data_offset())); // data. | |
| 161 | |
| 162 // Note that EBX is Smi, i.e, times 2. | |
| 163 ASSERT(kSmiTagShift == 1); | |
| 164 __ movl(EAX, FieldAddress(EAX, EBX, TIMES_2, Array::data_offset())); | |
| 165 __ ret(); | |
| 166 __ Bind(&fall_through); | |
| 167 } | |
| 168 | |
| 169 | |
| 170 // Set value into growable object array at specified index. | |
| 171 // On stack: growable array (+3), index (+2), value (+1), return-address (+0). | |
| 172 void Intrinsifier::GrowableArraySetIndexed(Assembler* assembler) { | |
| 173 if (FLAG_enable_type_checks) { | |
| 174 return; | |
| 175 } | |
| 176 Label fall_through; | |
| 177 __ movl(EBX, Address(ESP, + 2 * kWordSize)); // Index. | |
| 178 __ movl(EAX, Address(ESP, + 3 * kWordSize)); // GrowableArray. | |
| 179 __ testl(EBX, Immediate(kSmiTagMask)); | |
| 180 __ j(NOT_ZERO, &fall_through); // Non-smi index. | |
| 181 // Range check using _length field. | |
| 182 __ cmpl(EBX, FieldAddress(EAX, GrowableObjectArray::length_offset())); | |
| 183 // Runtime throws exception. | |
| 184 __ j(ABOVE_EQUAL, &fall_through); | |
| 185 __ movl(EAX, FieldAddress(EAX, GrowableObjectArray::data_offset())); // data. | |
| 186 __ movl(EDI, Address(ESP, + 1 * kWordSize)); // Value. | |
| 187 // Note that EBX is Smi, i.e, times 2. | |
| 188 ASSERT(kSmiTagShift == 1); | |
| 189 __ StoreIntoObject(EAX, | |
| 190 FieldAddress(EAX, EBX, TIMES_2, Array::data_offset()), | |
| 191 EDI); | |
| 192 __ ret(); | |
| 193 __ Bind(&fall_through); | |
| 194 } | |
| 195 | |
| 196 | |
| 197 // Set length of growable object array. The length cannot | |
| 198 // be greater than the length of the data container. | |
| 199 // On stack: growable array (+2), length (+1), return-address (+0). | |
| 200 void Intrinsifier::GrowableArraySetLength(Assembler* assembler) { | |
| 201 Label fall_through; | |
| 202 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Growable array. | |
| 203 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Length value. | |
| 204 __ testl(EBX, Immediate(kSmiTagMask)); | |
| 205 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi length. | |
| 206 FieldAddress length_field(EAX, GrowableObjectArray::length_offset()); | |
| 207 __ StoreIntoSmiField(length_field, EBX); | |
| 208 __ ret(); | |
| 209 __ Bind(&fall_through); | |
| 210 } | |
| 211 | |
| 212 | |
| 213 // Set data of growable object array. | |
| 214 // On stack: growable array (+2), data (+1), return-address (+0). | |
| 215 void Intrinsifier::GrowableArraySetData(Assembler* assembler) { | |
| 216 if (FLAG_enable_type_checks) { | |
| 217 return; | |
| 218 } | |
| 219 Label fall_through; | |
| 220 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Data. | |
| 221 // Check that data is an ObjectArray. | |
| 222 __ testl(EBX, Immediate(kSmiTagMask)); | |
| 223 __ j(ZERO, &fall_through); // Data is Smi. | |
| 224 __ CompareClassId(EBX, kArrayCid, EAX); | |
| 225 __ j(NOT_EQUAL, &fall_through); | |
| 226 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Growable array. | |
| 227 __ StoreIntoObject(EAX, | |
| 228 FieldAddress(EAX, GrowableObjectArray::data_offset()), | |
| 229 EBX); | |
| 230 __ ret(); | |
| 231 __ Bind(&fall_through); | |
| 232 } | |
| 233 | |
| 234 | |
| 235 // Add an element to growable array if it doesn't need to grow, otherwise | 148 // Add an element to growable array if it doesn't need to grow, otherwise |
| 236 // call into regular code. | 149 // call into regular code. |
| 237 // On stack: growable array (+2), value (+1), return-address (+0). | 150 // On stack: growable array (+2), value (+1), return-address (+0). |
| 238 void Intrinsifier::GrowableArray_add(Assembler* assembler) { | 151 void Intrinsifier::GrowableArray_add(Assembler* assembler) { |
| 239 // In checked mode we need to type-check the incoming argument. | 152 // In checked mode we need to type-check the incoming argument. |
| 240 if (FLAG_enable_type_checks) return; | 153 if (FLAG_enable_type_checks) return; |
| 241 | 154 |
| 242 Label fall_through; | 155 Label fall_through; |
| 243 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Array. | 156 __ movl(EAX, Address(ESP, + 2 * kWordSize)); // Array. |
| 244 __ movl(EBX, FieldAddress(EAX, GrowableObjectArray::length_offset())); | 157 __ movl(EBX, FieldAddress(EAX, GrowableObjectArray::length_offset())); |
| (...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2140 Isolate::current_tag_offset()); | 2053 Isolate::current_tag_offset()); |
| 2141 // Set return value to Isolate::current_tag_. | 2054 // Set return value to Isolate::current_tag_. |
| 2142 __ movl(EAX, current_tag_addr); | 2055 __ movl(EAX, current_tag_addr); |
| 2143 __ ret(); | 2056 __ ret(); |
| 2144 } | 2057 } |
| 2145 | 2058 |
| 2146 #undef __ | 2059 #undef __ |
| 2147 } // namespace dart | 2060 } // namespace dart |
| 2148 | 2061 |
| 2149 #endif // defined TARGET_ARCH_IA32 | 2062 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |