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 RUNTIME_VM_OBJECT_STORE_H_ | 5 #ifndef RUNTIME_VM_OBJECT_STORE_H_ |
6 #define RUNTIME_VM_OBJECT_STORE_H_ | 6 #define RUNTIME_VM_OBJECT_STORE_H_ |
7 | 7 |
8 #include "vm/object.h" | 8 #include "vm/object.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
11 | 11 |
12 // Forward declarations. | 12 // Forward declarations. |
13 class Isolate; | 13 class Isolate; |
14 class ObjectPointerVisitor; | 14 class ObjectPointerVisitor; |
15 | 15 |
16 // A list of the bootstrap libraries including CamelName and hacker_name. | |
17 // | |
18 // These are listed in the order that they are compiled (see vm/bootstrap.cc). | |
19 #define FOR_EACH_PRODUCT_LIBRARY(M) \ | |
hausner
2016/11/09 00:42:49
Similar to Florian's comment, I would prefer to ha
Vyacheslav Egorov (Google)
2016/11/09 14:43:16
It's in separate CL now: https://codereview.chromi
| |
20 M(Core, core) \ | |
21 M(Async, async) \ | |
22 M(Collection, collection) \ | |
23 M(Convert, convert) \ | |
24 M(Developer, developer) \ | |
25 M(Internal, _internal) \ | |
26 M(Isolate, isolate) \ | |
27 M(Math, math) \ | |
28 M(Profiler, profiler) \ | |
29 M(TypedData, typed_data) \ | |
30 M(VMService, _vmservice) | |
31 | |
32 #ifdef PRODUCT | |
33 #define FOR_EACH_BOOTSTRAP_LIBRARY(M) FOR_EACH_PRODUCT_LIBRARY(M) | |
34 | |
35 #else | |
36 #define FOR_EACH_BOOTSTRAP_LIBRARY(M) \ | |
37 FOR_EACH_PRODUCT_LIBRARY(M) \ | |
38 M(Mirrors, mirrors) | |
39 | |
40 #endif | |
41 | |
16 // The object store is a per isolate instance which stores references to | 42 // The object store is a per isolate instance which stores references to |
17 // objects used by the VM. | 43 // objects used by the VM. |
18 // TODO(iposva): Move the actual store into the object heap for quick handling | 44 // TODO(iposva): Move the actual store into the object heap for quick handling |
19 // by snapshots eventually. | 45 // by snapshots eventually. |
20 class ObjectStore { | 46 class ObjectStore { |
21 public: | 47 public: |
22 enum BootstrapLibraryId { | 48 enum BootstrapLibraryId { |
23 kNone = 0, | 49 #define MAKE_ID(Name, _) k##Name, |
24 kAsync, | 50 |
25 kCore, | 51 FOR_EACH_BOOTSTRAP_LIBRARY(MAKE_ID) |
26 kCollection, | 52 #undef MAKE_ID |
27 kConvert, | |
28 kDeveloper, | |
29 kInternal, | |
30 kIsolate, | |
31 kMath, | |
32 kMirrors, | |
33 kProfiler, | |
34 kTypedData, | |
35 kVMService, | |
36 }; | 53 }; |
37 | 54 |
38 ~ObjectStore(); | 55 ~ObjectStore(); |
39 | 56 |
40 RawClass* object_class() const { | 57 RawClass* object_class() const { |
41 ASSERT(object_class_ != Object::null()); | 58 ASSERT(object_class_ != Object::null()); |
42 return object_class_; | 59 return object_class_; |
43 } | 60 } |
44 void set_object_class(const Class& value) { object_class_ = value.raw(); } | 61 void set_object_class(const Class& value) { object_class_ = value.raw(); } |
45 static intptr_t object_class_offset() { | 62 static intptr_t object_class_offset() { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 canonical_types_ = value.raw(); | 286 canonical_types_ = value.raw(); |
270 } | 287 } |
271 | 288 |
272 RawArray* canonical_type_arguments() const { | 289 RawArray* canonical_type_arguments() const { |
273 return canonical_type_arguments_; | 290 return canonical_type_arguments_; |
274 } | 291 } |
275 void set_canonical_type_arguments(const Array& value) { | 292 void set_canonical_type_arguments(const Array& value) { |
276 canonical_type_arguments_ = value.raw(); | 293 canonical_type_arguments_ = value.raw(); |
277 } | 294 } |
278 | 295 |
279 RawLibrary* async_library() const { return async_library_; } | 296 #define MAKE_GETTER(_, name) \ |
280 RawLibrary* builtin_library() const { return builtin_library_; } | 297 RawLibrary* name##_library() const { return name##_library_; } |
281 RawLibrary* core_library() const { return core_library_; } | 298 |
282 RawLibrary* collection_library() const { return collection_library_; } | 299 FOR_EACH_BOOTSTRAP_LIBRARY(MAKE_GETTER) |
283 RawLibrary* convert_library() const { return convert_library_; } | 300 #undef MAKE_GETTER |
284 RawLibrary* developer_library() const { return developer_library_; } | 301 |
285 RawLibrary* internal_library() const { return internal_library_; } | 302 RawLibrary* bootstrap_library(BootstrapLibraryId index) { |
286 RawLibrary* isolate_library() const { return isolate_library_; } | 303 switch (index) { |
287 RawLibrary* math_library() const { return math_library_; } | 304 #define MAKE_CASE(CamelName, hacker_name) \ |
288 RawLibrary* mirrors_library() const { return mirrors_library_; } | 305 case k##CamelName: \ |
289 RawLibrary* profiler_library() const { return profiler_library_; } | 306 return hacker_name##_library_; |
290 RawLibrary* typed_data_library() const { return typed_data_library_; } | 307 |
291 RawLibrary* vmservice_library() const { return vmservice_library_; } | 308 FOR_EACH_BOOTSTRAP_LIBRARY(MAKE_CASE) |
309 #undef MAKE_CASE | |
310 | |
311 default: | |
312 UNREACHABLE(); | |
313 return Library::null(); | |
314 } | |
315 } | |
292 | 316 |
293 void set_bootstrap_library(BootstrapLibraryId index, const Library& value) { | 317 void set_bootstrap_library(BootstrapLibraryId index, const Library& value) { |
294 switch (index) { | 318 switch (index) { |
295 case kAsync: | 319 #define MAKE_CASE(CamelName, hacker_name) \ |
296 async_library_ = value.raw(); | 320 case k##CamelName: \ |
297 break; | 321 hacker_name##_library_ = value.raw(); \ |
298 case kCore: | 322 break; |
299 core_library_ = value.raw(); | 323 |
300 break; | 324 FOR_EACH_BOOTSTRAP_LIBRARY(MAKE_CASE) |
301 case kCollection: | 325 #undef MAKE_CASE |
302 collection_library_ = value.raw(); | |
303 break; | |
304 case kConvert: | |
305 convert_library_ = value.raw(); | |
306 break; | |
307 case kDeveloper: | |
308 developer_library_ = value.raw(); | |
309 break; | |
310 case kInternal: | |
311 internal_library_ = value.raw(); | |
312 break; | |
313 case kIsolate: | |
314 isolate_library_ = value.raw(); | |
315 break; | |
316 case kMath: | |
317 math_library_ = value.raw(); | |
318 break; | |
319 case kMirrors: | |
320 mirrors_library_ = value.raw(); | |
321 break; | |
322 case kProfiler: | |
323 profiler_library_ = value.raw(); | |
324 break; | |
325 case kTypedData: | |
326 typed_data_library_ = value.raw(); | |
327 break; | |
328 case kVMService: | |
329 vmservice_library_ = value.raw(); | |
330 break; | |
331 default: | 326 default: |
332 UNREACHABLE(); | 327 UNREACHABLE(); |
333 } | 328 } |
334 } | 329 } |
335 | 330 |
336 void set_builtin_library(const Library& value) { | 331 void set_builtin_library(const Library& value) { |
337 builtin_library_ = value.raw(); | 332 builtin_library_ = value.raw(); |
338 } | 333 } |
339 | 334 |
340 RawLibrary* native_wrappers_library() const { | 335 RawLibrary* native_wrappers_library() const { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 V(RawClass*, weak_property_class_) \ | 565 V(RawClass*, weak_property_class_) \ |
571 V(RawArray*, symbol_table_) \ | 566 V(RawArray*, symbol_table_) \ |
572 V(RawArray*, canonical_types_) \ | 567 V(RawArray*, canonical_types_) \ |
573 V(RawArray*, canonical_type_arguments_) \ | 568 V(RawArray*, canonical_type_arguments_) \ |
574 V(RawLibrary*, async_library_) \ | 569 V(RawLibrary*, async_library_) \ |
575 V(RawLibrary*, builtin_library_) \ | 570 V(RawLibrary*, builtin_library_) \ |
576 V(RawLibrary*, core_library_) \ | 571 V(RawLibrary*, core_library_) \ |
577 V(RawLibrary*, collection_library_) \ | 572 V(RawLibrary*, collection_library_) \ |
578 V(RawLibrary*, convert_library_) \ | 573 V(RawLibrary*, convert_library_) \ |
579 V(RawLibrary*, developer_library_) \ | 574 V(RawLibrary*, developer_library_) \ |
580 V(RawLibrary*, internal_library_) \ | 575 V(RawLibrary*, _internal_library_) \ |
581 V(RawLibrary*, isolate_library_) \ | 576 V(RawLibrary*, isolate_library_) \ |
582 V(RawLibrary*, math_library_) \ | 577 V(RawLibrary*, math_library_) \ |
583 V(RawLibrary*, mirrors_library_) \ | 578 V(RawLibrary*, mirrors_library_) \ |
584 V(RawLibrary*, native_wrappers_library_) \ | 579 V(RawLibrary*, native_wrappers_library_) \ |
585 V(RawLibrary*, profiler_library_) \ | 580 V(RawLibrary*, profiler_library_) \ |
586 V(RawLibrary*, root_library_) \ | 581 V(RawLibrary*, root_library_) \ |
587 V(RawLibrary*, typed_data_library_) \ | 582 V(RawLibrary*, typed_data_library_) \ |
588 V(RawLibrary*, vmservice_library_) \ | 583 V(RawLibrary*, _vmservice_library_) \ |
589 V(RawGrowableObjectArray*, libraries_) \ | 584 V(RawGrowableObjectArray*, libraries_) \ |
590 V(RawArray*, libraries_map_) \ | 585 V(RawArray*, libraries_map_) \ |
591 V(RawGrowableObjectArray*, closure_functions_) \ | 586 V(RawGrowableObjectArray*, closure_functions_) \ |
592 V(RawGrowableObjectArray*, pending_classes_) \ | 587 V(RawGrowableObjectArray*, pending_classes_) \ |
593 V(RawGrowableObjectArray*, pending_deferred_loads_) \ | 588 V(RawGrowableObjectArray*, pending_deferred_loads_) \ |
594 V(RawGrowableObjectArray*, resume_capabilities_) \ | 589 V(RawGrowableObjectArray*, resume_capabilities_) \ |
595 V(RawGrowableObjectArray*, exit_listeners_) \ | 590 V(RawGrowableObjectArray*, exit_listeners_) \ |
596 V(RawGrowableObjectArray*, error_listeners_) \ | 591 V(RawGrowableObjectArray*, error_listeners_) \ |
597 V(RawContext*, empty_context_) \ | 592 V(RawContext*, empty_context_) \ |
598 V(RawInstance*, stack_overflow_) \ | 593 V(RawInstance*, stack_overflow_) \ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
641 | 636 |
642 friend class Serializer; | 637 friend class Serializer; |
643 friend class Deserializer; | 638 friend class Deserializer; |
644 | 639 |
645 DISALLOW_COPY_AND_ASSIGN(ObjectStore); | 640 DISALLOW_COPY_AND_ASSIGN(ObjectStore); |
646 }; | 641 }; |
647 | 642 |
648 } // namespace dart | 643 } // namespace dart |
649 | 644 |
650 #endif // RUNTIME_VM_OBJECT_STORE_H_ | 645 #endif // RUNTIME_VM_OBJECT_STORE_H_ |
OLD | NEW |