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
+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];
}