FIR DFA: split flow for postponed lambdas from a single node

This removes the need for hacks around the order in which function
call arguments are visited, fixes called-in-place lambda arguments
for augmented assignment operators, and makes CFG dumps a bit prettier.
This commit is contained in:
pyos
2022-11-24 18:01:32 +01:00
committed by teamcity
parent 402ea98e02
commit 664a70ec13
16 changed files with 819 additions and 910 deletions
File diff suppressed because it is too large Load Diff
@@ -5,26 +5,26 @@ digraph lambdaAsReturnOfLambda_kt {
subgraph cluster_0 {
color=red
14 [label="Enter property" style="filled" fillcolor=red];
15 [label="Postponed enter to lambda"];
13 [label="Enter property" style="filled" fillcolor=red];
14 [label="Postponed enter to lambda"];
subgraph cluster_1 {
color=blue
0 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_2 {
color=blue
1 [label="Enter block"];
2 [label="Postponed enter to lambda"];
2 [label="Exit anonymous function expression"];
subgraph cluster_3 {
color=blue
8 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
7 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_4 {
color=blue
9 [label="Enter block"];
10 [label="Access variable R|<local>/foo|"];
11 [label="Function call: R|/bar|(...)" style="filled" fillcolor=yellow];
12 [label="Exit block"];
8 [label="Enter block"];
9 [label="Access variable R|<local>/foo|"];
10 [label="Function call: R|/bar|(...)" style="filled" fillcolor=yellow];
11 [label="Exit block"];
}
13 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
12 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
3 [label="Jump: ^@run lambda@fun <anonymous>(foo: R|kotlin/String|): R|kotlin/Unit| <inline=Unknown> {
R|/bar|(R|<local>/foo|)
@@ -35,64 +35,62 @@ digraph lambdaAsReturnOfLambda_kt {
}
6 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
7 [label="Postponed exit from lambda"];
16 [label="Postponed exit from lambda"];
17 [label="Function call: R|/run|<R|(kotlin/String) -> kotlin/Unit|>(...)" style="filled" fillcolor=yellow];
18 [label="Exit property" style="filled" fillcolor=red];
15 [label="Postponed exit from lambda"];
16 [label="Function call: R|/run|<R|(kotlin/String) -> kotlin/Unit|>(...)" style="filled" fillcolor=yellow];
17 [label="Exit property" style="filled" fillcolor=red];
}
14 -> {15};
15 -> {16 0 17};
15 -> {0} [style=dashed];
13 -> {14};
14 -> {15 0 16};
14 -> {0} [style=dashed];
15 -> {16};
16 -> {17};
17 -> {18};
0 -> {1};
1 -> {2};
2 -> {7 3 8};
2 -> {8} [style=dashed];
2 -> {3 7};
2 -> {7} [style=dashed];
3 -> {6};
3 -> {4} [style=dotted];
4 -> {5} [style=dotted];
5 -> {6} [style=dotted];
7 -> {17};
7 -> {8};
8 -> {9};
9 -> {10};
10 -> {11};
11 -> {12};
12 -> {13};
subgraph cluster_5 {
color=red
19 [label="Enter function bar" style="filled" fillcolor=red];
18 [label="Enter function bar" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
20 [label="Enter block"];
21 [label="Exit block"];
19 [label="Enter block"];
20 [label="Exit block"];
}
22 [label="Exit function bar" style="filled" fillcolor=red];
21 [label="Exit function bar" style="filled" fillcolor=red];
}
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {22};
subgraph cluster_7 {
color=red
23 [label="Enter function run" style="filled" fillcolor=red];
22 [label="Enter function run" style="filled" fillcolor=red];
subgraph cluster_8 {
color=blue
24 [label="Enter block"];
25 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()" style="filled" fillcolor=yellow];
26 [label="Jump: ^run R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()"];
27 [label="Stub" style="filled" fillcolor=gray];
28 [label="Exit block" style="filled" fillcolor=gray];
23 [label="Enter block"];
24 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()" style="filled" fillcolor=yellow];
25 [label="Jump: ^run R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()"];
26 [label="Stub" style="filled" fillcolor=gray];
27 [label="Exit block" style="filled" fillcolor=gray];
}
29 [label="Exit function run" style="filled" fillcolor=red];
28 [label="Exit function run" style="filled" fillcolor=red];
}
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {26};
26 -> {29};
25 -> {28};
25 -> {26} [style=dotted];
26 -> {27} [style=dotted];
27 -> {28} [style=dotted];
28 -> {29} [style=dotted];
}
+83 -85
View File
@@ -113,30 +113,29 @@ digraph lambdas_kt {
subgraph cluster_13 {
color=blue
39 [label="Enter block"];
40 [label="Local function declaration test_2"];
41 [label="Exit anonymous function expression"];
42 [label="Variable declaration: lval lambda: R|() -> kotlin/Int|"];
43 [label="Exit block"];
40 [label="Exit anonymous function expression"];
41 [label="Variable declaration: lval lambda: R|() -> kotlin/Int|"];
42 [label="Exit block"];
}
44 [label="Exit when branch result"];
45 [label="Exit when"];
43 [label="Exit when branch result"];
44 [label="Exit when"];
}
46 [label="Exit block"];
45 [label="Exit block"];
}
47 [label="Exit function test_2" style="filled" fillcolor=red];
46 [label="Exit function test_2" style="filled" fillcolor=red];
}
subgraph cluster_14 {
color=blue
48 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
47 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_15 {
color=blue
49 [label="Enter block"];
50 [label="Access variable R|<local>/x|"];
51 [label="Smart cast: R|<local>/x|"];
52 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()" style="filled" fillcolor=yellow];
53 [label="Exit block"];
48 [label="Enter block"];
49 [label="Access variable R|<local>/x|"];
50 [label="Smart cast: R|<local>/x|"];
51 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()" style="filled" fillcolor=yellow];
52 [label="Exit block"];
}
54 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
53 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
30 -> {31};
31 -> {32};
@@ -145,147 +144,146 @@ digraph lambdas_kt {
34 -> {35};
35 -> {36};
36 -> {38 37};
37 -> {45};
37 -> {44};
38 -> {39};
39 -> {40};
40 -> {48 41};
40 -> {48} [style=dashed];
40 -> {47 41};
40 -> {47} [style=dashed];
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {54};
subgraph cluster_16 {
color=red
55 [label="Enter function getInt" style="filled" fillcolor=red];
54 [label="Enter function getInt" style="filled" fillcolor=red];
subgraph cluster_17 {
color=blue
56 [label="Enter block"];
57 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
58 [label="Const: Int(1)"];
59 [label="Jump: ^getInt Int(1)"];
60 [label="Stub" style="filled" fillcolor=gray];
61 [label="Exit block" style="filled" fillcolor=gray];
55 [label="Enter block"];
56 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
57 [label="Const: Int(1)"];
58 [label="Jump: ^getInt Int(1)"];
59 [label="Stub" style="filled" fillcolor=gray];
60 [label="Exit block" style="filled" fillcolor=gray];
}
62 [label="Exit function getInt" style="filled" fillcolor=red];
61 [label="Exit function getInt" style="filled" fillcolor=red];
}
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {59};
59 -> {62};
58 -> {61};
58 -> {59} [style=dotted];
59 -> {60} [style=dotted];
60 -> {61} [style=dotted];
61 -> {62} [style=dotted];
subgraph cluster_18 {
color=red
63 [label="Enter function test_3" style="filled" fillcolor=red];
62 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_19 {
color=blue
64 [label="Enter block"];
65 [label="Postponed enter to lambda"];
63 [label="Enter block"];
64 [label="Postponed enter to lambda"];
subgraph cluster_20 {
color=blue
72 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
71 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_21 {
color=blue
73 [label="Enter block"];
74 [label="Const: Int(1)"];
75 [label="Jump: ^test_3 Int(1)"];
76 [label="Stub" style="filled" fillcolor=gray];
77 [label="Exit block" style="filled" fillcolor=gray];
72 [label="Enter block"];
73 [label="Const: Int(1)"];
74 [label="Jump: ^test_3 Int(1)"];
75 [label="Stub" style="filled" fillcolor=gray];
76 [label="Exit block" style="filled" fillcolor=gray];
}
78 [label="Exit function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray];
77 [label="Exit function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray];
}
66 [label="Postponed exit from lambda"];
67 [label="Function call: R|/getInt|(...)" style="filled" fillcolor=yellow];
68 [label="Jump: ^test_3 R|/getInt|(<L> = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
65 [label="Postponed exit from lambda"];
66 [label="Function call: R|/getInt|(...)" style="filled" fillcolor=yellow];
67 [label="Jump: ^test_3 R|/getInt|(<L> = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
^test_3 Int(1)
}
)"];
69 [label="Stub" style="filled" fillcolor=gray];
70 [label="Exit block" style="filled" fillcolor=gray];
68 [label="Stub" style="filled" fillcolor=gray];
69 [label="Exit block" style="filled" fillcolor=gray];
}
71 [label="Exit function test_3" style="filled" fillcolor=red];
70 [label="Exit function test_3" style="filled" fillcolor=red];
}
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {66 72 67};
65 -> {72} [style=dashed];
64 -> {65 71 66};
64 -> {71} [style=dashed];
65 -> {66};
65 -> {64} [color=green style=dashed];
66 -> {67};
66 -> {65} [color=green style=dashed];
67 -> {68};
68 -> {71};
67 -> {70};
67 -> {68} [style=dotted];
68 -> {69} [style=dotted];
69 -> {70} [style=dotted];
70 -> {71} [style=dotted];
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {75};
75 -> {71};
74 -> {70};
74 -> {75} [style=dotted];
75 -> {76} [style=dotted];
76 -> {77} [style=dotted];
77 -> {78} [style=dotted];
78 -> {66} [style=dotted];
77 -> {65} [style=dotted];
subgraph cluster_22 {
color=red
79 [label="Enter function test_4" style="filled" fillcolor=red];
78 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_23 {
color=blue
80 [label="Enter block"];
81 [label="Postponed enter to lambda"];
79 [label="Enter block"];
80 [label="Postponed enter to lambda"];
subgraph cluster_24 {
color=blue
88 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
87 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_25 {
color=blue
89 [label="Enter block"];
90 [label="Const: Int(1)"];
91 [label="Jump: ^test_4 Int(1)"];
92 [label="Stub" style="filled" fillcolor=gray];
93 [label="Exit block" style="filled" fillcolor=gray];
88 [label="Enter block"];
89 [label="Const: Int(1)"];
90 [label="Jump: ^test_4 Int(1)"];
91 [label="Stub" style="filled" fillcolor=gray];
92 [label="Exit block" style="filled" fillcolor=gray];
}
94 [label="Exit function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray];
93 [label="Exit function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray];
}
82 [label="Postponed exit from lambda"];
83 [label="Function call: R|/getInt|(...)" style="filled" fillcolor=yellow];
84 [label="Jump: ^test_4 R|/getInt|(block = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
81 [label="Postponed exit from lambda"];
82 [label="Function call: R|/getInt|(...)" style="filled" fillcolor=yellow];
83 [label="Jump: ^test_4 R|/getInt|(block = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
^test_4 Int(1)
}
)"];
85 [label="Stub" style="filled" fillcolor=gray];
86 [label="Exit block" style="filled" fillcolor=gray];
84 [label="Stub" style="filled" fillcolor=gray];
85 [label="Exit block" style="filled" fillcolor=gray];
}
87 [label="Exit function test_4" style="filled" fillcolor=red];
86 [label="Exit function test_4" style="filled" fillcolor=red];
}
78 -> {79};
79 -> {80};
80 -> {81};
81 -> {82 88 83};
81 -> {88} [style=dashed];
80 -> {81 87 82};
80 -> {87} [style=dashed];
81 -> {82};
81 -> {80} [color=green style=dashed];
82 -> {83};
82 -> {81} [color=green style=dashed];
83 -> {84};
84 -> {87};
83 -> {86};
83 -> {84} [style=dotted];
84 -> {85} [style=dotted];
85 -> {86} [style=dotted];
86 -> {87} [style=dotted];
87 -> {88};
88 -> {89};
89 -> {90};
90 -> {91};
91 -> {87};
90 -> {86};
90 -> {91} [style=dotted];
91 -> {92} [style=dotted];
92 -> {93} [style=dotted];
93 -> {94} [style=dotted];
94 -> {82} [style=dotted];
93 -> {81} [style=dotted];
}
@@ -30,23 +30,22 @@ digraph postponedLambdaInConstructor_kt {
subgraph cluster_4 {
color=blue
13 [label="Enter block"];
14 [label="Postponed enter to lambda"];
14 [label="Exit anonymous function expression"];
subgraph cluster_5 {
color=blue
18 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
17 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
19 [label="Enter block"];
20 [label="Access variable R|<local>/it|"];
21 [label="Exit block"];
18 [label="Enter block"];
19 [label="Access variable R|<local>/it|"];
20 [label="Exit block"];
}
22 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
21 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
15 [label="Exit block"];
}
16 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
17 [label="Postponed exit from lambda"];
8 [label="Postponed exit from lambda"];
9 [label="Function call: R|<local>/s|.R|kotlin/let|<R|kotlin/String|, R|() -> kotlin/String|>(...)" style="filled" fillcolor=yellow];
10 [label="Delegated constructor call: super<R|A|>(...)" style="filled" fillcolor=yellow];
@@ -63,52 +62,50 @@ digraph postponedLambdaInConstructor_kt {
10 -> {11};
12 -> {13};
13 -> {14};
14 -> {17 15 18};
14 -> {18} [style=dashed];
14 -> {15 17};
14 -> {17} [style=dashed];
15 -> {16};
16 -> {8};
17 -> {10} [color=red];
17 -> {9} [color=green];
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {22};
subgraph cluster_7 {
color=red
23 [label="Enter property" style="filled" fillcolor=red];
24 [label="Access variable R|<local>/s|"];
25 [label="Exit property" style="filled" fillcolor=red];
22 [label="Enter property" style="filled" fillcolor=red];
23 [label="Access variable R|<local>/s|"];
24 [label="Exit property" style="filled" fillcolor=red];
}
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {33} [color=green];
24 -> {32} [color=green];
subgraph cluster_8 {
color=red
26 [label="Enter function foo" style="filled" fillcolor=red];
25 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_9 {
color=blue
27 [label="Enter block"];
28 [label="Function call: this@R|/B|.R|/B.foo|()" style="filled" fillcolor=yellow];
29 [label="Exit block"];
26 [label="Enter block"];
27 [label="Function call: this@R|/B|.R|/B.foo|()" style="filled" fillcolor=yellow];
28 [label="Exit block"];
}
30 [label="Exit function foo" style="filled" fillcolor=red];
29 [label="Exit function foo" style="filled" fillcolor=red];
}
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
subgraph cluster_10 {
color=red
31 [label="Enter class B" style="filled" fillcolor=red];
32 [label="Part of class initialization"];
33 [label="Exit class B" style="filled" fillcolor=red];
30 [label="Enter class B" style="filled" fillcolor=red];
31 [label="Part of class initialization"];
32 [label="Exit class B" style="filled" fillcolor=red];
}
31 -> {32} [color=green];
32 -> {33} [style=dotted];
32 -> {23} [color=green];
32 -> {23} [style=dashed];
30 -> {31} [color=green];
31 -> {32} [style=dotted];
31 -> {22} [color=green];
31 -> {22} [style=dashed];
}