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

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

Issue 2979763002: [VM generic function types] Properly set the scope function after parsing a (Closed)
Patch Set: work in progress Created 3 years, 5 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) 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/become.h" 10 #include "vm/become.h"
(...skipping 4759 matching lines...) Expand 10 before | Expand all | Expand 10 after
4770 // type argument will be replaced by a non-null type before the type is 4770 // type argument will be replaced by a non-null type before the type is
4771 // marked as finalized. 4771 // marked as finalized.
4772 if (type.IsNull() || type.IsRecursive()) { 4772 if (type.IsNull() || type.IsRecursive()) {
4773 return true; 4773 return true;
4774 } 4774 }
4775 } 4775 }
4776 return false; 4776 return false;
4777 } 4777 }
4778 4778
4779 4779
4780 void TypeArguments::SetScopeFunction(const Function& function) const {
4781 if (IsNull()) return;
4782 const intptr_t num_types = Length();
4783 AbstractType& type = AbstractType::Handle();
4784 for (intptr_t i = 0; i < num_types; i++) {
4785 type = TypeAt(i);
4786 if (!type.IsNull()) {
4787 type.SetScopeFunction(function);
4788 }
4789 }
4790 }
4791
4792
4780 bool TypeArguments::IsDynamicTypes(bool raw_instantiated, 4793 bool TypeArguments::IsDynamicTypes(bool raw_instantiated,
4781 intptr_t from_index, 4794 intptr_t from_index,
4782 intptr_t len) const { 4795 intptr_t len) const {
4783 ASSERT(Length() >= (from_index + len)); 4796 ASSERT(Length() >= (from_index + len));
4784 AbstractType& type = AbstractType::Handle(); 4797 AbstractType& type = AbstractType::Handle();
4785 Class& type_class = Class::Handle(); 4798 Class& type_class = Class::Handle();
4786 for (intptr_t i = 0; i < len; i++) { 4799 for (intptr_t i = 0; i < len; i++) {
4787 type = TypeAt(from_index + i); 4800 type = TypeAt(from_index + i);
4788 if (type.IsNull()) { 4801 if (type.IsNull()) {
4789 return false; 4802 return false;
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
5726 ASSERT(!obj.IsNull()); 5739 ASSERT(!obj.IsNull());
5727 if (IsSignatureFunction()) { 5740 if (IsSignatureFunction()) {
5728 return SignatureData::Cast(obj).signature_type(); 5741 return SignatureData::Cast(obj).signature_type();
5729 } else { 5742 } else {
5730 ASSERT(IsClosureFunction()); 5743 ASSERT(IsClosureFunction());
5731 return ClosureData::Cast(obj).signature_type(); 5744 return ClosureData::Cast(obj).signature_type();
5732 } 5745 }
5733 } 5746 }
5734 5747
5735 5748
5736 RawFunction* Function::CanonicalSignatureFunction(TrailPtr trail) const {
5737 ASSERT(!IsSignatureFunction());
5738 Zone* zone = Thread::Current()->zone();
5739 Function& parent = Function::Handle(zone, parent_function());
5740 if (!parent.IsNull() && !parent.IsSignatureFunction()) {
5741 // Make sure the parent function is also a signature function.
5742 parent = parent.CanonicalSignatureFunction(trail);
5743 }
5744 const Class& owner = Class::Handle(zone, Owner());
5745 const Function& sig_fun = Function::Handle(
5746 zone,
5747 Function::NewSignatureFunction(owner, parent, TokenPosition::kNoSource));
5748 // In case of a generic function, the function type parameters in the
5749 // signature will still refer to the original function. This should not
5750 // be a problem, since once finalized the indices will be identical.
5751 sig_fun.set_type_parameters(TypeArguments::Handle(zone, type_parameters()));
5752 ASSERT(HasGenericParent() == sig_fun.HasGenericParent());
5753 ASSERT(IsGeneric() == sig_fun.IsGeneric());
5754 AbstractType& type = AbstractType::Handle(zone);
5755 type = result_type();
5756 type = type.Canonicalize(trail);
5757 sig_fun.set_result_type(type);
5758 const intptr_t num_params = NumParameters();
5759 sig_fun.set_num_fixed_parameters(num_fixed_parameters());
5760 sig_fun.SetNumOptionalParameters(NumOptionalParameters(),
5761 HasOptionalPositionalParameters());
5762 sig_fun.set_parameter_types(
5763 Array::Handle(Array::New(num_params, Heap::kOld)));
5764 for (intptr_t i = 0; i < num_params; i++) {
5765 type = ParameterTypeAt(i);
5766 type = type.Canonicalize(trail);
5767 sig_fun.SetParameterTypeAt(i, type);
5768 }
5769 sig_fun.set_parameter_names(Array::Handle(zone, parameter_names()));
5770 return sig_fun.raw();
5771 }
5772
5773
5774 RawType* Function::SignatureType() const { 5749 RawType* Function::SignatureType() const {
5775 Type& type = Type::Handle(ExistingSignatureType()); 5750 Type& type = Type::Handle(ExistingSignatureType());
5776 if (type.IsNull()) { 5751 if (type.IsNull()) {
5777 // The function type of this function is not yet cached and needs to be 5752 // The function type of this function is not yet cached and needs to be
5778 // constructed and cached here. 5753 // constructed and cached here.
5779 // A function type is type parameterized in the same way as the owner class 5754 // A function type is type parameterized in the same way as the owner class
5780 // of its non-static signature function. 5755 // of its non-static signature function.
5781 // It is not type parameterized if its signature function is static, or if 5756 // It is not type parameterized if its signature function is static, or if
5782 // none of its result type or formal parameter types are type parameterized. 5757 // none of its result type or formal parameter types are type parameterized.
5783 // Unless the function type is a generic typedef, the type arguments of the 5758 // Unless the function type is a generic typedef, the type arguments of the
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
6038 const Array& pair = Array::Handle(Array::New(2, Heap::kOld)); 6013 const Array& pair = Array::Handle(Array::New(2, Heap::kOld));
6039 pair.SetAt(0, value); 6014 pair.SetAt(0, value);
6040 // pair[1] will be the implicit closure function if needed. 6015 // pair[1] will be the implicit closure function if needed.
6041 set_data(pair); 6016 set_data(pair);
6042 } 6017 }
6043 6018
6044 6019
6045 void Function::set_result_type(const AbstractType& value) const { 6020 void Function::set_result_type(const AbstractType& value) const {
6046 ASSERT(!value.IsNull()); 6021 ASSERT(!value.IsNull());
6047 StorePointer(&raw_ptr()->result_type_, value.raw()); 6022 StorePointer(&raw_ptr()->result_type_, value.raw());
6048 if (value.IsFunctionType()) {
6049 // The function result type may refer to this function's type parameters.
6050 // Change its parent function.
6051 const Function& result_signature_function =
6052 Function::Handle(Type::Cast(value).signature());
6053 result_signature_function.set_parent_function(*this);
6054 }
6055 } 6023 }
6056 6024
6057 6025
6058 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const { 6026 RawAbstractType* Function::ParameterTypeAt(intptr_t index) const {
6059 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_); 6027 const Array& parameter_types = Array::Handle(raw_ptr()->parameter_types_);
6060 return AbstractType::RawCast(parameter_types.At(index)); 6028 return AbstractType::RawCast(parameter_types.At(index));
6061 } 6029 }
6062 6030
6063 6031
6064 void Function::SetParameterTypeAt(intptr_t index, 6032 void Function::SetParameterTypeAt(intptr_t index,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
6114 6082
6115 intptr_t Function::NumParentTypeParameters() const { 6083 intptr_t Function::NumParentTypeParameters() const {
6116 if (IsImplicitClosureFunction()) { 6084 if (IsImplicitClosureFunction()) {
6117 return 0; 6085 return 0;
6118 } 6086 }
6119 Thread* thread = Thread::Current(); 6087 Thread* thread = Thread::Current();
6120 Function& parent = Function::Handle(parent_function()); 6088 Function& parent = Function::Handle(parent_function());
6121 intptr_t num_parent_type_params = 0; 6089 intptr_t num_parent_type_params = 0;
6122 while (!parent.IsNull()) { 6090 while (!parent.IsNull()) {
6123 num_parent_type_params += parent.NumTypeParameters(thread); 6091 num_parent_type_params += parent.NumTypeParameters(thread);
6092 if (parent.IsImplicitClosureFunction()) break;
6124 parent ^= parent.parent_function(); 6093 parent ^= parent.parent_function();
6125 } 6094 }
6126 return num_parent_type_params; 6095 return num_parent_type_params;
6127 } 6096 }
6128 6097
6129 6098
6099 void Function::PrintSignatureTypes() const {
6100 Function& sig_fun = Function::Handle(raw());
6101 Type& sig_type = Type::Handle();
6102 while (!sig_fun.IsNull()) {
6103 sig_type = sig_fun.SignatureType();
6104 THR_Print("%s%s\n",
6105 sig_fun.IsImplicitClosureFunction() ? "implicit closure: " : "",
6106 sig_type.ToCString());
6107 sig_fun ^= sig_fun.parent_function();
6108 }
6109 }
6110
6111
6130 RawTypeParameter* Function::LookupTypeParameter( 6112 RawTypeParameter* Function::LookupTypeParameter(
6131 const String& type_name, 6113 const String& type_name,
6132 intptr_t* function_level) const { 6114 intptr_t* function_level) const {
6133 ASSERT(!type_name.IsNull()); 6115 ASSERT(!type_name.IsNull());
6134 Thread* thread = Thread::Current(); 6116 Thread* thread = Thread::Current();
6135 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread); 6117 REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread);
6136 REUSABLE_TYPE_PARAMETER_HANDLESCOPE(thread); 6118 REUSABLE_TYPE_PARAMETER_HANDLESCOPE(thread);
6137 REUSABLE_STRING_HANDLESCOPE(thread); 6119 REUSABLE_STRING_HANDLESCOPE(thread);
6138 REUSABLE_FUNCTION_HANDLESCOPE(thread); 6120 REUSABLE_FUNCTION_HANDLESCOPE(thread);
6139 TypeArguments& type_params = thread->TypeArgumentsHandle(); 6121 TypeArguments& type_params = thread->TypeArgumentsHandle();
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
6596 return true; 6578 return true;
6597 } 6579 }
6598 6580
6599 6581
6600 RawFunction* Function::InstantiateSignatureFrom( 6582 RawFunction* Function::InstantiateSignatureFrom(
6601 const TypeArguments& instantiator_type_arguments, 6583 const TypeArguments& instantiator_type_arguments,
6602 const TypeArguments& function_type_arguments, 6584 const TypeArguments& function_type_arguments,
6603 Heap::Space space) const { 6585 Heap::Space space) const {
6604 Zone* zone = Thread::Current()->zone(); 6586 Zone* zone = Thread::Current()->zone();
6605 const Object& owner = Object::Handle(zone, RawOwner()); 6587 const Object& owner = Object::Handle(zone, RawOwner());
6588 // Note that parent pointers in newly instantiated signatures still points to
6589 // the original uninstantiated parent signatures. That is not a problem.
6606 const Function& parent = Function::Handle(zone, parent_function()); 6590 const Function& parent = Function::Handle(zone, parent_function());
6607 ASSERT(!HasInstantiatedSignature()); 6591 ASSERT(!HasInstantiatedSignature());
6608 Function& sig = Function::Handle( 6592 Function& sig = Function::Handle(
6609 zone, Function::NewSignatureFunction(owner, parent, 6593 zone, Function::NewSignatureFunction(owner, parent,
6610 TokenPosition::kNoSource, space)); 6594 TokenPosition::kNoSource, space));
6611 sig.set_type_parameters(TypeArguments::Handle(zone, type_parameters())); 6595 sig.set_type_parameters(TypeArguments::Handle(zone, type_parameters()));
6612 AbstractType& type = AbstractType::Handle(zone, result_type()); 6596 AbstractType& type = AbstractType::Handle(zone, result_type());
6613 if (!type.IsInstantiated()) { 6597 if (!type.IsInstantiated()) {
6614 type = 6598 type =
6615 type.InstantiateFrom(instantiator_type_arguments, 6599 type.InstantiateFrom(instantiator_type_arguments,
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
7291 name = res_type.BuildName(name_visibility); 7275 name = res_type.BuildName(name_visibility);
7292 pieces.Add(name); 7276 pieces.Add(name);
7293 return Symbols::FromConcatAll(thread, pieces); 7277 return Symbols::FromConcatAll(thread, pieces);
7294 } 7278 }
7295 7279
7296 7280
7297 bool Function::HasInstantiatedSignature(Genericity genericity, 7281 bool Function::HasInstantiatedSignature(Genericity genericity,
7298 intptr_t num_free_fun_type_params, 7282 intptr_t num_free_fun_type_params,
7299 TrailPtr trail) const { 7283 TrailPtr trail) const {
7300 if (genericity != kCurrentClass) { 7284 if (genericity != kCurrentClass) {
7301 // We only consider the function type parameters declared by the parents of 7285 // A generic typedef may declare a non-generic function type and get
7302 // this signature function. 7286 // instantiated with unrelated function type parameters. In that case, its
7303 const int num_parent_type_params = NumParentTypeParameters(); 7287 // signature is still uninstantiated, because these type parameters are
7304 if (num_parent_type_params < num_free_fun_type_params) { 7288 // free (they are not declared by the typedef).
7305 num_free_fun_type_params = num_parent_type_params; 7289 // For that reason, we only adjust num_free_fun_type_params is this
rmacnak 2017/07/19 19:56:39 if
regis 2017/07/19 20:14:23 Done.
7290 // signature is generic or has a generic parent.
7291 if (IsGeneric() || HasGenericParent()) {
7292 // We only consider the function type parameters declared by the parents
7293 // of this signature function as free.
7294 const int num_parent_type_params = NumParentTypeParameters();
7295 if (num_parent_type_params < num_free_fun_type_params) {
7296 num_free_fun_type_params = num_parent_type_params;
7297 }
7306 } 7298 }
7299 // TODO(regis): Should we check the owners of the function type parameters
7300 // in addition to their indexes to decide if they are free or not?
7307 } 7301 }
7308 AbstractType& type = AbstractType::Handle(result_type()); 7302 AbstractType& type = AbstractType::Handle(result_type());
7309 if (!type.IsInstantiated(genericity, num_free_fun_type_params, trail)) { 7303 if (!type.IsInstantiated(genericity, num_free_fun_type_params, trail)) {
7310 return false; 7304 return false;
7311 } 7305 }
7312 const intptr_t num_parameters = NumParameters(); 7306 const intptr_t num_parameters = NumParameters();
7313 for (intptr_t i = 0; i < num_parameters; i++) { 7307 for (intptr_t i = 0; i < num_parameters; i++) {
7314 type = ParameterTypeAt(i); 7308 type = ParameterTypeAt(i);
7315 if (!type.IsInstantiated(genericity, num_free_fun_type_params, trail)) { 7309 if (!type.IsInstantiated(genericity, num_free_fun_type_params, trail)) {
7316 return false; 7310 return false;
(...skipping 9109 matching lines...) Expand 10 before | Expand all | Expand 10 after
16426 } 16420 }
16427 16421
16428 16422
16429 bool AbstractType::IsRecursive() const { 16423 bool AbstractType::IsRecursive() const {
16430 // AbstractType is an abstract class. 16424 // AbstractType is an abstract class.
16431 UNREACHABLE(); 16425 UNREACHABLE();
16432 return false; 16426 return false;
16433 } 16427 }
16434 16428
16435 16429
16430 void AbstractType::SetScopeFunction(const Function& function) const {
16431 // AbstractType is an abstract class.
16432 UNREACHABLE();
16433 }
16434
16435
16436 RawAbstractType* AbstractType::InstantiateFrom( 16436 RawAbstractType* AbstractType::InstantiateFrom(
16437 const TypeArguments& instantiator_type_arguments, 16437 const TypeArguments& instantiator_type_arguments,
16438 const TypeArguments& function_type_arguments, 16438 const TypeArguments& function_type_arguments,
16439 Error* bound_error, 16439 Error* bound_error,
16440 TrailPtr instantiation_trail, 16440 TrailPtr instantiation_trail,
16441 TrailPtr bound_trail, 16441 TrailPtr bound_trail,
16442 Heap::Space space) const { 16442 Heap::Space space) const {
16443 // AbstractType is an abstract class. 16443 // AbstractType is an abstract class.
16444 UNREACHABLE(); 16444 UNREACHABLE();
16445 return NULL; 16445 return NULL;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
16853 // For example, with class A<K, V extends K>, new A<T, T> called from within 16853 // For example, with class A<K, V extends K>, new A<T, T> called from within
16854 // a class B<T> will never require a run time bound check, even if T is 16854 // a class B<T> will never require a run time bound check, even if T is
16855 // uninstantiated at compile time. 16855 // uninstantiated at compile time.
16856 if (IsTypeParameter()) { 16856 if (IsTypeParameter()) {
16857 const TypeParameter& type_param = TypeParameter::Cast(*this); 16857 const TypeParameter& type_param = TypeParameter::Cast(*this);
16858 if (other.IsTypeParameter()) { 16858 if (other.IsTypeParameter()) {
16859 const TypeParameter& other_type_param = TypeParameter::Cast(other); 16859 const TypeParameter& other_type_param = TypeParameter::Cast(other);
16860 if (type_param.Equals(other_type_param)) { 16860 if (type_param.Equals(other_type_param)) {
16861 return true; 16861 return true;
16862 } 16862 }
16863 // TODO(regis): Should we update TypeParameter::IsEquivalent() instead?
16864 if (type_param.IsFunctionTypeParameter() && 16863 if (type_param.IsFunctionTypeParameter() &&
16865 other_type_param.IsFunctionTypeParameter() && 16864 other_type_param.IsFunctionTypeParameter() &&
16866 type_param.IsFinalized() && other_type_param.IsFinalized()) { 16865 type_param.IsFinalized() && other_type_param.IsFinalized()) {
16867 // To be compatible, the function type parameters should be declared at 16866 // To be compatible, the function type parameters should be declared at
16868 // the same position in the generic function. Their index therefore 16867 // the same position in the generic function. Their index therefore
16869 // needs adjustement before comparison. 16868 // needs adjustement before comparison.
16870 // Example: 'foo<F>(bar<B>(B b)) { }' and 'baz<Z>(Z z) { }', baz can be 16869 // Example: 'foo<F>(bar<B>(B b)) { }' and 'baz<Z>(Z z) { }', baz can be
16871 // assigned to bar, although B has index 1 and Z index 0. 16870 // assigned to bar, although B has index 1 and Z index 0.
16872 const Function& sig_fun = 16871 const Function& sig_fun =
16873 Function::Handle(zone, type_param.parameterized_function()); 16872 Function::Handle(zone, type_param.parameterized_function());
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
17476 } 17475 }
17477 return true; 17476 return true;
17478 } 17477 }
17479 17478
17480 17479
17481 bool Type::IsRecursive() const { 17480 bool Type::IsRecursive() const {
17482 return TypeArguments::Handle(arguments()).IsRecursive(); 17481 return TypeArguments::Handle(arguments()).IsRecursive();
17483 } 17482 }
17484 17483
17485 17484
17485 void Type::SetScopeFunction(const Function& function) const {
17486 TypeArguments::Handle(arguments()).SetScopeFunction(function);
17487 if (IsFunctionType()) {
17488 const Function& sig_fun = Function::Handle(signature());
17489 sig_fun.set_parent_function(function);
17490 // No need to traverse result type and parameter types (and bounds, in case
17491 // sig_fun is generic), since they have sig_fun as scope function.
17492 }
17493 }
17494
17495
17486 RawAbstractType* Type::CloneUnfinalized() const { 17496 RawAbstractType* Type::CloneUnfinalized() const {
17487 ASSERT(IsResolved()); 17497 ASSERT(IsResolved());
17488 if (IsFinalized()) { 17498 if (IsFinalized()) {
17489 return raw(); 17499 return raw();
17490 } 17500 }
17491 ASSERT(!IsMalformed()); // Malformed types are finalized. 17501 ASSERT(!IsMalformed()); // Malformed types are finalized.
17492 ASSERT(!IsBeingFinalized()); // Cloning must occur prior to finalization. 17502 ASSERT(!IsBeingFinalized()); // Cloning must occur prior to finalization.
17493 Zone* zone = Thread::Current()->zone(); 17503 Zone* zone = Thread::Current()->zone();
17494 const TypeArguments& type_args = TypeArguments::Handle(zone, arguments()); 17504 const TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
17495 const TypeArguments& type_args_clone = 17505 const TypeArguments& type_args_clone =
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
17716 if (IsCanonical()) { 17726 if (IsCanonical()) {
17717 // Canonicalizing type_args canonicalized this type as a side effect. 17727 // Canonicalizing type_args canonicalized this type as a side effect.
17718 ASSERT(IsRecursive()); 17728 ASSERT(IsRecursive());
17719 // Cycles via typedefs are detected and disallowed, but a function type 17729 // Cycles via typedefs are detected and disallowed, but a function type
17720 // can be recursive due to a cycle in its type arguments. 17730 // can be recursive due to a cycle in its type arguments.
17721 return this->raw(); 17731 return this->raw();
17722 } 17732 }
17723 set_arguments(type_args); 17733 set_arguments(type_args);
17724 ASSERT(type_args.IsNull() || type_args.IsOld()); 17734 ASSERT(type_args.IsNull() || type_args.IsOld());
17725 17735
17726 // In case of a function type, replace the actual function by a signature 17736 // In case of a function type, the signature has already been canonicalized
17727 // function. 17737 // when finalizing the type and passing kCanonicalize as finalization.
17728 if (IsFunctionType()) { 17738 // Therefore, we do not canonicalize the signature here, which would have no
17729 Function& sig_fun = Function::Handle(zone, signature()); 17739 // effect on selecting the canonical type anyway, because the function
17730 if (!sig_fun.IsSignatureFunction()) { 17740 // object is not replaced when canonicalizing the signature.
17731 sig_fun = sig_fun.CanonicalSignatureFunction(trail);
17732 set_signature(sig_fun);
17733 // Note that the signature type of the signature function may be
17734 // different than the type being canonicalized.
17735 // Consider F<int> being canonicalized, with F being a typedef and F<T>
17736 // being its signature type.
17737 }
17738 }
17739 17741
17740 // Check to see if the type got added to canonical list as part of the 17742 // Check to see if the type got added to canonical list as part of the
17741 // type arguments canonicalization. 17743 // type arguments canonicalization.
17742 SafepointMutexLocker ml(isolate->type_canonicalization_mutex()); 17744 SafepointMutexLocker ml(isolate->type_canonicalization_mutex());
17743 CanonicalTypeSet table(zone, object_store->canonical_types()); 17745 CanonicalTypeSet table(zone, object_store->canonical_types());
17744 type ^= table.GetOrNull(CanonicalTypeKey(*this)); 17746 type ^= table.GetOrNull(CanonicalTypeKey(*this));
17745 if (type.IsNull()) { 17747 if (type.IsNull()) {
17746 // Add this Type into the canonical list of types. 17748 // Add this Type into the canonical list of types.
17747 if (this->IsNew()) { 17749 if (this->IsNew()) {
17748 type ^= Object::Clone(*this, Heap::kOld); 17750 type ^= Object::Clone(*this, Heap::kOld);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
17976 return false; 17978 return false;
17977 } 17979 }
17978 if (TestAndAddBuddyToTrail(&trail, AbstractType::Cast(other))) { 17980 if (TestAndAddBuddyToTrail(&trail, AbstractType::Cast(other))) {
17979 return true; 17981 return true;
17980 } 17982 }
17981 const AbstractType& ref_type = AbstractType::Handle(type()); 17983 const AbstractType& ref_type = AbstractType::Handle(type());
17982 return !ref_type.IsNull() && ref_type.IsEquivalent(other, trail); 17984 return !ref_type.IsNull() && ref_type.IsEquivalent(other, trail);
17983 } 17985 }
17984 17986
17985 17987
17988 void TypeRef::SetScopeFunction(const Function& function) const {
17989 // TypeRefs are created during finalization, when scope functions have
17990 // already been adjusted.
17991 UNREACHABLE();
17992 }
17993
17994
17986 RawTypeRef* TypeRef::InstantiateFrom( 17995 RawTypeRef* TypeRef::InstantiateFrom(
17987 const TypeArguments& instantiator_type_arguments, 17996 const TypeArguments& instantiator_type_arguments,
17988 const TypeArguments& function_type_arguments, 17997 const TypeArguments& function_type_arguments,
17989 Error* bound_error, 17998 Error* bound_error,
17990 TrailPtr instantiation_trail, 17999 TrailPtr instantiation_trail,
17991 TrailPtr bound_trail, 18000 TrailPtr bound_trail,
17992 Heap::Space space) const { 18001 Heap::Space space) const {
17993 TypeRef& instantiated_type_ref = TypeRef::Handle(); 18002 TypeRef& instantiated_type_ref = TypeRef::Handle();
17994 instantiated_type_ref ^= OnlyBuddyInTrail(instantiation_trail); 18003 instantiated_type_ref ^= OnlyBuddyInTrail(instantiation_trail);
17995 if (!instantiated_type_ref.IsNull()) { 18004 if (!instantiated_type_ref.IsNull()) {
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
18536 return this_bound.IsFinalized() && other_bound.IsFinalized() && 18545 return this_bound.IsFinalized() && other_bound.IsFinalized() &&
18537 this_bound.Equals(other_bound); // Different graph, do not pass trail. 18546 this_bound.Equals(other_bound); // Different graph, do not pass trail.
18538 } 18547 }
18539 18548
18540 18549
18541 bool BoundedType::IsRecursive() const { 18550 bool BoundedType::IsRecursive() const {
18542 return AbstractType::Handle(type()).IsRecursive(); 18551 return AbstractType::Handle(type()).IsRecursive();
18543 } 18552 }
18544 18553
18545 18554
18555 void BoundedType::SetScopeFunction(const Function& function) const {
18556 AbstractType::Handle(type()).SetScopeFunction(function);
18557 AbstractType::Handle(bound()).SetScopeFunction(function);
18558 }
18559
18560
18546 void BoundedType::set_type(const AbstractType& value) const { 18561 void BoundedType::set_type(const AbstractType& value) const {
18547 ASSERT(value.IsFinalized() || value.IsBeingFinalized() || 18562 ASSERT(value.IsFinalized() || value.IsBeingFinalized() ||
18548 value.IsTypeParameter()); 18563 value.IsTypeParameter());
18549 ASSERT(!value.IsMalformed()); 18564 ASSERT(!value.IsMalformed());
18550 StorePointer(&raw_ptr()->type_, value.raw()); 18565 StorePointer(&raw_ptr()->type_, value.raw());
18551 } 18566 }
18552 18567
18553 18568
18554 void BoundedType::set_bound(const AbstractType& value) const { 18569 void BoundedType::set_bound(const AbstractType& value) const {
18555 // The bound may still be unfinalized because of legal cycles. 18570 // The bound may still be unfinalized because of legal cycles.
(...skipping 5033 matching lines...) Expand 10 before | Expand all | Expand 10 after
23589 return UserTag::null(); 23604 return UserTag::null();
23590 } 23605 }
23591 23606
23592 23607
23593 const char* UserTag::ToCString() const { 23608 const char* UserTag::ToCString() const {
23594 const String& tag_label = String::Handle(label()); 23609 const String& tag_label = String::Handle(label());
23595 return tag_label.ToCString(); 23610 return tag_label.ToCString();
23596 } 23611 }
23597 23612
23598 } // namespace dart 23613 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698