diff options
author | Björn Gustavsson <[email protected]> | 2019-03-27 06:15:55 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-03-27 06:27:04 +0100 |
commit | 90e291e8fd42d6c9cf0695e940f34c92df1fa103 (patch) | |
tree | a75c5875b500d064842aa18db8f1526f4bc147d7 /erts/emulator/beam | |
parent | f75cf3bd6c433f71b6fd6d58dee95b0c0fb8a238 (diff) | |
download | otp-90e291e8fd42d6c9cf0695e940f34c92df1fa103.tar.gz otp-90e291e8fd42d6c9cf0695e940f34c92df1fa103.tar.bz2 otp-90e291e8fd42d6c9cf0695e940f34c92df1fa103.zip |
Fix unsafe optimization made by the loader
Fix the unsafe load-time optimization introduced in 07bdbb3a1edc.
https://bugs.erlang.org/browse/ERL-899
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/beam_load.c | 7 | ||||
-rw-r--r-- | erts/emulator/beam/ops.tab | 2 |
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 |