Skip to content

Commit 1171c3a

Browse files
committed
test: add test for getLibuvNow() fast api
1 parent 2b2816c commit 1171c3a

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

test/parallel/test-timers-now.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,16 @@ const binding = internalBinding('timers');
1111
assert(binding.getLibuvNow() < 0x3ffffff);
1212

1313
{
14-
// V8 Fast API
15-
function optimized() { // eslint-disable-line no-unused-vars
14+
// Only javascript methods can be optimized through %OptimizeFunctionOnNextCall
15+
// This is why we surround the C++ method we want to optimize with a JS function.
16+
function getLibuvNow() {
1617
return binding.getLibuvNow();
1718
}
1819

19-
function testFastPaths() {
20-
assert(binding.getLibuvNow() < 0x3ffffff);
21-
}
22-
23-
eval('%PrepareFunctionForOptimization(optimized)');
24-
testFastPaths();
25-
eval('%OptimizeFunctionOnNextCall(optimized)');
26-
testFastPaths();
20+
eval('%PrepareFunctionForOptimization(getLibuvNow)');
21+
getLibuvNow();
22+
eval('%OptimizeFunctionOnNextCall(getLibuvNow)');
23+
assert(getLibuvNow() < 0x3ffffff);
2724

2825
if (common.isDebug) {
2926
const { getV8FastApiCallCount } = internalBinding('debug');

0 commit comments

Comments
 (0)