Commit 95b2cf0
authored
Inlining: Handle local dependencies when splitting (#8064)
In pattern B there, we handle stuff like
if (..) { .. }
return x;
We split out the if body if it is large-enough, which allows inlining the if
condition + the return (efficient if the condition rarely happens). This did
not handle local effects: imagine that the if body contains x = 42, then
after splitting it out to another function, that value is not picked up in
the return of x. Fix that by checking local dependencies.
More detailed example:
function foo(x) {
if (..) {
work();
x = 42;
}
return x;
}
function caller() {
foo(1);
}
=> the incorrect optimization before =>
function caller() {
// inlined call, but split: just the condition + return.
var x = 1; // inlined value sent in call
if (..) {
outlinedCode();
}
x = x;
}
function outlinedCode() {
// The setting of x to 42 is done here, and not picked up
// in the caller.
var x;
work();
x = 42;
}
After this PR, we do not do such split inlining.1 parent df3d896 commit 95b2cf0
File tree
2 files changed
+513
-1
lines changed- src/passes
- test/lit/passes
2 files changed
+513
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
978 | 978 | | |
979 | 979 | | |
980 | 980 | | |
981 | | - | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
982 | 994 | | |
983 | 995 | | |
984 | 996 | | |
| |||
995 | 1007 | | |
996 | 1008 | | |
997 | 1009 | | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
998 | 1015 | | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
999 | 1025 | | |
1000 | 1026 | | |
1001 | 1027 | | |
| |||
0 commit comments