| 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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( | 226 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( |
| 227 intptr_t token_pos, | 227 intptr_t token_pos, |
| 228 const AbstractType& type, | 228 const AbstractType& type, |
| 229 Label* is_instance_lbl, | 229 Label* is_instance_lbl, |
| 230 Label* is_not_instance_lbl) { | 230 Label* is_not_instance_lbl) { |
| 231 __ Comment("InstantiatedTypeWithArgumentsTest"); | 231 __ Comment("InstantiatedTypeWithArgumentsTest"); |
| 232 ASSERT(type.IsInstantiated()); | 232 ASSERT(type.IsInstantiated()); |
| 233 const Class& type_class = Class::ZoneHandle(type.type_class()); | 233 const Class& type_class = Class::ZoneHandle(type.type_class()); |
| 234 ASSERT(type_class.HasTypeArguments()); | 234 ASSERT(type_class.HasTypeArguments()); |
| 235 const Register kInstanceReg = EAX; | 235 const Register kInstanceReg = EAX; |
| 236 // A Smi object cannot be the instance of a parameterized class. | 236 Error& malformed_error = Error::Handle(); |
| 237 const Type& int_type = Type::Handle(Type::IntType()); |
| 238 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error); |
| 239 // Malforrmed type should have been handled at graph construction time. |
| 240 ASSERT(smi_is_ok || malformed_error.IsNull()); |
| 237 __ testl(kInstanceReg, Immediate(kSmiTagMask)); | 241 __ testl(kInstanceReg, Immediate(kSmiTagMask)); |
| 238 __ j(ZERO, is_not_instance_lbl); | 242 if (smi_is_ok) { |
| 243 __ j(ZERO, is_instance_lbl); |
| 244 } else { |
| 245 __ j(ZERO, is_not_instance_lbl); |
| 246 } |
| 239 const AbstractTypeArguments& type_arguments = | 247 const AbstractTypeArguments& type_arguments = |
| 240 AbstractTypeArguments::ZoneHandle(type.arguments()); | 248 AbstractTypeArguments::ZoneHandle(type.arguments()); |
| 241 const bool is_raw_type = type_arguments.IsNull() || | 249 const bool is_raw_type = type_arguments.IsNull() || |
| 242 type_arguments.IsRaw(type_arguments.Length()); | 250 type_arguments.IsRaw(type_arguments.Length()); |
| 243 if (is_raw_type) { | 251 if (is_raw_type) { |
| 244 const Register kClassIdReg = ECX; | 252 const Register kClassIdReg = ECX; |
| 245 // dynamic type argument, check only classes. | 253 // dynamic type argument, check only classes. |
| 246 __ LoadClassId(kClassIdReg, kInstanceReg); | 254 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 247 __ cmpl(kClassIdReg, Immediate(type_class.id())); | 255 __ cmpl(kClassIdReg, Immediate(type_class.id())); |
| 248 __ j(EQUAL, is_instance_lbl); | 256 __ j(EQUAL, is_instance_lbl); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 } else { | 515 } else { |
| 508 __ j(ZERO, is_not_instance_lbl); | 516 __ j(ZERO, is_not_instance_lbl); |
| 509 __ CompareClassId(kInstanceReg, type_cid, EDI); | 517 __ CompareClassId(kInstanceReg, type_cid, EDI); |
| 510 __ j(EQUAL, is_instance_lbl); | 518 __ j(EQUAL, is_instance_lbl); |
| 511 } | 519 } |
| 512 __ jmp(is_not_instance_lbl); | 520 __ jmp(is_not_instance_lbl); |
| 513 return SubtypeTestCache::null(); | 521 return SubtypeTestCache::null(); |
| 514 } | 522 } |
| 515 if (type.IsInstantiated()) { | 523 if (type.IsInstantiated()) { |
| 516 const Class& type_class = Class::ZoneHandle(type.type_class()); | 524 const Class& type_class = Class::ZoneHandle(type.type_class()); |
| 517 // A Smi object cannot be the instance of a parameterized class. | |
| 518 // A class equality check is only applicable with a dst type of a | 525 // A class equality check is only applicable with a dst type of a |
| 519 // non-parameterized class or with a raw dst type of a parameterized class. | 526 // non-parameterized class or with a raw dst type of a parameterized class. |
| 520 if (type_class.HasTypeArguments()) { | 527 if (type_class.HasTypeArguments()) { |
| 521 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, | 528 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, |
| 522 type, | 529 type, |
| 523 is_instance_lbl, | 530 is_instance_lbl, |
| 524 is_not_instance_lbl); | 531 is_not_instance_lbl); |
| 525 // Fall through to runtime call. | 532 // Fall through to runtime call. |
| 526 } | 533 } |
| 527 const bool has_fall_through = | 534 const bool has_fall_through = |
| (...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 __ movups(reg, Address(ESP, 0)); | 1907 __ movups(reg, Address(ESP, 0)); |
| 1901 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1908 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1902 } | 1909 } |
| 1903 | 1910 |
| 1904 | 1911 |
| 1905 #undef __ | 1912 #undef __ |
| 1906 | 1913 |
| 1907 } // namespace dart | 1914 } // namespace dart |
| 1908 | 1915 |
| 1909 #endif // defined TARGET_ARCH_IA32 | 1916 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |