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

Unified Diff: include/v8.h

Issue 1950963002: Introduce a new phantom weakness type without finalization callback. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
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 9a881f2383ce6e6107c7c3da77f234113e62749f..389935e3b3500523becffa659883c6e94724229b 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -545,6 +545,15 @@ template <class T> class PersistentBase {
typename WeakCallbackInfo<P>::Callback callback,
WeakCallbackType type);
+ /**
+ * Turns this handle into a weak phantom handle without finalization callback.
+ * The handle will be reset automatically when the garbage collector detects
+ * that the object is no longer reachable.
+ * A related function Isolate::NumberOfPhantomHandleResetsSinceLastCall
+ * returns how many phantom handles were reset by the garbage collector.
+ */
+ V8_INLINE void SetWeak();
+
template<typename P>
V8_INLINE P* ClearWeak();
@@ -5784,6 +5793,12 @@ class V8_EXPORT Isolate {
AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
/**
+ * Returns the number of phantom handles without callbacks that were reset
+ * by the garbage collector since the last call to this function.
+ */
+ size_t NumberOfPhantomHandleResetsSinceLastCall();
+
+ /**
* Returns heap profiler for this isolate. Will return NULL until the isolate
* is initialized.
*/
@@ -6628,16 +6643,17 @@ class V8_EXPORT V8 {
internal::Object** handle);
static internal::Object** CopyPersistent(internal::Object** handle);
static void DisposeGlobal(internal::Object** global_handle);
- static void MakeWeak(internal::Object** global_handle, void* data,
+ static void MakeWeak(internal::Object** location, void* data,
WeakCallbackInfo<void>::Callback weak_callback,
WeakCallbackType type);
- static void MakeWeak(internal::Object** global_handle, void* data,
+ static void MakeWeak(internal::Object** location, void* data,
// Must be 0 or -1.
int internal_field_index1,
// Must be 1 or -1.
int internal_field_index2,
WeakCallbackInfo<void>::Callback weak_callback);
- static void* ClearWeak(internal::Object** global_handle);
+ static void MakeWeak(internal::Object*** location_addr);
+ static void* ClearWeak(internal::Object** location);
static void Eternalize(Isolate* isolate,
Value* handle,
int* index);
@@ -7609,6 +7625,10 @@ V8_INLINE void PersistentBase<T>::SetWeak(
reinterpret_cast<Callback>(callback), type);
}
+template <class T>
+void PersistentBase<T>::SetWeak() {
+ V8::MakeWeak(reinterpret_cast<internal::Object***>(&this->val_));
+}
template <class T>
template <typename P>
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698