Age | Commit message (Collapse) | Author |
|
* kostis/beam_validator-minor-fix:
Change a list comprehension to a foreach/2 call
|
|
Partly to avoid unmatched return warnings from dialyzer and in order
to preserve the style of other similar-looking code in that file.
While at it, fix the wording in one comment.
|
|
* 'bjorn/lc-warnings/OTP-11626' (early part):
v3_core: Annotate list comprehensions to help out dialyzer
|
|
* nox/compiler/v3_core-case-arg-opt:
Optimise case arguments in sys_core_fold
Run sys_core_fold twice if any inliner is used
|
|
* bjorn/compiler/optimizations/OTP-11584:
Teach sys_core_fold:eval_case/2 to cope with handwritten Core Erlang
sys_core_fold: Remove a redundant word in a comment
|
|
Starting in e12b7d5331c58b41db06cadfa4af75b78b62a2b1,
sys_core_fold:eval_case/2 will crash on handwritten but legal
Core Erlang programs such as:
case let <Var> = Arg in {'x',Var} of
{x,X} -> X
end
The problem is that the only clause *is* guaranteed to match, but
cerl_clauses:match_list/2 does not understand that; all it can say is
that the clause *may* match. In those circumstances, we will need to
keep the case.
Also make sure that we keep the case if the guard is something else
than 'true'. That is not strictly necessary, because in a legal Core
Erlang program the guard in the last clause in a case must always
evaluate to 'true', so removing the guard test would still leave the
program correct. Keeping the guard, however, will make it somewhat
easier to debug an incorrect Core Erlang program. (The unsafe_case
test case has guard test in the only clause in a case, so we don't
need to write a new test case to test that.)
Reported-by: Anthony Ramine
|
|
|
|
If the argument of a case expression is a let, a seq or a case with two clauses
where the second one is a failing clause; it can be moved outside the case and
further optimisations can be performed.
module 'foo' ['t'/4]
attributes []
't'/4 =
fun (_cor14,Sub0,_cor15,_cor16) ->
let Ssa = call 'erlang':'get' ('foo') in
case let Ssa = {'ssa',_cor14,Sub0,_cor15,_cor16} in
let _rec11 = call 'erlang':'+' (_cor14, 1) in
let _cor4 = call 'erlang':'setelement' (2, Ssa, _rec11) in
{{'tmp',_cor14},_cor4} of
{NewReg,Foo} when 'true' ->
{NewReg,Foo,Ssa}
_cor20 when 'true' ->
primop 'match_failure' ({'case_clause',_cor20})
end
end
==>
module 'foo' ['t'/4]
attributes []
't'/4 =
fun (_cor14,Sub0,_cor15,_cor16) ->
let Ssa = call 'erlang':'get' ('foo') in
let _fol0 = {'ssa',_cor14,Sub0,_cor15,_cor16} in
let _rec11 = call 'erlang':'+' (_cor14, 1) in
let _cor4 = call 'erlang':'setelement' (2, _fol0, _rec11) in
let NewReg = {'tmp',_cor14} in
{NewReg,_cor4,Ssa}
end
|
|
* egil/compiler/maps-fix-sys_core_fold:
compiler: Fix sys_core_fold let optimization
compiler: Add debug listing after sys_core_fold
|
|
* egil/compiler/maps-fix-codegen:
compiler: Fix codegen multiple updates for Maps
erts,compiler: Correct and amend tests for Maps
|
|
Map variable was not covered and faulty optimization could occur.
Ex.
t() ->
M0 = id(#{ "a" => 1 }),
#{ "a" := _ } = M0,
M0#{ "a" := b }.
M0 was lost in let expression optimization.
|
|
|
|
|
|
This fixes an error on multiple updates optimization for map pairs.
The error was introduced with moving to term order in Maps.
This also fixes an error where register life time was lost for values
and could result in erroneuos values being emitted in for map pairs.
Simplified v3_codegen by moving multiple update optimizations to v3_kernel.
|
|
* hsv/using_lists_droplast:
lib/mnesia/test/ - Replace reverse(tl(reverse(L))) with lists:droplast/1
lib/ssh - Replace reverse(tl(reverse(L))) with lists:droplast/1
lib/wx - Replace reverse(tl(reverse(L))) with lists:droplast/1
Use lists:droplast/1 in orber/orber_interceptors.erl
Import and use lists:droplast/1 in v3_core/v3_kernel
OTP-11678
OTP-11677
|
|
* bjorn/compiler/applying-binary-crash/OTP-11672:
beam_bsm: Eliminate emulator crash when a binary is called
beam_validator: Validate the "fun" argument for a call_fun/1 instruction
|
|
* bjorn/compiler/optimizations/OTP-11584:
sys_core_fold: Prevent case expressions from being evaluated twice
sys_core_fold_SUITE: For cleanliness, move id/1 to the end
|
|
We must not do the delayed binary creation optimization if the
code attempts to call the matched out binary. Calling a matchstate
will crash the run-time system.
Reported-by: Loïc Hoguin
|
|
The fun argument for a call_fun/1 instruction was not validated.
|
|
* bjorn/eep37/OTP-11537:
Issue a warning when a named fun is constructed but not used
|
|
In e12b7d5331c58b41db06cadfa4af75b78b62a2b1, a bug was introduced
that would cause case expressions to be evaluated more than once
if there were aliases in the pattern. Example:
X = Y = io:put_chars("some chars"),
{X,Y}
That would be rewritten to code similar to (but in Core Erlang):
X = io:put_chars("some chars"),
X = io:put_chars("some chars"),
{X,Y}
Make sure that we only evalute the expression once by doing a
transformation similar to (but in Core Erlang):
NewVar = io:put_chars("some chars"),
X = NewVar,
Y = NewVar,
{X,Y}
Reported-by: José Valim
Reported-by: Anthony Ramine
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Simplify compiler internals and parsing of core format.
|
|
Simplify compiler internals for kernel passes.
|
|
|
|
|
|
|
|
|
|
|
|
Make map update expressions safe, i.e. (foo())#{ k1 := 1 }
|
|
The instruction get_map_element has a faillabel so you may not
use the instruction within a allocate/deallocate block.
|
|
|
|
|
|
|
|
With the => and := operators for updating maps, this optimization is
no longer valid.
|
|
The syntax is handled upto v3_kernel where it is reduced to
previous behaviour for construction and updates. Meaning,
the ':=' operator is handled exactly as '=>' operator.
|
|
|
|
Update erlang lint and syntax expand for #{ K := V }
|
|
To add a type-testing guard BIF, the following steps are needed:
* The BIF itself is added to bif.tab (note that it should be declared
using "ubif", not "bif"), and its implementation to erl_bif_op.c.
* erl_internal must be modified in 3 places: The type test must be
recognized as guard BIF, as a type test, and it must be auto-imported.
* There must be an instruction that implements the same type test as
the BIF (it will be used in guards). beam_utils:bif_to_test/3 must
be updated to recognize the new guard BIF.
|
|
All pairs in a Map needs to be in strict ascending key order.
|
|
|
|
If a literal key already is present in a Map update the latter should be used.
Warn for previous duplicates in the Map.
|
|
|
|
|
|
Can now handle {list [reg()]} elements in instructions.
|