OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. |
6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 542 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
543 // - Class equality (only if class is not parameterized). | 543 // - Class equality (only if class is not parameterized). |
544 // Inputs: | 544 // Inputs: |
545 // - R0: object. | 545 // - R0: object. |
546 // - R1: instantiator type arguments or raw_null. | 546 // - R1: instantiator type arguments or raw_null. |
547 // Returns: | 547 // Returns: |
548 // - true or false in R0. | 548 // - true or false in R0. |
549 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, | 549 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, |
550 intptr_t deopt_id, | 550 intptr_t deopt_id, |
551 const AbstractType& type, | 551 const AbstractType& type, |
| 552 bool negate_result, |
552 LocationSummary* locs) { | 553 LocationSummary* locs) { |
553 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); | 554 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); |
554 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); | 555 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); |
555 | 556 |
556 // Preserve instantiator type arguments (R1). | 557 // Preserve instantiator type arguments (R1). |
557 __ Push(R1); | 558 __ Push(R1); |
558 | 559 |
559 Label is_instance, is_not_instance; | 560 Label is_instance, is_not_instance; |
560 // If type is instantiated and non-parameterized, we can inline code | 561 // If type is instantiated and non-parameterized, we can inline code |
561 // checking whether the tested instance is a Smi. | 562 // checking whether the tested instance is a Smi. |
(...skipping 23 matching lines...) Expand all Loading... |
585 __ PushObject(Object::null_object()); // Make room for the result. | 586 __ PushObject(Object::null_object()); // Make room for the result. |
586 __ Push(R0); // Push the instance. | 587 __ Push(R0); // Push the instance. |
587 __ PushObject(type); // Push the type. | 588 __ PushObject(type); // Push the type. |
588 __ Push(R1); // Push instantiator type arguments (R1). | 589 __ Push(R1); // Push instantiator type arguments (R1). |
589 __ LoadUniqueObject(R0, test_cache); | 590 __ LoadUniqueObject(R0, test_cache); |
590 __ Push(R0); | 591 __ Push(R0); |
591 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 4, locs); | 592 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 4, locs); |
592 // Pop the parameters supplied to the runtime entry. The result of the | 593 // Pop the parameters supplied to the runtime entry. The result of the |
593 // instanceof runtime call will be left as the result of the operation. | 594 // instanceof runtime call will be left as the result of the operation. |
594 __ Drop(4); | 595 __ Drop(4); |
595 __ Pop(R0); | 596 if (negate_result) { |
| 597 __ Pop(R1); |
| 598 __ LoadObject(R0, Bool::True()); |
| 599 __ CompareRegisters(R1, R0); |
| 600 __ b(&done, NE); |
| 601 __ LoadObject(R0, Bool::False()); |
| 602 } else { |
| 603 __ Pop(R0); |
| 604 } |
596 __ b(&done); | 605 __ b(&done); |
597 } | 606 } |
598 __ Bind(&is_not_instance); | 607 __ Bind(&is_not_instance); |
599 __ LoadObject(R0, Bool::Get(false)); | 608 __ LoadObject(R0, Bool::Get(negate_result)); |
600 __ b(&done); | 609 __ b(&done); |
601 | 610 |
602 __ Bind(&is_instance); | 611 __ Bind(&is_instance); |
603 __ LoadObject(R0, Bool::Get(true)); | 612 __ LoadObject(R0, Bool::Get(!negate_result)); |
604 __ Bind(&done); | 613 __ Bind(&done); |
605 // Remove instantiator type arguments (R1). | 614 // Remove instantiator type arguments (R1). |
606 __ Drop(1); | 615 __ Drop(1); |
607 } | 616 } |
608 | 617 |
609 | 618 |
610 // Optimize assignable type check by adding inlined tests for: | 619 // Optimize assignable type check by adding inlined tests for: |
611 // - NULL -> return NULL. | 620 // - NULL -> return NULL. |
612 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 621 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
613 // - Class equality (only if class is not parameterized). | 622 // - Class equality (only if class is not parameterized). |
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1836 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { | 1845 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { |
1837 __ PopDouble(reg); | 1846 __ PopDouble(reg); |
1838 } | 1847 } |
1839 | 1848 |
1840 | 1849 |
1841 #undef __ | 1850 #undef __ |
1842 | 1851 |
1843 } // namespace dart | 1852 } // namespace dart |
1844 | 1853 |
1845 #endif // defined TARGET_ARCH_ARM64 | 1854 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |