-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
lib: make the builtInObjects set deterministic during bootstrap #33049
Changes from all commits
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 | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -130,9 +130,58 @@ const typedArraySizeGetter = uncurryThis( | |||||||
|
||||||||
let hexSlice; | ||||||||
|
||||||||
const builtInObjects = new Set( | ||||||||
ObjectGetOwnPropertyNames(global).filter((e) => /^[A-Z][a-zA-Z0-9]+$/.test(e)) | ||||||||
); | ||||||||
// Make this list explicit instead of filtering over globalThis so that | ||||||||
// this list is deterministic during the bootstrap regardless of: | ||||||||
// a) Whether this file is required when the context is going to be | ||||||||
// serialized, or what the V8 flags are. V8 does not add | ||||||||
// SharedArrayBuffer, Atomics, WebAssembly, and other flaggable | ||||||||
// globals e.g. harmony ones to a context that will be serialized. | ||||||||
// b) Whether this file is required before or after bootstrap | ||||||||
// (Node.js adds things like Buffer, URL, etc.) | ||||||||
const builtInObjects = new Set([ | ||||||||
'Object', | ||||||||
'Function', | ||||||||
'Array', | ||||||||
'Number', | ||||||||
'Infinity', | ||||||||
'NaN', | ||||||||
Comment on lines
+146
to
+147
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.
Suggested change
|
||||||||
'Boolean', | ||||||||
'String', | ||||||||
'Symbol', | ||||||||
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.
Suggested change
|
||||||||
'Date', | ||||||||
'Promise', | ||||||||
'RegExp', | ||||||||
'Error', | ||||||||
'EvalError', | ||||||||
'RangeError', | ||||||||
'ReferenceError', | ||||||||
'SyntaxError', | ||||||||
'TypeError', | ||||||||
'URIError', | ||||||||
'JSON', | ||||||||
'Math', | ||||||||
'Intl', | ||||||||
Comment on lines
+161
to
+163
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.
Suggested change
|
||||||||
'ArrayBuffer', | ||||||||
'Uint8Array', | ||||||||
'Int8Array', | ||||||||
'Uint16Array', | ||||||||
'Int16Array', | ||||||||
'Uint32Array', | ||||||||
'Int32Array', | ||||||||
'Float32Array', | ||||||||
'Float64Array', | ||||||||
'Uint8ClampedArray', | ||||||||
'BigUint64Array', | ||||||||
'BigInt64Array', | ||||||||
'DataView', | ||||||||
'Map', | ||||||||
'BigInt', | ||||||||
'Set', | ||||||||
'WeakMap', | ||||||||
'WeakSet', | ||||||||
'Proxy', | ||||||||
'Reflect' | ||||||||
Comment on lines
+182
to
+183
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.
Suggested change
|
||||||||
]); | ||||||||
|
||||||||
// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot | ||||||||
const isUndetectableObject = (v) => typeof v === 'undefined' && v !== undefined; | ||||||||
|
@@ -2033,5 +2082,6 @@ module.exports = { | |||||||
formatWithOptions, | ||||||||
getStringWidth, | ||||||||
inspectDefaultOptions, | ||||||||
stripVTControlCharacters | ||||||||
stripVTControlCharacters, | ||||||||
builtInObjects, | ||||||||
}; |
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.
This now contains these added by Node.js
We still need this loop if we want to pick up what get's added by V8 through harmony flags (like WeakRefs). I wonder which of these do we want to skip? @BridgeAR
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.
We mostly do not need those. The only ones that we should keep are global classes that have a prototype. The current RegExp is not matching exactly what we actually need. I just checked and this seems to ideally model what is needed for inspect: