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

Function warmUpMaglevTestFn

deps/v8/test/mjsunit/maglev/string-or-oddball-compare.js:13–34  ·  view source on GitHub ↗
(test_fn_src)

Source from the content-addressed store, hash-verified

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

Callers 1

testFunction · 0.70

Calls 5

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

Tested by 1

testFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…