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

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

Issue 2718513002: Void is not required to be `null` anymore. (Closed)
Patch Set: Fix more places in the VM. Created 3 years, 9 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_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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 // - preserved instance in RAX and optional instantiator type arguments in RDX. 504 // - preserved instance in RAX and optional instantiator type arguments in RDX.
505 // Note that this inlined code must be followed by the runtime_call code, as it 505 // Note that this inlined code must be followed by the runtime_call code, as it
506 // may fall through to it. Otherwise, this inline code will jump to the label 506 // may fall through to it. Otherwise, this inline code will jump to the label
507 // is_instance or to the label is_not_instance. 507 // is_instance or to the label is_not_instance.
508 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof( 508 RawSubtypeTestCache* FlowGraphCompiler::GenerateInlineInstanceof(
509 TokenPosition token_pos, 509 TokenPosition token_pos,
510 const AbstractType& type, 510 const AbstractType& type,
511 Label* is_instance_lbl, 511 Label* is_instance_lbl,
512 Label* is_not_instance_lbl) { 512 Label* is_not_instance_lbl) {
513 __ Comment("InlineInstanceof"); 513 __ Comment("InlineInstanceof");
514 if (type.IsVoidType()) {
515 // A non-null value is returned from a void function, which will result in a
516 // type error. A null value is handled prior to executing this inline code.
517 return SubtypeTestCache::null();
518 }
519 if (type.IsInstantiated()) { 514 if (type.IsInstantiated()) {
520 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); 515 const Class& type_class = Class::ZoneHandle(zone(), type.type_class());
521 // A class equality check is only applicable with a dst type (not a 516 // A class equality check is only applicable with a dst type (not a
522 // function type) of a non-parameterized class or with a raw dst type of 517 // function type) of a non-parameterized class or with a raw dst type of
523 // a parameterized class. 518 // a parameterized class.
524 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) { 519 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) {
525 return GenerateInstantiatedTypeWithArgumentsTest( 520 return GenerateInstantiatedTypeWithArgumentsTest(
526 token_pos, type, is_instance_lbl, is_not_instance_lbl); 521 token_pos, type, is_instance_lbl, is_not_instance_lbl);
527 // Fall through to runtime call. 522 // Fall through to runtime call.
528 } 523 }
(...skipping 23 matching lines...) Expand all
552 // - RDX: instantiator type arguments or raw_null. 547 // - RDX: instantiator type arguments or raw_null.
553 // Clobbers RDX. 548 // Clobbers RDX.
554 // Returns: 549 // Returns:
555 // - true or false in RAX. 550 // - true or false in RAX.
556 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos, 551 void FlowGraphCompiler::GenerateInstanceOf(TokenPosition token_pos,
557 intptr_t deopt_id, 552 intptr_t deopt_id,
558 const AbstractType& type, 553 const AbstractType& type,
559 bool negate_result, 554 bool negate_result,
560 LocationSummary* locs) { 555 LocationSummary* locs) {
561 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded()); 556 ASSERT(type.IsFinalized() && !type.IsMalformedOrMalbounded());
562 ASSERT(!type.IsObjectType() && !type.IsDynamicType()); 557 ASSERT(!type.IsObjectType() && !type.IsDynamicType() && !type.IsVoidType());
563 558
564 Label is_instance, is_not_instance; 559 Label is_instance, is_not_instance;
565 __ pushq(RDX); // Store instantiator type arguments. 560 __ pushq(RDX); // Store instantiator type arguments.
566 // If type is instantiated and non-parameterized, we can inline code 561 // If type is instantiated and non-parameterized, we can inline code
567 // checking whether the tested instance is a Smi. 562 // checking whether the tested instance is a Smi.
568 if (type.IsInstantiated()) { 563 if (type.IsInstantiated()) {
569 // A null object is only an instance of Null, Object, and dynamic. 564 // A null object is only an instance of Null, Object, void and dynamic.
570 // Object and dynamic have already been checked above (if the type is 565 // Object void and dynamic have already been checked above (if the type is
571 // instantiated). So we can return false here if the instance is null, 566 // instantiated). So we can return false here if the instance is null,
572 // unless the type is Null (and if the type is instantiated). 567 // unless the type is Null (and if the type is instantiated).
573 // We can only inline this null check if the type is instantiated at compile 568 // We can only inline this null check if the type is instantiated at compile
574 // time, since an uninstantiated type at compile time could be Null, Object, 569 // time, since an uninstantiated type at compile time could be Null, Object,
575 // or dynamic at run time. 570 // or dynamic at run time.
576 __ CompareObject(RAX, Object::null_object()); 571 __ CompareObject(RAX, Object::null_object());
577 __ j(EQUAL, type.IsNullType() ? &is_instance : &is_not_instance); 572 __ j(EQUAL, type.IsNullType() ? &is_instance : &is_not_instance);
578 } 573 }
579 574
580 // Generate inline instanceof test. 575 // Generate inline instanceof test.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 void FlowGraphCompiler::GenerateAssertAssignable(TokenPosition token_pos, 628 void FlowGraphCompiler::GenerateAssertAssignable(TokenPosition token_pos,
634 intptr_t deopt_id, 629 intptr_t deopt_id,
635 const AbstractType& dst_type, 630 const AbstractType& dst_type,
636 const String& dst_name, 631 const String& dst_name,
637 LocationSummary* locs) { 632 LocationSummary* locs) {
638 ASSERT(!token_pos.IsClassifying()); 633 ASSERT(!token_pos.IsClassifying());
639 ASSERT(!dst_type.IsNull()); 634 ASSERT(!dst_type.IsNull());
640 ASSERT(dst_type.IsFinalized()); 635 ASSERT(dst_type.IsFinalized());
641 // Assignable check is skipped in FlowGraphBuilder, not here. 636 // Assignable check is skipped in FlowGraphBuilder, not here.
642 ASSERT(dst_type.IsMalformedOrMalbounded() || 637 ASSERT(dst_type.IsMalformedOrMalbounded() ||
643 (!dst_type.IsDynamicType() && !dst_type.IsObjectType())); 638 (!dst_type.IsDynamicType() && !dst_type.IsObjectType() &&
639 !dst_type.IsVoidType()));
644 __ pushq(RDX); // Store instantiator type arguments. 640 __ pushq(RDX); // Store instantiator type arguments.
645 // A null object is always assignable and is returned as result. 641 // A null object is always assignable and is returned as result.
646 Label is_assignable, runtime_call; 642 Label is_assignable, runtime_call;
647 __ CompareObject(RAX, Object::null_object()); 643 __ CompareObject(RAX, Object::null_object());
648 __ j(EQUAL, &is_assignable); 644 __ j(EQUAL, &is_assignable);
649 645
650 // Generate throw new TypeError() if the type is malformed or malbounded. 646 // Generate throw new TypeError() if the type is malformed or malbounded.
651 if (dst_type.IsMalformedOrMalbounded()) { 647 if (dst_type.IsMalformedOrMalbounded()) {
652 __ PushObject(Object::null_object()); // Make room for the result. 648 __ PushObject(Object::null_object()); // Make room for the result.
653 __ pushq(RAX); // Push the source object. 649 __ pushq(RAX); // Push the source object.
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 __ movups(reg, Address(RSP, 0)); 1768 __ movups(reg, Address(RSP, 0));
1773 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); 1769 __ AddImmediate(RSP, Immediate(kFpuRegisterSize));
1774 } 1770 }
1775 1771
1776 1772
1777 #undef __ 1773 #undef __
1778 1774
1779 } // namespace dart 1775 } // namespace dart
1780 1776
1781 #endif // defined TARGET_ARCH_X64 1777 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698