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

Unified Diff: src/global-handles.h

Issue 842153004: Unify phantom and internal fields weak handle callbacks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Require callback to reset handle. Created 5 years, 11 months 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
Index: src/global-handles.h
diff --git a/src/global-handles.h b/src/global-handles.h
index b3756d0e62035f41d980f5efbe17538414ec2eb8..fe9ed5a2585afccd400b3f94c1efd3e504736527 100644
--- a/src/global-handles.h
+++ b/src/global-handles.h
@@ -98,9 +98,15 @@ 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.
+ NORMAL_WEAK, // Embedder gets a handle to the dying object.
+ // In the following cases, the embedder gets the parameter they passed in
+ // earlier, and the 0, 1 or 2 first internal fields. Note that the internal
+ // fields must contain aligned non-V8 pointers. Getting pointers to V8
+ // objects through this interface would be GC unsafe so in that case the
+ // embedder gets a null pointer instead.
+ PHANTOM_WEAK_0_INTERNAL_FIELDS,
+ PHANTOM_WEAK_1_INTERNAL_FIELDS,
+ PHANTOM_WEAK_2_INTERNAL_FIELDS
};
@@ -139,14 +145,9 @@ class GlobalHandles {
// 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);
+ Object** location, void* parameter, int number_of_internal_fields,
+ PhantomCallbackData<void, void, void>::Callback weak_callback);
void RecordStats(HeapStats* stats);
@@ -302,7 +303,6 @@ class GlobalHandles {
class NodeBlock;
class NodeIterator;
class PendingPhantomCallback;
- class PendingInternalFieldsCallback;
Isolate* isolate_;
@@ -336,7 +336,6 @@ class GlobalHandles {
List<ObjectGroupConnection> implicit_ref_connections_;
List<PendingPhantomCallback> pending_phantom_callbacks_;
- List<PendingInternalFieldsCallback> pending_internal_fields_callbacks_;
friend class Isolate;
@@ -346,7 +345,7 @@ class GlobalHandles {
class GlobalHandles::PendingPhantomCallback {
public:
- typedef PhantomCallbackData<void> Data;
+ typedef PhantomCallbackData<void, void, void> Data;
PendingPhantomCallback(Node* node, Data data, Data::Callback callback)
: node_(node), data_(data), callback_(callback) {}
@@ -361,20 +360,6 @@ class GlobalHandles::PendingPhantomCallback {
};
-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 {

Powered by Google App Engine
This is Rietveld 408576698