Commit 0413cb661e0 for nodejs
commit 0413cb661e02aa978c7fca3b67ee05e1cd98bc2f
Author: dasunNimantha <dasun4@pm.me>
Date: Thu Nov 19 13:17:19 2026 +0530
test: update fast API call counts for crc32 and canParse
String input to zlib.crc32()/crc32c() now uses the regular binding, so
the fast-path tests use a Buffer. The first optimized URL.canParse()
call deopts once on the result compare, so optimize it a second time
before checking that both overloads took the fast path.
Signed-off-by: dasunNimantha <dasun4@pm.me>
PR-URL: https://github.com/nodejs/node/pull/67536
Refs: https://github.com/nodejs/node/issues/66870
Refs: https://github.com/nodejs/node/pull/67136
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
diff --git a/test/parallel/test-whatwg-url-canparse.js b/test/parallel/test-whatwg-url-canparse.js
index f3972a8b9c8..cbca70c1b78 100644
--- a/test/parallel/test-whatwg-url-canparse.js
+++ b/test/parallel/test-whatwg-url-canparse.js
@@ -35,10 +35,15 @@ assert.strictEqual(URL.canParse('https://example.org'), true);
testFastPaths();
eval('%OptimizeFunctionOnNextCall(URL.canParse)');
testFastPaths();
+ // The interpreter only saw the slow binding's -1, so the first optimized
+ // call deopts on the `result === 1` compare after its first fast call.
+ // Optimize again; this time both overloads take the fast path.
+ eval('%OptimizeFunctionOnNextCall(URL.canParse)');
+ testFastPaths();
if (common.isDebug) {
const { getV8FastApiCallCount } = internalBinding('debug');
- assert.strictEqual(getV8FastApiCallCount('url.canParse'), 1);
+ assert.strictEqual(getV8FastApiCallCount('url.canParse'), 2);
assert.strictEqual(getV8FastApiCallCount('url.canParse.withBase'), 1);
}
}
diff --git a/test/sequential/test-zlib-crc32-fast-api.js b/test/sequential/test-zlib-crc32-fast-api.js
index 37d5682a7ea..313cdbb71d3 100644
--- a/test/sequential/test-zlib-crc32-fast-api.js
+++ b/test/sequential/test-zlib-crc32-fast-api.js
@@ -8,7 +8,9 @@ const zlib = require('zlib');
{
function testFastPath() {
const expected = 0xd87f7e0c; // zlib.crc32('test', 0)
- assert.strictEqual(zlib.crc32('test', 0), expected);
+ // Only ArrayBufferViews take the fast path; strings use the regular
+ // binding, since reading them may allocate.
+ assert.strictEqual(zlib.crc32(Buffer.from('test'), 0), expected);
return expected;
}
diff --git a/test/sequential/test-zlib-crc32c-fast-api.js b/test/sequential/test-zlib-crc32c-fast-api.js
index ab62d1d2024..4fab0ea374f 100644
--- a/test/sequential/test-zlib-crc32c-fast-api.js
+++ b/test/sequential/test-zlib-crc32c-fast-api.js
@@ -8,7 +8,9 @@ const zlib = require('zlib');
{
function testFastPath() {
const expected = 0x86a072c0; // zlib.crc32c('test', 0)
- assert.strictEqual(zlib.crc32c('test', 0), expected);
+ // Only ArrayBufferViews take the fast path; strings use the regular
+ // binding, since reading them may allocate.
+ assert.strictEqual(zlib.crc32c(Buffer.from('test'), 0), expected);
return expected;
}