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

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

Issue 2608373002: Move Null type to the Bottom in the VM (fixes #28025). (Closed)
Patch Set: work in progress 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
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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 return SubtypeTestCache::null(); 547 return SubtypeTestCache::null();
548 } 548 }
549 } 549 }
550 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl, 550 return GenerateUninstantiatedTypeTest(token_pos, type, is_instance_lbl,
551 is_not_instance_lbl); 551 is_not_instance_lbl);
552 } 552 }
553 553
554 554
555 // If instanceof type test cannot be performed successfully at compile time and 555 // If instanceof type test cannot be performed successfully at compile time and
556 // therefore eliminated, optimize it by adding inlined tests for: 556 // therefore eliminated, optimize it by adding inlined tests for:
557 // - NULL -> return false. 557 // - NULL -> return type == Null (type is not Object or dynamic).
558 // - Smi -> compile time subtype check (only if dst class is not parameterized). 558 // - Smi -> compile time subtype check (only if dst class is not parameterized).
559 // - Class equality (only if class is not parameterized). 559 // - Class equality (only if class is not parameterized).
560 // Inputs: 560 // Inputs:
561 // - EAX: object. 561 // - EAX: object.
562 // - EDX: instantiator type arguments or raw_null. 562 // - EDX: instantiator type arguments or raw_null.
563 // Clobbers EDX. 563 // Clobbers EDX.
564 // Returns: 564 // Returns:
565 // - true or false in EAX. 565 // - true or false in EAX.
566 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, 566 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos,
567 intptr_t deopt_id, 567 intptr_t deopt_id,
568 const AbstractType& type, 568 const AbstractType& type,
569 bool negate_result, 569 bool negate_result,
570 LocationSummary* locs) { 570 LocationSummary* locs) {
571 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); 571 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded());
572 572
573 const Immediate& raw_null = 573 const Immediate& raw_null =
574 Immediate(reinterpret_cast<intptr_t>(Object::null())); 574 Immediate(reinterpret_cast<intptr_t>(Object::null()));
575 Label is_instance, is_not_instance; 575 Label is_instance, is_not_instance;
576 __ pushl(EDX); // Store instantiator type arguments. 576 __ pushl(EDX); // Store instantiator type arguments.
577 // If type is instantiated and non-parameterized, we can inline code 577 // If type is instantiated and non-parameterized, we can inline code
578 // checking whether the tested instance is a Smi. 578 // checking whether the tested instance is a Smi.
579 if (type.IsInstantiated()) { 579 if (type.IsInstantiated()) {
580 // A null object is only an instance of Object and dynamic, which has 580 // A null object is only an instance of Null, Object, and dynamic.
581 // already been checked above (if the type is instantiated). So we can 581 // Object and dynamic have already been checked above (if the type is
582 // return false here if the instance is null (and if the type is 582 // instantiated). So we can return false here if the instance is null,
583 // instantiated). 583 // unless the type is Null (and if the type is instantiated).
584 // We can only inline this null check if the type is instantiated at compile 584 // We can only inline this null check if the type is instantiated at compile
585 // time, since an uninstantiated type at compile time could be Object or 585 // time, since an uninstantiated type at compile time could be Null, Object,
586 // dynamic at run time. 586 // or dynamic at run time.
587 __ cmpl(EAX, raw_null); 587 __ cmpl(EAX, raw_null);
588 __ j(EQUAL, type.IsNullType() ? &is_instance : &is_not_instance); 588 __ j(EQUAL, type.IsNullType() ? &is_instance : &is_not_instance);
589 } 589 }
590 590
591 // Generate inline instanceof test. 591 // Generate inline instanceof test.
592 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone()); 592 SubtypeTestCache& test_cache = SubtypeTestCache::ZoneHandle(zone());
593 test_cache = 593 test_cache =
594 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance); 594 GenerateInlineInstanceof(token_pos, type, &is_instance, &is_not_instance);
595 595
596 // test_cache is null if there is no fall-through. 596 // test_cache is null if there is no fall-through.
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 __ movups(reg, Address(ESP, 0)); 1774 __ movups(reg, Address(ESP, 0));
1775 __ addl(ESP, Immediate(kFpuRegisterSize)); 1775 __ addl(ESP, Immediate(kFpuRegisterSize));
1776 } 1776 }
1777 1777
1778 1778
1779 #undef __ 1779 #undef __
1780 1780
1781 } // namespace dart 1781 } // namespace dart
1782 1782
1783 #endif // defined TARGET_ARCH_IA32 1783 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698