| Index: src/global-handles.h
|
| diff --git a/src/global-handles.h b/src/global-handles.h
|
| index aacdcbc072d0ae26af7ce6264767d8366ee17f7a..b3756d0e62035f41d980f5efbe17538414ec2eb8 100644
|
| --- a/src/global-handles.h
|
| +++ b/src/global-handles.h
|
| @@ -97,6 +97,13 @@ struct ObjectGroupRetainerInfo {
|
| };
|
|
|
|
|
| +enum WeaknessType {
|
| + NORMAL_WEAK, // Embedder gets a handle to the dying object.
|
| + PHANTOM_WEAK, // Embedder gets the parameter they passed in earlier.
|
| + INTERNAL_FIELDS_WEAK // Embedder gets 2 internal fields from dying object.
|
| +};
|
| +
|
| +
|
| class GlobalHandles {
|
| public:
|
| ~GlobalHandles();
|
| @@ -128,8 +135,18 @@ class GlobalHandles {
|
| // before the callback is invoked, but the handle can still be identified
|
| // in the callback by using the location() of the handle.
|
| static void MakeWeak(Object** location, void* parameter,
|
| - WeakCallback weak_callback,
|
| - PhantomState phantom = Nonphantom);
|
| + WeakCallback weak_callback);
|
| +
|
| + // It would be nice to template this one, but it's really hard to get
|
| + // the template instantiator to work right if you do.
|
| + static void MakePhantom(Object** location, void* parameter,
|
| + PhantomCallbackData<void>::Callback weak_callback);
|
| +
|
| + static void MakePhantom(
|
| + Object** location,
|
| + v8::InternalFieldsCallbackData<void, void>::Callback weak_callback,
|
| + int16_t internal_field_index1,
|
| + int16_t internal_field_index2 = v8::Object::kNoInternalFieldIndex);
|
|
|
| void RecordStats(HeapStats* stats);
|
|
|
| @@ -145,6 +162,10 @@ class GlobalHandles {
|
| return number_of_global_handles_;
|
| }
|
|
|
| + // Collect up data for the weak handle callbacks after GC has completed, but
|
| + // before memory is reclaimed.
|
| + void CollectPhantomCallbackData();
|
| +
|
| // Clear the weakness of a global handle.
|
| static void* ClearWeakness(Object** location);
|
|
|
| @@ -270,10 +291,18 @@ class GlobalHandles {
|
| // don't assign any initial capacity.
|
| static const int kObjectGroupConnectionsCapacity = 20;
|
|
|
| + // Helpers for PostGarbageCollectionProcessing.
|
| + int PostScavengeProcessing(int initial_post_gc_processing_count);
|
| + int PostMarkSweepProcessing(int initial_post_gc_processing_count);
|
| + int DispatchPendingPhantomCallbacks();
|
| + void UpdateListOfNewSpaceNodes();
|
| +
|
| // Internal node structures.
|
| class Node;
|
| class NodeBlock;
|
| class NodeIterator;
|
| + class PendingPhantomCallback;
|
| + class PendingInternalFieldsCallback;
|
|
|
| Isolate* isolate_;
|
|
|
| @@ -306,12 +335,46 @@ class GlobalHandles {
|
| List<ObjectGroupRetainerInfo> retainer_infos_;
|
| List<ObjectGroupConnection> implicit_ref_connections_;
|
|
|
| + List<PendingPhantomCallback> pending_phantom_callbacks_;
|
| + List<PendingInternalFieldsCallback> pending_internal_fields_callbacks_;
|
| +
|
| friend class Isolate;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(GlobalHandles);
|
| };
|
|
|
|
|
| +class GlobalHandles::PendingPhantomCallback {
|
| + public:
|
| + typedef PhantomCallbackData<void> Data;
|
| + PendingPhantomCallback(Node* node, Data data, Data::Callback callback)
|
| + : node_(node), data_(data), callback_(callback) {}
|
| +
|
| + void invoke();
|
| +
|
| + Node* node() { return node_; }
|
| +
|
| + private:
|
| + Node* node_;
|
| + Data data_;
|
| + Data::Callback callback_;
|
| +};
|
| +
|
| +
|
| +class GlobalHandles::PendingInternalFieldsCallback {
|
| + public:
|
| + typedef InternalFieldsCallbackData<void, void> Data;
|
| + PendingInternalFieldsCallback(Data data, Data::Callback callback)
|
| + : data_(data), callback_(callback) {}
|
| +
|
| + void invoke() { callback_(data_); }
|
| +
|
| + private:
|
| + Data data_;
|
| + Data::Callback callback_;
|
| +};
|
| +
|
| +
|
| class EternalHandles {
|
| public:
|
| enum SingletonHandle {
|
|
|