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