summaryrefslogtreecommitdiff
path: root/lib/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/doc/src/notes.xml40
-rw-r--r--lib/compiler/src/beam_ssa_codegen.erl29
-rw-r--r--lib/compiler/src/beam_ssa_opt.erl2
-rw-r--r--lib/compiler/src/beam_ssa_pre_codegen.erl4
-rw-r--r--lib/compiler/src/beam_ssa_type.erl6
-rw-r--r--lib/compiler/src/beam_types.erl13
-rw-r--r--lib/compiler/src/beam_validator.erl6
-rw-r--r--lib/compiler/src/v3_kernel.erl4
-rw-r--r--lib/compiler/vsn.mk2
9 files changed, 66 insertions, 40 deletions
diff --git a/lib/compiler/doc/src/notes.xml b/lib/compiler/doc/src/notes.xml
index a2510f1426..af671ff7ba 100644
--- a/lib/compiler/doc/src/notes.xml
+++ b/lib/compiler/doc/src/notes.xml
@@ -32,6 +32,46 @@
<p>This document describes the changes made to the Compiler
application.</p>
+<section><title>Compiler 8.2.4</title>
+
+ <section><title>Fixed Bugs and Malfunctions</title>
+ <list>
+ <item>
+ <p>Fixed a bug that would cause the compiler to hang.</p>
+ <p>
+ Own Id: OTP-18378 Aux Id: GH-6604 </p>
+ </item>
+ <item>
+ <p>Fixed a crash when compiling code that contained
+ <c>maybe</c> expressions.</p>
+ <p>
+ Own Id: OTP-18381 Aux Id: GH-6601 </p>
+ </item>
+ <item>
+ <p>Constructing a binary with an explicit size of
+ <c>all</c> for a binary segment would crash the
+ compiler.</p>
+ <p>
+ Own Id: OTP-18407 Aux Id: GH-6707 </p>
+ </item>
+ <item>
+ <p>The compiler would generate incorrect code for the
+ following type of expression:</p>
+ <p><c>Pattern = BoundVar1 = . . . = BoundVarN =
+ Expression</c></p>
+ <p>An exception should be raised if any of the bound
+ variables have different values than <c>Expression</c>.
+ The compiler would generate code that would cause the
+ bound variables to be bound to the value of
+ <c>Expression</c>whether the value matched or not.</p>
+ <p>
+ Own Id: OTP-18470 Aux Id: GH-6873, PR-6877 </p>
+ </item>
+ </list>
+ </section>
+
+</section>
+
<section><title>Compiler 8.2.3</title>
<section><title>Fixed Bugs and Malfunctions</title>
diff --git a/lib/compiler/src/beam_ssa_codegen.erl b/lib/compiler/src/beam_ssa_codegen.erl
index 1e1374c484..08b0e5d856 100644
--- a/lib/compiler/src/beam_ssa_codegen.erl
+++ b/lib/compiler/src/beam_ssa_codegen.erl
@@ -157,13 +157,11 @@ assert_exception_block(Blocks) ->
add_parameter_annos([{label, _}=Entry | Body], Anno) ->
ParamTypes = maps:get(parameter_info, Anno, #{}),
- Annos = maps:fold(
- fun(K, V, Acc) when is_map_key(K, ParamTypes) ->
- Info = map_get(K, ParamTypes),
- [{'%', {var_info, V, Info}} | Acc];
- (_K, _V, Acc) ->
- Acc
- end, [], maps:get(registers, Anno)),
+ Annos = [begin
+ Info = map_get(K, ParamTypes),
+ {'%', {var_info, V, Info}}
+ end || K := V <- map_get(registers, Anno),
+ is_map_key(K, ParamTypes)],
[Entry | sort(Annos)] ++ Body.
@@ -515,10 +513,8 @@ prefer_xregs_prune(#cg_set{anno=#{clobbers:=true}}, _, _) ->
#{};
prefer_xregs_prune(#cg_set{dst=Dst}, Copies, St) ->
DstReg = beam_arg(Dst, St),
- F = fun(_, Alias) ->
- beam_arg(Alias, St) =/= DstReg
- end,
- maps:filter(F, Copies).
+ #{V => Alias || V := Alias <- Copies,
+ beam_arg(Alias, St) =/= DstReg}.
%% prefer_xregs_call(Instruction, Copies, St) -> Instruction.
%% Given a 'call' or 'old_make_fun' instruction rewrite the arguments
@@ -548,12 +544,11 @@ do_prefer_xreg(#b_var{}=A, Copies, St) ->
do_prefer_xreg(A, _, _) -> A.
merge_copies(Copies0, Copies1) when map_size(Copies0) =< map_size(Copies1) ->
- maps:filter(fun(K, V) ->
- case Copies1 of
- #{K:=V} -> true;
- #{} -> false
- end
- end, Copies0);
+ #{K => V || K := V <- Copies0,
+ case Copies1 of
+ #{K := V} -> true;
+ #{} -> false
+ end};
merge_copies(Copies0, Copies1) ->
merge_copies(Copies1, Copies0).
diff --git a/lib/compiler/src/beam_ssa_opt.erl b/lib/compiler/src/beam_ssa_opt.erl
index 851573a82b..13e4114319 100644
--- a/lib/compiler/src/beam_ssa_opt.erl
+++ b/lib/compiler/src/beam_ssa_opt.erl
@@ -990,7 +990,7 @@ cse_successors([#b_set{op={succeeded,_},args=[Src]},Bif|_], Blk, EsSucc, M0) ->
%% We must remove the substitution for Src from the failure branch.
#b_blk{last=#b_br{succ=Succ,fail=Fail}} = Blk,
M = cse_successors_1([Succ], EsSucc, M0),
- EsFail = maps:filter(fun(_, Val) -> Val =/= Src end, EsSucc),
+ EsFail = #{Var => Val || Var := Val <- EsSucc, Val =/= Src},
cse_successors_1([Fail], EsFail, M);
false ->
%% There can't be any replacement for Src in EsSucc. No need for
diff --git a/lib/compiler/src/beam_ssa_pre_codegen.erl b/lib/compiler/src/beam_ssa_pre_codegen.erl
index e1b5f59738..e3406f12de 100644
--- a/lib/compiler/src/beam_ssa_pre_codegen.erl
+++ b/lib/compiler/src/beam_ssa_pre_codegen.erl
@@ -2993,8 +2993,8 @@ init_free(Res) ->
#{x:=Xs0} = Free1 = maps:from_list(Free0),
Xs = init_xregs(Xs0),
Free = Free1#{x:=Xs},
- Next = maps:fold(fun(K, V, A) -> [{{next,K},length(V)}|A] end, [], Free),
- maps:merge(Free, maps:from_list(Next)).
+ Next = #{{next,K} => length(V) || K := V <- Free},
+ maps:merge(Free, Next).
init_free_1([{_,{prefer,{x,_}=Reg}}|Res]) ->
[{x,Reg}|init_free_1(Res)];
diff --git a/lib/compiler/src/beam_ssa_type.erl b/lib/compiler/src/beam_ssa_type.erl
index 5419090ddc..725eb9ee29 100644
--- a/lib/compiler/src/beam_ssa_type.erl
+++ b/lib/compiler/src/beam_ssa_type.erl
@@ -378,11 +378,7 @@ init_sig_st(StMap, FuncDb) ->
wl=wl_defer_list(Roots, wl_new()) }.
init_sig_roots(FuncDb) ->
- maps:fold(fun(Id, #func_info{exported=true}, Acc) ->
- [Id | Acc];
- (_, _, Acc) ->
- Acc
- end, [], FuncDb).
+ [Id || Id := #func_info{exported=true} <- FuncDb].
init_sig_args([Root | Roots], StMap, Acc) ->
#opt_st{args=Args0} = map_get(Root, StMap),
diff --git a/lib/compiler/src/beam_types.erl b/lib/compiler/src/beam_types.erl
index 35e164d707..cf81c34670 100644
--- a/lib/compiler/src/beam_types.erl
+++ b/lib/compiler/src/beam_types.erl
@@ -1137,7 +1137,7 @@ lub_bs_matchable(UnitA, UnitB) ->
lub_tuple_elements(MinSize, EsA, EsB) ->
Es0 = lub_elements(EsA, EsB),
- maps:filter(fun(Index, _Type) -> Index =< MinSize end, Es0).
+ #{Index => Type || Index := Type <- Es0, Index =< MinSize}.
lub_elements(Es1, Es2) ->
Keys = if
@@ -1368,12 +1368,11 @@ verified_normal_type(#t_tuple{size=Size,elements=Es}=T) ->
%% union). 'any' is prohibited since it's implicit and should never be
%% present in the map, and a 'none' element ought to have reduced the
%% entire tuple to 'none'.
- maps:fold(fun(Index, Element, _) when is_integer(Index),
- 1 =< Index, Index =< Size,
- Index =< ?TUPLE_ELEMENT_LIMIT,
- Element =/= any, Element =/= none ->
- verified_type(Element)
- end, [], Es),
+ _ = [verified_type(Element) ||
+ Index := Element <- Es,
+ is_integer(Index), 1 =< Index, Index =< Size,
+ Index =< ?TUPLE_ELEMENT_LIMIT,
+ Element =/= any, Element =/= none],
T.
%%%
diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl
index ee5f49d03a..e4a5965dd1 100644
--- a/lib/compiler/src/beam_validator.erl
+++ b/lib/compiler/src/beam_validator.erl
@@ -2073,7 +2073,7 @@ init_stack(Tag, Y, Vst) ->
init_stack(Tag, Y - 1, create_tag(Tag, allocate, [], {y,Y}, Vst)).
trim_stack(From, To, Top, #st{ys=Ys0}=St) when From =:= Top ->
- Ys = maps:filter(fun({y,Y}, _) -> Y < To end, Ys0),
+ Ys = #{Reg => Val || {y,Y}=Reg := Val <- Ys0, Y < To},
St#st{numy=To,ys=Ys};
trim_stack(From, To, Top, St0) ->
Src = {y, From},
@@ -2128,9 +2128,7 @@ prune_x_regs(Live, #vst{current=St0}=Vst) when is_integer(Live) ->
({y,_}) ->
true
end, Fragile0),
- Xs = maps:filter(fun({x,X}, _) ->
- X < Live
- end, Xs0),
+ Xs = #{Reg => Val || {x,X}=Reg := Val <- Xs0, X < Live},
St = St0#st{fragile=Fragile,xs=Xs},
Vst#vst{current=St}.
diff --git a/lib/compiler/src/v3_kernel.erl b/lib/compiler/src/v3_kernel.erl
index 3443f43959..809924c7f3 100644
--- a/lib/compiler/src/v3_kernel.erl
+++ b/lib/compiler/src/v3_kernel.erl
@@ -1565,9 +1565,7 @@ group_value(_, Us, Cs) ->
Map = group_values(Cs, #{}),
%% We must sort the grouped values to ensure consistent
%% order from compilation to compilation.
- sort(maps:fold(fun (_, Vcs, Css) ->
- [{Us,reverse(Vcs)}|Css]
- end, [], Map)).
+ sort([{Us,reverse(Vcs)} || _ := Vcs <- Map]).
group_values([C|Cs], Acc) ->
Val = clause_val(C),
diff --git a/lib/compiler/vsn.mk b/lib/compiler/vsn.mk
index 5b5306e4d3..0a39fcf419 100644
--- a/lib/compiler/vsn.mk
+++ b/lib/compiler/vsn.mk
@@ -1 +1 @@
-COMPILER_VSN = 8.2.3
+COMPILER_VSN = 8.2.4