Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 522d5a3

Browse filesBrowse files
targosRafaelGSS
authored andcommitted
test: run V8 Fast API tests in release mode too
Only keep the call count assertions under `common.isDebug`. PR-URL: #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>
1 parent edbecf5 commit 522d5a3
Copy full SHA for 522d5a3

File tree

Expand file treeCollapse file tree

3 files changed

+31
-27
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+31
-27
lines changed
Open diff view settings
Collapse file

‎doc/contributing/adding-v8-fast-api.md‎

Copy file name to clipboardExpand all lines: doc/contributing/adding-v8-fast-api.md
+15-16Lines changed: 15 additions & 16 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -173,25 +173,24 @@ A typical function that communicates between JavaScript and C++ is as follows.
173173
// We could also require a function that uses the internal binding internally.
174174
const { divide } = internalBinding('custom_namespace');
175175

176-
if (common.isDebug) {
177-
const { getV8FastApiCallCount } = internalBinding('debug');
178-
179-
// The function that will be optimized. It has to be a function written in
180-
// JavaScript. Since `divide` comes from the C++ side, we need to wrap it.
181-
function testFastPath(a, b) {
182-
return divide(a, b);
183-
}
176+
// The function that will be optimized. It has to be a function written in
177+
// JavaScript. Since `divide` comes from the C++ side, we need to wrap it.
178+
function testFastPath(a, b) {
179+
return divide(a, b);
180+
}
184181

185-
eval('%PrepareFunctionForOptimization(testFastPath)');
186-
// This call will let V8 know about the argument types that the function expects.
187-
assert.strictEqual(testFastPath(6, 3), 2);
182+
eval('%PrepareFunctionForOptimization(testFastPath)');
183+
// This call will let V8 know about the argument types that the function expects.
184+
assert.strictEqual(testFastPath(6, 3), 2);
188185

189-
eval('%OptimizeFunctionOnNextCall(testFastPath)');
190-
assert.strictEqual(testFastPath(8, 2), 4);
191-
assert.throws(() => testFastPath(1, 0), {
192-
code: 'ERR_INVALID_STATE',
193-
});
186+
eval('%OptimizeFunctionOnNextCall(testFastPath)');
187+
assert.strictEqual(testFastPath(8, 2), 4);
188+
assert.throws(() => testFastPath(1, 0), {
189+
code: 'ERR_INVALID_STATE',
190+
});
194191

192+
if (common.isDebug) {
193+
const { getV8FastApiCallCount } = internalBinding('debug');
195194
assert.strictEqual(getV8FastApiCallCount('custom_namespace.divide.ok'), 1);
196195
assert.strictEqual(getV8FastApiCallCount('custom_namespace.divide.error'), 1);
197196
}
Collapse file

‎test/parallel/test-whatwg-url-canparse.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-whatwg-url-canparse.js
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ assert.throws(() => {
1919
// It should not throw when called without a base string
2020
assert.strictEqual(URL.canParse('https://example.org'), true);
2121

22-
if (common.isDebug) {
23-
const { getV8FastApiCallCount } = internalBinding('debug');
24-
22+
{
23+
// V8 Fast API
2524
function testFastPaths() {
2625
// `canParse` binding has two overloads.
2726
assert.strictEqual(URL.canParse('https://www.example.com/path/?query=param#hash'), true);
@@ -33,6 +32,9 @@ if (common.isDebug) {
3332
eval('%OptimizeFunctionOnNextCall(URL.canParse)');
3433
testFastPaths();
3534

36-
assert.strictEqual(getV8FastApiCallCount('url.canParse'), 1);
37-
assert.strictEqual(getV8FastApiCallCount('url.canParse.withBase'), 1);
35+
if (common.isDebug) {
36+
const { getV8FastApiCallCount } = internalBinding('debug');
37+
assert.strictEqual(getV8FastApiCallCount('url.canParse'), 1);
38+
assert.strictEqual(getV8FastApiCallCount('url.canParse.withBase'), 1);
39+
}
3840
}
Collapse file

‎test/sequential/test-crypto-timing-safe-equal.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-crypto-timing-safe-equal.js
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,8 @@ assert.throws(
9393
}
9494
);
9595

96-
if (common.isDebug) {
97-
const { internalBinding } = require('internal/test/binding');
98-
const { getV8FastApiCallCount } = internalBinding('debug');
99-
96+
{
97+
// V8 Fast API
10098
const foo = Buffer.from('foo');
10199
const bar = Buffer.from('bar');
102100
const longer = Buffer.from('longer');
@@ -111,6 +109,11 @@ if (common.isDebug) {
111109
assert.throws(() => testFastPath(foo, longer), {
112110
code: 'ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH',
113111
});
114-
assert.strictEqual(getV8FastApiCallCount('crypto.timingSafeEqual.ok'), 2);
115-
assert.strictEqual(getV8FastApiCallCount('crypto.timingSafeEqual.error'), 1);
112+
113+
if (common.isDebug) {
114+
const { internalBinding } = require('internal/test/binding');
115+
const { getV8FastApiCallCount } = internalBinding('debug');
116+
assert.strictEqual(getV8FastApiCallCount('crypto.timingSafeEqual.ok'), 2);
117+
assert.strictEqual(getV8FastApiCallCount('crypto.timingSafeEqual.error'), 1);
118+
}
116119
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.