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

Function test

deps/v8/test/mjsunit/generated-transition-stub.js:8–202  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7%NeverOptimizeFunction(test);
8function test() {
9
10 const iteration_count = 1;
11
12 function transition1(a, i, v) {
13 a[i] = v;
14 }
15
16 //
17 // Test PACKED SMI -> PACKED DOUBLE
18 //
19
20 %PrepareFunctionForOptimization(transition1);
21 const a1 = [0, 1, 2, 3, 4];
22 transition1(a1, 0, 2.5);
23 const a2 = [0, 1, 2, 3, 4];
24 transition1(a2, 0, 2.5);
25 assertFalse(%HasHoleyElements(a2));
26 %OptimizeFunctionOnNextCall(transition1);
27
28 const a3 = [0, 1, 2, 3, 4];
29 assertTrue(%HasSmiElements(a3));
30 transition1(a3, 0, 2.5);
31 assertFalse(%HasHoleyElements(a3));
32 assertEquals(4, a3[4]);
33 assertEquals(2.5, a3[0]);
34
35 // Test handling of hole.
36 const a4 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
37 a4.length = 7;
38 assertTrue(%HasSmiElements(a4));
39 transition1(a4, 0, 2.5);
40 assertFalse(%HasHoleyElements(a4));
41 assertEquals(2.5, a4[0]);
42 assertEquals(undefined, a4[8]);
43
44 // Large array should deopt to runtimea
45 for (j = 0; j < iteration_count; ++j) {
46 const a5 = new Array();
47 for (i = 0; i < 0x40000; ++i) {
48 a5[i] = 0;
49 }
50 assertTrue(%HasSmiElements(a5) || %HasDoubleElements(a5));
51 transition1(a5, 0, 2.5);
52 assertEquals(2.5, a5[0]);
53 }
54
55 //
56 // Test HOLEY SMI -> HOLEY DOUBLE
57 //
58
59 function transition2(a, i, v) {
60 a[i] = v;
61 }
62
63 %PrepareFunctionForOptimization(transition2);
64 const b1 = [0, 1, 2, , 4];
65 transition2(b1, 0, 2.5);

Callers 1

Calls 3

assertTrueFunction · 0.70
assertFalseFunction · 0.50
assertEqualsFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…