Age | Commit message (Collapse) | Author |
|
It is not needed because it can be trivially calculated using
gb_trees:size/1.
|
|
|
|
The compiler (sys_core_fold) tries to avoid constructing tuples
in case expressions. The following code:
c(A, B) ->
case {A,B} of
{ok,X} -> X;
{_,_} -> error
end.
will be rewritten so that no tuple is built. If a clause
requires a tuple to be built as in this code:
c(A, B) ->
case {A,B} of
{ok,X} -> X;
V -> V %The tuple will be built here
end.
the tuple will be built in the clause(s) in which it is needed.
If the value returned from the case is not used as in this code:
c(A, B) ->
case {A,B} of
V -> V %Warning: a term is constructed, but never used
end,
ok.
there will be an incorrect warning. Basically, what happens is
that the code is reduced to:
c(A, B) ->
{A,B}, %Warning: a term is constructed, but never used
ok.
and the optimizer sees that the {A,B} tuple can't possibly be used.
Eliminate the warning by adding a 'compiler_generated' annotation
to the tuple.
Reported-by: Kostis Sagonas
|
|
|
|
In the following code:
m(<<Sz:8,_:Sz/binary>>) ->
Sz = wrong.
the Sz variable is supposed to be bound in the function header and the
matching "Sz = wrong" should cause a badarg exception. But what
happens is that the Sz variables seems to be unbound and the matching
succeds and the m/1 function returns 'wrong'.
If the Sz variable is used directly (not matched), it will have
the expected value. Thus the following code:
m(<<Sz:8,_:Sz/binary>>) ->
Sz.
will correctly return the value of Sz that was matched out from
the binary.
Reported-by: Bernard Duggan
|
|
|
|
|
|
|
|
* bjorn/fix-dialyzer-warnings:
v3_kernel_pp: Eliminate dialyzer warning
inet6_tcp_dist: Eliminate dialyzer warning for "tuple fun"
|
|
* bjorn/compiler/refactor-source-options:
compile: Refactor handling of source options (e.g. 'from_core')
|
|
Use conditional compilation instead of a run-time test.
Will also improve the coverage of the code.
|
|
|
|
* jp/dependencies_makefile:
Add dependencies Makefile generation to erlc(1) and compile(3)
Conflicts:
lib/compiler/test/compile_SUITE.erl
OTP-9065
|
|
This is useful when a project is built with Makefiles and erlc(1)
instead of EMakefiles. Tracking dependencies by hand is error-prone and
it becomes painful when using external application headers like EUnit's
one.
A dependencies Makefile will look like this:
module.beam: module.erl \
/usr/local/lib/erlang/lib/eunit-2.1.4/include/eunit.hrl \
header.hrl
When included in the main Makefile, 'module' will be recompiled only
when needed.
GCC offers the same feature and new erlc(1) options are compatible with
it.
More informations at:
http://wiki.github.com/dumbbell/otp/dependencies-makefile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The options for compiling from Core Erlang, BEAM assembler files,
and BEAM files are handled in several places, making it difficult
to change or add more similar options. Refactor the option handling
so that each option only need to be handled in one place.
|
|
* bjorn/compiler/eliminate-warnings:
compiler Makefile: Turn warnings into errors
v3_kernel_pp: Add support for pretty-printing #k_literal{} records
v3_kernel_pp: Eliminate warning
|
|
By accident a previous instance of St is used, which is
harmless in this case, but leads to worse quality of
the generated code.
|
|
We want to ensure that the compiler applications is kept
free of warnings.
|
|
|
|
|
|
Similar to -spec and -type, -export_type should be not be included
as attributes (and therefore loaded) in BEAM files, but only in
the abstract code chunk.
|
|
|
|
* bjorn/fix-compiler-bugs/OTP-8949:
beam_utils: Fix check_liveness/3 for receive loops
beam_utils: Fix liveness analysis for gc_bif instructions
|
|
Sometimes the beam_bool pass wants to know whether an
y register will be killed by the code that follows and
will do (effectively):
beam_utils:is_killed({y,Y}, Code, L)
When asked to calculate the liveness for an y register,
beam_utils:is_killed/3 will loop forever if the code
includes a receive loop.
Since this rarely occurs, fix the problem in the simplest
and most conservative way.
Reported-by: Christopher Williams
|
|
* pan/auto-import-doc-fix/OTP-8848:
Correct description of no_auto_import compiler directive
|
|
When gc_bif instructions occurred outside of a block,
beam_utils:check_liveness/3 did not take into account
that the instruction could do a garbage collection, and
could falsely report that an x register would be killed.
That could cause the beam_dead pass to make the code
unsafe by removing the assignment to an x register that
would subsequently be referenced by the garbage collector.
Reported-by: Christopher Williams
|
|
* ks/strengthen-specs:
lists: Strengthen and modernize specs
syntax_tools: Fix an erroneous type and strengthen some specs
ordsets: Export ordset/1 type and strengthen specs
compiler: Strengthen some specs to shut off dialyzer warnings
|
|
|
|
Moving of allocation instructions upwards in the instruction
stream (in order to enable further optimizations) in beam_block,
is implemented with the assumption that if a register {x,X}
contains a valid term, then all other x register with lower
numbers than X also contain valid terms. That assumption is
true after code generation.
The beam_utils:live_opt/1 optimization, however, may invalidate
that assumption. For instance, if a receive statement exports a
variable that is used, but the return value of the receive statement
is not used, then {x,1} but not {x,0} contains a valid term at the
end of the receive statement. If the receive statement is
followed by
{bif,self,{f,0},[],{x,0}}.
{test_heap,NumberOfWords,2}.
moving the allocation upwards will produce
{test_heap,NumberOfWords,2}.
{bif,self,{f,0},[],{x,0}}.
which will cause the beam_validator pass to scream loudly that
{x,0} is not live at the test_heap instruction.
Fix the problem by doing the optimizations in reverse order.
Reported-by: Jim Engquist
|
|
Silence the Dialyzer warning introduced in commit
7b283aa9507b45f2cd403b061ad92ab059fb71b5.
|
|
* bjorn/compiler-bin-generators/OTP-8864:
core_lint: Enforce that tail segments only occur at the end
Don't generate multiple tail segments in binary matching
Factor out some of the code for binary generators
Add tests for tail segments in binary generators
|
|
|
|
Code such as
foo(A) -> <<A:0>>.
would cause a compiler crash.
|
|
In binary matching, there must only be one "tail segment" (i.e.
a size-less segment of type binary) and it must be last. Thus,
the compiler will reject the following function definition:
foo(<<A/bits,B/bits>>) -> ok.
But code such as the following:
[42 || <<_:8/integer, _/bits>> <= Bits]
will internally (in the Core Erlang format) be translated to a
binary matching pattern containing two tail segments. The compiler
happens to generate correct code anyway (later passes will get
rid of the redundant tail segment), but it is ugly and will
confuse tools such as Dialyzer.
Change the transformation of binary generators (in both list and
binary comprehensions) not to generate add a tail segment if there
already is one.
|
|
In the code for handling binary generators (in list and binary
comprehensions), factor out the code for appending a match-all tail
segment onto a pattern into a separate function. That will only
make the code somewhat simpler, but will facilitate fixing a
bug/misfeture in the next commit.
|
|
|
|
|
|
|
|
|
|
* pan/ms_transform_warnings/OTP-6759:
Add testcases for ms_transform warning and fix scoping
Add warnings for shadowed variables in ms_transform funs
|
|
The code for generating the string table (which is now
only used for bit syntax matching) in a BEAM file is quite
complicated and potentially expensive when compiling modules
with many thousands of clauses doing bit syntax matching.
Simplify and optimize the code using bit syntax and
binary:match/2 instead of the list operations in the
original code.
|
|
* ks/cleanups:
compiler: Fix incorrect types and specs
escript: Add more types to records
debugger: Clean up as suggested by tidier
docbuilder: Clean up as suggested by tidier
Conflicts:
lib/debugger/src/dbg_iload.erl
lib/debugger/src/dbg_ui_trace_win.erl
|