mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
PR-URL: https://github.com/nodejs/node/pull/59813 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
27 lines
739 B
JavaScript
27 lines
739 B
JavaScript
// Flags: --expose-internals --no-warnings --allow-natives-syntax
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const zlib = require('zlib');
|
|
|
|
{
|
|
function testFastPath() {
|
|
const expected = 0xd87f7e0c; // zlib.crc32('test', 0)
|
|
assert.strictEqual(zlib.crc32('test', 0), expected);
|
|
return expected;
|
|
}
|
|
|
|
eval('%PrepareFunctionForOptimization(zlib.crc32)');
|
|
testFastPath();
|
|
eval('%OptimizeFunctionOnNextCall(zlib.crc32)');
|
|
testFastPath();
|
|
testFastPath();
|
|
|
|
if (common.isDebug) {
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const { getV8FastApiCallCount } = internalBinding('debug');
|
|
assert.strictEqual(getV8FastApiCallCount('zlib.crc32'), 2);
|
|
}
|
|
}
|