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

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

Issue 2965743002: [VM, generic functions reification, work in progress] (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | runtime/vm/object.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) 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 #ifndef RUNTIME_VM_OBJECT_H_ 5 #ifndef RUNTIME_VM_OBJECT_H_
6 #define RUNTIME_VM_OBJECT_H_ 6 #define RUNTIME_VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 bool IsEquivalent(const TypeArguments& other, TrailPtr trail = NULL) const { 1652 bool IsEquivalent(const TypeArguments& other, TrailPtr trail = NULL) const {
1653 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length(), trail); 1653 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length(), trail);
1654 } 1654 }
1655 bool IsSubvectorEquivalent(const TypeArguments& other, 1655 bool IsSubvectorEquivalent(const TypeArguments& other,
1656 intptr_t from_index, 1656 intptr_t from_index,
1657 intptr_t len, 1657 intptr_t len,
1658 TrailPtr trail = NULL) const; 1658 TrailPtr trail = NULL) const;
1659 1659
1660 // Check if the vector is instantiated (it must not be null). 1660 // Check if the vector is instantiated (it must not be null).
1661 bool IsInstantiated(Genericity genericity = kAny, 1661 bool IsInstantiated(Genericity genericity = kAny,
1662 intptr_t num_free_fun_type_params = kMaxInt32,
rmacnak 2017/06/30 21:52:27 2 billion type parameters should be enough for any
1662 TrailPtr trail = NULL) const { 1663 TrailPtr trail = NULL) const {
1663 return IsSubvectorInstantiated(0, Length(), genericity, trail); 1664 return IsSubvectorInstantiated(0, Length(), genericity,
1665 num_free_fun_type_params, trail);
1664 } 1666 }
1665 bool IsSubvectorInstantiated(intptr_t from_index, 1667 bool IsSubvectorInstantiated(intptr_t from_index,
1666 intptr_t len, 1668 intptr_t len,
1667 Genericity genericity = kAny, 1669 Genericity genericity = kAny,
1670 intptr_t num_free_fun_type_params = kMaxInt32,
1668 TrailPtr trail = NULL) const; 1671 TrailPtr trail = NULL) const;
1669 bool IsUninstantiatedIdentity() const; 1672 bool IsUninstantiatedIdentity() const;
1670 bool CanShareInstantiatorTypeArguments(const Class& instantiator_class) const; 1673 bool CanShareInstantiatorTypeArguments(const Class& instantiator_class) const;
1671 1674
1672 // Return true if all types of this vector are respectively, resolved, 1675 // Return true if all types of this vector are respectively, resolved,
1673 // finalized, or bounded. 1676 // finalized, or bounded.
1674 bool IsResolved() const; 1677 bool IsResolved() const;
1675 bool IsFinalized() const; 1678 bool IsFinalized() const;
1676 bool IsBounded() const; 1679 bool IsBounded() const;
1677 1680
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 // user visible signature of the given function. In this example, T and R are 2244 // user visible signature of the given function. In this example, T and R are
2242 // type parameters of class C, the owner of the function. 2245 // type parameters of class C, the owner of the function.
2243 // Implicit parameters are hidden. 2246 // Implicit parameters are hidden.
2244 RawString* UserVisibleSignature() const { 2247 RawString* UserVisibleSignature() const {
2245 return BuildSignature(kUserVisibleName); 2248 return BuildSignature(kUserVisibleName);
2246 } 2249 }
2247 2250
2248 // Returns true if the signature of this function is instantiated, i.e. if it 2251 // Returns true if the signature of this function is instantiated, i.e. if it
2249 // does not involve generic parameter types or generic result type. 2252 // does not involve generic parameter types or generic result type.
2250 bool HasInstantiatedSignature(Genericity genericity = kAny, 2253 bool HasInstantiatedSignature(Genericity genericity = kAny,
2254 intptr_t num_free_fun_type_params = kMaxInt32,
2251 TrailPtr trail = NULL) const; 2255 TrailPtr trail = NULL) const;
2252 2256
2253 // Build a string of the form 'T, {B b, C c}' representing the user 2257 // Build a string of the form 'T, {B b, C c}' representing the user
2254 // visible formal parameters of the function. 2258 // visible formal parameters of the function.
2255 RawString* UserVisibleFormalParameters() const; 2259 RawString* UserVisibleFormalParameters() const;
2256 2260
2257 // Reloading support: 2261 // Reloading support:
2258 void Reparent(const Class& new_cls) const; 2262 void Reparent(const Class& new_cls) const;
2259 void ZeroEdgeCounters() const; 2263 void ZeroEdgeCounters() const;
2260 2264
(...skipping 3503 matching lines...) Expand 10 before | Expand all | Expand 10 after
5764 virtual bool IsResolved() const; 5768 virtual bool IsResolved() const;
5765 virtual void SetIsResolved() const; 5769 virtual void SetIsResolved() const;
5766 virtual bool HasResolvedTypeClass() const; 5770 virtual bool HasResolvedTypeClass() const;
5767 virtual classid_t type_class_id() const; 5771 virtual classid_t type_class_id() const;
5768 virtual RawClass* type_class() const; 5772 virtual RawClass* type_class() const;
5769 virtual RawUnresolvedClass* unresolved_class() const; 5773 virtual RawUnresolvedClass* unresolved_class() const;
5770 virtual RawTypeArguments* arguments() const; 5774 virtual RawTypeArguments* arguments() const;
5771 virtual void set_arguments(const TypeArguments& value) const; 5775 virtual void set_arguments(const TypeArguments& value) const;
5772 virtual TokenPosition token_pos() const; 5776 virtual TokenPosition token_pos() const;
5773 virtual bool IsInstantiated(Genericity genericity = kAny, 5777 virtual bool IsInstantiated(Genericity genericity = kAny,
5778 intptr_t num_free_fun_type_params = kMaxInt32,
5774 TrailPtr trail = NULL) const; 5779 TrailPtr trail = NULL) const;
5775 virtual bool CanonicalizeEquals(const Instance& other) const { 5780 virtual bool CanonicalizeEquals(const Instance& other) const {
5776 return Equals(other); 5781 return Equals(other);
5777 } 5782 }
5778 virtual bool Equals(const Instance& other) const { 5783 virtual bool Equals(const Instance& other) const {
5779 return IsEquivalent(other); 5784 return IsEquivalent(other);
5780 } 5785 }
5781 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; 5786 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
5782 virtual bool IsRecursive() const; 5787 virtual bool IsRecursive() const;
5783 5788
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
5985 virtual bool HasResolvedTypeClass() const; // Own type class resolved. 5990 virtual bool HasResolvedTypeClass() const; // Own type class resolved.
5986 virtual classid_t type_class_id() const; 5991 virtual classid_t type_class_id() const;
5987 virtual RawClass* type_class() const; 5992 virtual RawClass* type_class() const;
5988 void set_type_class(const Class& value) const; 5993 void set_type_class(const Class& value) const;
5989 void set_unresolved_class(const Object& value) const; 5994 void set_unresolved_class(const Object& value) const;
5990 virtual RawUnresolvedClass* unresolved_class() const; 5995 virtual RawUnresolvedClass* unresolved_class() const;
5991 virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; } 5996 virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; }
5992 virtual void set_arguments(const TypeArguments& value) const; 5997 virtual void set_arguments(const TypeArguments& value) const;
5993 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } 5998 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; }
5994 virtual bool IsInstantiated(Genericity genericity = kAny, 5999 virtual bool IsInstantiated(Genericity genericity = kAny,
6000 intptr_t num_free_fun_type_params = kMaxInt32,
5995 TrailPtr trail = NULL) const; 6001 TrailPtr trail = NULL) const;
5996 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; 6002 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
5997 virtual bool IsRecursive() const; 6003 virtual bool IsRecursive() const;
5998 // If signature is not null, this type represents a function type. Note that 6004 // If signature is not null, this type represents a function type. Note that
5999 // the signature fully represents the type and type arguments can be ignored. 6005 // the signature fully represents the type and type arguments can be ignored.
6000 // However, in case of a generic typedef, they document how the typedef class 6006 // However, in case of a generic typedef, they document how the typedef class
6001 // was parameterized to obtain the actual signature. 6007 // was parameterized to obtain the actual signature.
6002 RawFunction* signature() const; 6008 RawFunction* signature() const;
6003 void set_signature(const Function& value) const; 6009 void set_signature(const Function& value) const;
6004 virtual bool IsFunctionType() const { 6010 virtual bool IsFunctionType() const {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
6134 virtual RawClass* type_class() const { 6140 virtual RawClass* type_class() const {
6135 return AbstractType::Handle(type()).type_class(); 6141 return AbstractType::Handle(type()).type_class();
6136 } 6142 }
6137 virtual RawTypeArguments* arguments() const { 6143 virtual RawTypeArguments* arguments() const {
6138 return AbstractType::Handle(type()).arguments(); 6144 return AbstractType::Handle(type()).arguments();
6139 } 6145 }
6140 virtual TokenPosition token_pos() const { 6146 virtual TokenPosition token_pos() const {
6141 return AbstractType::Handle(type()).token_pos(); 6147 return AbstractType::Handle(type()).token_pos();
6142 } 6148 }
6143 virtual bool IsInstantiated(Genericity genericity = kAny, 6149 virtual bool IsInstantiated(Genericity genericity = kAny,
6150 intptr_t num_free_fun_type_params = kMaxInt32,
6144 TrailPtr trail = NULL) const; 6151 TrailPtr trail = NULL) const;
6145 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; 6152 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
6146 virtual bool IsRecursive() const { return true; } 6153 virtual bool IsRecursive() const { return true; }
6147 virtual RawTypeRef* InstantiateFrom( 6154 virtual RawTypeRef* InstantiateFrom(
6148 const TypeArguments& instantiator_type_arguments, 6155 const TypeArguments& instantiator_type_arguments,
6149 const TypeArguments& function_type_arguments, 6156 const TypeArguments& function_type_arguments,
6150 Error* bound_error, 6157 Error* bound_error,
6151 TrailPtr instantiation_trail, 6158 TrailPtr instantiation_trail,
6152 TrailPtr bound_trail, 6159 TrailPtr bound_trail,
6153 Heap::Space space) const; 6160 Heap::Space space) const;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
6219 // and set bound_error if both bounded_type and upper_bound are instantiated. 6226 // and set bound_error if both bounded_type and upper_bound are instantiated.
6220 // If one or both are not instantiated, returning false only means that the 6227 // If one or both are not instantiated, returning false only means that the
6221 // bound cannot be checked yet and this is not an error. 6228 // bound cannot be checked yet and this is not an error.
6222 bool CheckBound(const AbstractType& bounded_type, 6229 bool CheckBound(const AbstractType& bounded_type,
6223 const AbstractType& upper_bound, 6230 const AbstractType& upper_bound,
6224 Error* bound_error, 6231 Error* bound_error,
6225 TrailPtr bound_trail, 6232 TrailPtr bound_trail,
6226 Heap::Space space) const; 6233 Heap::Space space) const;
6227 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } 6234 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; }
6228 virtual bool IsInstantiated(Genericity genericity = kAny, 6235 virtual bool IsInstantiated(Genericity genericity = kAny,
6236 intptr_t num_free_fun_type_params = kMaxInt32,
6229 TrailPtr trail = NULL) const; 6237 TrailPtr trail = NULL) const;
6230 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; 6238 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
6231 virtual bool IsRecursive() const { return false; } 6239 virtual bool IsRecursive() const { return false; }
6232 virtual RawAbstractType* InstantiateFrom( 6240 virtual RawAbstractType* InstantiateFrom(
6233 const TypeArguments& instantiator_type_arguments, 6241 const TypeArguments& instantiator_type_arguments,
6234 const TypeArguments& function_type_arguments, 6242 const TypeArguments& function_type_arguments,
6235 Error* bound_error, 6243 Error* bound_error,
6236 TrailPtr instantiation_trail, 6244 TrailPtr instantiation_trail,
6237 TrailPtr bound_trail, 6245 TrailPtr bound_trail,
6238 Heap::Space space) const; 6246 Heap::Space space) const;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
6313 } 6321 }
6314 RawAbstractType* type() const { return raw_ptr()->type_; } 6322 RawAbstractType* type() const { return raw_ptr()->type_; }
6315 RawAbstractType* bound() const { return raw_ptr()->bound_; } 6323 RawAbstractType* bound() const { return raw_ptr()->bound_; }
6316 RawTypeParameter* type_parameter() const { 6324 RawTypeParameter* type_parameter() const {
6317 return raw_ptr()->type_parameter_; 6325 return raw_ptr()->type_parameter_;
6318 } 6326 }
6319 virtual TokenPosition token_pos() const { 6327 virtual TokenPosition token_pos() const {
6320 return AbstractType::Handle(type()).token_pos(); 6328 return AbstractType::Handle(type()).token_pos();
6321 } 6329 }
6322 virtual bool IsInstantiated(Genericity genericity = kAny, 6330 virtual bool IsInstantiated(Genericity genericity = kAny,
6331 intptr_t num_free_fun_type_params = kMaxInt32,
6323 TrailPtr trail = NULL) const { 6332 TrailPtr trail = NULL) const {
6324 // It is not possible to encounter an instantiated bounded type with an 6333 // It is not possible to encounter an instantiated bounded type with an
6325 // uninstantiated upper bound. Therefore, we do not need to check if the 6334 // uninstantiated upper bound. Therefore, we do not need to check if the
6326 // bound is instantiated. Moreover, doing so could lead into cycles, as in 6335 // bound is instantiated. Moreover, doing so could lead into cycles, as in
6327 // class C<T extends C<C>> { }. 6336 // class C<T extends C<C>> { }.
6328 return AbstractType::Handle(type()).IsInstantiated(genericity, trail); 6337 return AbstractType::Handle(type()).IsInstantiated(
6338 genericity, num_free_fun_type_params, trail);
6329 } 6339 }
6330 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; 6340 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
6331 virtual bool IsRecursive() const; 6341 virtual bool IsRecursive() const;
6332 virtual RawAbstractType* InstantiateFrom( 6342 virtual RawAbstractType* InstantiateFrom(
6333 const TypeArguments& instantiator_type_arguments, 6343 const TypeArguments& instantiator_type_arguments,
6334 const TypeArguments& function_type_arguments, 6344 const TypeArguments& function_type_arguments,
6335 Error* bound_error, 6345 Error* bound_error,
6336 TrailPtr instantiation_trail, 6346 TrailPtr instantiation_trail,
6337 TrailPtr bound_trail, 6347 TrailPtr bound_trail,
6338 Heap::Space space) const; 6348 Heap::Space space) const;
(...skipping 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after
9061 9071
9062 inline void TypeArguments::SetHash(intptr_t value) const { 9072 inline void TypeArguments::SetHash(intptr_t value) const {
9063 // This is only safe because we create a new Smi, which does not cause 9073 // This is only safe because we create a new Smi, which does not cause
9064 // heap allocation. 9074 // heap allocation.
9065 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 9075 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
9066 } 9076 }
9067 9077
9068 } // namespace dart 9078 } // namespace dart
9069 9079
9070 #endif // RUNTIME_VM_OBJECT_H_ 9080 #endif // RUNTIME_VM_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698