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

Side by Side Diff: runtime/vm/flow_graph_compiler_x64.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_mips.cc ('k') | runtime/vm/flow_graph_type_propagator.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) 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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 return SubtypeTestCache::null(); 542 return SubtypeTestCache::null();
543 } 543 }
544 } 544 }
545 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl, 545 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl,
546 is_not_instance_lbl); 546 is_not_instance_lbl);
547 } 547 }
548 548
549 549
550 // If instanceof type test cannot be performed successfully at compile time and 550 // If instanceof type test cannot be performed successfully at compile time and
551 // therefore eliminated, optimize it by adding inlined tests for: 551 // therefore eliminated, optimize it by adding inlined tests for:
552 // - NULL -> return false. 552 // - NULL -> return type == Null (type is not Object or dynamic).
553 // - Smi -> compile time subtype check (only if dst class is not parameterized). 553 // - Smi -> compile time subtype check (only if dst class is not parameterized).
554 // - Class equality (only if class is not parameterized). 554 // - Class equality (only if class is not parameterized).
555 // Inputs: 555 // Inputs:
556 // - RAX: object. 556 // - RAX: object.
557 // - RDX: instantiator type arguments or raw_null. 557 // - RDX: instantiator type arguments or raw_null.
558 // Clobbers RDX. 558 // Clobbers RDX.
559 // Returns: 559 // Returns:
560 // - true or false in RAX. 560 // - true or false in RAX.
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.IsMalformedOrMalbounded()); 566 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded());
567 ASSERT(!type.IsObjectType() && !type.IsDynamicType());
567 568
568 Label is_instance, is_not_instance; 569 Label is_instance, is_not_instance;
569 __ pushq(RDX); // Store instantiator type arguments. 570 __ pushq(RDX); // Store instantiator type arguments.
570 // If type is instantiated and non-parameterized, we can inline code 571 // If type is instantiated and non-parameterized, we can inline code
571 // checking whether the tested instance is a Smi. 572 // checking whether the tested instance is a Smi.
572 if (type.IsInstantiated()) { 573 if (type.IsInstantiated()) {
573 // A null object is only an instance of Object and dynamic, which has 574 // A null object is only an instance of Null, Object, and dynamic.
574 // already been checked above (if the type is instantiated). So we can 575 // Object and dynamic have already been checked above (if the type is
575 // return false here if the instance is null (and if the type is 576 // instantiated). So we can return false here if the instance is null,
576 // instantiated). 577 // unless the type is Null (and if the type is instantiated).
577 // We can only inline this null check if the type is instantiated at compile 578 // We can only inline this null check if the type is instantiated at compile
578 // time, since an uninstantiated type at compile time could be Object or 579 // time, since an uninstantiated type at compile time could be Null, Object,
579 // dynamic at run time. 580 // or dynamic at run time.
580 __ CompareObject(RAX, Object::null_object()); 581 __ CompareObject(RAX, Object::null_object());
581 __ j(EQUAL, type.IsNullType() ? &is_instance : &is_not_instance); 582 __ j(EQUAL, type.IsNullType() ? &is_instance : &is_not_instance);
582 } 583 }
583 584
584 // Generate inline instanceof test. 585 // Generate inline instanceof test.
585 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone()); 586 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone());
586 test_cache = 587 test_cache =
587 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance); 588 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance);
588 589
589 // test_cache is null if there is no fall-through. 590 // test_cache is null if there is no fall-through.
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 __ movups(reg, Address(RSP, 0)); 1778 __ movups(reg, Address(RSP, 0));
1778 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); 1779 __ AddImmediate(RSP, Immediate(kFpuRegisterSize));
1779 } 1780 }
1780 1781
1781 1782
1782 #undef __ 1783 #undef __
1783 1784
1784 } // namespace dart 1785 } // namespace dart
1785 1786
1786 #endif // defined TARGET_ARCH_X64 1787 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_mips.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698