Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: runtime/vm/flow_graph_compiler_arm64.cc

Issue 2608373002: Move Null type to the Bottom in the VM (fixes #28025). (Closed)
Patch Set: address comments and sync Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 return SubtypeTestCache::null(); 536 return SubtypeTestCache::null();
537 } 537 }
538 } 538 }
539 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl, 539 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl,
540 is_not_instance_lbl); 540 is_not_instance_lbl);
541 } 541 }
542 542
543 543
544 // If instanceof type test cannot be performed successfully at compile time and 544 // If instanceof type test cannot be performed successfully at compile time and
545 // therefore eliminated, optimize it by adding inlined tests for: 545 // therefore eliminated, optimize it by adding inlined tests for:
546 // - NULL -> return false. 546 // - NULL -> return type == Null (type is not Object or dynamic).
547 // - Smi -> compile time subtype check (only if dst class is not parameterized). 547 // - Smi -> compile time subtype check (only if dst class is not parameterized).
548 // - Class equality (only if class is not parameterized). 548 // - Class equality (only if class is not parameterized).
549 // Inputs: 549 // Inputs:
550 // - R0: object. 550 // - R0: object.
551 // - R1: instantiator type arguments or raw_null. 551 // - R1: instantiator type arguments or raw_null.
552 // Returns: 552 // Returns:
553 // - true or false in R0. 553 // - true or false in R0.
554 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, 554 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos,
555 intptr_t deopt_id, 555 intptr_t deopt_id,
556 const AbstractType& type, 556 const AbstractType& type,
557 bool negate_result, 557 bool negate_result,
558 LocationSummary* locs) { 558 LocationSummary* locs) {
559 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); 559 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded());
560 ASSERT(!type.IsObjectType() && !type.IsDynamicType());
560 561
561 // Preserve instantiator type arguments (R1). 562 // Preserve instantiator type arguments (R1).
562 __ Push(R1); 563 __ Push(R1);
563 564
564 Label is_instance, is_not_instance; 565 Label is_instance, is_not_instance;
565 // If type is instantiated and non-parameterized, we can inline code 566 // If type is instantiated and non-parameterized, we can inline code
566 // checking whether the tested instance is a Smi. 567 // checking whether the tested instance is a Smi.
567 if (type.IsInstantiated()) { 568 if (type.IsInstantiated()) {
568 // A null object is only an instance of Object and dynamic, which has 569 // A null object is only an instance of Null, Object, and dynamic.
569 // already been checked above (if the type is instantiated). So we can 570 // Object and dynamic have already been checked above (if the type is
570 // return false here if the instance is null (and if the type is 571 // instantiated). So we can return false here if the instance is null,
571 // instantiated). 572 // unless the type is Null (and if the type is instantiated).
572 // We can only inline this null check if the type is instantiated at compile 573 // We can only inline this null check if the type is instantiated at compile
573 // time, since an uninstantiated type at compile time could be Object or 574 // time, since an uninstantiated type at compile time could be Null, Object,
574 // dynamic at run time. 575 // or dynamic at run time.
575 __ CompareObject(R0, Object::null_object()); 576 __ CompareObject(R0, Object::null_object());
576 __ b(type.IsNullType() ? &is_instance : &is_not_instance, EQ); 577 __ b(type.IsNullType() ? &is_instance : &is_not_instance, EQ);
577 } 578 }
578 579
579 // Generate inline instanceof test. 580 // Generate inline instanceof test.
580 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone()); 581 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone());
581 test_cache = 582 test_cache =
582 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance); 583 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance);
583 584
584 // test_cache is null if there is no fall-through. 585 // test_cache is null if there is no fall-through.
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { 1855 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) {
1855 __ PopDouble(reg); 1856 __ PopDouble(reg);
1856 } 1857 }
1857 1858
1858 1859
1859 #undef __ 1860 #undef __
1860 1861
1861 } // namespace dart 1862 } // namespace dart
1862 1863
1863 #endif // defined TARGET_ARCH_ARM64 1864 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698