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

Unified Diff: vm/dart.cc

Issue 11648006: Create read only handles for empty_array and sentinel objects (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vm/dart.h ('k') | vm/dart_api_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/dart.cc
===================================================================
--- vm/dart.cc (revision 16415)
+++ 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,29 @@
};
+// 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.)
+// The ReadOnlyHandles C++ Wrapper around VMHandles which is a ValueObject is
+// to ensure that the handles area is not trashed by automatic running of C++
+// static destructors when 'exit()" is called by any isolate. There might be
+// other isolates running at the same time and trashing the handles area will
+// have unintended consequences.
+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 +93,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 +237,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
« no previous file with comments | « vm/dart.h ('k') | vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698