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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 // optional function type arguments in RCX. | 531 // optional function type arguments in RCX. |
532 // Note that this inlined code must be followed by the runtime_call code, as it | 532 // Note that this inlined code must be followed by the runtime_call code, as it |
533 // may fall through to it. Otherwise, this inline code will jump to the label | 533 // may fall through to it. Otherwise, this inline code will jump to the label |
534 // is_instance or to the label is_not_instance. | 534 // is_instance or to the label is_not_instance. |
535 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof( | 535 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof( |
536 TokenPosition token_pos, | 536 TokenPosition token_pos, |
537 const AbstractType& type, | 537 const AbstractType& type, |
538 Label* is_instance_lbl, | 538 Label* is_instance_lbl, |
539 Label* is_not_instance_lbl) { | 539 Label* is_not_instance_lbl) { |
540 __ Comment("InlineInstanceof"); | 540 __ Comment("InlineInstanceof"); |
| 541 if (type.IsVoidType()) { |
| 542 // A non-null value is returned from a void function, which will result in a |
| 543 // type error. A null value is handled prior to executing this inline code. |
| 544 return SubtypeTestCache::null(); |
| 545 } |
541 if (type.IsInstantiated()) { | 546 if (type.IsInstantiated()) { |
542 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); | 547 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); |
543 // A class equality check is only applicable with a dst type (not a | 548 // 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 | 549 // function type) of a non-parameterized class or with a raw dst type of |
545 // a parameterized class. | 550 // a parameterized class. |
546 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) { | 551 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) { |
547 return GenerateInstantiatedTypeWithArgumentsTest( | 552 return GenerateInstantiatedTypeWithArgumentsTest( |
548 token_pos, type, is_instance_lbl, is_not_instance_lbl); | 553 token_pos, type, is_instance_lbl, is_not_instance_lbl); |
549 // Fall through to runtime call. | 554 // Fall through to runtime call. |
550 } | 555 } |
(...skipping 22 matching lines...) Expand all Loading... |
573 // - EAX: object. | 578 // - EAX: object. |
574 // - EDX: instantiator type arguments or raw_null. | 579 // - EDX: instantiator type arguments or raw_null. |
575 // - ECX: function type arguments or raw_null. | 580 // - ECX: function type arguments or raw_null. |
576 // Returns: | 581 // Returns: |
577 // - true or false in EAX. | 582 // - true or false in EAX. |
578 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, | 583 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, |
579 intptr_t deopt_id, | 584 intptr_t deopt_id, |
580 const AbstractType& type, | 585 const AbstractType& type, |
581 LocationSummary* locs) { | 586 LocationSummary* locs) { |
582 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); | 587 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); |
583 ASSERT(!type.IsObjectType() && !type.IsDynamicType() && !type.IsVoidType()); | 588 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); |
584 | 589 |
585 __ pushl(EDX); // Store instantiator type arguments. | 590 __ pushl(EDX); // Store instantiator type arguments. |
586 __ pushl(ECX); // Store function type arguments. | 591 __ pushl(ECX); // Store function type arguments. |
587 | 592 |
588 const Immediate& raw_null = | 593 const Immediate& raw_null = |
589 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 594 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
590 Label is_instance, is_not_instance; | 595 Label is_instance, is_not_instance; |
591 // If type is instantiated and non-parameterized, we can inline code | 596 // If type is instantiated and non-parameterized, we can inline code |
592 // checking whether the tested instance is a Smi. | 597 // checking whether the tested instance is a Smi. |
593 if (type.IsInstantiated()) { | 598 if (type.IsInstantiated()) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 void FlowGraphCompiler::GenerateAssertAssignable(TokenPosition token_pos, | 659 void FlowGraphCompiler::GenerateAssertAssignable(TokenPosition token_pos, |
655 intptr_t deopt_id, | 660 intptr_t deopt_id, |
656 const AbstractType& dst_type, | 661 const AbstractType& dst_type, |
657 const String& dst_name, | 662 const String& dst_name, |
658 LocationSummary* locs) { | 663 LocationSummary* locs) { |
659 ASSERT(!token_pos.IsClassifying()); | 664 ASSERT(!token_pos.IsClassifying()); |
660 ASSERT(!dst_type.IsNull()); | 665 ASSERT(!dst_type.IsNull()); |
661 ASSERT(dst_type.IsFinalized()); | 666 ASSERT(dst_type.IsFinalized()); |
662 // Assignable check is skipped in FlowGraphBuilder, not here. | 667 // Assignable check is skipped in FlowGraphBuilder, not here. |
663 ASSERT(dst_type.IsMalformedOrMalbounded() || | 668 ASSERT(dst_type.IsMalformedOrMalbounded() || |
664 (!dst_type.IsDynamicType() && !dst_type.IsObjectType() && | 669 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); |
665 !dst_type.IsVoidType())); | |
666 __ pushl(EDX); // Store instantiator type arguments. | 670 __ pushl(EDX); // Store instantiator type arguments. |
667 __ pushl(ECX); // Store function type arguments. | 671 __ pushl(ECX); // Store function type arguments. |
668 // A null object is always assignable and is returned as result. | 672 // A null object is always assignable and is returned as result. |
669 const Immediate& raw_null = | 673 const Immediate& raw_null = |
670 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 674 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
671 Label is_assignable, runtime_call; | 675 Label is_assignable, runtime_call; |
672 __ cmpl(EAX, raw_null); | 676 __ cmpl(EAX, raw_null); |
673 __ j(EQUAL, &is_assignable); | 677 __ j(EQUAL, &is_assignable); |
674 | 678 |
675 // Generate throw new TypeError() if the type is malformed or malbounded. | 679 // Generate throw new TypeError() if the type is malformed or malbounded. |
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 __ movups(reg, Address(ESP, 0)); | 1733 __ movups(reg, Address(ESP, 0)); |
1730 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1734 __ addl(ESP, Immediate(kFpuRegisterSize)); |
1731 } | 1735 } |
1732 | 1736 |
1733 | 1737 |
1734 #undef __ | 1738 #undef __ |
1735 | 1739 |
1736 } // namespace dart | 1740 } // namespace dart |
1737 | 1741 |
1738 #endif // defined TARGET_ARCH_IA32 | 1742 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |