mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test: run V8 Fast API tests in release mode too
Only keep the call count assertions under `common.isDebug`. PR-URL: https://github.com/nodejs/node/pull/54570 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
01f751b529
commit
8966787624
@ -173,25 +173,24 @@ A typical function that communicates between JavaScript and C++ is as follows.
|
||||
// We could also require a function that uses the internal binding internally.
|
||||
const { divide } = internalBinding('custom_namespace');
|
||||
|
||||
// The function that will be optimized. It has to be a function written in
|
||||
// JavaScript. Since `divide` comes from the C++ side, we need to wrap it.
|
||||
function testFastPath(a, b) {
|
||||
return divide(a, b);
|
||||
}
|
||||
|
||||
eval('%PrepareFunctionForOptimization(testFastPath)');
|
||||
// This call will let V8 know about the argument types that the function expects.
|
||||
assert.strictEqual(testFastPath(6, 3), 2);
|
||||
|
||||
eval('%OptimizeFunctionOnNextCall(testFastPath)');
|
||||
assert.strictEqual(testFastPath(8, 2), 4);
|
||||
assert.throws(() => testFastPath(1, 0), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
|
||||
if (common.isDebug) {
|
||||
const { getV8FastApiCallCount } = internalBinding('debug');
|
||||
|
||||
// The function that will be optimized. It has to be a function written in
|
||||
// JavaScript. Since `divide` comes from the C++ side, we need to wrap it.
|
||||
function testFastPath(a, b) {
|
||||
return divide(a, b);
|
||||
}
|
||||
|
||||
eval('%PrepareFunctionForOptimization(testFastPath)');
|
||||
// This call will let V8 know about the argument types that the function expects.
|
||||
assert.strictEqual(testFastPath(6, 3), 2);
|
||||
|
||||
eval('%OptimizeFunctionOnNextCall(testFastPath)');
|
||||
assert.strictEqual(testFastPath(8, 2), 4);
|
||||
assert.throws(() => testFastPath(1, 0), {
|
||||
code: 'ERR_INVALID_STATE',
|
||||
});
|
||||
|
||||
assert.strictEqual(getV8FastApiCallCount('custom_namespace.divide.ok'), 1);
|
||||
assert.strictEqual(getV8FastApiCallCount('custom_namespace.divide.error'), 1);
|
||||
}
|
||||
|
@ -19,9 +19,8 @@ assert.throws(() => {
|
||||
// It should not throw when called without a base string
|
||||
assert.strictEqual(URL.canParse('https://example.org'), true);
|
||||
|
||||
if (common.isDebug) {
|
||||
const { getV8FastApiCallCount } = internalBinding('debug');
|
||||
|
||||
{
|
||||
// V8 Fast API
|
||||
function testFastPaths() {
|
||||
// `canParse` binding has two overloads.
|
||||
assert.strictEqual(URL.canParse('https://www.example.com/path/?query=param#hash'), true);
|
||||
@ -33,6 +32,9 @@ if (common.isDebug) {
|
||||
eval('%OptimizeFunctionOnNextCall(URL.canParse)');
|
||||
testFastPaths();
|
||||
|
||||
assert.strictEqual(getV8FastApiCallCount('url.canParse'), 1);
|
||||
assert.strictEqual(getV8FastApiCallCount('url.canParse.withBase'), 1);
|
||||
if (common.isDebug) {
|
||||
const { getV8FastApiCallCount } = internalBinding('debug');
|
||||
assert.strictEqual(getV8FastApiCallCount('url.canParse'), 1);
|
||||
assert.strictEqual(getV8FastApiCallCount('url.canParse.withBase'), 1);
|
||||
}
|
||||
}
|
||||
|
@ -93,10 +93,8 @@ assert.throws(
|
||||
}
|
||||
);
|
||||
|
||||
if (common.isDebug) {
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const { getV8FastApiCallCount } = internalBinding('debug');
|
||||
|
||||
{
|
||||
// V8 Fast API
|
||||
const foo = Buffer.from('foo');
|
||||
const bar = Buffer.from('bar');
|
||||
const longer = Buffer.from('longer');
|
||||
@ -111,6 +109,11 @@ if (common.isDebug) {
|
||||
assert.throws(() => testFastPath(foo, longer), {
|
||||
code: 'ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH',
|
||||
});
|
||||
assert.strictEqual(getV8FastApiCallCount('crypto.timingSafeEqual.ok'), 2);
|
||||
assert.strictEqual(getV8FastApiCallCount('crypto.timingSafeEqual.error'), 1);
|
||||
|
||||
if (common.isDebug) {
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const { getV8FastApiCallCount } = internalBinding('debug');
|
||||
assert.strictEqual(getV8FastApiCallCount('crypto.timingSafeEqual.ok'), 2);
|
||||
assert.strictEqual(getV8FastApiCallCount('crypto.timingSafeEqual.error'), 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user