From 7e5698fb2e15aef910ce27a44b754e525022c96d Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 17 Aug 2021 12:04:09 +0200 Subject: chore: add `FinalizationRegistry` and `WeakRef` to primordials (#11735) Because it was possible to disable those with a runtime flag, they were not available through primordials. The flag has since been removed upstream. Refs: https://github.com/v8/v8/commit/d59db06bf5425ddb388fb5a576f4bf39bdcc0f8f --- core/00_primordials.js | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'core/00_primordials.js') diff --git a/core/00_primordials.js b/core/00_primordials.js index c6132620e..86af76c38 100644 --- a/core/00_primordials.js +++ b/core/00_primordials.js @@ -206,8 +206,7 @@ "Date", "Error", "EvalError", - // TODO(lucacasonato): not present in snapshots. Why? - // "FinalizationRegistry", + "FinalizationRegistry", "Float32Array", "Float64Array", "Function", @@ -231,8 +230,7 @@ "Uint8Array", "Uint8ClampedArray", "WeakMap", - // TODO(lucacasonato): not present in snapshots. Why? - // "WeakRef", + "WeakRef", "WeakSet", ].forEach((name) => { const original = globalThis[name]; @@ -410,25 +408,23 @@ }, ); - // TODO(lucacasonato): not present in snapshots. Why? - // primordials.SafeFinalizationRegistry = makeSafe( - // FinalizationRegistry, - // class SafeFinalizationRegistry extends FinalizationRegistry { - // constructor(cleanupCallback) { - // super(cleanupCallback); - // } - // }, - // ); - - // TODO(lucacasonato): not present in snapshots. Why? - // primordials.SafeWeakRef = makeSafe( - // WeakRef, - // class SafeWeakRef extends WeakRef { - // constructor(target) { - // super(target); - // } - // }, - // ); + primordials.SafeFinalizationRegistry = makeSafe( + FinalizationRegistry, + class SafeFinalizationRegistry extends FinalizationRegistry { + constructor(cleanupCallback) { + super(cleanupCallback); + } + }, + ); + + primordials.SafeWeakRef = makeSafe( + WeakRef, + class SafeWeakRef extends WeakRef { + constructor(target) { + super(target); + } + }, + ); const SafePromise = makeSafe( Promise, -- cgit v1.2.3