Index: runtime/vm/isolate.cc |
=================================================================== |
--- runtime/vm/isolate.cc (revision 24200) |
+++ runtime/vm/isolate.cc (working copy) |
@@ -371,6 +371,9 @@ |
} |
+#define REUSABLE_HANDLE_INITIALIZERS(object) \ |
+ object##_handle_(NULL), |
+ |
Isolate::Isolate() |
: store_buffer_(), |
message_notify_callback_(NULL), |
@@ -409,11 +412,14 @@ |
deferred_objects_(NULL), |
stacktrace_(NULL), |
stack_frame_index_(-1), |
- object_histogram_(NULL) { |
+ object_histogram_(NULL), |
+ REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) |
+ handles_() { |
if (FLAG_print_object_histogram && (Dart::vm_isolate() != NULL)) { |
object_histogram_ = new ObjectHistogram(this); |
} |
} |
+#undef REUSABLE_HANDLE_INITIALIZERS |
Isolate::~Isolate() { |
@@ -461,6 +467,13 @@ |
// the current isolate. |
SetCurrent(result); |
+ // Setup the isolate specific resuable handles. |
+#define REUSABLE_HANDLE_ALLOCATION(object) \ |
+ result->object##_handle_ = result->AllocateReusableHandle<object>(); \ |
+ |
+ REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_ALLOCATION) |
+#undef REUSABLE_HANDLE_ALLOCATION |
+ |
// Setup the isolate message handler. |
MessageHandler* handler = new IsolateMessageHandler(result); |
ASSERT(handler != NULL); |
@@ -825,6 +838,9 @@ |
// Visit objects in zones. |
current_zone()->VisitObjectPointers(visitor); |
+ // Visit objects in isolate specific handles area. |
+ handles_.VisitObjectPointers(visitor); |
+ |
// Iterate over all the stack frames and visit objects on the stack. |
StackFrameIterator frames_iterator(validate_frames); |
StackFrame* frame = frames_iterator.NextFrame(); |
@@ -1050,6 +1066,14 @@ |
} |
+template<class T> |
+T* Isolate::AllocateReusableHandle() { |
+ T* handle = reinterpret_cast<T*>(handles_.AllocateScopedHandle()); |
+ T::initializeHandle(handle, T::null()); |
+ return handle; |
+} |
+ |
+ |
static void FillDeferredSlots(DeferredSlot** slot_list) { |
DeferredSlot* slot = *slot_list; |
*slot_list = NULL; |