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_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 537 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
538 // - Class equality (only if class is not parameterized). | 538 // - Class equality (only if class is not parameterized). |
539 // Inputs: | 539 // Inputs: |
540 // - A0: object. | 540 // - A0: object. |
541 // - A1: instantiator type arguments or raw_null. | 541 // - A1: instantiator type arguments or raw_null. |
542 // Returns: | 542 // Returns: |
543 // - true or false in V0. | 543 // - true or false in V0. |
544 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, | 544 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, |
545 intptr_t deopt_id, | 545 intptr_t deopt_id, |
546 const AbstractType& type, | 546 const AbstractType& type, |
| 547 bool negate_result, |
547 LocationSummary* locs) { | 548 LocationSummary* locs) { |
548 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); | 549 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); |
549 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); | 550 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); |
550 | 551 |
551 // Preserve instantiator type arguments (A1). | 552 // Preserve instantiator type arguments (A1). |
552 __ addiu(SP, SP, Immediate(-1 * kWordSize)); | 553 __ addiu(SP, SP, Immediate(-1 * kWordSize)); |
553 __ sw(A1, Address(SP, 0 * kWordSize)); | 554 __ sw(A1, Address(SP, 0 * kWordSize)); |
554 | 555 |
555 Label is_instance, is_not_instance; | 556 Label is_instance, is_not_instance; |
556 // If type is instantiated and non-parameterized, we can inline code | 557 // If type is instantiated and non-parameterized, we can inline code |
(...skipping 29 matching lines...) Expand all Loading... |
586 __ LoadObject(TMP, type); | 587 __ LoadObject(TMP, type); |
587 __ sw(TMP, Address(SP, 2 * kWordSize)); // Push the type. | 588 __ sw(TMP, Address(SP, 2 * kWordSize)); // Push the type. |
588 __ sw(A1, Address(SP, 1 * kWordSize)); // Push type arguments. | 589 __ sw(A1, Address(SP, 1 * kWordSize)); // Push type arguments. |
589 __ LoadUniqueObject(A0, test_cache); | 590 __ LoadUniqueObject(A0, test_cache); |
590 __ sw(A0, Address(SP, 0 * kWordSize)); | 591 __ sw(A0, Address(SP, 0 * kWordSize)); |
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 __ lw(T0, Address(SP, 4 * kWordSize)); | 595 __ lw(T0, Address(SP, 4 * kWordSize)); |
595 __ addiu(SP, SP, Immediate(5 * kWordSize)); | 596 __ addiu(SP, SP, Immediate(5 * kWordSize)); |
596 __ mov(V0, T0); | 597 if (negate_result) { |
| 598 __ LoadObject(V0, Bool::True()); |
| 599 __ bne(T0, V0, &done); |
| 600 __ LoadObject(V0, Bool::False()); |
| 601 } else { |
| 602 __ mov(V0, T0); |
| 603 } |
597 __ b(&done); | 604 __ b(&done); |
598 } | 605 } |
599 __ Bind(&is_not_instance); | 606 __ Bind(&is_not_instance); |
600 __ LoadObject(V0, Bool::Get(false)); | 607 __ LoadObject(V0, Bool::Get(negate_result)); |
601 __ b(&done); | 608 __ b(&done); |
602 | 609 |
603 __ Bind(&is_instance); | 610 __ Bind(&is_instance); |
604 __ LoadObject(V0, Bool::Get(true)); | 611 __ LoadObject(V0, Bool::Get(!negate_result)); |
605 __ Bind(&done); | 612 __ Bind(&done); |
606 // Remove instantiator type arguments (A1). | 613 // Remove instantiator type arguments (A1). |
607 __ Drop(1); | 614 __ Drop(1); |
608 } | 615 } |
609 | 616 |
610 | 617 |
611 // Optimize assignable type check by adding inlined tests for: | 618 // Optimize assignable type check by adding inlined tests for: |
612 // - NULL -> return NULL. | 619 // - NULL -> return NULL. |
613 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 620 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
614 // - Class equality (only if class is not parameterized). | 621 // - Class equality (only if class is not parameterized). |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1858 __ AddImmediate(SP, kDoubleSize); | 1865 __ AddImmediate(SP, kDoubleSize); |
1859 } | 1866 } |
1860 | 1867 |
1861 | 1868 |
1862 #undef __ | 1869 #undef __ |
1863 | 1870 |
1864 | 1871 |
1865 } // namespace dart | 1872 } // namespace dart |
1866 | 1873 |
1867 #endif // defined TARGET_ARCH_MIPS | 1874 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |