| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 const AbstractType& type, | 275 const AbstractType& type, |
| 276 Label* is_instance_lbl, | 276 Label* is_instance_lbl, |
| 277 Label* is_not_instance_lbl) { | 277 Label* is_not_instance_lbl) { |
| 278 __ Comment("InstantiatedTypeWithArgumentsTest"); | 278 __ Comment("InstantiatedTypeWithArgumentsTest"); |
| 279 ASSERT(type.IsInstantiated()); | 279 ASSERT(type.IsInstantiated()); |
| 280 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); | 280 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); |
| 281 ASSERT(type.IsFunctionType() || (type_class.NumTypeArguments() > 0)); | 281 ASSERT(type.IsFunctionType() || (type_class.NumTypeArguments() > 0)); |
| 282 const Register kInstanceReg = EAX; | 282 const Register kInstanceReg = EAX; |
| 283 Error& bound_error = Error::Handle(zone()); | 283 Error& bound_error = Error::Handle(zone()); |
| 284 const Type& int_type = Type::Handle(zone(), Type::IntType()); | 284 const Type& int_type = Type::Handle(zone(), Type::IntType()); |
| 285 const bool smi_is_ok = int_type.IsSubtypeOf(type, &bound_error, Heap::kOld); | 285 const bool smi_is_ok = |
| 286 int_type.IsSubtypeOf(type, &bound_error, NULL, Heap::kOld); |
| 286 // Malformed type should have been handled at graph construction time. | 287 // Malformed type should have been handled at graph construction time. |
| 287 ASSERT(smi_is_ok || bound_error.IsNull()); | 288 ASSERT(smi_is_ok || bound_error.IsNull()); |
| 288 __ testl(kInstanceReg, Immediate(kSmiTagMask)); | 289 __ testl(kInstanceReg, Immediate(kSmiTagMask)); |
| 289 if (smi_is_ok) { | 290 if (smi_is_ok) { |
| 290 __ j(ZERO, is_instance_lbl); | 291 __ j(ZERO, is_instance_lbl); |
| 291 } else { | 292 } else { |
| 292 __ j(ZERO, is_not_instance_lbl); | 293 __ j(ZERO, is_not_instance_lbl); |
| 293 } | 294 } |
| 294 // A function type test requires checking the function signature. | 295 // A function type test requires checking the function signature. |
| 295 if (!type.IsFunctionType()) { | 296 if (!type.IsFunctionType()) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 315 } | 316 } |
| 316 // If one type argument only, check if type argument is Object or dynamic. | 317 // If one type argument only, check if type argument is Object or dynamic. |
| 317 if (type_arguments.Length() == 1) { | 318 if (type_arguments.Length() == 1) { |
| 318 const AbstractType& tp_argument = AbstractType::ZoneHandle( | 319 const AbstractType& tp_argument = AbstractType::ZoneHandle( |
| 319 zone(), type_arguments.TypeAt(0)); | 320 zone(), type_arguments.TypeAt(0)); |
| 320 ASSERT(!tp_argument.IsMalformed()); | 321 ASSERT(!tp_argument.IsMalformed()); |
| 321 if (tp_argument.IsType()) { | 322 if (tp_argument.IsType()) { |
| 322 ASSERT(tp_argument.HasResolvedTypeClass()); | 323 ASSERT(tp_argument.HasResolvedTypeClass()); |
| 323 // Check if type argument is dynamic or Object. | 324 // Check if type argument is dynamic or Object. |
| 324 const Type& object_type = Type::Handle(zone(), Type::ObjectType()); | 325 const Type& object_type = Type::Handle(zone(), Type::ObjectType()); |
| 325 if (object_type.IsSubtypeOf(tp_argument, NULL, Heap::kOld)) { | 326 if (object_type.IsSubtypeOf(tp_argument, NULL, NULL, Heap::kOld)) { |
| 326 // Instance class test only necessary. | 327 // Instance class test only necessary. |
| 327 return GenerateSubtype1TestCacheLookup( | 328 return GenerateSubtype1TestCacheLookup( |
| 328 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); | 329 token_pos, type_class, is_instance_lbl, is_not_instance_lbl); |
| 329 } | 330 } |
| 330 } | 331 } |
| 331 } | 332 } |
| 332 } | 333 } |
| 333 // Regular subtype test cache involving instance's type arguments. | 334 // Regular subtype test cache involving instance's type arguments. |
| 334 const Register kTypeArgumentsReg = kNoRegister; | 335 const Register kTypeArgumentsReg = kNoRegister; |
| 335 const Register kTempReg = EDI; | 336 const Register kTempReg = EDI; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 ASSERT(type_class.NumTypeArguments() == 0); | 375 ASSERT(type_class.NumTypeArguments() == 0); |
| 375 | 376 |
| 376 const Register kInstanceReg = EAX; | 377 const Register kInstanceReg = EAX; |
| 377 __ testl(kInstanceReg, Immediate(kSmiTagMask)); | 378 __ testl(kInstanceReg, Immediate(kSmiTagMask)); |
| 378 // If instance is Smi, check directly. | 379 // If instance is Smi, check directly. |
| 379 const Class& smi_class = Class::Handle(zone(), Smi::Class()); | 380 const Class& smi_class = Class::Handle(zone(), Smi::Class()); |
| 380 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), | 381 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), |
| 381 type_class, | 382 type_class, |
| 382 TypeArguments::Handle(zone()), | 383 TypeArguments::Handle(zone()), |
| 383 NULL, | 384 NULL, |
| 385 NULL, |
| 384 Heap::kOld)) { | 386 Heap::kOld)) { |
| 385 __ j(ZERO, is_instance_lbl); | 387 __ j(ZERO, is_instance_lbl); |
| 386 } else { | 388 } else { |
| 387 __ j(ZERO, is_not_instance_lbl); | 389 __ j(ZERO, is_not_instance_lbl); |
| 388 } | 390 } |
| 389 // Compare if the classes are equal. | 391 // Compare if the classes are equal. |
| 390 const Register kClassIdReg = ECX; | 392 const Register kClassIdReg = ECX; |
| 391 __ LoadClassId(kClassIdReg, kInstanceReg); | 393 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 392 __ cmpl(kClassIdReg, Immediate(type_class.id())); | 394 __ cmpl(kClassIdReg, Immediate(type_class.id())); |
| 393 __ j(EQUAL, is_instance_lbl); | 395 __ j(EQUAL, is_instance_lbl); |
| 394 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted | 396 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted |
| 395 // interfaces. | 397 // interfaces. |
| 396 // Bool interface can be implemented only by core class Bool. | 398 // Bool interface can be implemented only by core class Bool. |
| 397 if (type.IsBoolType()) { | 399 if (type.IsBoolType()) { |
| 398 __ cmpl(kClassIdReg, Immediate(kBoolCid)); | 400 __ cmpl(kClassIdReg, Immediate(kBoolCid)); |
| 399 __ j(EQUAL, is_instance_lbl); | 401 __ j(EQUAL, is_instance_lbl); |
| 400 __ jmp(is_not_instance_lbl); | 402 __ jmp(is_not_instance_lbl); |
| 401 return false; | 403 return false; |
| 402 } | 404 } |
| 403 if (type.IsDartFunctionType()) { | 405 if (type.IsDartFunctionType()) { |
| 404 // Check if instance is a closure. | 406 // Check if instance is a closure. |
| 405 __ cmpl(kClassIdReg, Immediate(kClosureCid)); | 407 __ cmpl(kClassIdReg, Immediate(kClosureCid)); |
| 406 __ j(EQUAL, is_instance_lbl); | 408 __ j(EQUAL, is_instance_lbl); |
| 407 } | 409 } |
| 408 // Custom checking for numbers (Smi, Mint, Bigint and Double). | 410 // Custom checking for numbers (Smi, Mint, Bigint and Double). |
| 409 // Note that instance is not Smi (checked above). | 411 // Note that instance is not Smi (checked above). |
| 410 if (type.IsSubtypeOf( | 412 if (type.IsSubtypeOf( |
| 411 Type::Handle(zone(), Type::Number()), NULL, Heap::kOld)) { | 413 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) { |
| 412 GenerateNumberTypeCheck( | 414 GenerateNumberTypeCheck( |
| 413 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); | 415 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); |
| 414 return false; | 416 return false; |
| 415 } | 417 } |
| 416 if (type.IsStringType()) { | 418 if (type.IsStringType()) { |
| 417 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); | 419 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); |
| 418 return false; | 420 return false; |
| 419 } | 421 } |
| 420 // Otherwise fallthrough. | 422 // Otherwise fallthrough. |
| 421 return true; | 423 return true; |
| (...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1840 __ movups(reg, Address(ESP, 0)); | 1842 __ movups(reg, Address(ESP, 0)); |
| 1841 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1843 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1842 } | 1844 } |
| 1843 | 1845 |
| 1844 | 1846 |
| 1845 #undef __ | 1847 #undef __ |
| 1846 | 1848 |
| 1847 } // namespace dart | 1849 } // namespace dart |
| 1848 | 1850 |
| 1849 #endif // defined TARGET_ARCH_IA32 | 1851 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |