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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 // - EDX: instantiator type arguments or raw_null. | 565 // - EDX: instantiator type arguments or raw_null. |
566 // - ECX: instantiator or raw_null. | 566 // - ECX: instantiator or raw_null. |
567 // Clobbers ECX and EDX. | 567 // Clobbers ECX and EDX. |
568 // Returns: | 568 // Returns: |
569 // - true or false in EAX. | 569 // - true or false in EAX. |
570 void FlowGraphCompiler::GenerateInstanceOf(intptr_t token_pos, | 570 void FlowGraphCompiler::GenerateInstanceOf(intptr_t token_pos, |
571 intptr_t deopt_id, | 571 intptr_t deopt_id, |
572 const AbstractType& type, | 572 const AbstractType& type, |
573 bool negate_result, | 573 bool negate_result, |
574 LocationSummary* locs) { | 574 LocationSummary* locs) { |
575 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); | 575 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); |
576 | 576 |
577 const Immediate& raw_null = | 577 const Immediate& raw_null = |
578 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 578 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
579 Label is_instance, is_not_instance; | 579 Label is_instance, is_not_instance; |
580 __ pushl(ECX); // Store instantiator on stack. | 580 __ pushl(ECX); // Store instantiator on stack. |
581 __ pushl(EDX); // Store instantiator type arguments. | 581 __ pushl(EDX); // Store instantiator type arguments. |
582 // If type is instantiated and non-parameterized, we can inline code | 582 // If type is instantiated and non-parameterized, we can inline code |
583 // checking whether the tested instance is a Smi. | 583 // checking whether the tested instance is a Smi. |
584 if (type.IsInstantiated()) { | 584 if (type.IsInstantiated()) { |
585 // A null object is only an instance of Object and dynamic, which has | 585 // A null object is only an instance of Object and dynamic, which has |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 // as they throw an exception. | 656 // as they throw an exception. |
657 void FlowGraphCompiler::GenerateAssertAssignable(intptr_t token_pos, | 657 void FlowGraphCompiler::GenerateAssertAssignable(intptr_t token_pos, |
658 intptr_t deopt_id, | 658 intptr_t deopt_id, |
659 const AbstractType& dst_type, | 659 const AbstractType& dst_type, |
660 const String& dst_name, | 660 const String& dst_name, |
661 LocationSummary* locs) { | 661 LocationSummary* locs) { |
662 ASSERT(token_pos >= 0); | 662 ASSERT(token_pos >= 0); |
663 ASSERT(!dst_type.IsNull()); | 663 ASSERT(!dst_type.IsNull()); |
664 ASSERT(dst_type.IsFinalized()); | 664 ASSERT(dst_type.IsFinalized()); |
665 // Assignable check is skipped in FlowGraphBuilder, not here. | 665 // Assignable check is skipped in FlowGraphBuilder, not here. |
666 ASSERT(dst_type.IsMalformed() || dst_type.IsMalbounded() || | 666 ASSERT(dst_type.IsMalformedOrMalbounded() || |
667 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); | 667 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); |
668 __ pushl(ECX); // Store instantiator. | 668 __ pushl(ECX); // Store instantiator. |
669 __ pushl(EDX); // Store instantiator type arguments. | 669 __ pushl(EDX); // Store instantiator type arguments. |
670 // A null object is always assignable and is returned as result. | 670 // A null object is always assignable and is returned as result. |
671 const Immediate& raw_null = | 671 const Immediate& raw_null = |
672 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 672 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
673 Label is_assignable, runtime_call; | 673 Label is_assignable, runtime_call; |
674 __ cmpl(EAX, raw_null); | 674 __ cmpl(EAX, raw_null); |
675 __ j(EQUAL, &is_assignable); | 675 __ j(EQUAL, &is_assignable); |
676 | 676 |
677 if (!FLAG_eliminate_type_checks || dst_type.IsMalformed()) { | 677 if (!FLAG_eliminate_type_checks || dst_type.IsMalformed()) { |
678 // If type checks are not eliminated during the graph building then | 678 // If type checks are not eliminated during the graph building then |
679 // a transition sentinel can be seen here. | 679 // a transition sentinel can be seen here. |
680 const Immediate& raw_transition_sentinel = | 680 const Immediate& raw_transition_sentinel = |
681 Immediate(reinterpret_cast<intptr_t>( | 681 Immediate(reinterpret_cast<intptr_t>( |
682 Object::transition_sentinel().raw())); | 682 Object::transition_sentinel().raw())); |
683 __ cmpl(EAX, raw_transition_sentinel); | 683 __ cmpl(EAX, raw_transition_sentinel); |
684 __ j(EQUAL, &is_assignable); | 684 __ j(EQUAL, &is_assignable); |
685 } | 685 } |
686 | 686 |
687 // Generate throw new TypeError() if the type is malformed or malbounded. | 687 // Generate throw new TypeError() if the type is malformed or malbounded. |
688 if (dst_type.IsMalformed() || dst_type.IsMalbounded()) { | 688 if (dst_type.IsMalformedOrMalbounded()) { |
689 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 689 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
690 __ pushl(EAX); // Push the source object. | 690 __ pushl(EAX); // Push the source object. |
691 __ PushObject(dst_name); // Push the name of the destination. | 691 __ PushObject(dst_name); // Push the name of the destination. |
692 __ PushObject(dst_type); // Push the type of the destination. | 692 __ PushObject(dst_type); // Push the type of the destination. |
693 GenerateRuntimeCall(token_pos, | 693 GenerateRuntimeCall(token_pos, |
694 deopt_id, | 694 deopt_id, |
695 kBadTypeErrorRuntimeEntry, | 695 kBadTypeErrorRuntimeEntry, |
696 3, | 696 3, |
697 locs); | 697 locs); |
698 // We should never return here. | 698 // We should never return here. |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1878 __ movups(reg, Address(ESP, 0)); | 1878 __ movups(reg, Address(ESP, 0)); |
1879 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1879 __ addl(ESP, Immediate(kFpuRegisterSize)); |
1880 } | 1880 } |
1881 | 1881 |
1882 | 1882 |
1883 #undef __ | 1883 #undef __ |
1884 | 1884 |
1885 } // namespace dart | 1885 } // namespace dart |
1886 | 1886 |
1887 #endif // defined TARGET_ARCH_IA32 | 1887 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |