Skip to content

Commit 978501f

Browse files
committed
add fast api test
1 parent fbf55b2 commit 978501f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Flags: --expose-internals --no-warnings --allow-natives-syntax
2+
'use strict';
3+
4+
const common = require('../common');
5+
const assert = require('assert');
6+
const zlib = require('zlib');
7+
8+
{
9+
function testFastPath() {
10+
const expected = 0xd87f7e0c; // zlib.crc32('test', 0)
11+
assert.strictEqual(zlib.crc32('test', 0), expected);
12+
return expected;
13+
}
14+
15+
eval('%PrepareFunctionForOptimization(zlib.crc32)');
16+
testFastPath();
17+
eval('%OptimizeFunctionOnNextCall(zlib.crc32)');
18+
testFastPath();
19+
testFastPath();
20+
21+
if (common.isDebug) {
22+
const { internalBinding } = require('internal/test/binding');
23+
const { getV8FastApiCallCount } = internalBinding('debug');
24+
assert.strictEqual(getV8FastApiCallCount('zlib.crc32'), 2);
25+
}
26+
}

0 commit comments

Comments
 (0)