MCPcopy Index your code
hub / github.com/nodejs/node / warmUpTestFn

Function warmUpTestFn

deps/v8/test/mjsunit/compiler/string-or-oddball-compare.js:12–33  ·  view source on GitHub ↗
(test_fn_src)

Source from the content-addressed store, hash-verified

10let uniqueId = 0;
11
12function warmUpTestFn(test_fn_src) {
13 // Create a fresh and uncached function
14 test_fn_src = test_fn_src.toString();
15 const pattern = '(x, y) {\n';
16 assertTrue(test_fn_src.includes(pattern))
17 parts = test_fn_src.split(pattern)
18 assertEquals(parts.length, 2)
19 let test_fn = new Function('x', 'y', `{/*${uniqueId++}*/\n${parts[1]}`);
20
21 assertUnoptimized(test_fn);
22 %PrepareFunctionForOptimization(test_fn);
23
24 // Warm up with internalized strings and oddballs.
25 assertEquals(1, test_fn("2", "2"));
26 assertEquals(0, test_fn("2", null));
27 assertEquals(1, test_fn(internalized1234, internalized1234));
28
29 %OptimizeFunctionOnNextCall(test_fn);
30 assertEquals(0, test_fn("1", "2"));
31 assertOptimized(test_fn);
32 return test_fn;
33}
34
35function test(test_fn_src) {
36 assertEquals(internalized1234, nonInternalized1234);

Callers 1

testFunction · 0.85

Calls 5

includesMethod · 0.80
assertEqualsFunction · 0.70
assertTrueFunction · 0.50
toStringMethod · 0.45
splitMethod · 0.45

Tested by 1

testFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…