| 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 ASSERT(smi_is_ok || malformed_error.IsNull()); | 237 ASSERT(smi_is_ok || malformed_error.IsNull()); |
| 238 __ testq(kInstanceReg, Immediate(kSmiTagMask)); | 238 __ testq(kInstanceReg, Immediate(kSmiTagMask)); |
| 239 if (smi_is_ok) { | 239 if (smi_is_ok) { |
| 240 __ j(ZERO, is_instance_lbl); | 240 __ j(ZERO, is_instance_lbl); |
| 241 } else { | 241 } else { |
| 242 __ j(ZERO, is_not_instance_lbl); | 242 __ j(ZERO, is_not_instance_lbl); |
| 243 } | 243 } |
| 244 const intptr_t num_type_args = type_class.NumTypeArguments(); | 244 const intptr_t num_type_args = type_class.NumTypeArguments(); |
| 245 const intptr_t num_type_params = type_class.NumTypeParameters(); | 245 const intptr_t num_type_params = type_class.NumTypeParameters(); |
| 246 const intptr_t from_index = num_type_args - num_type_params; | 246 const intptr_t from_index = num_type_args - num_type_params; |
| 247 const AbstractTypeArguments& type_arguments = | 247 const TypeArguments& type_arguments = |
| 248 AbstractTypeArguments::ZoneHandle(type.arguments()); | 248 TypeArguments::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(from_index, num_type_params); | 250 type_arguments.IsRaw(from_index, num_type_params); |
| 251 // Signature class is an instantiated parameterized type. | 251 // Signature class is an instantiated parameterized type. |
| 252 if (!type_class.IsSignatureClass()) { | 252 if (!type_class.IsSignatureClass()) { |
| 253 if (is_raw_type) { | 253 if (is_raw_type) { |
| 254 const Register kClassIdReg = R10; | 254 const Register kClassIdReg = R10; |
| 255 // dynamic type argument, check only classes. | 255 // dynamic type argument, check only classes. |
| 256 __ LoadClassId(kClassIdReg, kInstanceReg); | 256 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 257 __ cmpl(kClassIdReg, Immediate(type_class.id())); | 257 __ cmpl(kClassIdReg, Immediate(type_class.id())); |
| 258 __ j(EQUAL, is_instance_lbl); | 258 __ j(EQUAL, is_instance_lbl); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 Label* is_instance_lbl, | 410 Label* is_instance_lbl, |
| 411 Label* is_not_instance_lbl) { | 411 Label* is_not_instance_lbl) { |
| 412 __ Comment("UninstantiatedTypeTest"); | 412 __ Comment("UninstantiatedTypeTest"); |
| 413 ASSERT(!type.IsInstantiated()); | 413 ASSERT(!type.IsInstantiated()); |
| 414 // Skip check if destination is a dynamic type. | 414 // Skip check if destination is a dynamic type. |
| 415 if (type.IsTypeParameter()) { | 415 if (type.IsTypeParameter()) { |
| 416 const TypeParameter& type_param = TypeParameter::Cast(type); | 416 const TypeParameter& type_param = TypeParameter::Cast(type); |
| 417 // Load instantiator (or null) and instantiator type arguments on stack. | 417 // Load instantiator (or null) and instantiator type arguments on stack. |
| 418 __ movq(RDX, Address(RSP, 0)); // Get instantiator type arguments. | 418 __ movq(RDX, Address(RSP, 0)); // Get instantiator type arguments. |
| 419 // RDX: instantiator type arguments. | 419 // RDX: instantiator type arguments. |
| 420 // Check if type argument is dynamic. | 420 // Check if type arguments are null, i.e. equivalent to vector of dynamic. |
| 421 __ CompareObject(RDX, Object::null_object(), PP); | 421 __ CompareObject(RDX, Object::null_object(), PP); |
| 422 __ j(EQUAL, is_instance_lbl); | 422 __ j(EQUAL, is_instance_lbl); |
| 423 // Can handle only type arguments that are instances of TypeArguments. | |
| 424 // (runtime checks canonicalize type arguments). | |
| 425 Label fall_through; | |
| 426 __ CompareClassId(RDX, kTypeArgumentsCid); | |
| 427 __ j(NOT_EQUAL, &fall_through); | |
| 428 __ movq(RDI, | 423 __ movq(RDI, |
| 429 FieldAddress(RDX, TypeArguments::type_at_offset(type_param.index()))); | 424 FieldAddress(RDX, TypeArguments::type_at_offset(type_param.index()))); |
| 430 // RDI: Concrete type of type. | 425 // RDI: Concrete type of type. |
| 431 // Check if type argument is dynamic. | 426 // Check if type argument is dynamic. |
| 432 __ CompareObject(RDI, Type::ZoneHandle(Type::DynamicType()), PP); | 427 __ CompareObject(RDI, Type::ZoneHandle(Type::DynamicType()), PP); |
| 433 __ j(EQUAL, is_instance_lbl); | 428 __ j(EQUAL, is_instance_lbl); |
| 434 __ CompareObject(RDI, Object::null_object(), PP); | |
| 435 __ j(EQUAL, is_instance_lbl); | |
| 436 const Type& object_type = Type::ZoneHandle(Type::ObjectType()); | 429 const Type& object_type = Type::ZoneHandle(Type::ObjectType()); |
| 437 __ CompareObject(RDI, object_type, PP); | 430 __ CompareObject(RDI, object_type, PP); |
| 438 __ j(EQUAL, is_instance_lbl); | 431 __ j(EQUAL, is_instance_lbl); |
| 439 | 432 |
| 440 // For Smi check quickly against int and num interfaces. | 433 // For Smi check quickly against int and num interfaces. |
| 441 Label not_smi; | 434 Label not_smi; |
| 442 __ testq(RAX, Immediate(kSmiTagMask)); // Value is Smi? | 435 __ testq(RAX, Immediate(kSmiTagMask)); // Value is Smi? |
| 443 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); | 436 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); |
| 444 __ CompareObject(RDI, Type::ZoneHandle(Type::IntType()), PP); | 437 __ CompareObject(RDI, Type::ZoneHandle(Type::IntType()), PP); |
| 445 __ j(EQUAL, is_instance_lbl); | 438 __ j(EQUAL, is_instance_lbl); |
| 446 __ CompareObject(RDI, Type::ZoneHandle(Type::Number()), PP); | 439 __ CompareObject(RDI, Type::ZoneHandle(Type::Number()), PP); |
| 447 __ j(EQUAL, is_instance_lbl); | 440 __ j(EQUAL, is_instance_lbl); |
| 448 // Smi must be handled in runtime. | 441 // Smi must be handled in runtime. |
| 442 Label fall_through; |
| 449 __ jmp(&fall_through); | 443 __ jmp(&fall_through); |
| 450 | 444 |
| 451 __ Bind(¬_smi); | 445 __ Bind(¬_smi); |
| 452 // RDX: instantiator type arguments. | 446 // RDX: instantiator type arguments. |
| 453 // RAX: instance. | 447 // RAX: instance. |
| 454 const Register kInstanceReg = RAX; | 448 const Register kInstanceReg = RAX; |
| 455 const Register kTypeArgumentsReg = RDX; | 449 const Register kTypeArgumentsReg = RDX; |
| 456 const Register kTempReg = R10; | 450 const Register kTempReg = R10; |
| 457 const SubtypeTestCache& type_test_cache = | 451 const SubtypeTestCache& type_test_cache = |
| 458 SubtypeTestCache::ZoneHandle( | 452 SubtypeTestCache::ZoneHandle( |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1851 __ movups(reg, Address(RSP, 0)); | 1845 __ movups(reg, Address(RSP, 0)); |
| 1852 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); | 1846 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); |
| 1853 } | 1847 } |
| 1854 | 1848 |
| 1855 | 1849 |
| 1856 #undef __ | 1850 #undef __ |
| 1857 | 1851 |
| 1858 } // namespace dart | 1852 } // namespace dart |
| 1859 | 1853 |
| 1860 #endif // defined TARGET_ARCH_X64 | 1854 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |