-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
lib: add internal/primordials_staging module
#63464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
fcf2b27
7319470
204c3c6
a56b827
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| 'use strict'; | ||
|
|
||
| // This file stores JS builtins that can not become primordials yet because | ||
| // they can be disabled by runtime flags, or are not enabled by default yet. | ||
|
|
||
| // Without this module, the only choice we would have is getting them from | ||
| // the global proxy which is mutable from userland. This is especially important | ||
| // for lazy-loaded builtins required in modules participating in early bootstrap. | ||
| // In such modules, we are usually unable to get these builtins synchronously, | ||
| // this applies to synchronous destructuring of this module. | ||
| // Importing the module itself is fine at any point, including top level of file. | ||
|
|
||
| let _AsyncDisposableStack; | ||
| let _DisposableStack; | ||
| let _Float16Array; | ||
| let _Intl; | ||
| let _Iterator; | ||
| let _ShadowRealm; | ||
| let _SharedArrayBuffer; | ||
| let _Temporal; | ||
| let _TemporalInstant; | ||
| let _Uint8ArrayFromHex; | ||
| let _Uint8ArrayFromBase64; | ||
| let _WebAssembly; | ||
| let _WebAssemblyInstance; | ||
| let _WebAssemblyLinkError; | ||
| let _WebAssemblyModule; | ||
|
|
||
| module.exports = { | ||
| get AsyncDisposableStack() { | ||
| return _AsyncDisposableStack; | ||
| }, | ||
| get DisposableStack() { | ||
| return _DisposableStack; | ||
| }, | ||
| get Float16Array() { | ||
| return _Float16Array; | ||
| }, | ||
| get Intl() { | ||
| return _Intl; | ||
| }, | ||
| get Iterator() { | ||
| return _Iterator; | ||
| }, | ||
| get ShadowRealm() { | ||
| return _ShadowRealm; | ||
| }, | ||
| get SharedArrayBuffer() { | ||
| return _SharedArrayBuffer; | ||
| }, | ||
| get Temporal() { | ||
| return _Temporal; | ||
| }, | ||
| get TemporalInstant() { | ||
| return _TemporalInstant; | ||
| }, | ||
| get Uint8ArrayFromHex() { | ||
| return _Uint8ArrayFromHex; | ||
| }, | ||
| get Uint8ArrayFromBase64() { | ||
| return _Uint8ArrayFromBase64; | ||
| }, | ||
| get WebAssembly() { | ||
| return _WebAssembly; | ||
| }, | ||
| get WebAssemblyInstance() { | ||
| return _WebAssemblyInstance; | ||
| }, | ||
| get WebAssemblyLinkError() { | ||
| return _WebAssemblyLinkError; | ||
| }, | ||
| get WebAssemblyModule() { | ||
| return _WebAssemblyModule; | ||
| }, | ||
| _init({ | ||
| AsyncDisposableStack, | ||
| DisposableStack, | ||
| Float16Array, | ||
| Intl, | ||
| Iterator, | ||
| ShadowRealm, | ||
| SharedArrayBuffer, | ||
| Temporal, | ||
| Uint8Array: { | ||
| fromBase64, | ||
| fromHex, | ||
| }, | ||
| WebAssembly, | ||
| }) { | ||
|
Comment on lines
+75
to
+89
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is only capturing the global object properties, not the object tree, so eg.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. There's intentionally no recursive object tree replication because realistically there's no need for that: nested objects that are actually used in internals can be added in follow-ups. |
||
| _AsyncDisposableStack = AsyncDisposableStack; | ||
| _DisposableStack = DisposableStack; | ||
| _Float16Array = Float16Array; | ||
| _Intl = Intl; | ||
| _Iterator = Iterator; | ||
| _ShadowRealm = ShadowRealm; | ||
| _SharedArrayBuffer = SharedArrayBuffer; | ||
| _Temporal = Temporal; | ||
| _TemporalInstant = Temporal?.Instant; | ||
| _Uint8ArrayFromBase64 = fromBase64; | ||
| _Uint8ArrayFromHex = fromHex; | ||
| _WebAssembly = WebAssembly; | ||
| _WebAssemblyInstance = WebAssembly?.Instance; | ||
| _WebAssemblyLinkError = WebAssembly?.LinkError; | ||
| _WebAssemblyModule = WebAssembly?.Module; | ||
|
|
||
| delete this._init; | ||
| }, | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
freeze_intrinsics also runs in pre-execution, so this wouldn't be necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Still, i'd prefer it to stay for consistency, so it doesn't differ from linter suggestion and the internals never take builtins from
globalThisdirectly.Unless there is another reason to keep
globalThishere.