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

Unified Diff: include/v8.h

Issue 649563006: Introduce phantom weak handles in the API and use them internally for debug info (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Actually make available through the API and fix scavenge Created 6 years, 2 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
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/global-handles.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index b231912eeb2ae91f19e8890206055ffb9a987b9a..abc7ae0964d77122e8d1025254112efdac009081 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -512,6 +512,18 @@ template <class T> class PersistentBase {
P* parameter,
typename WeakCallbackData<S, P>::Callback callback);
+ // Phantom persistents work like weak persistents, except that the pointer to
+ // the object being collected is not available in the finalization callback.
+ // This enables the garbage collector to collect the object and any objects
+ // it references transitively in one GC cycle.
+ template <typename P>
+ V8_INLINE void SetPhantom(P* parameter,
ulan 2014/10/20 14:03:10 Shouldn't phantom reference be in its own class, s
Erik Corry 2014/10/20 14:25:32 I think you want to allow deref before the object
Erik Corry 2014/10/22 13:21:00 I'll revise my answer to the second part slightly:
+ typename WeakCallbackData<T, P>::Callback callback);
+
+ template <typename S, typename P>
+ V8_INLINE void SetPhantom(P* parameter,
+ typename WeakCallbackData<S, P>::Callback callback);
+
template<typename P>
V8_INLINE P* ClearWeak();
@@ -5327,14 +5339,15 @@ class V8_EXPORT V8 {
private:
V8();
+ enum WeakHandleType { PhantomHandle, NonphantomHandle };
+
static internal::Object** GlobalizeReference(internal::Isolate* isolate,
internal::Object** handle);
static internal::Object** CopyPersistent(internal::Object** handle);
static void DisposeGlobal(internal::Object** global_handle);
typedef WeakCallbackData<Value, void>::Callback WeakCallback;
- static void MakeWeak(internal::Object** global_handle,
- void* data,
- WeakCallback weak_callback);
+ static void MakeWeak(internal::Object** global_handle, void* data,
+ WeakCallback weak_callback, WeakHandleType phantom);
static void* ClearWeak(internal::Object** global_handle);
static void Eternalize(Isolate* isolate,
Value* handle,
@@ -6197,9 +6210,8 @@ void PersistentBase<T>::SetWeak(
typename WeakCallbackData<S, P>::Callback callback) {
TYPE_CHECK(S, T);
typedef typename WeakCallbackData<Value, void>::Callback Callback;
- V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_),
- parameter,
- reinterpret_cast<Callback>(callback));
+ V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
+ reinterpret_cast<Callback>(callback), V8::NonphantomHandle);
}
@@ -6213,7 +6225,26 @@ void PersistentBase<T>::SetWeak(
template <class T>
-template<typename P>
+template <typename S, typename P>
+void PersistentBase<T>::SetPhantom(
+ P* parameter, typename WeakCallbackData<S, P>::Callback callback) {
+ TYPE_CHECK(S, T);
+ typedef typename WeakCallbackData<Value, void>::Callback Callback;
+ V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter,
+ reinterpret_cast<Callback>(callback), V8::PhantomHandle);
+}
+
+
+template <class T>
+template <typename P>
+void PersistentBase<T>::SetPhantom(
+ P* parameter, typename WeakCallbackData<T, P>::Callback callback) {
+ SetPhantom<T, P>(parameter, callback);
+}
+
+
+template <class T>
+template <typename P>
P* PersistentBase<T>::ClearWeak() {
return reinterpret_cast<P*>(
V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)));
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/global-handles.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698