aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-03-27 11:45:34 +0100
committerGitHub <[email protected]>2019-03-27 11:45:34 +0100
commit52dd4f4842d9c3314e7c10a4e05ceafdfc636649 (patch)
treea75c5875b500d064842aa18db8f1526f4bc147d7
parentf75cf3bd6c433f71b6fd6d58dee95b0c0fb8a238 (diff)
parent90e291e8fd42d6c9cf0695e940f34c92df1fa103 (diff)
downloadotp-52dd4f4842d9c3314e7c10a4e05ceafdfc636649.tar.gz
otp-52dd4f4842d9c3314e7c10a4e05ceafdfc636649.tar.bz2
otp-52dd4f4842d9c3314e7c10a4e05ceafdfc636649.zip
Merge pull request #2193 from bjorng/bjorn/erts/fix-unsafe-tuning/ERL-899
Fix unsafe optimization made by the loader
-rw-r--r--erts/emulator/beam/beam_load.c7
-rw-r--r--erts/emulator/beam/ops.tab2
2 files changed, 8 insertions, 1 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index 21740caa2c..69e49e97f3 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -3145,6 +3145,13 @@ is_killed(LoaderState* stp, GenOpArg Reg, GenOpArg Live)
Live.val <= Reg.val;
}
+static int
+is_killed_by_call_fun(LoaderState* stp, GenOpArg Reg, GenOpArg Live)
+{
+ return Reg.type == TAG_x && Live.type == TAG_u &&
+ Live.val+1 <= Reg.val;
+}
+
/*
* Test whether register Reg is killed by make_fun instruction that
* creates the fun given by index idx.
diff --git a/erts/emulator/beam/ops.tab b/erts/emulator/beam/ops.tab
index 6832e65b1b..3a95b1a37e 100644
--- a/erts/emulator/beam/ops.tab
+++ b/erts/emulator/beam/ops.tab
@@ -338,7 +338,7 @@ swap_temp R1 R2 Tmp | line Loc | apply Live | is_killed_apply(Tmp, Live) => \
swap_temp R1 R2 Tmp | line Loc | apply_last Live D | is_killed_apply(Tmp, Live) => \
swap R1 R2 | line Loc | apply_last Live D
-swap_temp R1 R2 Tmp | line Loc | call_fun Live | is_killed(Tmp, Live) => \
+swap_temp R1 R2 Tmp | line Loc | call_fun Live | is_killed_by_call_fun(Tmp, Live) => \
swap R1 R2 | line Loc | call_fun Live
swap_temp R1 R2 Tmp | make_fun2 OldIndex=u | is_killed_by_make_fun(Tmp, OldIndex) => \
swap R1 R2 | make_fun2 OldIndex