| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // Clobbers ECX, EDI. | 224 // Clobbers ECX, EDI. |
| 225 RawSubtypeTestCache* | 225 RawSubtypeTestCache* |
| 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() || type_class.IsSignatureClass()); |
| 235 const Register kInstanceReg = EAX; | 235 const Register kInstanceReg = EAX; |
| 236 Error& malformed_error = Error::Handle(); | 236 Error& malformed_error = Error::Handle(); |
| 237 const Type& int_type = Type::Handle(Type::IntType()); | 237 const Type& int_type = Type::Handle(Type::IntType()); |
| 238 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error); | 238 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error); |
| 239 // Malforrmed type should have been handled at graph construction time. | 239 // Malformed type should have been handled at graph construction time. |
| 240 ASSERT(smi_is_ok || malformed_error.IsNull()); | 240 ASSERT(smi_is_ok || malformed_error.IsNull()); |
| 241 __ testl(kInstanceReg, Immediate(kSmiTagMask)); | 241 __ testl(kInstanceReg, Immediate(kSmiTagMask)); |
| 242 if (smi_is_ok) { | 242 if (smi_is_ok) { |
| 243 __ j(ZERO, is_instance_lbl); | 243 __ j(ZERO, is_instance_lbl); |
| 244 } else { | 244 } else { |
| 245 __ j(ZERO, is_not_instance_lbl); | 245 __ j(ZERO, is_not_instance_lbl); |
| 246 } | 246 } |
| 247 const AbstractTypeArguments& type_arguments = | 247 const AbstractTypeArguments& type_arguments = |
| 248 AbstractTypeArguments::ZoneHandle(type.arguments()); | 248 AbstractTypeArguments::ZoneHandle(type.arguments()); |
| 249 const bool is_raw_type = type_arguments.IsNull() || | 249 const bool is_raw_type = type_arguments.IsNull() || |
| 250 type_arguments.IsRaw(type_arguments.Length()); | 250 type_arguments.IsRaw(type_arguments.Length()); |
| 251 if (is_raw_type) { | 251 if (!type_class.IsSignatureClass()) { |
| 252 const Register kClassIdReg = ECX; | 252 if (is_raw_type) { |
| 253 // dynamic type argument, check only classes. | 253 const Register kClassIdReg = ECX; |
| 254 __ LoadClassId(kClassIdReg, kInstanceReg); | 254 // dynamic type argument, check only classes. |
| 255 __ cmpl(kClassIdReg, Immediate(type_class.id())); | 255 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 256 __ j(EQUAL, is_instance_lbl); | 256 __ cmpl(kClassIdReg, Immediate(type_class.id())); |
| 257 // List is a very common case. | 257 __ j(EQUAL, is_instance_lbl); |
| 258 if (IsListClass(type_class)) { | 258 // List is a very common case. |
| 259 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); | 259 if (IsListClass(type_class)) { |
| 260 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); |
| 261 } |
| 262 return GenerateSubtype1TestCacheLookup( |
| 263 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); |
| 260 } | 264 } |
| 261 return GenerateSubtype1TestCacheLookup( | 265 // If one type argument only, check if type argument is Object or dynamic. |
| 262 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); | 266 if (type_arguments.Length() == 1) { |
| 263 } | 267 const AbstractType& tp_argument = AbstractType::ZoneHandle( |
| 264 // If one type argument only, check if type argument is Object or dynamic. | 268 type_arguments.TypeAt(0)); |
| 265 if (type_arguments.Length() == 1) { | 269 ASSERT(!tp_argument.IsMalformed()); |
| 266 const AbstractType& tp_argument = AbstractType::ZoneHandle( | 270 if (tp_argument.IsType()) { |
| 267 type_arguments.TypeAt(0)); | 271 ASSERT(tp_argument.HasResolvedTypeClass()); |
| 268 ASSERT(!tp_argument.IsMalformed()); | 272 // Check if type argument is dynamic or Object. |
| 269 if (tp_argument.IsType()) { | 273 const Type& object_type = Type::Handle(Type::ObjectType()); |
| 270 ASSERT(tp_argument.HasResolvedTypeClass()); | 274 if (object_type.IsSubtypeOf(tp_argument, NULL)) { |
| 271 // Check if type argument is dynamic or Object. | 275 // Instance class test only necessary. |
| 272 const Type& object_type = Type::Handle(Type::ObjectType()); | 276 return GenerateSubtype1TestCacheLookup( |
| 273 if (object_type.IsSubtypeOf(tp_argument, NULL)) { | 277 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); |
| 274 // Instance class test only necessary. | 278 } |
| 275 return GenerateSubtype1TestCacheLookup( | |
| 276 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); | |
| 277 } | 279 } |
| 278 } | 280 } |
| 279 } | 281 } |
| 280 // Regular subtype test cache involving instance's type arguments. | 282 // Regular subtype test cache involving instance's type arguments. |
| 281 const Register kTypeArgumentsReg = kNoRegister; | 283 const Register kTypeArgumentsReg = kNoRegister; |
| 282 const Register kTempReg = EDI; | 284 const Register kTempReg = EDI; |
| 283 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, | 285 return GenerateCallSubtypeTestStub(kTestTypeTwoArgs, |
| 284 kInstanceReg, | 286 kInstanceReg, |
| 285 kTypeArgumentsReg, | 287 kTypeArgumentsReg, |
| 286 kTempReg, | 288 kTempReg, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 __ CompareClassId(kInstanceReg, type_cid, EDI); | 519 __ CompareClassId(kInstanceReg, type_cid, EDI); |
| 518 __ j(EQUAL, is_instance_lbl); | 520 __ j(EQUAL, is_instance_lbl); |
| 519 } | 521 } |
| 520 __ jmp(is_not_instance_lbl); | 522 __ jmp(is_not_instance_lbl); |
| 521 return SubtypeTestCache::null(); | 523 return SubtypeTestCache::null(); |
| 522 } | 524 } |
| 523 if (type.IsInstantiated()) { | 525 if (type.IsInstantiated()) { |
| 524 const Class& type_class = Class::ZoneHandle(type.type_class()); | 526 const Class& type_class = Class::ZoneHandle(type.type_class()); |
| 525 // A class equality check is only applicable with a dst type of a | 527 // A class equality check is only applicable with a dst type of a |
| 526 // non-parameterized class or with a raw dst type of a parameterized class. | 528 // non-parameterized class or with a raw dst type of a parameterized class. |
| 527 if (type_class.HasTypeArguments()) { | 529 if (type_class.IsSignatureClass() || type_class.HasTypeArguments()) { |
| 528 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, | 530 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, |
| 529 type, | 531 type, |
| 530 is_instance_lbl, | 532 is_instance_lbl, |
| 531 is_not_instance_lbl); | 533 is_not_instance_lbl); |
| 532 // Fall through to runtime call. | 534 // Fall through to runtime call. |
| 533 } | 535 } |
| 534 const bool has_fall_through = | 536 const bool has_fall_through = |
| 535 GenerateInstantiatedTypeNoArgumentsTest(token_pos, | 537 GenerateInstantiatedTypeNoArgumentsTest(token_pos, |
| 536 type, | 538 type, |
| 537 is_instance_lbl, | 539 is_instance_lbl, |
| (...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 __ movups(reg, Address(ESP, 0)); | 1908 __ movups(reg, Address(ESP, 0)); |
| 1907 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1909 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1908 } | 1910 } |
| 1909 | 1911 |
| 1910 | 1912 |
| 1911 #undef __ | 1913 #undef __ |
| 1912 | 1914 |
| 1913 } // namespace dart | 1915 } // namespace dart |
| 1914 | 1916 |
| 1915 #endif // defined TARGET_ARCH_IA32 | 1917 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |