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

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

Issue 1513493002: Improve upper bound finalization in VM and fix #25122. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 3769 matching lines...) Expand 10 before | Expand all | Expand 10 after
3780 return (test_kind == Class::kIsMoreSpecificThan) || 3780 return (test_kind == Class::kIsMoreSpecificThan) ||
3781 other.IsObjectClass() || other.IsNullClass(); 3781 other.IsObjectClass() || other.IsNullClass();
3782 } 3782 }
3783 // Check for ObjectType. Any type that is not NullType or DynamicType 3783 // Check for ObjectType. Any type that is not NullType or DynamicType
3784 // (already checked above), is more specific than ObjectType. 3784 // (already checked above), is more specific than ObjectType.
3785 if (other.IsObjectClass()) { 3785 if (other.IsObjectClass()) {
3786 return true; 3786 return true;
3787 } 3787 }
3788 // Check for reflexivity. 3788 // Check for reflexivity.
3789 if (thsi.raw() == other.raw()) { 3789 if (thsi.raw() == other.raw()) {
3790 const intptr_t num_type_args = thsi.NumTypeArguments(); 3790 const intptr_t num_type_params = thsi.NumTypeParameters();
3791 if (num_type_args == 0) { 3791 if (num_type_params == 0) {
3792 return true; 3792 return true;
3793 } 3793 }
3794 const intptr_t num_type_params = thsi.NumTypeParameters(); 3794 const intptr_t num_type_args = thsi.NumTypeArguments();
3795 const intptr_t from_index = num_type_args - num_type_params; 3795 const intptr_t from_index = num_type_args - num_type_params;
3796 // Since we do not truncate the type argument vector of a subclass (see 3796 // Since we do not truncate the type argument vector of a subclass (see
3797 // below), we only check a subvector of the proper length. 3797 // below), we only check a subvector of the proper length.
3798 // Check for covariance. 3798 // Check for covariance.
3799 if (other_type_arguments.IsNull() || 3799 if (other_type_arguments.IsNull() ||
3800 other_type_arguments.IsRaw(from_index, num_type_params)) { 3800 other_type_arguments.IsRaw(from_index, num_type_params)) {
3801 return true; 3801 return true;
3802 } 3802 }
3803 if (type_arguments.IsNull() || 3803 if (type_arguments.IsNull() ||
3804 type_arguments.IsRaw(from_index, num_type_params)) { 3804 type_arguments.IsRaw(from_index, num_type_params)) {
(...skipping 11818 matching lines...) Expand 10 before | Expand all | Expand 10 after
15623 bool AbstractType::IsFunctionType() const { 15623 bool AbstractType::IsFunctionType() const {
15624 return HasResolvedTypeClass() && 15624 return HasResolvedTypeClass() &&
15625 (type_class() == Type::Handle(Type::Function()).type_class()); 15625 (type_class() == Type::Handle(Type::Function()).type_class());
15626 } 15626 }
15627 15627
15628 15628
15629 bool AbstractType::TypeTest(TypeTestKind test_kind, 15629 bool AbstractType::TypeTest(TypeTestKind test_kind,
15630 const AbstractType& other, 15630 const AbstractType& other,
15631 Error* bound_error, 15631 Error* bound_error,
15632 Heap::Space space) const { 15632 Heap::Space space) const {
15633 ASSERT(IsResolved()); 15633 ASSERT(IsFinalized());
15634 ASSERT(other.IsResolved()); 15634 ASSERT(other.IsFinalized());
15635 if (IsMalformed() || other.IsMalformed()) { 15635 if (IsMalformed() || other.IsMalformed()) {
15636 // Malformed types involved in subtype tests should be handled specially 15636 // Malformed types involved in subtype tests should be handled specially
15637 // by the caller. Malformed types should only be encountered here in a 15637 // by the caller. Malformed types should only be encountered here in a
15638 // more specific than test. 15638 // more specific than test.
15639 ASSERT(test_kind == kIsMoreSpecificThan); 15639 ASSERT(test_kind == kIsMoreSpecificThan);
15640 return false; 15640 return false;
15641 } 15641 }
15642 // In case the type checked in a type test is malbounded, the code generator 15642 // In case the type checked in a type test is malbounded, the code generator
15643 // may compile a throw instead of a run time call performing the type check. 15643 // may compile a throw instead of a run time call performing the type check.
15644 // However, in checked mode, a function type may include malbounded result 15644 // However, in checked mode, a function type may include malbounded result
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
15678 // uninstantiated at compile time. 15678 // uninstantiated at compile time.
15679 if (IsTypeParameter()) { 15679 if (IsTypeParameter()) {
15680 const TypeParameter& type_param = TypeParameter::Cast(*this); 15680 const TypeParameter& type_param = TypeParameter::Cast(*this);
15681 if (other.IsTypeParameter()) { 15681 if (other.IsTypeParameter()) {
15682 const TypeParameter& other_type_param = TypeParameter::Cast(other); 15682 const TypeParameter& other_type_param = TypeParameter::Cast(other);
15683 if (type_param.Equals(other_type_param)) { 15683 if (type_param.Equals(other_type_param)) {
15684 return true; 15684 return true;
15685 } 15685 }
15686 } 15686 }
15687 const AbstractType& bound = AbstractType::Handle(type_param.bound()); 15687 const AbstractType& bound = AbstractType::Handle(type_param.bound());
15688 // We may be checking bounds at finalization time and can encounter
15689 // a still unfinalized bound.
15690 if (!bound.IsFinalized() && !bound.IsBeingFinalized()) {
15691 ClassFinalizer::FinalizeType(
15692 Class::Handle(type_param.parameterized_class()),
15693 bound,
15694 ClassFinalizer::kCanonicalize);
15695 type_param.set_bound(bound);
15696 }
15688 if (bound.IsMoreSpecificThan(other, bound_error)) { 15697 if (bound.IsMoreSpecificThan(other, bound_error)) {
15689 return true; 15698 return true;
15690 } 15699 }
15691 return false; // TODO(regis): We should return "maybe after instantiation". 15700 return false; // TODO(regis): We should return "maybe after instantiation".
15692 } 15701 }
15693 if (other.IsTypeParameter()) { 15702 if (other.IsTypeParameter()) {
15694 return false; // TODO(regis): We should return "maybe after instantiation". 15703 return false; // TODO(regis): We should return "maybe after instantiation".
15695 } 15704 }
15696 const Class& cls = Class::Handle(type_class()); 15705 const Class& cls = Class::Handle(type_class());
15697 return cls.TypeTest(test_kind, 15706 return cls.TypeTest(test_kind,
(...skipping 6258 matching lines...) Expand 10 before | Expand all | Expand 10 after
21956 return tag_label.ToCString(); 21965 return tag_label.ToCString();
21957 } 21966 }
21958 21967
21959 21968
21960 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21969 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21961 Instance::PrintJSONImpl(stream, ref); 21970 Instance::PrintJSONImpl(stream, ref);
21962 } 21971 }
21963 21972
21964 21973
21965 } // namespace dart 21974 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698