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