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

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

Issue 2818273002: Remove parent_level field of function type parameters. (Closed)
Patch Set: address comments Created 3 years, 8 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 | « runtime/vm/kernel_to_il.cc ('k') | 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return *null_string_; 357 return *null_string_;
358 } 358 }
359 static const Instance& null_instance() { 359 static const Instance& null_instance() {
360 ASSERT(null_instance_ != NULL); 360 ASSERT(null_instance_ != NULL);
361 return *null_instance_; 361 return *null_instance_;
362 } 362 }
363 static const TypeArguments& null_type_arguments() { 363 static const TypeArguments& null_type_arguments() {
364 ASSERT(null_type_arguments_ != NULL); 364 ASSERT(null_type_arguments_ != NULL);
365 return *null_type_arguments_; 365 return *null_type_arguments_;
366 } 366 }
367 static const TypeArguments& empty_type_arguments() {
368 ASSERT(empty_type_arguments_ != NULL);
369 return *empty_type_arguments_;
370 }
367 371
368 static const Array& empty_array() { 372 static const Array& empty_array() {
369 ASSERT(empty_array_ != NULL); 373 ASSERT(empty_array_ != NULL);
370 return *empty_array_; 374 return *empty_array_;
371 } 375 }
372 static const Array& zero_array() { 376 static const Array& zero_array() {
373 ASSERT(zero_array_ != NULL); 377 ASSERT(zero_array_ != NULL);
374 return *zero_array_; 378 return *zero_array_;
375 } 379 }
376 380
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 static RawClass* unhandled_exception_class_; // Class of UnhandledException. 785 static RawClass* unhandled_exception_class_; // Class of UnhandledException.
782 static RawClass* unwind_error_class_; // Class of UnwindError. 786 static RawClass* unwind_error_class_; // Class of UnwindError.
783 787
784 // The static values below are read-only handle pointers for singleton 788 // The static values below are read-only handle pointers for singleton
785 // objects that are shared between the different isolates. 789 // objects that are shared between the different isolates.
786 static Object* null_object_; 790 static Object* null_object_;
787 static Array* null_array_; 791 static Array* null_array_;
788 static String* null_string_; 792 static String* null_string_;
789 static Instance* null_instance_; 793 static Instance* null_instance_;
790 static TypeArguments* null_type_arguments_; 794 static TypeArguments* null_type_arguments_;
795 static TypeArguments* empty_type_arguments_;
791 static Array* empty_array_; 796 static Array* empty_array_;
792 static Array* zero_array_; 797 static Array* zero_array_;
793 static Context* empty_context_; 798 static Context* empty_context_;
794 static ContextScope* empty_context_scope_; 799 static ContextScope* empty_context_scope_;
795 static ObjectPool* empty_object_pool_; 800 static ObjectPool* empty_object_pool_;
796 static PcDescriptors* empty_descriptors_; 801 static PcDescriptors* empty_descriptors_;
797 static LocalVarDescriptors* empty_var_descriptors_; 802 static LocalVarDescriptors* empty_var_descriptors_;
798 static ExceptionHandlers* empty_exception_handlers_; 803 static ExceptionHandlers* empty_exception_handlers_;
799 static Array* extractor_parameter_types_; 804 static Array* extractor_parameter_types_;
800 static Array* extractor_parameter_names_; 805 static Array* extractor_parameter_names_;
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); 1557 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object);
1553 friend class Class; 1558 friend class Class;
1554 }; 1559 };
1555 1560
1556 1561
1557 // Classification of type genericity according to type parameter owners. 1562 // Classification of type genericity according to type parameter owners.
1558 enum Genericity { 1563 enum Genericity {
1559 kAny, // Consider type params of current class and functions. 1564 kAny, // Consider type params of current class and functions.
1560 kCurrentClass, // Consider type params of current class only. 1565 kCurrentClass, // Consider type params of current class only.
1561 kFunctions, // Consider type params of current and parent functions. 1566 kFunctions, // Consider type params of current and parent functions.
1562 kCurrentFunction, // Consider type params of current function only.
1563 kParentFunctions // Consider type params of parent functions only.
1564 }; 1567 };
1565 1568
1566 1569
1567 // A TypeArguments is an array of AbstractType. 1570 // A TypeArguments is an array of AbstractType.
1568 class TypeArguments : public Object { 1571 class TypeArguments : public Object {
1569 public: 1572 public:
1570 // We use 30 bits for the hash code so hashes in a snapshot taken on a 1573 // We use 30 bits for the hash code so hashes in a snapshot taken on a
1571 // 64-bit architecture stay in Smi range when loaded on a 32-bit 1574 // 64-bit architecture stay in Smi range when loaded on a 32-bit
1572 // architecture. 1575 // architecture.
1573 static const intptr_t kHashBits = 30; 1576 static const intptr_t kHashBits = 30;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 void set_instantiations(const Array& value) const; 1768 void set_instantiations(const Array& value) const;
1766 RawAbstractType* const* TypeAddr(intptr_t index) const; 1769 RawAbstractType* const* TypeAddr(intptr_t index) const;
1767 void SetLength(intptr_t value) const; 1770 void SetLength(intptr_t value) const;
1768 // Number of fields in the raw object=3 (instantiations_, length_ and hash_). 1771 // Number of fields in the raw object=3 (instantiations_, length_ and hash_).
1769 static const int kNumFields = 3; 1772 static const int kNumFields = 3;
1770 1773
1771 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeArguments, Object); 1774 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeArguments, Object);
1772 friend class AbstractType; 1775 friend class AbstractType;
1773 friend class Class; 1776 friend class Class;
1774 friend class ClearTypeHashVisitor; 1777 friend class ClearTypeHashVisitor;
1778 friend class Object;
1775 }; 1779 };
1776 1780
1777 1781
1778 class PatchClass : public Object { 1782 class PatchClass : public Object {
1779 public: 1783 public:
1780 RawClass* patched_class() const { return raw_ptr()->patched_class_; } 1784 RawClass* patched_class() const { return raw_ptr()->patched_class_; }
1781 RawClass* origin_class() const { return raw_ptr()->origin_class_; } 1785 RawClass* origin_class() const { return raw_ptr()->origin_class_; }
1782 RawScript* script() const { return raw_ptr()->script_; } 1786 RawScript* script() const { return raw_ptr()->script_; }
1783 1787
1784 static intptr_t InstanceSize() { 1788 static intptr_t InstanceSize() {
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 // TypeParameter. 2275 // TypeParameter.
2272 RawTypeArguments* type_parameters() const { 2276 RawTypeArguments* type_parameters() const {
2273 return raw_ptr()->type_parameters_; 2277 return raw_ptr()->type_parameters_;
2274 } 2278 }
2275 void set_type_parameters(const TypeArguments& value) const; 2279 void set_type_parameters(const TypeArguments& value) const;
2276 intptr_t NumTypeParameters(Thread* thread) const; 2280 intptr_t NumTypeParameters(Thread* thread) const;
2277 intptr_t NumTypeParameters() const { 2281 intptr_t NumTypeParameters() const {
2278 return NumTypeParameters(Thread::Current()); 2282 return NumTypeParameters(Thread::Current());
2279 } 2283 }
2280 2284
2285 // Return the number of type parameters declared in parent generic functions.
2286 intptr_t NumParentTypeParameters() const;
2287
2281 // Return a TypeParameter if the type_name is a type parameter of this 2288 // Return a TypeParameter if the type_name is a type parameter of this
2282 // function or of one of its parent functions. 2289 // function or of one of its parent functions.
2283 // Unless NULL, adjust function_level accordingly (in and out parameter). 2290 // Unless NULL, adjust function_level accordingly (in and out parameter).
2284 // Return null otherwise. 2291 // Return null otherwise.
2285 RawTypeParameter* LookupTypeParameter(const String& type_name, 2292 RawTypeParameter* LookupTypeParameter(const String& type_name,
2286 intptr_t* function_level) const; 2293 intptr_t* function_level) const;
2287 2294
2288 // Return true if this function declares type parameters. 2295 // Return true if this function declares type parameters.
2289 bool IsGeneric() const { return NumTypeParameters(Thread::Current()) > 0; } 2296 bool IsGeneric() const { return NumTypeParameters(Thread::Current()) > 0; }
2290 2297
(...skipping 3840 matching lines...) Expand 10 before | Expand all | Expand 10 after
6131 } 6138 }
6132 bool IsClassTypeParameter() const { 6139 bool IsClassTypeParameter() const {
6133 return parameterized_class_id() != kFunctionCid; 6140 return parameterized_class_id() != kFunctionCid;
6134 } 6141 }
6135 bool IsFunctionTypeParameter() const { 6142 bool IsFunctionTypeParameter() const {
6136 return parameterized_function() != Function::null(); 6143 return parameterized_function() != Function::null();
6137 } 6144 }
6138 RawString* name() const { return raw_ptr()->name_; } 6145 RawString* name() const { return raw_ptr()->name_; }
6139 intptr_t index() const { return raw_ptr()->index_; } 6146 intptr_t index() const { return raw_ptr()->index_; }
6140 void set_index(intptr_t value) const; 6147 void set_index(intptr_t value) const;
6141 intptr_t parent_level() const { return raw_ptr()->parent_level_; }
6142 RawAbstractType* bound() const { return raw_ptr()->bound_; } 6148 RawAbstractType* bound() const { return raw_ptr()->bound_; }
6143 void set_bound(const AbstractType& value) const; 6149 void set_bound(const AbstractType& value) const;
6144 // Returns true if bounded_type is below upper_bound, otherwise return false 6150 // Returns true if bounded_type is below upper_bound, otherwise return false
6145 // and set bound_error if both bounded_type and upper_bound are instantiated. 6151 // and set bound_error if both bounded_type and upper_bound are instantiated.
6146 // If one or both are not instantiated, returning false only means that the 6152 // If one or both are not instantiated, returning false only means that the
6147 // bound cannot be checked yet and this is not an error. 6153 // bound cannot be checked yet and this is not an error.
6148 bool CheckBound(const AbstractType& bounded_type, 6154 bool CheckBound(const AbstractType& bounded_type,
6149 const AbstractType& upper_bound, 6155 const AbstractType& upper_bound,
6150 Error* bound_error, 6156 Error* bound_error,
6151 TrailPtr bound_trail, 6157 TrailPtr bound_trail,
(...skipping 25 matching lines...) Expand all
6177 virtual intptr_t Hash() const; 6183 virtual intptr_t Hash() const;
6178 6184
6179 static intptr_t InstanceSize() { 6185 static intptr_t InstanceSize() {
6180 return RoundedAllocationSize(sizeof(RawTypeParameter)); 6186 return RoundedAllocationSize(sizeof(RawTypeParameter));
6181 } 6187 }
6182 6188
6183 // Only one of parameterized_class and parameterized_function is non-null. 6189 // Only one of parameterized_class and parameterized_function is non-null.
6184 static RawTypeParameter* New(const Class& parameterized_class, 6190 static RawTypeParameter* New(const Class& parameterized_class,
6185 const Function& parameterized_function, 6191 const Function& parameterized_function,
6186 intptr_t index, 6192 intptr_t index,
6187 intptr_t parent_level,
6188 const String& name, 6193 const String& name,
6189 const AbstractType& bound, 6194 const AbstractType& bound,
6190 TokenPosition token_pos); 6195 TokenPosition token_pos);
6191 6196
6192 private: 6197 private:
6193 intptr_t ComputeHash() const; 6198 intptr_t ComputeHash() const;
6194 void SetHash(intptr_t value) const; 6199 void SetHash(intptr_t value) const;
6195 6200
6196 void set_parameterized_class(const Class& value) const; 6201 void set_parameterized_class(const Class& value) const;
6197 void set_parameterized_function(const Function& value) const; 6202 void set_parameterized_function(const Function& value) const;
6198 void set_name(const String& value) const; 6203 void set_name(const String& value) const;
6199 void set_token_pos(TokenPosition token_pos) const; 6204 void set_token_pos(TokenPosition token_pos) const;
6200 void set_parent_level(intptr_t value) const;
6201 void set_type_state(int8_t state) const; 6205 void set_type_state(int8_t state) const;
6202 6206
6203 static RawTypeParameter* New(); 6207 static RawTypeParameter* New();
6204 6208
6205 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); 6209 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType);
6206 friend class Class; 6210 friend class Class;
6207 friend class ClearTypeHashVisitor; 6211 friend class ClearTypeHashVisitor;
6208 }; 6212 };
6209 6213
6210 6214
(...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after
8348 // Used during deserialization (since map might contain itself as key/value). 8352 // Used during deserialization (since map might contain itself as key/value).
8349 static RawLinkedHashMap* NewUninitialized(Heap::Space space = Heap::kNew); 8353 static RawLinkedHashMap* NewUninitialized(Heap::Space space = Heap::kNew);
8350 8354
8351 friend class Class; 8355 friend class Class;
8352 friend class LinkedHashMapDeserializationCluster; 8356 friend class LinkedHashMapDeserializationCluster;
8353 }; 8357 };
8354 8358
8355 8359
8356 class Closure : public Instance { 8360 class Closure : public Instance {
8357 public: 8361 public:
8358 RawTypeArguments* instantiator() const { return raw_ptr()->instantiator_; } 8362 RawTypeArguments* instantiator_type_arguments() const {
8359 static intptr_t instantiator_offset() { 8363 return raw_ptr()->instantiator_type_arguments_;
8360 return OFFSET_OF(RawClosure, instantiator_); 8364 }
8365 static intptr_t instantiator_type_arguments_offset() {
8366 return OFFSET_OF(RawClosure, instantiator_type_arguments_);
8367 }
8368
8369 RawTypeArguments* function_type_arguments() const {
8370 return raw_ptr()->function_type_arguments_;
8371 }
8372 static intptr_t function_type_arguments_offset() {
8373 return OFFSET_OF(RawClosure, function_type_arguments_);
8361 } 8374 }
8362 8375
8363 RawFunction* function() const { return raw_ptr()->function_; } 8376 RawFunction* function() const { return raw_ptr()->function_; }
8364 static intptr_t function_offset() { return OFFSET_OF(RawClosure, function_); } 8377 static intptr_t function_offset() { return OFFSET_OF(RawClosure, function_); }
8365 8378
8366 RawContext* context() const { return raw_ptr()->context_; } 8379 RawContext* context() const { return raw_ptr()->context_; }
8367 static intptr_t context_offset() { return OFFSET_OF(RawClosure, context_); } 8380 static intptr_t context_offset() { return OFFSET_OF(RawClosure, context_); }
8368 8381
8369 static intptr_t InstanceSize() { 8382 static intptr_t InstanceSize() {
8370 return RoundedAllocationSize(sizeof(RawClosure)); 8383 return RoundedAllocationSize(sizeof(RawClosure));
8371 } 8384 }
8372 8385
8373 // Returns true if all elements are OK for canonicalization. 8386 // Returns true if all elements are OK for canonicalization.
8374 virtual bool CheckAndCanonicalizeFields(Thread* thread, 8387 virtual bool CheckAndCanonicalizeFields(Thread* thread,
8375 const char** error_str) const { 8388 const char** error_str) const {
8376 // None of the fields of a closure are instances. 8389 // None of the fields of a closure are instances.
8377 return true; 8390 return true;
8378 } 8391 }
8379 8392
8380 static RawClosure* New(const TypeArguments& instantiator, 8393 static RawClosure* New(const TypeArguments& instantiator_type_arguments,
8394 const TypeArguments& function_type_arguments,
8381 const Function& function, 8395 const Function& function,
8382 const Context& context, 8396 const Context& context,
8383 Heap::Space space = Heap::kNew); 8397 Heap::Space space = Heap::kNew);
8384 8398
8385 private: 8399 private:
8386 static RawClosure* New(); 8400 static RawClosure* New();
8387 8401
8388 FINAL_HEAP_OBJECT_IMPLEMENTATION(Closure, Instance); 8402 FINAL_HEAP_OBJECT_IMPLEMENTATION(Closure, Instance);
8389 friend class Class; 8403 friend class Class;
8390 }; 8404 };
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
8969 8983
8970 inline void TypeArguments::SetHash(intptr_t value) const { 8984 inline void TypeArguments::SetHash(intptr_t value) const {
8971 // This is only safe because we create a new Smi, which does not cause 8985 // This is only safe because we create a new Smi, which does not cause
8972 // heap allocation. 8986 // heap allocation.
8973 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 8987 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
8974 } 8988 }
8975 8989
8976 } // namespace dart 8990 } // namespace dart
8977 8991
8978 #endif // RUNTIME_VM_OBJECT_H_ 8992 #endif // RUNTIME_VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/kernel_to_il.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698