assert,util: fix constructor lookup in deep equal comparison

The latest performance optimization did not take into account that
an object may have a property called constructor. This is addressed
in this PR by adding a new fast path and using fallbacks.

PR-URL: https://github.com/nodejs/node/pull/57876
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Ruben Bridgewater 2025-04-19 13:10:40 +02:00 committed by GitHub
parent 2b76dca0fa
commit 733e0fc2c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 211 additions and 50 deletions

View file

@ -10,6 +10,7 @@ const notCircular = {};
notCircular.circular = {};
const primValues = {
'null_prototype': { __proto__: null },
'string': 'abcdef',
'number': 1_000,
'boolean': true,
@ -24,6 +25,7 @@ const primValues = {
};
const primValues2 = {
'null_prototype': { __proto__: null },
'object': { property: 'abcdef' },
'array': [1, 2, 3],
'set_object': new Set([[1]]),
@ -35,6 +37,7 @@ const primValues2 = {
};
const primValuesUnequal = {
'null_prototype': { __proto__: { __proto__: null } },
'string': 'abcdez',
'number': 1_001,
'boolean': false,