| 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 return SubtypeTestCache::null(); | 531 return SubtypeTestCache::null(); |
| 532 } | 532 } |
| 533 } | 533 } |
| 534 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl, | 534 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl, |
| 535 is_not_instance_lbl); | 535 is_not_instance_lbl); |
| 536 } | 536 } |
| 537 | 537 |
| 538 | 538 |
| 539 // If instanceof type test cannot be performed successfully at compile time and | 539 // If instanceof type test cannot be performed successfully at compile time and |
| 540 // therefore eliminated, optimize it by adding inlined tests for: | 540 // therefore eliminated, optimize it by adding inlined tests for: |
| 541 // - NULL -> return false. | 541 // - NULL -> return type == Null (type is not Object or dynamic). |
| 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 // - A0: object. | 545 // - A0: object. |
| 546 // - A1: instantiator type arguments or raw_null. | 546 // - A1: instantiator type arguments or raw_null. |
| 547 // Returns: | 547 // Returns: |
| 548 // - true or false in V0. | 548 // - true or false in V0. |
| 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 bool negate_result, |
| 553 LocationSummary* locs) { | 553 LocationSummary* locs) { |
| 554 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); | 554 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); |
| 555 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); |
| 555 | 556 |
| 556 // Preserve instantiator type arguments (A1). | 557 // Preserve instantiator type arguments (A1). |
| 557 __ addiu(SP, SP, Immediate(-1 * kWordSize)); | 558 __ addiu(SP, SP, Immediate(-1 * kWordSize)); |
| 558 __ sw(A1, Address(SP, 0 * kWordSize)); | 559 __ sw(A1, Address(SP, 0 * kWordSize)); |
| 559 | 560 |
| 560 Label is_instance, is_not_instance; | 561 Label is_instance, is_not_instance; |
| 561 // If type is instantiated and non-parameterized, we can inline code | 562 // If type is instantiated and non-parameterized, we can inline code |
| 562 // checking whether the tested instance is a Smi. | 563 // checking whether the tested instance is a Smi. |
| 563 if (type.IsInstantiated()) { | 564 if (type.IsInstantiated()) { |
| 564 // A null object is only an instance of Object and dynamic, which has | 565 // A null object is only an instance of Null, Object, and dynamic. |
| 565 // already been checked above (if the type is instantiated). So we can | 566 // Object and dynamic have already been checked above (if the type is |
| 566 // return false here if the instance is null (and if the type is | 567 // instantiated). So we can return false here if the instance is null, |
| 567 // instantiated). | 568 // unless the type is Null (and if the type is instantiated). |
| 568 // We can only inline this null check if the type is instantiated at compile | 569 // We can only inline this null check if the type is instantiated at compile |
| 569 // time, since an uninstantiated type at compile time could be Object or | 570 // time, since an uninstantiated type at compile time could be Null, Object, |
| 570 // dynamic at run time. | 571 // or dynamic at run time. |
| 571 __ BranchEqual(A0, Object::null_object(), | 572 __ BranchEqual(A0, Object::null_object(), |
| 572 type.IsNullType() ? &is_instance : &is_not_instance); | 573 type.IsNullType() ? &is_instance : &is_not_instance); |
| 573 } | 574 } |
| 574 | 575 |
| 575 // Generate inline instanceof test. | 576 // Generate inline instanceof test. |
| 576 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone()); | 577 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone()); |
| 577 test_cache = | 578 test_cache = |
| 578 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance); | 579 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance); |
| 579 | 580 |
| 580 // test_cache is null if there is no fall-through. | 581 // test_cache is null if there is no fall-through. |
| (...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1874 __ AddImmediate(SP, kDoubleSize); | 1875 __ AddImmediate(SP, kDoubleSize); |
| 1875 } | 1876 } |
| 1876 | 1877 |
| 1877 | 1878 |
| 1878 #undef __ | 1879 #undef __ |
| 1879 | 1880 |
| 1880 | 1881 |
| 1881 } // namespace dart | 1882 } // namespace dart |
| 1882 | 1883 |
| 1883 #endif // defined TARGET_ARCH_MIPS | 1884 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |