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, | |
548 LocationSummary* locs) { | 547 LocationSummary* locs) { |
549 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); | 548 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); |
550 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); | 549 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); |
551 | 550 |
552 // Preserve instantiator type arguments (A1). | 551 // Preserve instantiator type arguments (A1). |
553 __ addiu(SP, SP, Immediate(-1 * kWordSize)); | 552 __ addiu(SP, SP, Immediate(-1 * kWordSize)); |
554 __ sw(A1, Address(SP, 0 * kWordSize)); | 553 __ sw(A1, Address(SP, 0 * kWordSize)); |
555 | 554 |
556 Label is_instance, is_not_instance; | 555 Label is_instance, is_not_instance; |
557 // If type is instantiated and non-parameterized, we can inline code | 556 // If type is instantiated and non-parameterized, we can inline code |
(...skipping 29 matching lines...) Expand all Loading... |
587 __ LoadObject(TMP, type); | 586 __ LoadObject(TMP, type); |
588 __ sw(TMP, Address(SP, 2 * kWordSize)); // Push the type. | 587 __ sw(TMP, Address(SP, 2 * kWordSize)); // Push the type. |
589 __ sw(A1, Address(SP, 1 * kWordSize)); // Push type arguments. | 588 __ sw(A1, Address(SP, 1 * kWordSize)); // Push type arguments. |
590 __ LoadUniqueObject(A0, test_cache); | 589 __ LoadUniqueObject(A0, test_cache); |
591 __ sw(A0, Address(SP, 0 * kWordSize)); | 590 __ sw(A0, Address(SP, 0 * kWordSize)); |
592 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 4, locs); | 591 GenerateRuntimeCall(token_pos, deopt_id, kInstanceofRuntimeEntry, 4, locs); |
593 // Pop the parameters supplied to the runtime entry. The result of the | 592 // Pop the parameters supplied to the runtime entry. The result of the |
594 // instanceof runtime call will be left as the result of the operation. | 593 // instanceof runtime call will be left as the result of the operation. |
595 __ lw(T0, Address(SP, 4 * kWordSize)); | 594 __ lw(T0, Address(SP, 4 * kWordSize)); |
596 __ addiu(SP, SP, Immediate(5 * kWordSize)); | 595 __ addiu(SP, SP, Immediate(5 * kWordSize)); |
597 if (negate_result) { | 596 __ mov(V0, T0); |
598 __ LoadObject(V0, Bool::True()); | |
599 __ bne(T0, V0, &done); | |
600 __ LoadObject(V0, Bool::False()); | |
601 } else { | |
602 __ mov(V0, T0); | |
603 } | |
604 __ b(&done); | 597 __ b(&done); |
605 } | 598 } |
606 __ Bind(&is_not_instance); | 599 __ Bind(&is_not_instance); |
607 __ LoadObject(V0, Bool::Get(negate_result)); | 600 __ LoadObject(V0, Bool::Get(false)); |
608 __ b(&done); | 601 __ b(&done); |
609 | 602 |
610 __ Bind(&is_instance); | 603 __ Bind(&is_instance); |
611 __ LoadObject(V0, Bool::Get(!negate_result)); | 604 __ LoadObject(V0, Bool::Get(true)); |
612 __ Bind(&done); | 605 __ Bind(&done); |
613 // Remove instantiator type arguments (A1). | 606 // Remove instantiator type arguments (A1). |
614 __ Drop(1); | 607 __ Drop(1); |
615 } | 608 } |
616 | 609 |
617 | 610 |
618 // Optimize assignable type check by adding inlined tests for: | 611 // Optimize assignable type check by adding inlined tests for: |
619 // - NULL -> return NULL. | 612 // - NULL -> return NULL. |
620 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 613 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
621 // - Class equality (only if class is not parameterized). | 614 // - Class equality (only if class is not parameterized). |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 __ AddImmediate(SP, kDoubleSize); | 1858 __ AddImmediate(SP, kDoubleSize); |
1866 } | 1859 } |
1867 | 1860 |
1868 | 1861 |
1869 #undef __ | 1862 #undef __ |
1870 | 1863 |
1871 | 1864 |
1872 } // namespace dart | 1865 } // namespace dart |
1873 | 1866 |
1874 #endif // defined TARGET_ARCH_MIPS | 1867 #endif // defined TARGET_ARCH_MIPS |
OLD | NEW |