| 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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( | 222 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( |
| 223 intptr_t token_pos, | 223 intptr_t token_pos, |
| 224 const AbstractType& type, | 224 const AbstractType& type, |
| 225 Label* is_instance_lbl, | 225 Label* is_instance_lbl, |
| 226 Label* is_not_instance_lbl) { | 226 Label* is_not_instance_lbl) { |
| 227 __ Comment("InstantiatedTypeWithArgumentsTest"); | 227 __ Comment("InstantiatedTypeWithArgumentsTest"); |
| 228 ASSERT(type.IsInstantiated()); | 228 ASSERT(type.IsInstantiated()); |
| 229 const Class& type_class = Class::ZoneHandle(type.type_class()); | 229 const Class& type_class = Class::ZoneHandle(type.type_class()); |
| 230 ASSERT(type_class.HasTypeArguments()); | 230 ASSERT(type_class.HasTypeArguments()); |
| 231 const Register kInstanceReg = RAX; | 231 const Register kInstanceReg = RAX; |
| 232 // A Smi object cannot be the instance of a parameterized class. | 232 Error& malformed_error = Error::Handle(); |
| 233 const Type& int_type = Type::Handle(Type::IntType()); |
| 234 const bool smi_is_ok = int_type.IsSubtypeOf(type, &malformed_error); |
| 235 // Malforrmed type should have been handled at graph construction time. |
| 236 ASSERT(smi_is_ok || malformed_error.IsNull()); |
| 233 __ testq(kInstanceReg, Immediate(kSmiTagMask)); | 237 __ testq(kInstanceReg, Immediate(kSmiTagMask)); |
| 234 __ j(ZERO, is_not_instance_lbl); | 238 if (smi_is_ok) { |
| 239 __ j(ZERO, is_instance_lbl); |
| 240 } else { |
| 241 __ j(ZERO, is_not_instance_lbl); |
| 242 } |
| 235 const AbstractTypeArguments& type_arguments = | 243 const AbstractTypeArguments& type_arguments = |
| 236 AbstractTypeArguments::ZoneHandle(type.arguments()); | 244 AbstractTypeArguments::ZoneHandle(type.arguments()); |
| 237 const bool is_raw_type = type_arguments.IsNull() || | 245 const bool is_raw_type = type_arguments.IsNull() || |
| 238 type_arguments.IsRaw(type_arguments.Length()); | 246 type_arguments.IsRaw(type_arguments.Length()); |
| 239 if (is_raw_type) { | 247 if (is_raw_type) { |
| 240 const Register kClassIdReg = R10; | 248 const Register kClassIdReg = R10; |
| 241 // dynamic type argument, check only classes. | 249 // dynamic type argument, check only classes. |
| 242 __ LoadClassId(kClassIdReg, kInstanceReg); | 250 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 243 __ cmpl(kClassIdReg, Immediate(type_class.id())); | 251 __ cmpl(kClassIdReg, Immediate(type_class.id())); |
| 244 __ j(EQUAL, is_instance_lbl); | 252 __ j(EQUAL, is_instance_lbl); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 } else { | 511 } else { |
| 504 __ j(ZERO, is_not_instance_lbl); | 512 __ j(ZERO, is_not_instance_lbl); |
| 505 __ CompareClassId(kInstanceReg, type_cid); | 513 __ CompareClassId(kInstanceReg, type_cid); |
| 506 __ j(EQUAL, is_instance_lbl); | 514 __ j(EQUAL, is_instance_lbl); |
| 507 } | 515 } |
| 508 __ jmp(is_not_instance_lbl); | 516 __ jmp(is_not_instance_lbl); |
| 509 return SubtypeTestCache::null(); | 517 return SubtypeTestCache::null(); |
| 510 } | 518 } |
| 511 if (type.IsInstantiated()) { | 519 if (type.IsInstantiated()) { |
| 512 const Class& type_class = Class::ZoneHandle(type.type_class()); | 520 const Class& type_class = Class::ZoneHandle(type.type_class()); |
| 513 // A Smi object cannot be the instance of a parameterized class. | |
| 514 // A class equality check is only applicable with a dst type of a | 521 // A class equality check is only applicable with a dst type of a |
| 515 // non-parameterized class or with a raw dst type of a parameterized class. | 522 // non-parameterized class or with a raw dst type of a parameterized class. |
| 516 if (type_class.HasTypeArguments()) { | 523 if (type_class.HasTypeArguments()) { |
| 517 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, | 524 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, |
| 518 type, | 525 type, |
| 519 is_instance_lbl, | 526 is_instance_lbl, |
| 520 is_not_instance_lbl); | 527 is_not_instance_lbl); |
| 521 // Fall through to runtime call. | 528 // Fall through to runtime call. |
| 522 } | 529 } |
| 523 const bool has_fall_through = | 530 const bool has_fall_through = |
| (...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1879 __ movups(reg, Address(RSP, 0)); | 1886 __ movups(reg, Address(RSP, 0)); |
| 1880 __ addq(RSP, Immediate(kFpuRegisterSize)); | 1887 __ addq(RSP, Immediate(kFpuRegisterSize)); |
| 1881 } | 1888 } |
| 1882 | 1889 |
| 1883 | 1890 |
| 1884 #undef __ | 1891 #undef __ |
| 1885 | 1892 |
| 1886 } // namespace dart | 1893 } // namespace dart |
| 1887 | 1894 |
| 1888 #endif // defined TARGET_ARCH_X64 | 1895 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |