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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 return SubtypeTestCache::null(); | 547 return SubtypeTestCache::null(); |
548 } | 548 } |
549 } | 549 } |
550 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl, | 550 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl, |
551 is_not_instance_lbl); | 551 is_not_instance_lbl); |
552 } | 552 } |
553 | 553 |
554 | 554 |
555 // If instanceof type test cannot be performed successfully at compile time and | 555 // If instanceof type test cannot be performed successfully at compile time and |
556 // therefore eliminated, optimize it by adding inlined tests for: | 556 // therefore eliminated, optimize it by adding inlined tests for: |
557 // - NULL -> return false. | 557 // - NULL -> return type == Null (type is not Object or dynamic). |
558 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 558 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
559 // - Class equality (only if class is not parameterized). | 559 // - Class equality (only if class is not parameterized). |
560 // Inputs: | 560 // Inputs: |
561 // - EAX: object. | 561 // - EAX: object. |
562 // - EDX: instantiator type arguments or raw_null. | 562 // - EDX: instantiator type arguments or raw_null. |
563 // Clobbers EDX. | 563 // Clobbers EDX. |
564 // Returns: | 564 // Returns: |
565 // - true or false in EAX. | 565 // - true or false in EAX. |
566 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, | 566 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, |
567 intptr_t deopt_id, | 567 intptr_t deopt_id, |
568 const AbstractType& type, | 568 const AbstractType& type, |
569 bool negate_result, | 569 bool negate_result, |
570 LocationSummary* locs) { | 570 LocationSummary* locs) { |
571 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); | 571 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); |
| 572 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); |
572 | 573 |
573 const Immediate& raw_null = | 574 const Immediate& raw_null = |
574 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 575 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
575 Label is_instance, is_not_instance; | 576 Label is_instance, is_not_instance; |
576 __ pushl(EDX); // Store instantiator type arguments. | 577 __ pushl(EDX); // Store instantiator type arguments. |
577 // If type is instantiated and non-parameterized, we can inline code | 578 // If type is instantiated and non-parameterized, we can inline code |
578 // checking whether the tested instance is a Smi. | 579 // checking whether the tested instance is a Smi. |
579 if (type.IsInstantiated()) { | 580 if (type.IsInstantiated()) { |
580 // A null object is only an instance of Object and dynamic, which has | 581 // A null object is only an instance of Null, Object, and dynamic. |
581 // already been checked above (if the type is instantiated). So we can | 582 // Object and dynamic have already been checked above (if the type is |
582 // return false here if the instance is null (and if the type is | 583 // instantiated). So we can return false here if the instance is null, |
583 // instantiated). | 584 // unless the type is Null (and if the type is instantiated). |
584 // We can only inline this null check if the type is instantiated at compile | 585 // We can only inline this null check if the type is instantiated at compile |
585 // time, since an uninstantiated type at compile time could be Object or | 586 // time, since an uninstantiated type at compile time could be Null, Object, |
586 // dynamic at run time. | 587 // or dynamic at run time. |
587 __ cmpl(EAX, raw_null); | 588 __ cmpl(EAX, raw_null); |
588 __ j(EQUAL, type.IsNullType() ? &is_instance : &is_not_instance); | 589 __ j(EQUAL, type.IsNullType() ? &is_instance : &is_not_instance); |
589 } | 590 } |
590 | 591 |
591 // Generate inline instanceof test. | 592 // Generate inline instanceof test. |
592 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone()); | 593 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone()); |
593 test_cache = | 594 test_cache = |
594 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance); | 595 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance); |
595 | 596 |
596 // test_cache is null if there is no fall-through. | 597 // test_cache is null if there is no fall-through. |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 __ movups(reg, Address(ESP, 0)); | 1775 __ movups(reg, Address(ESP, 0)); |
1775 __ addl(ESP, Immediate(kFpuRegisterSize)); | 1776 __ addl(ESP, Immediate(kFpuRegisterSize)); |
1776 } | 1777 } |
1777 | 1778 |
1778 | 1779 |
1779 #undef __ | 1780 #undef __ |
1780 | 1781 |
1781 } // namespace dart | 1782 } // namespace dart |
1782 | 1783 |
1783 #endif // defined TARGET_ARCH_IA32 | 1784 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |