| 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 // - preserved instance in EAX and optional instantiator type arguments in EDX. | 509 // - preserved instance in EAX and optional instantiator type arguments in EDX. |
| 510 // Note that this inlined code must be followed by the runtime_call code, as it | 510 // Note that this inlined code must be followed by the runtime_call code, as it |
| 511 // may fall through to it. Otherwise, this inline code will jump to the label | 511 // may fall through to it. Otherwise, this inline code will jump to the label |
| 512 // is_instance or to the label is_not_instance. | 512 // is_instance or to the label is_not_instance. |
| 513 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof( | 513 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof( |
| 514 TokenPosition token_pos, | 514 TokenPosition token_pos, |
| 515 const AbstractType& type, | 515 const AbstractType& type, |
| 516 Label* is_instance_lbl, | 516 Label* is_instance_lbl, |
| 517 Label* is_not_instance_lbl) { | 517 Label* is_not_instance_lbl) { |
| 518 __ Comment("InlineInstanceof"); | 518 __ Comment("InlineInstanceof"); |
| 519 if (type.IsVoidType()) { | |
| 520 // A non-null value is returned from a void function, which will result in a | |
| 521 // type error. A null value is handled prior to executing this inline code. | |
| 522 return SubtypeTestCache::null(); | |
| 523 } | |
| 524 if (type.IsInstantiated()) { | 519 if (type.IsInstantiated()) { |
| 525 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); | 520 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); |
| 526 // A class equality check is only applicable with a dst type (not a | 521 // A class equality check is only applicable with a dst type (not a |
| 527 // function type) of a non-parameterized class or with a raw dst type of | 522 // function type) of a non-parameterized class or with a raw dst type of |
| 528 // a parameterized class. | 523 // a parameterized class. |
| 529 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) { | 524 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) { |
| 530 return GenerateInstantiatedTypeWithArgumentsTest( | 525 return GenerateInstantiatedTypeWithArgumentsTest( |
| 531 token_pos, type, is_instance_lbl, is_not_instance_lbl); | 526 token_pos, type, is_instance_lbl, is_not_instance_lbl); |
| 532 // Fall through to runtime call. | 527 // Fall through to runtime call. |
| 533 } | 528 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 557 // - EDX: instantiator type arguments or raw_null. | 552 // - EDX: instantiator type arguments or raw_null. |
| 558 // Clobbers EDX. | 553 // Clobbers EDX. |
| 559 // Returns: | 554 // Returns: |
| 560 // - true or false in EAX. | 555 // - true or false in EAX. |
| 561 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, | 556 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, |
| 562 intptr_t deopt_id, | 557 intptr_t deopt_id, |
| 563 const AbstractType& type, | 558 const AbstractType& type, |
| 564 bool negate_result, | 559 bool negate_result, |
| 565 LocationSummary* locs) { | 560 LocationSummary* locs) { |
| 566 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); | 561 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); |
| 567 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); | 562 ASSERT(!type.IsObjectType() && !type.IsDynamicType() && !type.IsVoidType()); |
| 568 | 563 |
| 569 const Immediate& raw_null = | 564 const Immediate& raw_null = |
| 570 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 565 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 571 Label is_instance, is_not_instance; | 566 Label is_instance, is_not_instance; |
| 572 __ pushl(EDX); // Store instantiator type arguments. | 567 __ pushl(EDX); // Store instantiator type arguments. |
| 573 // If type is instantiated and non-parameterized, we can inline code | 568 // If type is instantiated and non-parameterized, we can inline code |
| 574 // checking whether the tested instance is a Smi. | 569 // checking whether the tested instance is a Smi. |
| 575 if (type.IsInstantiated()) { | 570 if (type.IsInstantiated()) { |
| 576 // A null object is only an instance of Null, Object, and dynamic. | 571 // A null object is only an instance of Null, Object, and dynamic. |
| 577 // Object and dynamic have already been checked above (if the type is | 572 // Object and dynamic have already been checked above (if the type is |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 void FlowGraphCompiler::GenerateAssertAssignable(TokenPosition token_pos, | 635 void FlowGraphCompiler::GenerateAssertAssignable(TokenPosition token_pos, |
| 641 intptr_t deopt_id, | 636 intptr_t deopt_id, |
| 642 const AbstractType& dst_type, | 637 const AbstractType& dst_type, |
| 643 const String& dst_name, | 638 const String& dst_name, |
| 644 LocationSummary* locs) { | 639 LocationSummary* locs) { |
| 645 ASSERT(!token_pos.IsClassifying()); | 640 ASSERT(!token_pos.IsClassifying()); |
| 646 ASSERT(!dst_type.IsNull()); | 641 ASSERT(!dst_type.IsNull()); |
| 647 ASSERT(dst_type.IsFinalized()); | 642 ASSERT(dst_type.IsFinalized()); |
| 648 // Assignable check is skipped in FlowGraphBuilder, not here. | 643 // Assignable check is skipped in FlowGraphBuilder, not here. |
| 649 ASSERT(dst_type.IsMalformedOrMalbounded() || | 644 ASSERT(dst_type.IsMalformedOrMalbounded() || |
| 650 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); | 645 (!dst_type.IsDynamicType() && !dst_type.IsObjectType() && |
| 646 !dst_type.IsVoidType())); |
| 651 __ pushl(EDX); // Store instantiator type arguments. | 647 __ pushl(EDX); // Store instantiator type arguments. |
| 652 // A null object is always assignable and is returned as result. | 648 // A null object is always assignable and is returned as result. |
| 653 const Immediate& raw_null = | 649 const Immediate& raw_null = |
| 654 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 650 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 655 Label is_assignable, runtime_call; | 651 Label is_assignable, runtime_call; |
| 656 __ cmpl(EAX, raw_null); | 652 __ cmpl(EAX, raw_null); |
| 657 __ j(EQUAL, &is_assignable); | 653 __ j(EQUAL, &is_assignable); |
| 658 | 654 |
| 659 // Generate throw new TypeError() if the type is malformed or malbounded. | 655 // Generate throw new TypeError() if the type is malformed or malbounded. |
| 660 if (dst_type.IsMalformedOrMalbounded()) { | 656 if (dst_type.IsMalformedOrMalbounded()) { |
| (...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 __ movups(reg, Address(ESP, 0)); | 1766 __ movups(reg, Address(ESP, 0)); |
| 1771 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1767 __ addl(ESP, Immediate(kFpuRegisterSize)); |
| 1772 } | 1768 } |
| 1773 | 1769 |
| 1774 | 1770 |
| 1775 #undef __ | 1771 #undef __ |
| 1776 | 1772 |
| 1777 } // namespace dart | 1773 } // namespace dart |
| 1778 | 1774 |
| 1779 #endif // defined TARGET_ARCH_IA32 | 1775 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |