OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. |
6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 // optional function type arguments in R2. | 517 // optional function type arguments in R2. |
518 // Note that this inlined code must be followed by the runtime_call code, as it | 518 // Note that this inlined code must be followed by the runtime_call code, as it |
519 // may fall through to it. Otherwise, this inline code will jump to the label | 519 // may fall through to it. Otherwise, this inline code will jump to the label |
520 // is_instance or to the label is_not_instance. | 520 // is_instance or to the label is_not_instance. |
521 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof( | 521 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof( |
522 TokenPosition token_pos, | 522 TokenPosition token_pos, |
523 const AbstractType& type, | 523 const AbstractType& type, |
524 Label* is_instance_lbl, | 524 Label* is_instance_lbl, |
525 Label* is_not_instance_lbl) { | 525 Label* is_not_instance_lbl) { |
526 __ Comment("InlineInstanceof"); | 526 __ Comment("InlineInstanceof"); |
| 527 if (type.IsVoidType()) { |
| 528 // A non-null value is returned from a void function, which will result in a |
| 529 // type error. A null value is handled prior to executing this inline code. |
| 530 return SubtypeTestCache::null(); |
| 531 } |
527 if (type.IsInstantiated()) { | 532 if (type.IsInstantiated()) { |
528 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); | 533 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); |
529 // A class equality check is only applicable with a dst type (not a | 534 // A class equality check is only applicable with a dst type (not a |
530 // function type) of a non-parameterized class or with a raw dst type of | 535 // function type) of a non-parameterized class or with a raw dst type of |
531 // a parameterized class. | 536 // a parameterized class. |
532 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) { | 537 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) { |
533 return GenerateInstantiatedTypeWithArgumentsTest( | 538 return GenerateInstantiatedTypeWithArgumentsTest( |
534 token_pos, type, is_instance_lbl, is_not_instance_lbl); | 539 token_pos, type, is_instance_lbl, is_not_instance_lbl); |
535 // Fall through to runtime call. | 540 // Fall through to runtime call. |
536 } | 541 } |
(...skipping 22 matching lines...) Expand all Loading... |
559 // - R0: object. | 564 // - R0: object. |
560 // - R1: instantiator type arguments or raw_null. | 565 // - R1: instantiator type arguments or raw_null. |
561 // - R2: function type arguments or raw_null. | 566 // - R2: function type arguments or raw_null. |
562 // Returns: | 567 // Returns: |
563 // - true or false in R0. | 568 // - true or false in R0. |
564 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, | 569 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, |
565 intptr_t deopt_id, | 570 intptr_t deopt_id, |
566 const AbstractType& type, | 571 const AbstractType& type, |
567 LocationSummary* locs) { | 572 LocationSummary* locs) { |
568 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); | 573 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); |
569 ASSERT(!type.IsObjectType() && !type.IsDynamicType() && !type.IsVoidType()); | 574 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); |
570 const Register kInstantiatorTypeArgumentsReg = R1; | 575 const Register kInstantiatorTypeArgumentsReg = R1; |
571 const Register kFunctionTypeArgumentsReg = R2; | 576 const Register kFunctionTypeArgumentsReg = R2; |
572 __ PushPair(kFunctionTypeArgumentsReg, kInstantiatorTypeArgumentsReg); | 577 __ PushPair(kFunctionTypeArgumentsReg, kInstantiatorTypeArgumentsReg); |
573 Label is_instance, is_not_instance; | 578 Label is_instance, is_not_instance; |
574 // If type is instantiated and non-parameterized, we can inline code | 579 // If type is instantiated and non-parameterized, we can inline code |
575 // checking whether the tested instance is a Smi. | 580 // checking whether the tested instance is a Smi. |
576 if (type.IsInstantiated()) { | 581 if (type.IsInstantiated()) { |
577 // A null object is only an instance of Null, Object, and dynamic. | 582 // A null object is only an instance of Null, Object, and dynamic. |
578 // Object and dynamic have already been checked above (if the type is | 583 // Object and dynamic have already been checked above (if the type is |
579 // instantiated). So we can return false here if the instance is null, | 584 // instantiated). So we can return false here if the instance is null, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 void FlowGraphCompiler::GenerateAssertAssignable(TokenPosition token_pos, | 643 void FlowGraphCompiler::GenerateAssertAssignable(TokenPosition token_pos, |
639 intptr_t deopt_id, | 644 intptr_t deopt_id, |
640 const AbstractType& dst_type, | 645 const AbstractType& dst_type, |
641 const String& dst_name, | 646 const String& dst_name, |
642 LocationSummary* locs) { | 647 LocationSummary* locs) { |
643 ASSERT(!TokenPosition(token_pos).IsClassifying()); | 648 ASSERT(!TokenPosition(token_pos).IsClassifying()); |
644 ASSERT(!dst_type.IsNull()); | 649 ASSERT(!dst_type.IsNull()); |
645 ASSERT(dst_type.IsFinalized()); | 650 ASSERT(dst_type.IsFinalized()); |
646 // Assignable check is skipped in FlowGraphBuilder, not here. | 651 // Assignable check is skipped in FlowGraphBuilder, not here. |
647 ASSERT(dst_type.IsMalformedOrMalbounded() || | 652 ASSERT(dst_type.IsMalformedOrMalbounded() || |
648 (!dst_type.IsDynamicType() && !dst_type.IsObjectType() && | 653 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); |
649 !dst_type.IsVoidType())); | |
650 const Register kInstantiatorTypeArgumentsReg = R1; | 654 const Register kInstantiatorTypeArgumentsReg = R1; |
651 const Register kFunctionTypeArgumentsReg = R2; | 655 const Register kFunctionTypeArgumentsReg = R2; |
652 __ PushPair(kFunctionTypeArgumentsReg, kInstantiatorTypeArgumentsReg); | 656 __ PushPair(kFunctionTypeArgumentsReg, kInstantiatorTypeArgumentsReg); |
653 // A null object is always assignable and is returned as result. | 657 // A null object is always assignable and is returned as result. |
654 Label is_assignable, runtime_call; | 658 Label is_assignable, runtime_call; |
655 __ CompareObject(R0, Object::null_object()); | 659 __ CompareObject(R0, Object::null_object()); |
656 __ b(&is_assignable, EQ); | 660 __ b(&is_assignable, EQ); |
657 | 661 |
658 // Generate throw new TypeError() if the type is malformed or malbounded. | 662 // Generate throw new TypeError() if the type is malformed or malbounded. |
659 if (dst_type.IsMalformedOrMalbounded()) { | 663 if (dst_type.IsMalformedOrMalbounded()) { |
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 1776 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
1773 __ PopDouble(reg); | 1777 __ PopDouble(reg); |
1774 } | 1778 } |
1775 | 1779 |
1776 | 1780 |
1777 #undef __ | 1781 #undef __ |
1778 | 1782 |
1779 } // namespace dart | 1783 } // namespace dart |
1780 | 1784 |
1781 #endif // defined TARGET_ARCH_ARM64 | 1785 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |