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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 // - Class equality (only if class is not parameterized). | 549 // - Class equality (only if class is not parameterized). |
550 // Inputs: | 550 // Inputs: |
551 // - RAX: object. | 551 // - RAX: object. |
552 // - RDX: instantiator type arguments or raw_null. | 552 // - RDX: instantiator type arguments or raw_null. |
553 // Clobbers RDX. | 553 // Clobbers RDX. |
554 // Returns: | 554 // Returns: |
555 // - true or false in RAX. | 555 // - true or false in RAX. |
556 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, | 556 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, |
557 intptr_t deopt_id, | 557 intptr_t deopt_id, |
558 const AbstractType& type, | 558 const AbstractType& type, |
| 559 bool negate_result, |
559 LocationSummary* locs) { | 560 LocationSummary* locs) { |
560 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); | 561 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); |
561 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); | 562 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); |
562 | 563 |
563 Label is_instance, is_not_instance; | 564 Label is_instance, is_not_instance; |
564 __ pushq(RDX); // Store instantiator type arguments. | 565 __ pushq(RDX); // Store instantiator type arguments. |
565 // If type is instantiated and non-parameterized, we can inline code | 566 // If type is instantiated and non-parameterized, we can inline code |
566 // checking whether the tested instance is a Smi. | 567 // checking whether the tested instance is a Smi. |
567 if (type.IsInstantiated()) { | 568 if (type.IsInstantiated()) { |
568 // A null object is only an instance of Null, Object, and dynamic. | 569 // A null object is only an instance of Null, Object, and dynamic. |
(...skipping 20 matching lines...) Expand all Loading... |
589 __ PushObject(Object::null_object()); // Make room for the result. | 590 __ PushObject(Object::null_object()); // Make room for the result. |
590 __ pushq(RAX); // Push the instance. | 591 __ pushq(RAX); // Push the instance. |
591 __ PushObject(type); // Push the type. | 592 __ PushObject(type); // Push the type. |
592 __ pushq(RDX); // Instantiator type arguments. | 593 __ pushq(RDX); // Instantiator type arguments. |
593 __ LoadUniqueObject(RAX, test_cache); | 594 __ LoadUniqueObject(RAX, test_cache); |
594 __ pushq(RAX); | 595 __ pushq(RAX); |
595 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 4, locs); | 596 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 4, locs); |
596 // Pop the parameters supplied to the runtime entry. The result of the | 597 // Pop the parameters supplied to the runtime entry. The result of the |
597 // instanceof runtime call will be left as the result of the operation. | 598 // instanceof runtime call will be left as the result of the operation. |
598 __ Drop(4); | 599 __ Drop(4); |
599 __ popq(RAX); | 600 if (negate_result) { |
| 601 __ popq(RDX); |
| 602 __ LoadObject(RAX, Bool::True()); |
| 603 __ cmpq(RDX, RAX); |
| 604 __ j(NOT_EQUAL, &done, Assembler::kNearJump); |
| 605 __ LoadObject(RAX, Bool::False()); |
| 606 } else { |
| 607 __ popq(RAX); |
| 608 } |
600 __ jmp(&done, Assembler::kNearJump); | 609 __ jmp(&done, Assembler::kNearJump); |
601 } | 610 } |
602 __ Bind(&is_not_instance); | 611 __ Bind(&is_not_instance); |
603 __ LoadObject(RAX, Bool::Get(false)); | 612 __ LoadObject(RAX, Bool::Get(negate_result)); |
604 __ jmp(&done, Assembler::kNearJump); | 613 __ jmp(&done, Assembler::kNearJump); |
605 | 614 |
606 __ Bind(&is_instance); | 615 __ Bind(&is_instance); |
607 __ LoadObject(RAX, Bool::Get(true)); | 616 __ LoadObject(RAX, Bool::Get(!negate_result)); |
608 __ Bind(&done); | 617 __ Bind(&done); |
609 __ popq(RDX); // Remove pushed instantiator type arguments. | 618 __ popq(RDX); // Remove pushed instantiator type arguments. |
610 } | 619 } |
611 | 620 |
612 | 621 |
613 // Optimize assignable type check by adding inlined tests for: | 622 // Optimize assignable type check by adding inlined tests for: |
614 // - NULL -> return NULL. | 623 // - NULL -> return NULL. |
615 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 624 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
616 // - Class equality (only if class is not parameterized). | 625 // - Class equality (only if class is not parameterized). |
617 // Inputs: | 626 // Inputs: |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 __ movups(reg, Address(RSP, 0)); | 1768 __ movups(reg, Address(RSP, 0)); |
1760 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); | 1769 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); |
1761 } | 1770 } |
1762 | 1771 |
1763 | 1772 |
1764 #undef __ | 1773 #undef __ |
1765 | 1774 |
1766 } // namespace dart | 1775 } // namespace dart |
1767 | 1776 |
1768 #endif // defined TARGET_ARCH_X64 | 1777 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |