diff options
author | Antoine du Hamel <duhamelantoine1995@gmail.com> | 2021-08-17 12:04:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-17 12:04:09 +0200 |
commit | 7e5698fb2e15aef910ce27a44b754e525022c96d (patch) | |
tree | b20f5ef4b0fd100f9ad117620d0e45e917d8aad2 | |
parent | 5d24ddf9b21213f19136b11b1b5862098b2c688c (diff) |
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
-rw-r--r-- | core/00_primordials.js | 42 |
1 files changed, 19 insertions, 23 deletions
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, |