Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); | 207 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); |
| 208 // Note that EBX is Smi, i.e, times 2. | 208 // Note that EBX is Smi, i.e, times 2. |
| 209 ASSERT(kSmiTagShift == 1); | 209 ASSERT(kSmiTagShift == 1); |
| 210 __ movl(EAX, FieldAddress(EAX, EBX, TIMES_2, sizeof(RawArray))); | 210 __ movl(EAX, FieldAddress(EAX, EBX, TIMES_2, sizeof(RawArray))); |
| 211 __ ret(); | 211 __ ret(); |
| 212 __ Bind(&fall_through); | 212 __ Bind(&fall_through); |
| 213 return false; | 213 return false; |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 static intptr_t ComputeObjectArrayTypeArgumentsOffset() { | |
| 218 const String& class_name = String::Handle(String::NewSymbol("ObjectArray")); | |
| 219 const Class& cls = Class::Handle( | |
| 220 Library::Handle(Library::CoreImplLibrary()).LookupClass(class_name)); | |
| 221 ASSERT(!cls.IsNull()); | |
| 222 ASSERT(cls.HasTypeArguments()); | |
| 223 ASSERT(cls.NumTypeParameters() == 1); | |
|
regis
2012/03/26 22:30:29
You actually want to make sure that the full type
srdjan
2012/03/26 22:43:51
Done.
| |
| 224 intptr_t field_offset = cls.type_arguments_instance_field_offset(); | |
| 225 ASSERT(field_offset != Class::kNoTypeArguments); | |
| 226 return field_offset; | |
| 227 } | |
| 228 | |
| 229 | |
| 217 // Intrinsify only for Smi value and index. Non-smi values need a store buffer | 230 // Intrinsify only for Smi value and index. Non-smi values need a store buffer |
| 218 // update. Array length is always a Smi. | 231 // update. Array length is always a Smi. |
| 219 static bool Array_setIndexed(Assembler* assembler) { | 232 static bool Array_setIndexed(Assembler* assembler) { |
| 233 Label fall_through; | |
| 220 if (FLAG_enable_type_checks) { | 234 if (FLAG_enable_type_checks) { |
| 221 return false; | 235 intptr_t type_args_field_offset = ComputeObjectArrayTypeArgumentsOffset(); |
| 236 ASSERT(type_args_field_offset >= 0); | |
| 237 // Inline simple tests (Smi, null), fallthrough if not positive. | |
| 238 const Immediate raw_null = | |
| 239 Immediate(reinterpret_cast<intptr_t>(Object::null())); | |
| 240 Label checked_ok; | |
| 241 __ movl(EAX, Address(ESP, + 1 * kWordSize)); | |
|
regis
2012/03/26 22:30:29
I guess you are accessing the last argument, i.e.
srdjan
2012/03/26 22:43:51
Done.
| |
| 242 __ cmpl(EAX, raw_null); | |
| 243 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | |
| 244 __ testl(EAX, Immediate(kSmiTagMask)); | |
| 245 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi value. | |
| 246 | |
| 247 // Check if generic type is OK. | |
| 248 __ movl(EBX, Address(ESP, + 3 * kWordSize)); // Array. | |
| 249 __ movl(EBX, FieldAddress(EBX, type_args_field_offset)); | |
| 250 // EBX: Type arguments of array. | |
| 251 __ movl(EAX, FieldAddress(EBX, Object::class_offset())); | |
| 252 // Check if it's Dynamic, int, or num. | |
| 253 __ cmpl(EAX, raw_null); // Dynamic? | |
| 254 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | |
| 255 // For now handle only TypeArguments and bail out if InstantiatedTypeArgs. | |
| 256 __ CompareObject(EAX, Object::ZoneHandle(Object::type_arguments_class())); | |
| 257 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); | |
| 258 // Get type at index 0. | |
| 259 __ movl(EAX, FieldAddress(EBX, TypeArguments::type_at_offset(0))); | |
| 260 __ CompareObject(EAX, Type::ZoneHandle(Type::DynamicType())); | |
| 261 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | |
| 262 __ CompareObject(EAX, Type::ZoneHandle(Type::IntInterface())); | |
| 263 __ j(EQUAL, &checked_ok, Assembler::kNearJump); | |
| 264 __ CompareObject(EAX, Type::ZoneHandle(Type::NumberInterface())); | |
| 265 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); | |
| 266 // TODO(srdjan): Check classes. | |
|
regis
2012/03/26 22:30:29
What do you mean by "Check classes"?
srdjan
2012/03/26 22:43:51
Removed.
| |
| 267 __ Bind(&checked_ok); | |
| 222 } | 268 } |
| 223 Label fall_through; | |
| 224 __ movl(EBX, Address(ESP, + 2 * kWordSize)); // Index. | 269 __ movl(EBX, Address(ESP, + 2 * kWordSize)); // Index. |
| 225 __ testl(EBX, Immediate(kSmiTagMask)); | 270 __ testl(EBX, Immediate(kSmiTagMask)); |
| 226 // Index not Smi. | 271 // Index not Smi. |
| 227 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); | 272 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); |
| 228 __ movl(EAX, Address(ESP, + 3 * kWordSize)); // Array. | 273 __ movl(EAX, Address(ESP, + 3 * kWordSize)); // Array. |
| 229 // Range check. | 274 // Range check. |
| 230 __ cmpl(EBX, FieldAddress(EAX, Array::length_offset())); | 275 __ cmpl(EBX, FieldAddress(EAX, Array::length_offset())); |
| 231 // Runtime throws exception. | 276 // Runtime throws exception. |
| 232 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); | 277 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); |
| 233 // Note that EBX is Smi, i.e, times 2. | 278 // Note that EBX is Smi, i.e, times 2. |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1244 } \ | 1289 } \ |
| 1245 | 1290 |
| 1246 INTRINSIC_LIST(FIND_INTRINSICS); | 1291 INTRINSIC_LIST(FIND_INTRINSICS); |
| 1247 #undef FIND_INTRINSICS | 1292 #undef FIND_INTRINSICS |
| 1248 return false; | 1293 return false; |
| 1249 } | 1294 } |
| 1250 | 1295 |
| 1251 } // namespace dart | 1296 } // namespace dart |
| 1252 | 1297 |
| 1253 #endif // defined TARGET_ARCH_IA32 | 1298 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |