... instead of the native data property.
This fixes the JS spec violation when reading a data property does not
expect any observable side effects. For example, OrdinaryGetOwnProperty
(see https://tc39.es/ecma262/#sec-ordinarygetownproperty, step 4a).
Differences to previous behaviour:
- Error.stack is defined as a JavaScript accessor property.
- all Error objects get a private "error_stack_symbol" field where
the captured stack trace is stored (previously it was added only when
the error was actually thrown which caused unnecessary transitions).
- Error.captureStackTrace(obj) adds public "stack" accessor property
and private "error_stack_symbol" property to given "obj".
- calling "stack" getter/setter is a no-op in case receiver is not an
"Error-like" object, i.e. it doesn't have a "error_stack_symbol"
property and it doesn't have a prototype with such a property (the
lookup stops at JSProxy or interceptor).
- the "stack" getter walks the prototype chain from receiver until it
finds a holder with the "error_stack_symbol" property which is then
used for computing the result.
This is slightly different from the previous behaviour in case
receiver's prototype chain contains multiple error objects.
- the "stack" setter walks the prototype chain from receiver until it
finds a holder with the "error_stack_symbol" property and stores the
value there.
Drive-by: handle lazy accessor pairs in ObjectVisitorDeepFreezer.
Bug: v8:5962
Change-Id: I109d6fbbbdb9588d13ca86d217efd9a4a11d8447
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4459251
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#87286}