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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 // optional function type arguments in RCX. | 526 // optional function type arguments in RCX. |
527 // Note that this inlined code must be followed by the runtime_call code, as it | 527 // Note that this inlined code must be followed by the runtime_call code, as it |
528 // may fall through to it. Otherwise, this inline code will jump to the label | 528 // may fall through to it. Otherwise, this inline code will jump to the label |
529 // is_instance or to the label is_not_instance. | 529 // is_instance or to the label is_not_instance. |
530 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof( | 530 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof( |
531 TokenPosition token_pos, | 531 TokenPosition token_pos, |
532 const AbstractType& type, | 532 const AbstractType& type, |
533 Label* is_instance_lbl, | 533 Label* is_instance_lbl, |
534 Label* is_not_instance_lbl) { | 534 Label* is_not_instance_lbl) { |
535 __ Comment("InlineInstanceof"); | 535 __ Comment("InlineInstanceof"); |
536 if (type.IsVoidType()) { | |
537 // A non-null value is returned from a void function, which will result in a | |
538 // type error. A null value is handled prior to executing this inline code. | |
539 return SubtypeTestCache::null(); | |
540 } | |
541 if (type.IsInstantiated()) { | 536 if (type.IsInstantiated()) { |
542 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); | 537 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); |
543 // A class equality check is only applicable with a dst type (not a | 538 // A class equality check is only applicable with a dst type (not a |
544 // function type) of a non-parameterized class or with a raw dst type of | 539 // function type) of a non-parameterized class or with a raw dst type of |
545 // a parameterized class. | 540 // a parameterized class. |
546 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) { | 541 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) { |
547 return GenerateInstantiatedTypeWithArgumentsTest( | 542 return GenerateInstantiatedTypeWithArgumentsTest( |
548 token_pos, type, is_instance_lbl, is_not_instance_lbl); | 543 token_pos, type, is_instance_lbl, is_not_instance_lbl); |
549 // Fall through to runtime call. | 544 // Fall through to runtime call. |
550 } | 545 } |
(...skipping 22 matching lines...) Expand all Loading... |
573 // - RAX: object. | 568 // - RAX: object. |
574 // - RDX: instantiator type arguments or raw_null. | 569 // - RDX: instantiator type arguments or raw_null. |
575 // - RCX: function type arguments or raw_null. | 570 // - RCX: function type arguments or raw_null. |
576 // Returns: | 571 // Returns: |
577 // - true or false in RAX. | 572 // - true or false in RAX. |
578 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, | 573 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, |
579 intptr_t deopt_id, | 574 intptr_t deopt_id, |
580 const AbstractType& type, | 575 const AbstractType& type, |
581 LocationSummary* locs) { | 576 LocationSummary* locs) { |
582 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); | 577 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); |
583 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); | 578 ASSERT(!type.IsObjectType() && !type.IsDynamicType() && !type.IsVoidType()); |
584 | 579 |
585 __ pushq(RDX); // Store instantiator type arguments. | 580 __ pushq(RDX); // Store instantiator type arguments. |
586 __ pushq(RCX); // Store function type arguments. | 581 __ pushq(RCX); // Store function type arguments. |
587 | 582 |
588 Label is_instance, is_not_instance; | 583 Label is_instance, is_not_instance; |
589 // If type is instantiated and non-parameterized, we can inline code | 584 // If type is instantiated and non-parameterized, we can inline code |
590 // checking whether the tested instance is a Smi. | 585 // checking whether the tested instance is a Smi. |
591 if (type.IsInstantiated()) { | 586 if (type.IsInstantiated()) { |
592 // A null object is only an instance of Null, Object, and dynamic. | 587 // A null object is only an instance of Null, Object, void and dynamic. |
593 // Object and dynamic have already been checked above (if the type is | 588 // Object void and dynamic have already been checked above (if the type is |
594 // instantiated). So we can return false here if the instance is null, | 589 // instantiated). So we can return false here if the instance is null, |
595 // unless the type is Null (and if the type is instantiated). | 590 // unless the type is Null (and if the type is instantiated). |
596 // We can only inline this null check if the type is instantiated at compile | 591 // We can only inline this null check if the type is instantiated at compile |
597 // time, since an uninstantiated type at compile time could be Null, Object, | 592 // time, since an uninstantiated type at compile time could be Null, Object, |
598 // or dynamic at run time. | 593 // or dynamic at run time. |
599 __ CompareObject(RAX, Object::null_object()); | 594 __ CompareObject(RAX, Object::null_object()); |
600 __ j(EQUAL, type.IsNullType() ? &is_instance : &is_not_instance); | 595 __ j(EQUAL, type.IsNullType() ? &is_instance : &is_not_instance); |
601 } | 596 } |
602 | 597 |
603 // Generate inline instanceof test. | 598 // Generate inline instanceof test. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 void FlowGraphCompiler::GenerateAssertAssignable(TokenPosition token_pos, | 647 void FlowGraphCompiler::GenerateAssertAssignable(TokenPosition token_pos, |
653 intptr_t deopt_id, | 648 intptr_t deopt_id, |
654 const AbstractType& dst_type, | 649 const AbstractType& dst_type, |
655 const String& dst_name, | 650 const String& dst_name, |
656 LocationSummary* locs) { | 651 LocationSummary* locs) { |
657 ASSERT(!token_pos.IsClassifying()); | 652 ASSERT(!token_pos.IsClassifying()); |
658 ASSERT(!dst_type.IsNull()); | 653 ASSERT(!dst_type.IsNull()); |
659 ASSERT(dst_type.IsFinalized()); | 654 ASSERT(dst_type.IsFinalized()); |
660 // Assignable check is skipped in FlowGraphBuilder, not here. | 655 // Assignable check is skipped in FlowGraphBuilder, not here. |
661 ASSERT(dst_type.IsMalformedOrMalbounded() || | 656 ASSERT(dst_type.IsMalformedOrMalbounded() || |
662 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); | 657 (!dst_type.IsDynamicType() && !dst_type.IsObjectType() && |
| 658 !dst_type.IsVoidType())); |
663 __ pushq(RDX); // Store instantiator type arguments. | 659 __ pushq(RDX); // Store instantiator type arguments. |
664 __ pushq(RCX); // Store function type arguments. | 660 __ pushq(RCX); // Store function type arguments. |
665 // A null object is always assignable and is returned as result. | 661 // A null object is always assignable and is returned as result. |
666 Label is_assignable, runtime_call; | 662 Label is_assignable, runtime_call; |
667 __ CompareObject(RAX, Object::null_object()); | 663 __ CompareObject(RAX, Object::null_object()); |
668 __ j(EQUAL, &is_assignable); | 664 __ j(EQUAL, &is_assignable); |
669 | 665 |
670 // Generate throw new TypeError() if the type is malformed or malbounded. | 666 // Generate throw new TypeError() if the type is malformed or malbounded. |
671 if (dst_type.IsMalformedOrMalbounded()) { | 667 if (dst_type.IsMalformedOrMalbounded()) { |
672 __ PushObject(Object::null_object()); // Make room for the result. | 668 __ PushObject(Object::null_object()); // Make room for the result. |
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1724 __ movups(reg, Address(RSP, 0)); | 1720 __ movups(reg, Address(RSP, 0)); |
1725 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); | 1721 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); |
1726 } | 1722 } |
1727 | 1723 |
1728 | 1724 |
1729 #undef __ | 1725 #undef __ |
1730 | 1726 |
1731 } // namespace dart | 1727 } // namespace dart |
1732 | 1728 |
1733 #endif // defined TARGET_ARCH_X64 | 1729 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |