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

Side by Side Diff: src/global-handles.h

Issue 1953263002: [API] Remove deprecated WeakCallbackData and related functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « src/api.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_GLOBAL_HANDLES_H_ 5 #ifndef V8_GLOBAL_HANDLES_H_
6 #define V8_GLOBAL_HANDLES_H_ 6 #define V8_GLOBAL_HANDLES_H_
7 7
8 #include "include/v8.h" 8 #include "include/v8.h"
9 #include "include/v8-profiler.h" 9 #include "include/v8-profiler.h"
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 bool operator<(const ObjectGroupRetainerInfo& other) const { 91 bool operator<(const ObjectGroupRetainerInfo& other) const {
92 return id < other.id; 92 return id < other.id;
93 } 93 }
94 94
95 UniqueId id; 95 UniqueId id;
96 RetainedObjectInfo* info; 96 RetainedObjectInfo* info;
97 }; 97 };
98 98
99 enum WeaknessType { 99 enum WeaknessType {
100 NORMAL_WEAK, // Embedder gets a handle to the dying object.
101 // In the following cases, the embedder gets the parameter they passed in 100 // In the following cases, the embedder gets the parameter they passed in
102 // earlier, and 0 or 2 first internal fields. Note that the internal 101 // earlier, and 0 or 2 first internal fields. Note that the internal
103 // fields must contain aligned non-V8 pointers. Getting pointers to V8 102 // fields must contain aligned non-V8 pointers. Getting pointers to V8
104 // objects through this interface would be GC unsafe so in that case the 103 // objects through this interface would be GC unsafe so in that case the
105 // embedder gets a null pointer instead. 104 // embedder gets a null pointer instead.
106 PHANTOM_WEAK, 105 PHANTOM_WEAK,
107 PHANTOM_WEAK_2_INTERNAL_FIELDS, 106 PHANTOM_WEAK_2_INTERNAL_FIELDS,
108 // Like NORMAL_WEAK, but uses WeakCallbackInfo instead of WeakCallbackData. 107 // Embedder gets a handle to the dying object.
109 FINALIZER_WEAK, 108 FINALIZER_WEAK,
110 }; 109 };
111 110
112 class GlobalHandles { 111 class GlobalHandles {
113 public: 112 public:
114 ~GlobalHandles(); 113 ~GlobalHandles();
115 114
116 // Creates a new global handle that is alive until Destroy is called. 115 // Creates a new global handle that is alive until Destroy is called.
117 Handle<Object> Create(Object* value); 116 Handle<Object> Create(Object* value);
118 117
119 // Copy a global handle 118 // Copy a global handle
120 static Handle<Object> CopyGlobal(Object** location); 119 static Handle<Object> CopyGlobal(Object** location);
121 120
122 // Destroy a global handle. 121 // Destroy a global handle.
123 static void Destroy(Object** location); 122 static void Destroy(Object** location);
124 123
125 typedef WeakCallbackData<v8::Value, void>::Callback WeakCallback;
126
127 // For a phantom weak reference, the callback does not have access to the
128 // dying object. Phantom weak references are preferred because they allow
129 // memory to be reclaimed in one GC cycle rather than two. However, for
130 // historical reasons the default is non-phantom.
131 enum PhantomState { Nonphantom, Phantom };
132
133 // Make the global handle weak and set the callback parameter for the 124 // Make the global handle weak and set the callback parameter for the
134 // handle. When the garbage collector recognizes that only weak global 125 // handle. When the garbage collector recognizes that only weak global
135 // handles point to an object the callback function is invoked (for each 126 // handles point to an object the callback function is invoked (for each
136 // handle) with the handle and corresponding parameter as arguments. By 127 // handle) with the handle and corresponding parameter as arguments. By
137 // default the handle still contains a pointer to the object that is being 128 // default the handle still contains a pointer to the object that is being
138 // collected. For this reason the object is not collected until the next 129 // collected. For this reason the object is not collected until the next
139 // GC. For a phantom weak handle the handle is cleared (set to a Smi) 130 // GC. For a phantom weak handle the handle is cleared (set to a Smi)
140 // before the callback is invoked, but the handle can still be identified 131 // before the callback is invoked, but the handle can still be identified
141 // in the callback by using the location() of the handle. 132 // in the callback by using the location() of the handle.
142 static void MakeWeak(Object** location, void* parameter, 133 static void MakeWeak(Object** location, void* parameter,
143 WeakCallback weak_callback);
144
145 // It would be nice to template this one, but it's really hard to get
146 // the template instantiator to work right if you do.
147 static void MakeWeak(Object** location, void* parameter,
148 WeakCallbackInfo<void>::Callback weak_callback, 134 WeakCallbackInfo<void>::Callback weak_callback,
149 v8::WeakCallbackType type); 135 v8::WeakCallbackType type);
150 136
151 void RecordStats(HeapStats* stats); 137 void RecordStats(HeapStats* stats);
152 138
153 // Returns the current number of weak handles. 139 // Returns the current number of weak handles.
154 int NumberOfWeakHandles(); 140 int NumberOfWeakHandles();
155 141
156 // Returns the current number of weak handles to global objects. 142 // Returns the current number of weak handles to global objects.
157 // These handles are also included in NumberOfWeakHandles(). 143 // These handles are also included in NumberOfWeakHandles().
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; 441 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES];
456 442
457 DISALLOW_COPY_AND_ASSIGN(EternalHandles); 443 DISALLOW_COPY_AND_ASSIGN(EternalHandles);
458 }; 444 };
459 445
460 446
461 } // namespace internal 447 } // namespace internal
462 } // namespace v8 448 } // namespace v8
463 449
464 #endif // V8_GLOBAL_HANDLES_H_ 450 #endif // V8_GLOBAL_HANDLES_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698