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/+/3507991 Reviewed-by: Dominik Inführ <dinfuehr@chromium.org> Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/main@{#79394}
This commit is contained in:
parent
e043b44d48
commit
1e9f077576
@ -51,12 +51,26 @@ class WeakCallbackInfo {
|
||||
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
|
||||
// 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
|
||||
// possible to request a second pass callback.
|
||||
enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer };
|
||||
/**
|
||||
* Weakness type for weak handles.
|
||||
*/
|
||||
enum class WeakCallbackType {
|
||||
/**
|
||||
* 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>
|
||||
void* WeakCallbackInfo<T>::GetInternalField(int index) const {
|
||||
|
@ -517,9 +517,11 @@ class GlobalHandles::Node final : public NodeBase<GlobalHandles::Node> {
|
||||
case v8::WeakCallbackType::kInternalFields:
|
||||
set_weakness_type(PHANTOM_WEAK_2_EMBEDDER_FIELDS);
|
||||
break;
|
||||
START_ALLOW_USE_DEPRECATED()
|
||||
case v8::WeakCallbackType::kFinalizer:
|
||||
set_weakness_type(FINALIZER_WEAK);
|
||||
break;
|
||||
END_ALLOW_USE_DEPRECATED()
|
||||
}
|
||||
set_parameter(parameter);
|
||||
weak_callback_ = phantom_callback;
|
||||
|
Loading…
Reference in New Issue
Block a user