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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
9 | 9 |
10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 ASSERT(smi_is_ok || malformed_error.IsNull()); | 252 ASSERT(smi_is_ok || malformed_error.IsNull()); |
253 __ testl(kInstanceReg, Immediate(kSmiTagMask)); | 253 __ testl(kInstanceReg, Immediate(kSmiTagMask)); |
254 if (smi_is_ok) { | 254 if (smi_is_ok) { |
255 __ j(ZERO, is_instance_lbl); | 255 __ j(ZERO, is_instance_lbl); |
256 } else { | 256 } else { |
257 __ j(ZERO, is_not_instance_lbl); | 257 __ j(ZERO, is_not_instance_lbl); |
258 } | 258 } |
259 const intptr_t num_type_args = type_class.NumTypeArguments(); | 259 const intptr_t num_type_args = type_class.NumTypeArguments(); |
260 const intptr_t num_type_params = type_class.NumTypeParameters(); | 260 const intptr_t num_type_params = type_class.NumTypeParameters(); |
261 const intptr_t from_index = num_type_args - num_type_params; | 261 const intptr_t from_index = num_type_args - num_type_params; |
262 const AbstractTypeArguments& type_arguments = | 262 const TypeArguments& type_arguments = |
263 AbstractTypeArguments::ZoneHandle(type.arguments()); | 263 TypeArguments::ZoneHandle(type.arguments()); |
264 const bool is_raw_type = type_arguments.IsNull() || | 264 const bool is_raw_type = type_arguments.IsNull() || |
265 type_arguments.IsRaw(from_index, num_type_params); | 265 type_arguments.IsRaw(from_index, num_type_params); |
266 // Signature class is an instantiated parameterized type. | 266 // Signature class is an instantiated parameterized type. |
267 if (!type_class.IsSignatureClass()) { | 267 if (!type_class.IsSignatureClass()) { |
268 if (is_raw_type) { | 268 if (is_raw_type) { |
269 const Register kClassIdReg = ECX; | 269 const Register kClassIdReg = ECX; |
270 // dynamic type argument, check only classes. | 270 // dynamic type argument, check only classes. |
271 __ LoadClassId(kClassIdReg, kInstanceReg); | 271 __ LoadClassId(kClassIdReg, kInstanceReg); |
272 __ cmpl(kClassIdReg, Immediate(type_class.id())); | 272 __ cmpl(kClassIdReg, Immediate(type_class.id())); |
273 __ j(EQUAL, is_instance_lbl); | 273 __ j(EQUAL, is_instance_lbl); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 __ Comment("UninstantiatedTypeTest"); | 429 __ Comment("UninstantiatedTypeTest"); |
430 ASSERT(!type.IsInstantiated()); | 430 ASSERT(!type.IsInstantiated()); |
431 // Skip check if destination is a dynamic type. | 431 // Skip check if destination is a dynamic type. |
432 const Immediate& raw_null = | 432 const Immediate& raw_null = |
433 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 433 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
434 if (type.IsTypeParameter()) { | 434 if (type.IsTypeParameter()) { |
435 const TypeParameter& type_param = TypeParameter::Cast(type); | 435 const TypeParameter& type_param = TypeParameter::Cast(type); |
436 // Load instantiator (or null) and instantiator type arguments on stack. | 436 // Load instantiator (or null) and instantiator type arguments on stack. |
437 __ movl(EDX, Address(ESP, 0)); // Get instantiator type arguments. | 437 __ movl(EDX, Address(ESP, 0)); // Get instantiator type arguments. |
438 // EDX: instantiator type arguments. | 438 // EDX: instantiator type arguments. |
439 // Check if type argument is dynamic. | 439 // Check if type arguments are null, i.e. equivalent to vector of dynamic. |
440 __ cmpl(EDX, raw_null); | 440 __ cmpl(EDX, raw_null); |
441 __ j(EQUAL, is_instance_lbl); | 441 __ j(EQUAL, is_instance_lbl); |
442 // Can handle only type arguments that are instances of TypeArguments. | |
443 // (runtime checks canonicalize type arguments). | |
444 Label fall_through; | |
445 __ CompareClassId(EDX, kTypeArgumentsCid, EDI); | |
446 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); | |
447 __ movl(EDI, | 442 __ movl(EDI, |
448 FieldAddress(EDX, TypeArguments::type_at_offset(type_param.index()))); | 443 FieldAddress(EDX, TypeArguments::type_at_offset(type_param.index()))); |
449 // EDI: concrete type of type. | 444 // EDI: concrete type of type. |
450 // Check if type argument is dynamic. | 445 // Check if type argument is dynamic. |
451 __ CompareObject(EDI, Type::ZoneHandle(Type::DynamicType())); | 446 __ CompareObject(EDI, Type::ZoneHandle(Type::DynamicType())); |
452 __ j(EQUAL, is_instance_lbl); | 447 __ j(EQUAL, is_instance_lbl); |
453 __ cmpl(EDI, raw_null); | 448 __ CompareObject(EDI, Type::ZoneHandle(Type::ObjectType())); |
454 __ j(EQUAL, is_instance_lbl); | |
455 const Type& object_type = Type::ZoneHandle(Type::ObjectType()); | |
456 __ CompareObject(EDI, object_type); | |
457 __ j(EQUAL, is_instance_lbl); | 449 __ j(EQUAL, is_instance_lbl); |
458 | 450 |
459 // For Smi check quickly against int and num interfaces. | 451 // For Smi check quickly against int and num interfaces. |
460 Label not_smi; | 452 Label not_smi; |
461 __ testl(EAX, Immediate(kSmiTagMask)); // Value is Smi? | 453 __ testl(EAX, Immediate(kSmiTagMask)); // Value is Smi? |
462 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); | 454 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); |
463 __ CompareObject(EDI, Type::ZoneHandle(Type::IntType())); | 455 __ CompareObject(EDI, Type::ZoneHandle(Type::IntType())); |
464 __ j(EQUAL, is_instance_lbl); | 456 __ j(EQUAL, is_instance_lbl); |
465 __ CompareObject(EDI, Type::ZoneHandle(Type::Number())); | 457 __ CompareObject(EDI, Type::ZoneHandle(Type::Number())); |
466 __ j(EQUAL, is_instance_lbl); | 458 __ j(EQUAL, is_instance_lbl); |
467 // Smi must be handled in runtime. | 459 // Smi must be handled in runtime. |
| 460 Label fall_through; |
468 __ jmp(&fall_through); | 461 __ jmp(&fall_through); |
469 | 462 |
470 __ Bind(¬_smi); | 463 __ Bind(¬_smi); |
471 // EDX: instantiator type arguments. | 464 // EDX: instantiator type arguments. |
472 // EAX: instance. | 465 // EAX: instance. |
473 const Register kInstanceReg = EAX; | 466 const Register kInstanceReg = EAX; |
474 const Register kTypeArgumentsReg = EDX; | 467 const Register kTypeArgumentsReg = EDX; |
475 const Register kTempReg = EDI; | 468 const Register kTempReg = EDI; |
476 const SubtypeTestCache& type_test_cache = | 469 const SubtypeTestCache& type_test_cache = |
477 SubtypeTestCache::ZoneHandle( | 470 SubtypeTestCache::ZoneHandle( |
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 __ movups(reg, Address(ESP, 0)); | 1831 __ movups(reg, Address(ESP, 0)); |
1839 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1832 __ addl(ESP, Immediate(kFpuRegisterSize)); |
1840 } | 1833 } |
1841 | 1834 |
1842 | 1835 |
1843 #undef __ | 1836 #undef __ |
1844 | 1837 |
1845 } // namespace dart | 1838 } // namespace dart |
1846 | 1839 |
1847 #endif // defined TARGET_ARCH_IA32 | 1840 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |