aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-01-29 15:41:47 +0100
committerBjörn Gustavsson <[email protected]>2018-01-29 15:41:47 +0100
commitcaec48ae5d76fff1b3aee5ae8fafb81c1d9fc931 (patch)
treeda2d1c52282fc299820789e154e6d46474ab9c3b /lib/compiler/src
parent0db59d8427240477a2f4b27064d3a75b628c85ba (diff)
parent244bad23877191a66f5c1d63cf1845101c73229b (diff)
downloadotp-caec48ae5d76fff1b3aee5ae8fafb81c1d9fc931.tar.gz
otp-caec48ae5d76fff1b3aee5ae8fafb81c1d9fc931.tar.bz2
otp-caec48ae5d76fff1b3aee5ae8fafb81c1d9fc931.zip
Merge branch 'bjorn/compiler/integer-encoding'
* bjorn/compiler/integer-encoding: Speed up misc_SUITE:integer_encoding/1 beam_asm: Encode big numbers as literals
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/beam_asm.erl12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_asm.erl b/lib/compiler/src/beam_asm.erl
index 453e00fce3..fa919ca862 100644
--- a/lib/compiler/src/beam_asm.erl
+++ b/lib/compiler/src/beam_asm.erl
@@ -407,7 +407,17 @@ encode_arg({atom, Atom}, Dict0) when is_atom(Atom) ->
{Index, Dict} = beam_dict:atom(Atom, Dict0),
{encode(?tag_a, Index), Dict};
encode_arg({integer, N}, Dict) ->
- {encode(?tag_i, N), Dict};
+ %% Conservatily assume that all integers whose absolute
+ %% value is greater than 1 bsl 128 will be bignums in
+ %% the runtime system.
+ if
+ N >= 1 bsl 128 ->
+ encode_arg({literal, N}, Dict);
+ N =< -(1 bsl 128) ->
+ encode_arg({literal, N}, Dict);
+ true ->
+ {encode(?tag_i, N), Dict}
+ end;
encode_arg(nil, Dict) ->
{encode(?tag_a, 0), Dict};
encode_arg({f, W}, Dict) ->