Age | Commit message (Collapse) | Author |
|
The inlining code for inline_list_funcs silenced the function_clause
error that should occur when calling lists:map(3.5, []).
|
|
The function_clause errors produced by inline_list_funcs should properly
be annotated with their function names to avoid kernel_v3 making them
into case_clauses errors. See v3_kernel:translate_match_fail_1/4.
|
|
|
|
|
|
* bjorn/compiler/illegal-size/OTP-10197:
compiler: Warn if the size of a binary segment is invalid
|
|
Column numbers was merged without understanding all the whole
story. See mail on erlang-patches for details.
This reverts commit df8e67e203b83f95d1e098fec88ad5d0ad840069, reversing
changes made to 0c9d90f314f364e5b1301ec89d762baabc57c7aa.
|
|
The compiler would silently accept and Dialyzer would crash on
code like:
<<X:(2.5)>>
It is never acceptable for Dialyzer to crash. The compiler should
at least generate a warning for such code. It is tempting to let
the compiler generate an error, but that would mean that code like:
Sz = 42.0,
<<X:Sz>>.
would be possible to compile with optimizations disabled, but not
with optimizations enabled.
Dialyzer crashes because it calls cerl:bitstr_bitsize/1, which
crashes if the type of size for the segment is invalid. The easiest
way to avoid that crash is to extend the sanity checks in v3_core
to also include the size field of binary segments. That will cause
the compiler to issue a warning and to replace the bad binary
construction with a call to erlang:error/1. (It also means that
Dialyzer will not issue a warning for bad size fields.)
|
|
* bjorn/compiler/minor-fixes/OTP-10185:
erl_lint: Add a deprecated warning for literal tuple funs
beam_utils:live_opt/1: Correct handling of try_case_end/1
Correct guard_SUITE_tuple_size.S
beam_type: Print the offending function if this pass crashes
beam_validator: Validate the size operand in bs_init_bits and bs_init2
|
|
The number of live registers in the gc_bif instructions was wrong.
It was not noticed because the beam_type pass silently corrected it.
|
|
|
|
* nox/compile-column-numbers:
Fix messages ordering with column numbers
Fix type compile:err_info/0
Test column number reporting in error_SUITE
Fix printing of errors with column numbers
Create a new "column" option in compile
Allow setting of initial position in epp
Export type erl_scan:location/0
|
|
If a process trap exits, calling the compiler would leave an EXIT
message in the message queue of the calling process because the
compiler spawns a temporary work process. Eliminate the EXIT process
by monitoring the temporary process instead of linking to it.
Reported-by: Jeremy Heater
|
|
Correct the forms_2 test case introduced in 2d785c07fbf9f533bf so
that it will work on Windows. As originally written, the test case
assumed that filename:absname("/foo/bar") would return "/foo/bar",
which is not true on Windows (typically, the result will be
"c:/foo/bar").
While at it, clean up indentation, the overlong line, and comments.
|
|
* jv/forms-source:
Allow the source to be set when compiling forms
OTP-10150
|
|
Because of a copy-and-paste error in erlc.c, the -MP flag had the same
effect as -MG. As a workaround, you had to pass +makedep_phony to enable
the MP option. This patch makes -MP work as intended.
|
|
OTP-10106
OTP-10107
|
|
|
|
This commit adds a source option to compile:forms() that
sets the source value returned by module_info(compile).
|
|
|
|
* bjorn/compiler/coverage-and-minor-fixes/OTP-9982:
v3_life: Use common code for guards and bodies
v3_core: Don't put negative line numbers in annotations
v3_kernel: Dig out the line number only when generating a warning
v3_kernel: Clean up handling of guards
v3_kernel: Introduce is_in_guard/1
v3_kernel: Removed unreached clause for #k_bin_int{} in sub_size_var/1
v3_kernel: Remove unreached handling of #k_bin_int{} in arg_con/1
v3_codegen: Eliminate the special case of 'put' without destination
v3_kernel: Don't attempt to share identical literals
v3_kernel: Handle sequences in guards
v3_kernel: Remove clauses that are never executed in arg_val/1
v3_kernel.hrl: Remove unused record #k_string{}
v3_kernel.erl: Remove unused define of EXPENSIVE_BINARY_LIMIT
sys_core_fold: Refactor previous_ctx_to_binary/2 to cover it completely
sys_core_fold: Fix opt_guard_try/1
sys_core_fold: Simplify opt_bool_not() to cover it completely
sys_core_fold: Remove duplicate optimization
|
|
* ks/compile_info-fix:
compiler: Fix discrepancy in compile_info
OTP-9917
|
|
The BEAM disassembler used the atom 'none' to signify the absence
of a compile_info chunk in a .beam file. This clashes with the type
declaration of the compile_info field of a #beam_file{} record as
containing a list. Use [] to signify the absence of this chunk.
This simplifies the code and avoids a dialyzer warning.
For fixing a similar problem and for consistency, changed also the
return type of the attributes field of the #beam_file{} record.
This required a change in the beam_disasm test suite.
|
|
The inliner was ignorant of on_load functions and would discard them
(unless they were exported or referenced).
Noticed-by: Yiannis Tsiouris <[email protected]>
|
|
Compiling the same source code with the same options may not produce
the same BEAM file because the compilation time is included in the
"CInf" chunk.
|
|
In the following code excerpt, the instruction marked below was
incorrectly removed:
.
.
.
{'try',{y,2},{f,TryCaseLabel}}.
{bif,get,{f,0},[{x,0}],{x,0}}.
{move,{x,1},{y,0}}.
{move,{x,3},{y,1}}. <======= Incorrectly removed
{jump,{f,TryEndLabel}}.
{label,TryEndLabel}.
{try_end,{y,2}}.
{deallocate,3}.
return.
{label,TryCaseLabel}.
{try_case,{y,2}}.
.
.
.
beam_utils indicated that {y,1} was not used at TryEndLabel,
which by itself is correct. But it is still not safe to remove
the instruction, because {y,1} might be used at TryCaseLabel
if an exception occurs.
Noticed-by: Eric Merritt
|
|
A guard with a sequence will cause a crash in v3_codegen. Currently,
it seems that a sequence in a guard will never happen when compiling
from Erlang code, but there are several reasons to fix this problem
anyway:
* There are other compilers that generate Core Erlang code.
* Changes to sys_core_fold (perhaps additional optimizations) may
cause sequences to be generated in guards.
* A previously uncovered line in sys_core_fold:opt_guard_try/1 will
now be covered.
|
|
opt_guard_try/1 assumed that it was only operating on guards, and
implicitly assumed that any function call was to BIFs without
any side effects.
|
|
|
|
Modules would not get excluded. While at it, no longer exclude
sys_pre_attributes since we will want to test it.
|
|
|
|
|
|
|
|
Also correct the comment in bsm_ensure_no_partition_2/5, and while at
it correct typos in the comment for bsm_nonempty/2.
|
|
|
|
|
|
We need to write a test case in Core Erlang in order to cover
make_effect_seq/2, since v3_core does not generate "deep" Core Erlang
code.
|
|
|
|
On my Mac Pro with 8 cores, this change make self_compile/1 more
than twice as fast, and self_compile_old_inliner/1 more than 4 times
faster.
|
|
In the self compilation test cases, the compiler compiles itself
and runs the newly compiled version on a slave node. Having the
cover server starting on the slave node defeats the purpose of
the test, since it will load the SAME cover-compiled code on the
slave node. (It will also be slower, but will not improve coverage
since it compiles the same source files again.)
Use a shielded node to prevent the cover server from getting
started on the slave node.
|
|
We probably don't gain anything by using more processes than available
schedulers. Also, if 'cover' is being run, using more than one process
may make it slower, so we will be very conservative and use only one
process in that case.
|
|
This test suite has been superseded by other test suites (e.g.
guard_SUITE). Removing it does not decrease the coverage.
|
|
In order to save space, rewrite suitable calls to erlang:error/{1,2}
to special BEAM instructions.
This code is probably longer than the code taken out of v3_life and
v3_codegen in the previous commit, but it is much easier to
understand and maintain since the BEAM assembler format is better
understood than the v3_life format.
|
|
In the v3_life pass, it is assumed that a 'match_fail' primop
only occur at the top-level and at the end of a function.
But this code:
do_split_cases(A) ->
case A of
x ->
Z = dummy1;
_ ->
Z = dummy2,
a=b
end,
Z.
will be optimized by sys_core_fold to the following code:
'split_cases'/1 =
fun (_cor0) ->
let <_cor7,Z> =
case _cor0 of
<'x'> when 'true' ->
< 'dummy1','dummy1' >
<_cor6> when 'true' ->
%% Here follows a 'match_fail' primop inside
%% multiple return values:
< primop 'match_fail'({'badmatch','b'}),'dummy2' >
end
in
Z
moving the 'match_fail' primop into a "values" construction.
In the future, we would like to get rid of the v3_life pass (it is
there for historical reasons), so in the mean-time we prefer to not
add more code to it by generalizing the handling of 'match_fail'.
Since the 'match_fail' primop can be simulated by erlang:error/{1,2},
the simplest solution is to translate 'match_fail' to a call to
erlang:error/{1,2} in v3_kernel and remove the handling of
'match_fail' in v3_life and v3_codegen.
It is tempting to get rid of 'match_fail' also in the Core Erlang
format, but there are two issues:
- Removing the support for 'match_fail' completely may break tools
that generate Core Erlang code. We should not do that in a minor
release.
- There is no easy way to generate a 'function_clause' exception
that will remain correct if it will be inlined into another
function. (Calling "erlang:error(function_clause, Args)" is
fine only if it is not inlined into another function.) A good
solution probably involves introducing new instructions, which
is better done in a major release.
Noticed-by: Håkan Matsson
Minimized-test-case-by: Erik Søe Sørensen
|
|
|
|
Compilation would fail with an error message similar to:
comma_splitter: function split_at_comma/2+32:
Internal consistency check failed - please report this bug.
Instruction: {put,{x,0}}
Error: {match_context,{x,0}}:
Noticed-by: René Kijewski
|
|
* bjorn/compiler/options/OTP-9752:
filename documentation: Recommend against using filename:find_src/1,2
Teach filename:find_src/1,2 to handle slim or stripped BEAM files
filename: Eliminate failing call to Mod:module_info(source_file)
filename.erl:filter_options/1: Remove handling of dead options
compiler: Don't include {cwd,_} in module_info(compile)
compiler: Don't include source code options in module_info(compile)
hipe: Teach hipe to handle slim or stripped BEAM files
|
|
As far as I know, the purpose of the compiler options included in
Mod:module_info(compile) has never been documented.
An educated guess is that they are there in case you want to
re-compile the module with the same options, and also to aid in
debugging when you need to know how a module was compiled.
In neither case is there any need to include options given in the
source itself in options included in Mod:module_info(compile).
Including those options will only waste memory.
Therefore, only include in the BEAM file the options that were
given to compile:file/2.
|
|
|
|
Starting in ff432e262e65243cbc983fcb002527f8fae8c78b, sys_pre_expand
passes external funs through to the downstream passes. It used to
translate external funs to a call to erlang:make_fun/3. Therefore, we
will now need to handle external funs in sys_expand_pmod.
Noticed-by: Stavros Aronis
|
|
Currently, the external fun syntax "fun M:F/A" only supports
literals. That is, "fun lists:reverse/1" is allowed but not
"fun M:F/A".
In many real-life situations, some or all of M, F, A are
not known until run-time, and one is forced to either use
the undocumented erlang:make_fun/3 BIF or to use a
"tuple fun" (which is deprecated).
EEP-23 suggests that the parser (erl_parse) should immediately
transform "fun M:F/A" to "erlang:make_fun(M, F, A)". We have
not followed that approach in this implementation, because we
want the abstract code to mirror the source code as closely
as possible, and we also consider erlang:make_fun/3 to
be an implementation detail that we might want to remove in
the future.
Instead, we will change the abstract format for "fun M:F/A" (in a way
that is not backwards compatible), and while we are at it, we will
move the translation from "fun M:F/A" to "erlang:make_fun(M, F, A)"
from sys_pre_expand down to the v3_core pass. We will also update
the debugger and xref to use the new format.
We did consider making the abstract format backward compatible if
no variables were used in the fun, but decided against it. Keeping
it backward compatible would mean that there would be different
abstract formats for the no-variable and variable case, and tools
would have to handle both formats, probably forever.
Reference: http://www.erlang.org/eeps/eep-0023.html
|