| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), | 380 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), |
| 381 type_class, | 381 type_class, |
| 382 TypeArguments::Handle(zone()), | 382 TypeArguments::Handle(zone()), |
| 383 NULL, | 383 NULL, |
| 384 NULL, | 384 NULL, |
| 385 Heap::kOld)) { | 385 Heap::kOld)) { |
| 386 __ j(ZERO, is_instance_lbl); | 386 __ j(ZERO, is_instance_lbl); |
| 387 } else { | 387 } else { |
| 388 __ j(ZERO, is_not_instance_lbl); | 388 __ j(ZERO, is_not_instance_lbl); |
| 389 } | 389 } |
| 390 // Compare if the classes are equal. | |
| 391 const Register kClassIdReg = R10; | 390 const Register kClassIdReg = R10; |
| 392 __ LoadClassId(kClassIdReg, kInstanceReg); | 391 __ LoadClassId(kClassIdReg, kInstanceReg); |
| 393 __ cmpl(kClassIdReg, Immediate(type_class.id())); | |
| 394 __ j(EQUAL, is_instance_lbl); | |
| 395 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted | 392 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted |
| 396 // interfaces. | 393 // interfaces. |
| 397 // Bool interface can be implemented only by core class Bool. | 394 // Bool interface can be implemented only by core class Bool. |
| 398 if (type.IsBoolType()) { | 395 if (type.IsBoolType()) { |
| 399 __ cmpl(kClassIdReg, Immediate(kBoolCid)); | 396 __ cmpl(kClassIdReg, Immediate(kBoolCid)); |
| 400 __ j(EQUAL, is_instance_lbl); | 397 __ j(EQUAL, is_instance_lbl); |
| 401 __ jmp(is_not_instance_lbl); | 398 __ jmp(is_not_instance_lbl); |
| 402 return false; | 399 return false; |
| 403 } | 400 } |
| 404 if (type.IsDartFunctionType()) { | |
| 405 // Check if instance is a closure. | |
| 406 __ cmpq(kClassIdReg, Immediate(kClosureCid)); | |
| 407 __ j(EQUAL, is_instance_lbl); | |
| 408 } | |
| 409 // Custom checking for numbers (Smi, Mint, Bigint and Double). | 401 // Custom checking for numbers (Smi, Mint, Bigint and Double). |
| 410 // Note that instance is not Smi (checked above). | 402 // Note that instance is not Smi (checked above). |
| 411 if (type.IsSubtypeOf( | 403 if (type.IsSubtypeOf( |
| 412 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) { | 404 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) { |
| 413 GenerateNumberTypeCheck( | 405 GenerateNumberTypeCheck( |
| 414 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); | 406 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); |
| 415 return false; | 407 return false; |
| 416 } | 408 } |
| 417 if (type.IsStringType()) { | 409 if (type.IsStringType()) { |
| 418 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); | 410 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); |
| 419 return false; | 411 return false; |
| 420 } | 412 } |
| 413 if (type.IsDartFunctionType()) { |
| 414 // Check if instance is a closure. |
| 415 __ cmpq(kClassIdReg, Immediate(kClosureCid)); |
| 416 __ j(EQUAL, is_instance_lbl); |
| 417 return true; |
| 418 } |
| 419 // Compare if the classes are equal. |
| 420 if (!type_class.is_abstract()) { |
| 421 __ cmpl(kClassIdReg, Immediate(type_class.id())); |
| 422 __ j(EQUAL, is_instance_lbl); |
| 423 } |
| 421 // Otherwise fallthrough. | 424 // Otherwise fallthrough. |
| 422 return true; | 425 return true; |
| 423 } | 426 } |
| 424 | 427 |
| 425 | 428 |
| 426 // Uses SubtypeTestCache to store instance class and result. | 429 // Uses SubtypeTestCache to store instance class and result. |
| 427 // RAX: instance to test. | 430 // RAX: instance to test. |
| 428 // Clobbers R10, R13. | 431 // Clobbers R10, R13. |
| 429 // Immediate class test already done. | 432 // Immediate class test already done. |
| 430 // TODO(srdjan): Implement a quicker subtype check, as type test | 433 // TODO(srdjan): Implement a quicker subtype check, as type test |
| (...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 __ movups(reg, Address(RSP, 0)); | 1865 __ movups(reg, Address(RSP, 0)); |
| 1863 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); | 1866 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); |
| 1864 } | 1867 } |
| 1865 | 1868 |
| 1866 | 1869 |
| 1867 #undef __ | 1870 #undef __ |
| 1868 | 1871 |
| 1869 } // namespace dart | 1872 } // namespace dart |
| 1870 | 1873 |
| 1871 #endif // defined TARGET_ARCH_X64 | 1874 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |