Chromium Code Reviews| Index: vm/dart.cc |
| =================================================================== |
| --- vm/dart.cc (revision 16331) |
| +++ vm/dart.cc (working copy) |
| @@ -33,6 +33,7 @@ |
| Isolate* Dart::vm_isolate_ = NULL; |
| ThreadPool* Dart::thread_pool_ = NULL; |
| DebugInfo* Dart::pprof_symbol_generator_ = NULL; |
| +ReadOnlyHandles* Dart::predefined_handles_ = NULL; |
| // An object visitor which will mark all visited objects. This is used to |
| // premark all objects in the vm_isolate_ heap. |
| @@ -49,6 +50,24 @@ |
| }; |
| +// Structure for managing read only global handles allocation used for |
| +// creating global read only handles that are pre created and initialized |
| +// for use across all isolates. Having these global pre created handles |
| +// stored in the vm isolate ensures that we don't constantly create and |
| +// destroy handles for read only objects referred in the VM code |
| +// (e.g: symbols, null object, empty array etc. |
|
Ivan Posva
2012/12/20 23:43:52
Maybe explain why this is wrapped in an object in
siva
2012/12/21 02:28:06
Done.
|
| +class ReadOnlyHandles { |
| + public: |
| + ReadOnlyHandles() { } |
| + |
| + private: |
| + VMHandles handles_; |
| + |
| + friend class Dart; |
| + DISALLOW_COPY_AND_ASSIGN(ReadOnlyHandles); |
| +}; |
| + |
| + |
| // TODO(turnidge): We should add a corresponding Dart::Cleanup. |
| const char* Dart::InitOnce(Dart_IsolateCreateCallback create, |
| Dart_IsolateInterruptCallback interrupt, |
| @@ -69,6 +88,9 @@ |
| FreeListElement::InitOnce(); |
| Api::InitOnce(); |
| CodeObservers::InitOnce(); |
| + // Create the read only handles area. |
| + ASSERT(predefined_handles_ == NULL); |
| + predefined_handles_ = new ReadOnlyHandles(); |
| // Create the VM isolate and finish the VM initialization. |
| ASSERT(thread_pool_ == NULL); |
| thread_pool_ = new ThreadPool(); |
| @@ -210,4 +232,15 @@ |
| } |
| +uword Dart::AllocateReadOnlyHandle() { |
| + ASSERT(predefined_handles_ != NULL); |
| + return predefined_handles_->handles_.AllocateScopedHandle(); |
| +} |
| + |
| + |
| +bool Dart::IsReadOnlyHandle(uword address) { |
| + ASSERT(predefined_handles_ != NULL); |
| + return predefined_handles_->handles_.IsValidScopedHandle(address); |
| +} |
| + |
| } // namespace dart |