summaryrefslogtreecommitdiff
path: root/lib/compiler/src/compile.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <bjorn@erlang.org>2019-05-14 10:11:31 +0200
committerBjörn Gustavsson <bjorn@erlang.org>2019-05-22 10:47:22 +0200
commit18dc9a8099d1ad8f52b9db7bd251bcbfd632ce5e (patch)
treecb7d2a6d3620c53cc098a2cb863bd3adf9427d0c /lib/compiler/src/compile.erl
parentfe2b1323a3866ed0a9712e9d12e1f8f84793ec47 (diff)
downloaderlang-18dc9a8099d1ad8f52b9db7bd251bcbfd632ce5e.tar.gz
Make the swap instruction known to the compiler
BEAM has had a `swap` instruction for several releases, but it was not known to the compiler. The loader would translate a sequence of three `move` instructions to the `swap` instructions, but only when it was possible to determine that it would be safe. By making `swap` known to the compiler, it can be applied in more situations since it is easier for the compiler than for the loader to ensure that the usage is safe, and the loader shenanigans can be eliminated.
Diffstat (limited to 'lib/compiler/src/compile.erl')
-rw-r--r--lib/compiler/src/compile.erl6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 28db8986ff..2878edcbbe 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -265,7 +265,9 @@ expand_opt(r19, Os) ->
expand_opt(r20, Os) ->
expand_opt_before_21(Os);
expand_opt(r21, Os) ->
- [no_put_tuple2 | expand_opt(no_bsm3, Os)];
+ [no_swap, no_put_tuple2 | expand_opt(no_bsm3, Os)];
+expand_opt(r22, Os) ->
+ [no_swap | Os];
expand_opt({debug_info_key,_}=O, Os) ->
[encrypt_debug_info,O|Os];
expand_opt(no_type_opt, Os) ->
@@ -275,7 +277,7 @@ expand_opt(no_type_opt, Os) ->
expand_opt(O, Os) -> [O|Os].
expand_opt_before_21(Os) ->
- [no_put_tuple2, no_get_hd_tl, no_ssa_opt_record,
+ [no_swap, no_put_tuple2, no_get_hd_tl, no_ssa_opt_record,
no_utf8_atoms | expand_opt(no_bsm3, Os)].
%% format_error(ErrorDescriptor) -> string()