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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 return SubtypeTestCache::null(); | 543 return SubtypeTestCache::null(); |
544 } | 544 } |
545 } | 545 } |
546 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl, | 546 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl, |
547 is_not_instance_lbl); | 547 is_not_instance_lbl); |
548 } | 548 } |
549 | 549 |
550 | 550 |
551 // If instanceof type test cannot be performed successfully at compile time and | 551 // If instanceof type test cannot be performed successfully at compile time and |
552 // therefore eliminated, optimize it by adding inlined tests for: | 552 // therefore eliminated, optimize it by adding inlined tests for: |
553 // - NULL -> return false. | 553 // - NULL -> return type == Null (type is not Object or dynamic). |
554 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 554 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
555 // - Class equality (only if class is not parameterized). | 555 // - Class equality (only if class is not parameterized). |
556 // Inputs: | 556 // Inputs: |
557 // - R0: object. | 557 // - R0: object. |
558 // - R1: instantiator type arguments or raw_null. | 558 // - R1: instantiator type arguments or raw_null. |
559 // Returns: | 559 // Returns: |
560 // - true or false in R0. | 560 // - true or false in R0. |
561 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, | 561 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, |
562 intptr_t deopt_id, | 562 intptr_t deopt_id, |
563 const AbstractType& type, | 563 const AbstractType& type, |
564 bool negate_result, | 564 bool negate_result, |
565 LocationSummary* locs) { | 565 LocationSummary* locs) { |
566 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); | 566 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); |
| 567 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); |
567 | 568 |
568 // Preserve instantiator type arguments (R1). | 569 // Preserve instantiator type arguments (R1). |
569 __ Push(R1); | 570 __ Push(R1); |
570 | 571 |
571 Label is_instance, is_not_instance; | 572 Label is_instance, is_not_instance; |
572 // If type is instantiated and non-parameterized, we can inline code | 573 // If type is instantiated and non-parameterized, we can inline code |
573 // checking whether the tested instance is a Smi. | 574 // checking whether the tested instance is a Smi. |
574 if (type.IsInstantiated()) { | 575 if (type.IsInstantiated()) { |
575 // A null object is only an instance of Object and dynamic, which has | 576 // A null object is only an instance of Null, Object, and dynamic. |
576 // already been checked above (if the type is instantiated). So we can | 577 // Object and dynamic have already been checked above (if the type is |
577 // return false here if the instance is null (and if the type is | 578 // instantiated). So we can return false here if the instance is null, |
578 // instantiated). | 579 // unless the type is Null (and if the type is instantiated). |
579 // We can only inline this null check if the type is instantiated at compile | 580 // We can only inline this null check if the type is instantiated at compile |
580 // time, since an uninstantiated type at compile time could be Object or | 581 // time, since an uninstantiated type at compile time could be Null, Object, |
581 // dynamic at run time. | 582 // or dynamic at run time. |
582 __ CompareObject(R0, Object::null_object()); | 583 __ CompareObject(R0, Object::null_object()); |
583 __ b(type.IsNullType() ? &is_instance : &is_not_instance, EQ); | 584 __ b(type.IsNullType() ? &is_instance : &is_not_instance, EQ); |
584 } | 585 } |
585 | 586 |
586 // Generate inline instanceof test. | 587 // Generate inline instanceof test. |
587 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone()); | 588 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone()); |
588 test_cache = | 589 test_cache = |
589 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance); | 590 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance); |
590 | 591 |
591 // test_cache is null if there is no fall-through. | 592 // test_cache is null if there is no fall-through. |
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1911 DRegister dreg = EvenDRegisterOf(reg); | 1912 DRegister dreg = EvenDRegisterOf(reg); |
1912 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); | 1913 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); |
1913 } | 1914 } |
1914 | 1915 |
1915 | 1916 |
1916 #undef __ | 1917 #undef __ |
1917 | 1918 |
1918 } // namespace dart | 1919 } // namespace dart |
1919 | 1920 |
1920 #endif // defined TARGET_ARCH_ARM | 1921 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |