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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
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 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 549 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
550 // - Class equality (only if class is not parameterized). | 550 // - Class equality (only if class is not parameterized). |
551 // Inputs: | 551 // Inputs: |
552 // - R0: object. | 552 // - R0: object. |
553 // - R1: instantiator type arguments or raw_null. | 553 // - R1: instantiator type arguments or raw_null. |
554 // Returns: | 554 // Returns: |
555 // - true or false in R0. | 555 // - true or false in R0. |
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.IsMalformed() && !type.IsMalbounded()); | 561 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); |
561 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); | 562 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); |
562 | 563 |
563 // Preserve instantiator type arguments (R1). | 564 // Preserve instantiator type arguments (R1). |
564 __ Push(R1); | 565 __ Push(R1); |
565 | 566 |
566 Label is_instance, is_not_instance; | 567 Label is_instance, is_not_instance; |
567 // If type is instantiated and non-parameterized, we can inline code | 568 // If type is instantiated and non-parameterized, we can inline code |
568 // checking whether the tested instance is a Smi. | 569 // checking whether the tested instance is a Smi. |
(...skipping 23 matching lines...) Expand all Loading... |
592 __ PushObject(Object::null_object()); // Make room for the result. | 593 __ PushObject(Object::null_object()); // Make room for the result. |
593 __ Push(R0); // Push the instance. | 594 __ Push(R0); // Push the instance. |
594 __ PushObject(type); // Push the type. | 595 __ PushObject(type); // Push the type. |
595 __ Push(R1); // Push instantiator type arguments (R1). | 596 __ Push(R1); // Push instantiator type arguments (R1). |
596 __ LoadUniqueObject(R0, test_cache); | 597 __ LoadUniqueObject(R0, test_cache); |
597 __ Push(R0); | 598 __ Push(R0); |
598 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 4, locs); | 599 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 4, locs); |
599 // Pop the parameters supplied to the runtime entry. The result of the | 600 // Pop the parameters supplied to the runtime entry. The result of the |
600 // instanceof runtime call will be left as the result of the operation. | 601 // instanceof runtime call will be left as the result of the operation. |
601 __ Drop(4); | 602 __ Drop(4); |
602 __ Pop(R0); | 603 if (negate_result) { |
| 604 __ Pop(R1); |
| 605 __ LoadObject(R0, Bool::True()); |
| 606 __ cmp(R1, Operand(R0)); |
| 607 __ b(&done, NE); |
| 608 __ LoadObject(R0, Bool::False()); |
| 609 } else { |
| 610 __ Pop(R0); |
| 611 } |
603 __ b(&done); | 612 __ b(&done); |
604 } | 613 } |
605 __ Bind(&is_not_instance); | 614 __ Bind(&is_not_instance); |
606 __ LoadObject(R0, Bool::Get(false)); | 615 __ LoadObject(R0, Bool::Get(negate_result)); |
607 __ b(&done); | 616 __ b(&done); |
608 | 617 |
609 __ Bind(&is_instance); | 618 __ Bind(&is_instance); |
610 __ LoadObject(R0, Bool::Get(true)); | 619 __ LoadObject(R0, Bool::Get(!negate_result)); |
611 __ Bind(&done); | 620 __ Bind(&done); |
612 // Remove instantiator type arguments (R1). | 621 // Remove instantiator type arguments (R1). |
613 __ Drop(1); | 622 __ Drop(1); |
614 } | 623 } |
615 | 624 |
616 | 625 |
617 // Optimize assignable type check by adding inlined tests for: | 626 // Optimize assignable type check by adding inlined tests for: |
618 // - NULL -> return NULL. | 627 // - NULL -> return NULL. |
619 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 628 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
620 // - Class equality (only if class is not parameterized). | 629 // - Class equality (only if class is not parameterized). |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1893 DRegister dreg = EvenDRegisterOf(reg); | 1902 DRegister dreg = EvenDRegisterOf(reg); |
1894 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); | 1903 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); |
1895 } | 1904 } |
1896 | 1905 |
1897 | 1906 |
1898 #undef __ | 1907 #undef __ |
1899 | 1908 |
1900 } // namespace dart | 1909 } // namespace dart |
1901 | 1910 |
1902 #endif // defined TARGET_ARCH_ARM | 1911 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |