OLD | NEW |
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 VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 raw_ = value; \ | 194 raw_ = value; \ |
195 CHECK_HANDLE(); \ | 195 CHECK_HANDLE(); \ |
196 } \ | 196 } \ |
197 private: /* NOLINT */ \ | 197 private: /* NOLINT */ \ |
198 object() : super() {} \ | 198 object() : super() {} \ |
199 BASE_OBJECT_IMPLEMENTATION(object, super) \ | 199 BASE_OBJECT_IMPLEMENTATION(object, super) \ |
200 Raw##object* raw_ptr() const { \ | 200 Raw##object* raw_ptr() const { \ |
201 ASSERT(raw() != null()); \ | 201 ASSERT(raw() != null()); \ |
202 return raw()->ptr(); \ | 202 return raw()->ptr(); \ |
203 } \ | 203 } \ |
| 204 static intptr_t NextFieldOffset() { \ |
| 205 return -kWordSize; \ |
| 206 } \ |
204 SNAPSHOT_READER_SUPPORT(object) \ | 207 SNAPSHOT_READER_SUPPORT(object) \ |
205 friend class Isolate; \ | 208 friend class Isolate; \ |
206 friend class StackFrame; \ | 209 friend class StackFrame; \ |
207 | 210 |
208 class Object { | 211 class Object { |
209 public: | 212 public: |
210 virtual ~Object() { } | 213 virtual ~Object() { } |
211 | 214 |
212 RawObject* raw() const { return raw_; } | 215 RawObject* raw() const { return raw_; } |
213 void operator=(RawObject* value) { | 216 void operator=(RawObject* value) { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 if (value->IsNewObject() && raw()->IsOldObject() && | 524 if (value->IsNewObject() && raw()->IsOldObject() && |
522 !raw()->IsRemembered()) { | 525 !raw()->IsRemembered()) { |
523 raw()->SetRememberedBit(); | 526 raw()->SetRememberedBit(); |
524 Isolate::Current()->store_buffer()->AddObject(raw()); | 527 Isolate::Current()->store_buffer()->AddObject(raw()); |
525 } | 528 } |
526 } | 529 } |
527 | 530 |
528 RawObject* raw_; // The raw object reference. | 531 RawObject* raw_; // The raw object reference. |
529 | 532 |
530 private: | 533 private: |
| 534 static intptr_t NextFieldOffset() { |
| 535 // Indicates this class cannot be extended by dart code. |
| 536 return -kWordSize; |
| 537 } |
| 538 |
531 static void InitializeObject(uword address, intptr_t id, intptr_t size); | 539 static void InitializeObject(uword address, intptr_t id, intptr_t size); |
532 | 540 |
533 static void RegisterClass(const Class& cls, | 541 static void RegisterClass(const Class& cls, |
534 const String& name, | 542 const String& name, |
535 const Library& lib); | 543 const Library& lib); |
536 static void RegisterPrivateClass(const Class& cls, | 544 static void RegisterPrivateClass(const Class& cls, |
537 const String& name, | 545 const String& name, |
538 const Library& lib); | 546 const Library& lib); |
539 | 547 |
540 /* Initialize the handle based on the raw_ptr in the presence of null. */ | 548 /* Initialize the handle based on the raw_ptr in the presence of null. */ |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 } | 656 } |
649 | 657 |
650 intptr_t next_field_offset() const { | 658 intptr_t next_field_offset() const { |
651 return raw_ptr()->next_field_offset_in_words_ * kWordSize; | 659 return raw_ptr()->next_field_offset_in_words_ * kWordSize; |
652 } | 660 } |
653 void set_next_field_offset(intptr_t value_in_bytes) const { | 661 void set_next_field_offset(intptr_t value_in_bytes) const { |
654 ASSERT(kWordSize != 0); | 662 ASSERT(kWordSize != 0); |
655 set_next_field_offset_in_words(value_in_bytes / kWordSize); | 663 set_next_field_offset_in_words(value_in_bytes / kWordSize); |
656 } | 664 } |
657 void set_next_field_offset_in_words(intptr_t value) const { | 665 void set_next_field_offset_in_words(intptr_t value) const { |
658 ASSERT((Utils::IsAligned((value * kWordSize), kObjectAlignment) && | 666 ASSERT((value == -1) || |
| 667 (Utils::IsAligned((value * kWordSize), kObjectAlignment) && |
659 (value == raw_ptr()->instance_size_in_words_)) || | 668 (value == raw_ptr()->instance_size_in_words_)) || |
660 (!Utils::IsAligned((value * kWordSize), kObjectAlignment) && | 669 (!Utils::IsAligned((value * kWordSize), kObjectAlignment) && |
661 ((value + 1) == raw_ptr()->instance_size_in_words_))); | 670 ((value + 1) == raw_ptr()->instance_size_in_words_))); |
662 raw_ptr()->next_field_offset_in_words_ = value; | 671 raw_ptr()->next_field_offset_in_words_ = value; |
663 } | 672 } |
664 | 673 |
665 cpp_vtable handle_vtable() const { return raw_ptr()->handle_vtable_; } | 674 cpp_vtable handle_vtable() const { return raw_ptr()->handle_vtable_; } |
666 void set_handle_vtable(cpp_vtable value) const { | 675 void set_handle_vtable(cpp_vtable value) const { |
667 raw_ptr()->handle_vtable_ = value; | 676 raw_ptr()->handle_vtable_ = value; |
668 } | 677 } |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 void set_constants(const Array& value) const; | 1085 void set_constants(const Array& value) const; |
1077 | 1086 |
1078 void set_canonical_types(const Array& value) const; | 1087 void set_canonical_types(const Array& value) const; |
1079 RawArray* canonical_types() const; | 1088 RawArray* canonical_types() const; |
1080 | 1089 |
1081 RawArray* invocation_dispatcher_cache() const; | 1090 RawArray* invocation_dispatcher_cache() const; |
1082 void set_invocation_dispatcher_cache(const Array& cache) const; | 1091 void set_invocation_dispatcher_cache(const Array& cache) const; |
1083 RawFunction* CreateInvocationDispatcher(const String& target_name, | 1092 RawFunction* CreateInvocationDispatcher(const String& target_name, |
1084 const Array& args_desc, | 1093 const Array& args_desc, |
1085 RawFunction::Kind kind) const; | 1094 RawFunction::Kind kind) const; |
| 1095 |
1086 void CalculateFieldOffsets() const; | 1096 void CalculateFieldOffsets() const; |
1087 | 1097 |
1088 // Initial value for the cached number of type arguments. | 1098 // Initial value for the cached number of type arguments. |
1089 static const intptr_t kUnknownNumTypeArguments = -1; | 1099 static const intptr_t kUnknownNumTypeArguments = -1; |
1090 | 1100 |
1091 int16_t num_type_arguments() const { | 1101 int16_t num_type_arguments() const { |
1092 return raw_ptr()->num_type_arguments_; | 1102 return raw_ptr()->num_type_arguments_; |
1093 } | 1103 } |
1094 void set_num_type_arguments(intptr_t value) const; | 1104 void set_num_type_arguments(intptr_t value) const; |
1095 | 1105 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 return raw_ptr()->library_prefix_; | 1147 return raw_ptr()->library_prefix_; |
1138 } | 1148 } |
1139 RawString* ident() const { return raw_ptr()->ident_; } | 1149 RawString* ident() const { return raw_ptr()->ident_; } |
1140 intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 1150 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
1141 | 1151 |
1142 RawString* Name() const; | 1152 RawString* Name() const; |
1143 | 1153 |
1144 static intptr_t InstanceSize() { | 1154 static intptr_t InstanceSize() { |
1145 return RoundedAllocationSize(sizeof(RawUnresolvedClass)); | 1155 return RoundedAllocationSize(sizeof(RawUnresolvedClass)); |
1146 } | 1156 } |
| 1157 |
1147 static RawUnresolvedClass* New(const LibraryPrefix& library_prefix, | 1158 static RawUnresolvedClass* New(const LibraryPrefix& library_prefix, |
1148 const String& ident, | 1159 const String& ident, |
1149 intptr_t token_pos); | 1160 intptr_t token_pos); |
1150 | 1161 |
1151 private: | 1162 private: |
1152 void set_library_prefix(const LibraryPrefix& library_prefix) const; | 1163 void set_library_prefix(const LibraryPrefix& library_prefix) const; |
1153 void set_ident(const String& ident) const; | 1164 void set_ident(const String& ident) const; |
1154 void set_token_pos(intptr_t token_pos) const; | 1165 void set_token_pos(intptr_t token_pos) const; |
1155 | 1166 |
1156 static RawUnresolvedClass* New(); | 1167 static RawUnresolvedClass* New(); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 | 1388 |
1378 static RawInstantiatedTypeArguments* New( | 1389 static RawInstantiatedTypeArguments* New( |
1379 const AbstractTypeArguments& uninstantiated_type_arguments, | 1390 const AbstractTypeArguments& uninstantiated_type_arguments, |
1380 const AbstractTypeArguments& instantiator_type_arguments); | 1391 const AbstractTypeArguments& instantiator_type_arguments); |
1381 | 1392 |
1382 private: | 1393 private: |
1383 void set_uninstantiated_type_arguments( | 1394 void set_uninstantiated_type_arguments( |
1384 const AbstractTypeArguments& value) const; | 1395 const AbstractTypeArguments& value) const; |
1385 void set_instantiator_type_arguments( | 1396 void set_instantiator_type_arguments( |
1386 const AbstractTypeArguments& value) const; | 1397 const AbstractTypeArguments& value) const; |
| 1398 |
1387 static RawInstantiatedTypeArguments* New(); | 1399 static RawInstantiatedTypeArguments* New(); |
1388 | 1400 |
1389 FINAL_HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments, | 1401 FINAL_HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments, |
1390 AbstractTypeArguments); | 1402 AbstractTypeArguments); |
1391 friend class Class; | 1403 friend class Class; |
1392 }; | 1404 }; |
1393 | 1405 |
1394 | 1406 |
1395 class PatchClass : public Object { | 1407 class PatchClass : public Object { |
1396 public: | 1408 public: |
1397 RawClass* patched_class() const { return raw_ptr()->patched_class_; } | 1409 RawClass* patched_class() const { return raw_ptr()->patched_class_; } |
1398 RawClass* source_class() const { return raw_ptr()->source_class_; } | 1410 RawClass* source_class() const { return raw_ptr()->source_class_; } |
1399 RawScript* Script() const; | 1411 RawScript* Script() const; |
1400 | 1412 |
1401 static intptr_t InstanceSize() { | 1413 static intptr_t InstanceSize() { |
1402 return RoundedAllocationSize(sizeof(RawPatchClass)); | 1414 return RoundedAllocationSize(sizeof(RawPatchClass)); |
1403 } | 1415 } |
1404 | 1416 |
1405 static RawPatchClass* New(const Class& patched_class, | 1417 static RawPatchClass* New(const Class& patched_class, |
1406 const Class& source_class); | 1418 const Class& source_class); |
1407 | 1419 |
1408 private: | 1420 private: |
1409 void set_patched_class(const Class& value) const; | 1421 void set_patched_class(const Class& value) const; |
1410 void set_source_class(const Class& value) const; | 1422 void set_source_class(const Class& value) const; |
| 1423 |
1411 static RawPatchClass* New(); | 1424 static RawPatchClass* New(); |
1412 | 1425 |
1413 FINAL_HEAP_OBJECT_IMPLEMENTATION(PatchClass, Object); | 1426 FINAL_HEAP_OBJECT_IMPLEMENTATION(PatchClass, Object); |
1414 friend class Class; | 1427 friend class Class; |
1415 }; | 1428 }; |
1416 | 1429 |
1417 | 1430 |
1418 class Function : public Object { | 1431 class Function : public Object { |
1419 public: | 1432 public: |
1420 RawString* name() const { return raw_ptr()->name_; } | 1433 RawString* name() const { return raw_ptr()->name_; } |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 // Returns true if this function represents a local function. | 1865 // Returns true if this function represents a local function. |
1853 bool IsLocalFunction() const { | 1866 bool IsLocalFunction() const { |
1854 return parent_function() != Function::null(); | 1867 return parent_function() != Function::null(); |
1855 } | 1868 } |
1856 | 1869 |
1857 // Returns true if this function represents a signature function without code. | 1870 // Returns true if this function represents a signature function without code. |
1858 bool IsSignatureFunction() const { | 1871 bool IsSignatureFunction() const { |
1859 return kind() == RawFunction::kSignatureFunction; | 1872 return kind() == RawFunction::kSignatureFunction; |
1860 } | 1873 } |
1861 | 1874 |
1862 | |
1863 static intptr_t InstanceSize() { | 1875 static intptr_t InstanceSize() { |
1864 return RoundedAllocationSize(sizeof(RawFunction)); | 1876 return RoundedAllocationSize(sizeof(RawFunction)); |
1865 } | 1877 } |
1866 | 1878 |
1867 static RawFunction* New(const String& name, | 1879 static RawFunction* New(const String& name, |
1868 RawFunction::Kind kind, | 1880 RawFunction::Kind kind, |
1869 bool is_static, | 1881 bool is_static, |
1870 bool is_const, | 1882 bool is_const, |
1871 bool is_abstract, | 1883 bool is_abstract, |
1872 bool is_external, | 1884 bool is_external, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 void set_is_external(bool value) const; | 1951 void set_is_external(bool value) const; |
1940 void set_parent_function(const Function& value) const; | 1952 void set_parent_function(const Function& value) const; |
1941 void set_owner(const Object& value) const; | 1953 void set_owner(const Object& value) const; |
1942 RawFunction* implicit_closure_function() const; | 1954 RawFunction* implicit_closure_function() const; |
1943 void set_implicit_closure_function(const Function& value) const; | 1955 void set_implicit_closure_function(const Function& value) const; |
1944 RawInstance* implicit_static_closure() const; | 1956 RawInstance* implicit_static_closure() const; |
1945 void set_implicit_static_closure(const Instance& closure) const; | 1957 void set_implicit_static_closure(const Instance& closure) const; |
1946 void set_num_optional_parameters(intptr_t value) const; // Encoded value. | 1958 void set_num_optional_parameters(intptr_t value) const; // Encoded value. |
1947 void set_kind_tag(intptr_t value) const; | 1959 void set_kind_tag(intptr_t value) const; |
1948 void set_data(const Object& value) const; | 1960 void set_data(const Object& value) const; |
| 1961 |
1949 static RawFunction* New(); | 1962 static RawFunction* New(); |
1950 | 1963 |
1951 void BuildSignatureParameters(bool instantiate, | 1964 void BuildSignatureParameters(bool instantiate, |
1952 NameVisibility name_visibility, | 1965 NameVisibility name_visibility, |
1953 const AbstractTypeArguments& instantiator, | 1966 const AbstractTypeArguments& instantiator, |
1954 const GrowableObjectArray& pieces) const; | 1967 const GrowableObjectArray& pieces) const; |
1955 RawString* BuildSignature(bool instantiate, | 1968 RawString* BuildSignature(bool instantiate, |
1956 NameVisibility name_visibility, | 1969 NameVisibility name_visibility, |
1957 const AbstractTypeArguments& instantiator) const; | 1970 const AbstractTypeArguments& instantiator) const; |
1958 | 1971 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2205 } | 2218 } |
2206 void set_owner(const Object& value) const { | 2219 void set_owner(const Object& value) const { |
2207 StorePointer(&raw_ptr()->owner_, value.raw()); | 2220 StorePointer(&raw_ptr()->owner_, value.raw()); |
2208 } | 2221 } |
2209 void set_token_pos(intptr_t token_pos) const { | 2222 void set_token_pos(intptr_t token_pos) const { |
2210 raw_ptr()->token_pos_ = token_pos; | 2223 raw_ptr()->token_pos_ = token_pos; |
2211 } | 2224 } |
2212 void set_kind_bits(intptr_t value) const { | 2225 void set_kind_bits(intptr_t value) const { |
2213 raw_ptr()->kind_bits_ = static_cast<uint8_t>(value); | 2226 raw_ptr()->kind_bits_ = static_cast<uint8_t>(value); |
2214 } | 2227 } |
| 2228 |
2215 static RawField* New(); | 2229 static RawField* New(); |
2216 | 2230 |
2217 FINAL_HEAP_OBJECT_IMPLEMENTATION(Field, Object); | 2231 FINAL_HEAP_OBJECT_IMPLEMENTATION(Field, Object); |
2218 friend class Class; | 2232 friend class Class; |
2219 friend class HeapProfiler; | 2233 friend class HeapProfiler; |
2220 }; | 2234 }; |
2221 | 2235 |
2222 | 2236 |
2223 class LiteralToken : public Object { | 2237 class LiteralToken : public Object { |
2224 public: | 2238 public: |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 | 2385 |
2372 static RawScript* New(const String& url, | 2386 static RawScript* New(const String& url, |
2373 const String& source, | 2387 const String& source, |
2374 RawScript::Kind kind); | 2388 RawScript::Kind kind); |
2375 | 2389 |
2376 private: | 2390 private: |
2377 void set_url(const String& value) const; | 2391 void set_url(const String& value) const; |
2378 void set_source(const String& value) const; | 2392 void set_source(const String& value) const; |
2379 void set_kind(RawScript::Kind value) const; | 2393 void set_kind(RawScript::Kind value) const; |
2380 void set_tokens(const TokenStream& value) const; | 2394 void set_tokens(const TokenStream& value) const; |
| 2395 |
2381 static RawScript* New(); | 2396 static RawScript* New(); |
2382 | 2397 |
2383 FINAL_HEAP_OBJECT_IMPLEMENTATION(Script, Object); | 2398 FINAL_HEAP_OBJECT_IMPLEMENTATION(Script, Object); |
2384 friend class Class; | 2399 friend class Class; |
2385 }; | 2400 }; |
2386 | 2401 |
2387 | 2402 |
2388 class DictionaryIterator : public ValueObject { | 2403 class DictionaryIterator : public ValueObject { |
2389 public: | 2404 public: |
2390 explicit DictionaryIterator(const Library& library); | 2405 explicit DictionaryIterator(const Library& library); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2585 | 2600 |
2586 | 2601 |
2587 // Return Function::null() if function does not exist in libs. | 2602 // Return Function::null() if function does not exist in libs. |
2588 static RawFunction* GetFunction(const GrowableArray<Library*>& libs, | 2603 static RawFunction* GetFunction(const GrowableArray<Library*>& libs, |
2589 const char* class_name, | 2604 const char* class_name, |
2590 const char* function_name); | 2605 const char* function_name); |
2591 | 2606 |
2592 private: | 2607 private: |
2593 static const int kInitialImportsCapacity = 4; | 2608 static const int kInitialImportsCapacity = 4; |
2594 static const int kImportsCapacityIncrement = 8; | 2609 static const int kImportsCapacityIncrement = 8; |
| 2610 |
2595 static RawLibrary* New(); | 2611 static RawLibrary* New(); |
2596 | 2612 |
2597 void set_num_imports(intptr_t value) const { | 2613 void set_num_imports(intptr_t value) const { |
2598 raw_ptr()->num_imports_ = value; | 2614 raw_ptr()->num_imports_ = value; |
2599 } | 2615 } |
2600 RawArray* imports() const { return raw_ptr()->imports_; } | 2616 RawArray* imports() const { return raw_ptr()->imports_; } |
2601 RawArray* exports() const { return raw_ptr()->exports_; } | 2617 RawArray* exports() const { return raw_ptr()->exports_; } |
2602 bool HasExports() const; | 2618 bool HasExports() const; |
2603 RawArray* loaded_scripts() const { return raw_ptr()->loaded_scripts_; } | 2619 RawArray* loaded_scripts() const { return raw_ptr()->loaded_scripts_; } |
2604 RawGrowableObjectArray* metadata() const { return raw_ptr()->metadata_; } | 2620 RawGrowableObjectArray* metadata() const { return raw_ptr()->metadata_; } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2647 | 2663 |
2648 static RawLibraryPrefix* New(const String& name, const Namespace& import); | 2664 static RawLibraryPrefix* New(const String& name, const Namespace& import); |
2649 | 2665 |
2650 private: | 2666 private: |
2651 static const int kInitialSize = 2; | 2667 static const int kInitialSize = 2; |
2652 static const int kIncrementSize = 2; | 2668 static const int kIncrementSize = 2; |
2653 | 2669 |
2654 void set_name(const String& value) const; | 2670 void set_name(const String& value) const; |
2655 void set_imports(const Array& value) const; | 2671 void set_imports(const Array& value) const; |
2656 void set_num_imports(intptr_t value) const; | 2672 void set_num_imports(intptr_t value) const; |
| 2673 |
2657 static RawLibraryPrefix* New(); | 2674 static RawLibraryPrefix* New(); |
2658 | 2675 |
2659 FINAL_HEAP_OBJECT_IMPLEMENTATION(LibraryPrefix, Object); | 2676 FINAL_HEAP_OBJECT_IMPLEMENTATION(LibraryPrefix, Object); |
2660 friend class Class; | 2677 friend class Class; |
2661 }; | 2678 }; |
2662 | 2679 |
2663 | 2680 |
2664 // A Namespace contains the names in a library dictionary, filtered by | 2681 // A Namespace contains the names in a library dictionary, filtered by |
2665 // the show/hide combinators. | 2682 // the show/hide combinators. |
2666 class Namespace : public Object { | 2683 class Namespace : public Object { |
2667 public: | 2684 public: |
2668 RawLibrary* library() const { return raw_ptr()->library_; } | 2685 RawLibrary* library() const { return raw_ptr()->library_; } |
2669 RawArray* show_names() const { return raw_ptr()->show_names_; } | 2686 RawArray* show_names() const { return raw_ptr()->show_names_; } |
2670 RawArray* hide_names() const { return raw_ptr()->hide_names_; } | 2687 RawArray* hide_names() const { return raw_ptr()->hide_names_; } |
2671 | 2688 |
2672 static intptr_t InstanceSize() { | 2689 static intptr_t InstanceSize() { |
2673 return RoundedAllocationSize(sizeof(RawNamespace)); | 2690 return RoundedAllocationSize(sizeof(RawNamespace)); |
2674 } | 2691 } |
2675 | 2692 |
2676 bool HidesName(const String& name) const; | 2693 bool HidesName(const String& name) const; |
2677 RawObject* Lookup(const String& name) const; | 2694 RawObject* Lookup(const String& name) const; |
2678 | 2695 |
2679 static RawNamespace* New(const Library& library, | 2696 static RawNamespace* New(const Library& library, |
2680 const Array& show_names, | 2697 const Array& show_names, |
2681 const Array& hide_names); | 2698 const Array& hide_names); |
| 2699 |
2682 private: | 2700 private: |
2683 static RawNamespace* New(); | 2701 static RawNamespace* New(); |
2684 | 2702 |
2685 FINAL_HEAP_OBJECT_IMPLEMENTATION(Namespace, Object); | 2703 FINAL_HEAP_OBJECT_IMPLEMENTATION(Namespace, Object); |
2686 friend class Class; | 2704 friend class Class; |
2687 }; | 2705 }; |
2688 | 2706 |
2689 | 2707 |
2690 class Instructions : public Object { | 2708 class Instructions : public Object { |
2691 public: | 2709 public: |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2981 // We would have a VisitPointers function here to traverse the | 2999 // We would have a VisitPointers function here to traverse the |
2982 // exception handler table to visit objects if any in the table. | 3000 // exception handler table to visit objects if any in the table. |
2983 | 3001 |
2984 private: | 3002 private: |
2985 // Pick somewhat arbitrary maximum number of exception handlers | 3003 // Pick somewhat arbitrary maximum number of exception handlers |
2986 // for a function. This value is used to catch potentially | 3004 // for a function. This value is used to catch potentially |
2987 // malicious code. | 3005 // malicious code. |
2988 static const intptr_t kMaxHandlers = 1024 * 1024; | 3006 static const intptr_t kMaxHandlers = 1024 * 1024; |
2989 | 3007 |
2990 void set_handled_types_data(const Array& value) const; | 3008 void set_handled_types_data(const Array& value) const; |
| 3009 |
2991 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers, Object); | 3010 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers, Object); |
2992 friend class Class; | 3011 friend class Class; |
2993 }; | 3012 }; |
2994 | 3013 |
2995 | 3014 |
2996 // Holds deopt information at one deoptimization point. The information consists | 3015 // Holds deopt information at one deoptimization point. The information consists |
2997 // of two parts: | 3016 // of two parts: |
2998 // - first a prefix consiting of kMaterializeObject instructions describing | 3017 // - first a prefix consiting of kMaterializeObject instructions describing |
2999 // objects which had their allocation removed as part of AllocationSinking | 3018 // objects which had their allocation removed as part of AllocationSinking |
3000 // pass and have to be materialized; | 3019 // pass and have to be materialized; |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3738 return RoundedAllocationSize(sizeof(RawApiError)); | 3757 return RoundedAllocationSize(sizeof(RawApiError)); |
3739 } | 3758 } |
3740 | 3759 |
3741 static RawApiError* New(const String& message, | 3760 static RawApiError* New(const String& message, |
3742 Heap::Space space = Heap::kNew); | 3761 Heap::Space space = Heap::kNew); |
3743 | 3762 |
3744 virtual const char* ToErrorCString() const; | 3763 virtual const char* ToErrorCString() const; |
3745 | 3764 |
3746 private: | 3765 private: |
3747 void set_message(const String& message) const; | 3766 void set_message(const String& message) const; |
| 3767 |
3748 static RawApiError* New(); | 3768 static RawApiError* New(); |
3749 | 3769 |
3750 FINAL_HEAP_OBJECT_IMPLEMENTATION(ApiError, Error); | 3770 FINAL_HEAP_OBJECT_IMPLEMENTATION(ApiError, Error); |
3751 friend class Class; | 3771 friend class Class; |
3752 }; | 3772 }; |
3753 | 3773 |
3754 | 3774 |
3755 class LanguageError : public Error { | 3775 class LanguageError : public Error { |
3756 public: | 3776 public: |
3757 RawString* message() const { return raw_ptr()->message_; } | 3777 RawString* message() const { return raw_ptr()->message_; } |
3758 static intptr_t message_offset() { | 3778 static intptr_t message_offset() { |
3759 return OFFSET_OF(RawLanguageError, message_); | 3779 return OFFSET_OF(RawLanguageError, message_); |
3760 } | 3780 } |
3761 | 3781 |
3762 static intptr_t InstanceSize() { | 3782 static intptr_t InstanceSize() { |
3763 return RoundedAllocationSize(sizeof(RawLanguageError)); | 3783 return RoundedAllocationSize(sizeof(RawLanguageError)); |
3764 } | 3784 } |
3765 | 3785 |
3766 static RawLanguageError* New(const String& message, | 3786 static RawLanguageError* New(const String& message, |
3767 Heap::Space space = Heap::kNew); | 3787 Heap::Space space = Heap::kNew); |
3768 | 3788 |
3769 virtual const char* ToErrorCString() const; | 3789 virtual const char* ToErrorCString() const; |
3770 | 3790 |
3771 private: | 3791 private: |
3772 void set_message(const String& message) const; | 3792 void set_message(const String& message) const; |
| 3793 |
3773 static RawLanguageError* New(); | 3794 static RawLanguageError* New(); |
3774 | 3795 |
3775 FINAL_HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error); | 3796 FINAL_HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error); |
3776 friend class Class; | 3797 friend class Class; |
3777 }; | 3798 }; |
3778 | 3799 |
3779 | 3800 |
3780 class UnhandledException : public Error { | 3801 class UnhandledException : public Error { |
3781 public: | 3802 public: |
3782 RawInstance* exception() const { return raw_ptr()->exception_; } | 3803 RawInstance* exception() const { return raw_ptr()->exception_; } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3906 return FieldAddrAtOffset(field.Offset()); | 3927 return FieldAddrAtOffset(field.Offset()); |
3907 } | 3928 } |
3908 RawObject** NativeFieldsAddr() const { | 3929 RawObject** NativeFieldsAddr() const { |
3909 return FieldAddrAtOffset(sizeof(RawObject)); | 3930 return FieldAddrAtOffset(sizeof(RawObject)); |
3910 } | 3931 } |
3911 void SetFieldAtOffset(intptr_t offset, const Object& value) const { | 3932 void SetFieldAtOffset(intptr_t offset, const Object& value) const { |
3912 StorePointer(FieldAddrAtOffset(offset), value.raw()); | 3933 StorePointer(FieldAddrAtOffset(offset), value.raw()); |
3913 } | 3934 } |
3914 bool IsValidFieldOffset(int offset) const; | 3935 bool IsValidFieldOffset(int offset) const; |
3915 | 3936 |
| 3937 static intptr_t NextFieldOffset() { |
| 3938 return sizeof(RawInstance); |
| 3939 } |
| 3940 |
3916 // TODO(iposva): Determine if this gets in the way of Smi. | 3941 // TODO(iposva): Determine if this gets in the way of Smi. |
3917 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); | 3942 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); |
3918 friend class Class; | 3943 friend class Class; |
3919 friend class Closure; | 3944 friend class Closure; |
| 3945 friend class SnapshotWriter; |
| 3946 friend class StubCode; |
3920 friend class TypedDataView; | 3947 friend class TypedDataView; |
3921 }; | 3948 }; |
3922 | 3949 |
3923 | 3950 |
3924 // AbstractType is an abstract superclass. | 3951 // AbstractType is an abstract superclass. |
3925 // Subclasses of AbstractType are Type and TypeParameter. | 3952 // Subclasses of AbstractType are Type and TypeParameter. |
3926 class AbstractType : public Instance { | 3953 class AbstractType : public Instance { |
3927 public: | 3954 public: |
3928 virtual bool IsFinalized() const; | 3955 virtual bool IsFinalized() const; |
3929 virtual bool IsBeingFinalized() const; | 3956 virtual bool IsBeingFinalized() const; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4218 intptr_t index, | 4245 intptr_t index, |
4219 const String& name, | 4246 const String& name, |
4220 const AbstractType& bound, | 4247 const AbstractType& bound, |
4221 intptr_t token_pos); | 4248 intptr_t token_pos); |
4222 | 4249 |
4223 private: | 4250 private: |
4224 void set_parameterized_class(const Class& value) const; | 4251 void set_parameterized_class(const Class& value) const; |
4225 void set_name(const String& value) const; | 4252 void set_name(const String& value) const; |
4226 void set_token_pos(intptr_t token_pos) const; | 4253 void set_token_pos(intptr_t token_pos) const; |
4227 void set_type_state(int8_t state) const; | 4254 void set_type_state(int8_t state) const; |
| 4255 |
4228 static RawTypeParameter* New(); | 4256 static RawTypeParameter* New(); |
4229 | 4257 |
4230 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); | 4258 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); |
4231 friend class Class; | 4259 friend class Class; |
4232 }; | 4260 }; |
4233 | 4261 |
4234 | 4262 |
4235 // A BoundedType represents a type instantiated at compile time from a type | 4263 // A BoundedType represents a type instantiated at compile time from a type |
4236 // parameter specifying a bound that either cannot be checked at compile time | 4264 // parameter specifying a bound that either cannot be checked at compile time |
4237 // because the type or the bound are still uninstantiated or can be checked and | 4265 // because the type or the bound are still uninstantiated or can be checked and |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4471 void operator=(RawSmi* value) { | 4499 void operator=(RawSmi* value) { |
4472 raw_ = value; | 4500 raw_ = value; |
4473 CHECK_HANDLE(); | 4501 CHECK_HANDLE(); |
4474 } | 4502 } |
4475 void operator^=(RawObject* value) { | 4503 void operator^=(RawObject* value) { |
4476 raw_ = value; | 4504 raw_ = value; |
4477 CHECK_HANDLE(); | 4505 CHECK_HANDLE(); |
4478 } | 4506 } |
4479 | 4507 |
4480 private: | 4508 private: |
| 4509 static intptr_t NextFieldOffset() { |
| 4510 // Indicates this class cannot be extended by dart code. |
| 4511 return -kWordSize; |
| 4512 } |
| 4513 |
4481 static intptr_t ValueFromRaw(uword raw_value) { | 4514 static intptr_t ValueFromRaw(uword raw_value) { |
4482 intptr_t value = raw_value; | 4515 intptr_t value = raw_value; |
4483 ASSERT((value & kSmiTagMask) == kSmiTag); | 4516 ASSERT((value & kSmiTagMask) == kSmiTag); |
4484 return (value >> kSmiTagShift); | 4517 return (value >> kSmiTagShift); |
4485 } | 4518 } |
| 4519 |
4486 static cpp_vtable handle_vtable_; | 4520 static cpp_vtable handle_vtable_; |
4487 | 4521 |
4488 Smi() : Integer() {} | 4522 Smi() : Integer() {} |
4489 BASE_OBJECT_IMPLEMENTATION(Smi, Integer); | 4523 BASE_OBJECT_IMPLEMENTATION(Smi, Integer); |
4490 | 4524 |
4491 friend class Api; // For ValueFromRaw | 4525 friend class Api; // For ValueFromRaw |
4492 friend class Class; | 4526 friend class Class; |
4493 friend class Object; | 4527 friend class Object; |
4494 }; | 4528 }; |
4495 | 4529 |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5194 raw_ptr(str)->external_data_ = data; | 5228 raw_ptr(str)->external_data_ = data; |
5195 } | 5229 } |
5196 | 5230 |
5197 static void Finalize(Dart_WeakPersistentHandle handle, void* peer); | 5231 static void Finalize(Dart_WeakPersistentHandle handle, void* peer); |
5198 | 5232 |
5199 static RawExternalOneByteString* ReadFrom(SnapshotReader* reader, | 5233 static RawExternalOneByteString* ReadFrom(SnapshotReader* reader, |
5200 intptr_t object_id, | 5234 intptr_t object_id, |
5201 intptr_t tags, | 5235 intptr_t tags, |
5202 Snapshot::Kind kind); | 5236 Snapshot::Kind kind); |
5203 | 5237 |
| 5238 static intptr_t NextFieldOffset() { |
| 5239 // Indicates this class cannot be extended by dart code. |
| 5240 return -kWordSize; |
| 5241 } |
| 5242 |
5204 friend class Class; | 5243 friend class Class; |
5205 friend class String; | 5244 friend class String; |
5206 friend class SnapshotReader; | 5245 friend class SnapshotReader; |
5207 }; | 5246 }; |
5208 | 5247 |
5209 | 5248 |
5210 class ExternalTwoByteString : public AllStatic { | 5249 class ExternalTwoByteString : public AllStatic { |
5211 public: | 5250 public: |
5212 static int32_t CharAt(const String& str, intptr_t index) { | 5251 static int32_t CharAt(const String& str, intptr_t index) { |
5213 return *CharAddr(str, index); | 5252 return *CharAddr(str, index); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5260 raw_ptr(str)->external_data_ = data; | 5299 raw_ptr(str)->external_data_ = data; |
5261 } | 5300 } |
5262 | 5301 |
5263 static void Finalize(Dart_WeakPersistentHandle handle, void* peer); | 5302 static void Finalize(Dart_WeakPersistentHandle handle, void* peer); |
5264 | 5303 |
5265 static RawExternalTwoByteString* ReadFrom(SnapshotReader* reader, | 5304 static RawExternalTwoByteString* ReadFrom(SnapshotReader* reader, |
5266 intptr_t object_id, | 5305 intptr_t object_id, |
5267 intptr_t tags, | 5306 intptr_t tags, |
5268 Snapshot::Kind kind); | 5307 Snapshot::Kind kind); |
5269 | 5308 |
| 5309 static intptr_t NextFieldOffset() { |
| 5310 // Indicates this class cannot be extended by dart code. |
| 5311 return -kWordSize; |
| 5312 } |
| 5313 |
5270 friend class Class; | 5314 friend class Class; |
5271 friend class String; | 5315 friend class String; |
5272 friend class SnapshotReader; | 5316 friend class SnapshotReader; |
5273 }; | 5317 }; |
5274 | 5318 |
5275 | 5319 |
5276 // Class Bool implements Dart core class bool. | 5320 // Class Bool implements Dart core class bool. |
5277 class Bool : public Instance { | 5321 class Bool : public Instance { |
5278 public: | 5322 public: |
5279 bool value() const { | 5323 bool value() const { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5429 | 5473 |
5430 static intptr_t InstanceSize() { | 5474 static intptr_t InstanceSize() { |
5431 return Array::InstanceSize(); | 5475 return Array::InstanceSize(); |
5432 } | 5476 } |
5433 | 5477 |
5434 static intptr_t InstanceSize(intptr_t len) { | 5478 static intptr_t InstanceSize(intptr_t len) { |
5435 return Array::InstanceSize(len); | 5479 return Array::InstanceSize(len); |
5436 } | 5480 } |
5437 | 5481 |
5438 private: | 5482 private: |
| 5483 static intptr_t NextFieldOffset() { |
| 5484 // Indicates this class cannot be extended by dart code. |
| 5485 return -kWordSize; |
| 5486 } |
| 5487 |
5439 static RawImmutableArray* raw(const Array& array) { | 5488 static RawImmutableArray* raw(const Array& array) { |
5440 return reinterpret_cast<RawImmutableArray*>(array.raw()); | 5489 return reinterpret_cast<RawImmutableArray*>(array.raw()); |
5441 } | 5490 } |
5442 | 5491 |
5443 friend class Class; | 5492 friend class Class; |
5444 }; | 5493 }; |
5445 | 5494 |
5446 | 5495 |
5447 class GrowableObjectArray : public Instance { | 5496 class GrowableObjectArray : public Instance { |
5448 public: | 5497 public: |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5900 | 5949 |
5901 static bool IsExternalTypedDataView(const Instance& view_obj) { | 5950 static bool IsExternalTypedDataView(const Instance& view_obj) { |
5902 const Instance& data = Instance::Handle(Data(view_obj)); | 5951 const Instance& data = Instance::Handle(Data(view_obj)); |
5903 intptr_t cid = data.raw()->GetClassId(); | 5952 intptr_t cid = data.raw()->GetClassId(); |
5904 ASSERT(RawObject::IsTypedDataClassId(cid) || | 5953 ASSERT(RawObject::IsTypedDataClassId(cid) || |
5905 RawObject::IsExternalTypedDataClassId(cid)); | 5954 RawObject::IsExternalTypedDataClassId(cid)); |
5906 return RawObject::IsExternalTypedDataClassId(cid); | 5955 return RawObject::IsExternalTypedDataClassId(cid); |
5907 } | 5956 } |
5908 | 5957 |
5909 static intptr_t NumberOfFields() { | 5958 static intptr_t NumberOfFields() { |
5910 return (kLengthOffset - kTypeArguments); | 5959 return kLengthOffset; |
5911 } | 5960 } |
5912 | 5961 |
5913 static intptr_t data_offset() { | 5962 static intptr_t data_offset() { |
5914 return kWordSize * kDataOffset; | 5963 return kWordSize * kDataOffset; |
5915 } | 5964 } |
5916 | 5965 |
5917 static intptr_t offset_in_bytes_offset() { | 5966 static intptr_t offset_in_bytes_offset() { |
5918 return kWordSize * kOffsetInBytesOffset; | 5967 return kWordSize * kOffsetInBytesOffset; |
5919 } | 5968 } |
5920 | 5969 |
5921 static intptr_t length_offset() { | 5970 static intptr_t length_offset() { |
5922 return kWordSize * kLengthOffset; | 5971 return kWordSize * kLengthOffset; |
5923 } | 5972 } |
5924 | 5973 |
5925 static intptr_t ElementSizeInBytes(intptr_t class_id) { | 5974 static intptr_t ElementSizeInBytes(intptr_t class_id) { |
5926 ASSERT(RawObject::IsTypedDataViewClassId(class_id)); | 5975 ASSERT(RawObject::IsTypedDataViewClassId(class_id)); |
5927 return (class_id == kByteDataViewCid) ? | 5976 return (class_id == kByteDataViewCid) ? |
5928 TypedData::element_size[kTypedDataInt8ArrayCid] : | 5977 TypedData::element_size[kTypedDataInt8ArrayCid] : |
5929 TypedData::element_size[class_id - kTypedDataInt8ArrayViewCid]; | 5978 TypedData::element_size[class_id - kTypedDataInt8ArrayViewCid]; |
5930 } | 5979 } |
5931 | 5980 |
5932 private: | 5981 private: |
5933 enum { | 5982 enum { |
5934 kTypeArguments = 1, | 5983 kDataOffset = 1, |
5935 kDataOffset = 2, | 5984 kOffsetInBytesOffset = 2, |
5936 kOffsetInBytesOffset = 3, | 5985 kLengthOffset = 3, |
5937 kLengthOffset = 4, | |
5938 }; | 5986 }; |
5939 }; | 5987 }; |
5940 | 5988 |
5941 | 5989 |
5942 class Closure : public AllStatic { | 5990 class Closure : public AllStatic { |
5943 public: | 5991 public: |
5944 static RawFunction* function(const Instance& closure) { | 5992 static RawFunction* function(const Instance& closure) { |
5945 return *FunctionAddr(closure); | 5993 return *FunctionAddr(closure); |
5946 } | 5994 } |
5947 static intptr_t function_offset() { | 5995 static intptr_t function_offset() { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6000 reinterpret_cast<intptr_t>(obj.raw_ptr()) + context_offset()); | 6048 reinterpret_cast<intptr_t>(obj.raw_ptr()) + context_offset()); |
6001 } | 6049 } |
6002 static void set_function(const Instance& closure, | 6050 static void set_function(const Instance& closure, |
6003 const Function& value) { | 6051 const Function& value) { |
6004 closure.StorePointer(FunctionAddr(closure), value.raw()); | 6052 closure.StorePointer(FunctionAddr(closure), value.raw()); |
6005 } | 6053 } |
6006 static void set_context(const Instance& closure, | 6054 static void set_context(const Instance& closure, |
6007 const Context& value) { | 6055 const Context& value) { |
6008 closure.StorePointer(ContextAddr(closure), value.raw()); | 6056 closure.StorePointer(ContextAddr(closure), value.raw()); |
6009 } | 6057 } |
| 6058 static intptr_t NextFieldOffset() { |
| 6059 // Indicates this class cannot be extended by dart code. |
| 6060 return -kWordSize; |
| 6061 } |
6010 | 6062 |
6011 friend class Class; | 6063 friend class Class; |
6012 }; | 6064 }; |
6013 | 6065 |
6014 | 6066 |
6015 // Internal stacktrace object used in exceptions for printing stack traces. | 6067 // Internal stacktrace object used in exceptions for printing stack traces. |
6016 class Stacktrace : public Instance { | 6068 class Stacktrace : public Instance { |
6017 public: | 6069 public: |
6018 static const int kPreallocatedStackdepth = 10; | 6070 static const int kPreallocatedStackdepth = 10; |
6019 | 6071 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6321 | 6373 |
6322 | 6374 |
6323 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6375 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6324 intptr_t index) { | 6376 intptr_t index) { |
6325 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6377 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6326 } | 6378 } |
6327 | 6379 |
6328 } // namespace dart | 6380 } // namespace dart |
6329 | 6381 |
6330 #endif // VM_OBJECT_H_ | 6382 #endif // VM_OBJECT_H_ |
OLD | NEW |