Commit 1e9f0775 authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

heap,api: Deprecate resurrecting finalizers

Resurrecting finalizers cause all sorts of problems, from performance
penalties when used to hard-to-debug memory leaks.

There's no more usage left in Blink as well as V8 internally, so
deprecate resurrecting finalizers.

Bug: v8:12672
Change-Id: I998373d6468bbd3bd581a41dec8904de80561f43
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3507991Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79394}
parent e043b44d
...@@ -51,12 +51,26 @@ class WeakCallbackInfo { ...@@ -51,12 +51,26 @@ class WeakCallbackInfo {
void* embedder_fields_[kEmbedderFieldsInWeakCallback]; void* embedder_fields_[kEmbedderFieldsInWeakCallback];
}; };
// kParameter will pass a void* parameter back to the callback, kInternalFields /**
// will pass the first two internal fields back to the callback, kFinalizer * Weakness type for weak handles.
// will pass a void* parameter back, but is invoked before the object is */
// actually collected, so it can be resurrected. In the last case, it is not enum class WeakCallbackType {
// possible to request a second pass callback. /**
enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer }; * Passes a user-defined void* parameter back to the callback.
*/
kParameter,
/**
* Passes the first two internal fields of the object back to the callback.
*/
kInternalFields,
/**
* Passes a user-defined void* parameter back to the callback. Will do so
* before the object is actually reclaimed, allowing it to be resurrected. In
* this case it is not possible to set a second-pass callback.
*/
kFinalizer V8_ENUM_DEPRECATE_SOON("Resurrecting finalizers are deprecated "
"and will not be supported going forward.")
};
template <class T> template <class T>
void* WeakCallbackInfo<T>::GetInternalField(int index) const { void* WeakCallbackInfo<T>::GetInternalField(int index) const {
......
...@@ -517,9 +517,11 @@ class GlobalHandles::Node final : public NodeBase<GlobalHandles::Node> { ...@@ -517,9 +517,11 @@ class GlobalHandles::Node final : public NodeBase<GlobalHandles::Node> {
case v8::WeakCallbackType::kInternalFields: case v8::WeakCallbackType::kInternalFields:
set_weakness_type(PHANTOM_WEAK_2_EMBEDDER_FIELDS); set_weakness_type(PHANTOM_WEAK_2_EMBEDDER_FIELDS);
break; break;
START_ALLOW_USE_DEPRECATED()
case v8::WeakCallbackType::kFinalizer: case v8::WeakCallbackType::kFinalizer:
set_weakness_type(FINALIZER_WEAK); set_weakness_type(FINALIZER_WEAK);
break; break;
END_ALLOW_USE_DEPRECATED()
} }
set_parameter(parameter); set_parameter(parameter);
weak_callback_ = phantom_callback; weak_callback_ = phantom_callback;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment