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

Unified Diff: src/global-handles.h

Issue 753553002: Phantom references support internal fields (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Delete allocated objects in test to make memory sanitizer happy Created 6 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
« include/v8.h ('K') | « src/debug.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« include/v8.h ('K') | « src/debug.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698