aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_asm.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-06-17 12:58:57 +0200
committerBjörn Gustavsson <[email protected]>2019-06-17 12:58:57 +0200
commit0a63f32c0cf828d07c33e4dd68ae561571279fe7 (patch)
tree9482190f7a64c42e4731149066c7ac8e06b16ca9 /lib/compiler/src/beam_asm.erl
parentd3f4351b6fc846f55fae221760da9b4c04560007 (diff)
parentfccac1598cc13fcd9a3d7e85e2c4cae722f1bfc4 (diff)
downloadotp-0a63f32c0cf828d07c33e4dd68ae561571279fe7.tar.gz
otp-0a63f32c0cf828d07c33e4dd68ae561571279fe7.tar.bz2
otp-0a63f32c0cf828d07c33e4dd68ae561571279fe7.zip
Merge branch 'bjorn/better-fun-info/OTP-15837'
* bjorn/better-fun-info/OTP-15837: Create a shared wrapper function for all occurrences of 'fun F/A' Support sharing of fun entries in the runtime system erl_fun.c: Remove unused struct definition hipe: Use the new index when translating funs Stop supporting decoding of old funs in the external term format genop.tab: Insert an "OTP 23" comment for clarity
Diffstat (limited to 'lib/compiler/src/beam_asm.erl')
-rw-r--r--lib/compiler/src/beam_asm.erl23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_asm.erl b/lib/compiler/src/beam_asm.erl
index df09dcb06c..60e19ec596 100644
--- a/lib/compiler/src/beam_asm.erl
+++ b/lib/compiler/src/beam_asm.erl
@@ -64,11 +64,30 @@ module(Code, ExtraChunks, CompileInfo, CompilerOpts) ->
assemble({Mod,Exp0,Attr0,Asm0,NumLabels}, ExtraChunks, CompileInfo, CompilerOpts) ->
{1,Dict0} = beam_dict:atom(Mod, beam_dict:new()),
{0,Dict1} = beam_dict:fname(atom_to_list(Mod) ++ ".erl", Dict0),
+ Dict2 = shared_fun_wrappers(CompilerOpts, Dict1),
NumFuncs = length(Asm0),
{Asm,Attr} = on_load(Asm0, Attr0),
Exp = cerl_sets:from_list(Exp0),
- {Code,Dict2} = assemble_1(Asm, Exp, Dict1, []),
- build_file(Code, Attr, Dict2, NumLabels, NumFuncs, ExtraChunks, CompileInfo, CompilerOpts).
+ {Code,Dict} = assemble_1(Asm, Exp, Dict2, []),
+ build_file(Code, Attr, Dict, NumLabels, NumFuncs,
+ ExtraChunks, CompileInfo, CompilerOpts).
+
+shared_fun_wrappers(Opts, Dict) ->
+ case proplists:get_bool(no_shared_fun_wrappers, Opts) of
+ false ->
+ %% The compiler in OTP 23 depends on the on the loader
+ %% using the new indices in funs and being able to have
+ %% multiple make_fun2 instructions referring to the same
+ %% fun entry. Artificially set the highest opcode for the
+ %% module to ensure that it cannot be loaded in OTP 22
+ %% and earlier.
+ Swap = beam_opcodes:opcode(swap, 2),
+ beam_dict:opcode(Swap, Dict);
+ true ->
+ %% Fun wrappers are not shared for compatibility with a
+ %% previous OTP release.
+ Dict
+ end.
on_load(Fs0, Attr0) ->
case proplists:get_value(on_load, Attr0) of