Age | Commit message (Collapse) | Author |
|
Make sure we don't optimize code such as:
is_tuple Fail Src
test_arity Fail Src Arity
get_tuple_element Src Pos Dst
is_map Fail Src
If we would reorder the instructions like this:
is_tuple Fail Src
test_arity Fail Src Arity
is_map Fail Src
get_tuple_element Src Pos Dst
beam_validator would complain that the type for Src is a map
instead of a tuple. Since the code has problems to begin with,
there is no need to do the optimization.
|
|
When calculating the sets of registers that must be killed or
unused, registers set in a {protected,_,_,_} block were not
considered. That could result in a crash in the
assertion in beam_utils:live_opt_block/4.
|
|
a3ec2644f5 attempted to teach v3_core not to generate code with
unbound variables. The approach taken in that commit is to
discard all expressions following a badmatch. That does not
work if the badmatch is nested:
{[V] = [] = foo,V},
V
That would be rewritten to:
{error({badmatch,foo})},
V
where V is unbound.
If we were to follow the same approach, the tuple construction
code would have to look out for a badmatch. As would list construction,
begin...end, and so on.
Therefore, as it is impractical to discard all expressions that
follow a badmatch, the only other solution is to ensure that the
variables that the pattern binds will somehow be bound. That can
be arranged by rewriting the pattern to a pattern that binds the
same variables. Thus:
error({badmatch,foo}),
E = foo,
case E of
{[V],[]} ->
V;
Other ->
error({badmatch,Other}
end
|
|
The following code:
simple() ->
case try 0 after [] end of
0 -> college;
1 -> 0
end.
would crash the compiler like this:
crash reason: {case_clause,
{'EXIT',
{function_clause,
[{beam_type,simplify_select_val_int,
[{select,select_val,
{x,0},
{f,7},
[{integer,1},{f,9},{integer,0},{f,8}]},
0],
[{file,"beam_type.erl"},{line,169}]},
{beam_type,simplify_basic_1,3,
[{file,"beam_type.erl"},{line,155}]},
{beam_type,opt,3,[{file,"beam_type.erl"},{line,57}]},
{beam_type,function,1,[{file,"beam_type.erl"},{line,36}]},
{beam_type,'-module/2-lc$^0/1-0-',1,
[{file,"beam_type.erl"},{line,30}]},
{beam_type,module,2,[{file,"beam_type.erl"},{line,30}]},
{compile,'-select_passes/2-anonymous-2-',2,
[{file,"compile.erl"},{line,521}]},
{compile,'-internal_comp/4-anonymous-1-',2,
[{file,"compile.erl"},{line,306}]}]}}}
The root cause is that the type representation is not well-defined.
Integers could be represented in three different ways:
integer
{integer,{1,10}}
{integer,0}
However, only the first two forms were handled.
To avoid similar problems in the future:
* Make the type representation stricter. Make sure that integers are
only represented as 'integer' or {integer,{Min,Max}}.
* Call verify_type/1 whenever a new type is added (not only when
merging types) to ensure that only the supported types are added
to the type database).
(ERL-150)
|
|
We must be careful how we treat the type info for the result of:
setelement(Index, Tuple, NewValue)
If Tuple had type information, the result of setelement/3 (in x(0))
would be assigned the same type information. But that is not safe
for:
setelement(1, Tuple, NewValue)
since the type for the first element will be changed.
Therefore, we must take care to remove the type information for
the first element of the tuple if might have been modified by
setelement/3.
|
|
As a preparation for better optimizations in beam_type, a list
literal must be accepted as a 'cons'.
|
|
As a preparation for upcoming better optimizations in beam_type,
we will need to keep better track of tuple literals so that
beam_validator will not falsely reject safe code.
|
|
* mururu/eunit/debugvalall/PR-1024/OTP-13612:
eunit: Add ?debugValAll macro
|
|
* egil/odbc/fix-unmatched_return/OTP-13595:
odbc: Fix unmatched return warnings
|
|
|
|
|
|
|
|
* egil/xmerl/fix-unmatched_return/OTP-13595:
xmerl: Fix unmatched return warnings
|
|
* egil/percept/fix-unmatched_return/OTP-13595:
egd: Fix unmatched return warnings
egd: Small code style refactoring
percept: Fix unmatched return warnings
percept: Small code style refactoring
|
|
* dgud/tools/emacs/PR-1054/OTP-13610:
Fix line-initial commas' indentation in type specs
|
|
Inside type specs, line-initial commas shall align with open curly
braces. This also applies to record definitions with type specs for
the fields.
For example:
-type foo() :: { a :: integer()
, b :: integer()
}.
For type specs for functions, the commas shall align with the opening
parenthese. So do a closing parenthese when put on a new line.
For example:
-spec foo( X :: integer()
, Y :: integer()
) -> integer().
This does not affect coding styles that don't put commas at the
beginning of lines.
|
|
* hasse/erl_docgen/datatype_anchors/OTP-13600/ERL-141:
kernel: Remove no longer needed anchors in documentation
stdlib: Remove no longer needed anchors in documentation
erts: Remove no longer needed anchors in documentation
erl_docgen: Add anchors to datatypes without name attribute
|
|
* bjorn/handle-bad-path/ERL-142:
Tolerate bad directories in the code path
|
|
|
|
|
|
Second merge of this branch to master
with some more docs
|
|
|
|
* dgud/wx/cmd-queue-bug:
Fix compilation warning
wx: Fix generated defines in gl.hrl
wx: Fix driver command queue
|
|
* jrobhoward/os_mon/fix-freebsd_get_os_wordsize/PR-1039/OTP-13601:
Fix memsup:get_os_wordsize() on 64-bit Linux PPC
os_mon: Test wordsize of memsup:get_os_wordsize/0
Fix memsup:get_os_wordsize() on 64-bit FreeBSD
|
|
|
|
|
|
* origin/ingela/public_key/tests:
public_key: Remove test_server config macros and unsed hooks
|
|
|
|
|
|
|
|
|
|
db_html.xsl generates anchors for data types referred to by strings
(instead of 'name' attributes). For example:
<datatype>
<name>edge()</name>
</datatype>
generates:
<p><a name="type-edge"><span class="bold_code">edge()</span></a><br></p>
|
|
* egil/egd/improve-line/OTP-13598:
egd: Save images during tests
egd: Use anti-aliasing for lines
egd: Add more line tests
egd: Add line thickness algorithm for lines
egd: Use maps to map height to line spans
egd: Refactor precompile objects
egd: Refactor object_on_line
egd: Refactor primitives style
egd: Improve span calculation
|
|
* ingela/inets/dialyzer:
inets: httpd_util:split does not return {error, Reason}
|
|
* hairyhum/eldap/ignore_tcp_errors_at_close/PR-1048/OTP-13590:
indentation
Ignore tcp errors during close request to eldap
|
|
|
|
Fix return value handling that was missed when code was refactored to
use re-module.
|
|
A bad directory in the path would prevent the run-time system
from starting:
$ echo >foobar
$ erl -pa foobar
{"init terminating in do_boot",{load_failed,[supervisor,kernel,gen_server,file_io_server,filename,file,erl_parse,error_logger,code_server,erl_lint,proc_lib,code,application_controller,application_master,gen_event,application,error_handler,lists,heart,gen,file_server,ets,erl_eval]}}
Crash dump is being written to: erl_crash.dump...done
init terminating in do_boot ()
The reason is that when attempting to read each of the BEAM files,
there would be an 'enotdir' error which
erl_prim_load:get_modules/2,3 assumed was a fatal error.
Update erl_prim_load:get_modules/2,3 to ignore any error and try
the next directory in the path.
Reported-by: http://bugs.erlang.org/browse/ERL-142
Reported-by: Michael Truog
|
|
|
|
Simple test against erlang:system_info({wordsize,external}).
|
|
* mururu/os_mon/cpu-sup-osx/PR-1049/OTP-13597:
os_mon: Implement cpu_sup:util/0,1 on OSX
|
|
* egil/common_test/fix-doc-lint:
common_test: Fix doc tags of ct_netconfc
|
|
* ingela/ssl/cipher-suites-refactor:
ssl: Refactor to make code easier to understand
|
|
|
|
* kostis/dialyzer/opaque_type/OTP-13586/PR-1047:
Declare the erl_types:var_table() type as opaque
|
|
* bjorn/compiler/beam_bool/ERL-143:
Eliminate crash in beam_bool
Add beam_bool_SUITE
Add missing test cases in andor_SUITE and beam_block_SUITE
|
|
* bjorn/compiler/misc:
beam_utils: Correct break in conventions for split_even/1 and join_even/1
beam_utils: Remove clause checking for illegal set/4 instruction
beam_utils: Simplify the return value for check_liveness/3
beam_utils: Remove unused code
beam_utils: Let code_at/2 fail if the label does not exist
beam_utils: Remove unused handling of try/3 in live_opt/4
beam_utils: Correct translation of BIFs to tests
core_pp: Remove uncovered clause in is_simple_term/1
core_pp: Crash on unhandled Core Erlang forms
core_pp: Remove unused clauses in unindent/3 to improve coverage
core_pp: Remove useless try...catch
core_pp: Simplify printing of map literals
compile_SUITE: Cover numeric variable names in core_pp
compile_SUITE: Eliminate clones when re-compiling test suites
test_lib: Add is_cloned_mod/1
trycatch_SUITE: Cover the only uncovered line in sys_core_fold
test_lib: Correct calculation of number of processes
|
|
beam_bool would crash when attempting to optimize BEAM code similar
to this code:
bif '=:=' Reg1 SomeValue => y(0)
bif '=:=' Reg2 {atom,true} => x(2)
bif '=:=' Reg3 {atom,true} => x(3)
bif 'or' x(2) x(3) => x(2)
is_eq_exact Fail x(2) {atom,true}
The problem is that the first instruction that assigns a value to a Y
register. beam_bool:ssa_assign/2 will not accept a Y register
argument.
We could change ssa_assign/2 to accept a Y register, but that would
only cause the entire optimization to be rejected later because the Y
register is alive in the code that follows. Therefore, a better
solution is to modify extend_block/3 so that the instruction that
assign to Y registers are not added to the block. That is, the
optimizer will only operate on the following code:
bif '=:=' Reg2 {atom,true} => x(2)
bif '=:=' Reg3 {atom,true} => x(3)
bif 'or' x(2) x(3) => x(2)
is_eq_exact Fail x(2) {atom,true}
Usually the optimization will succeed, rewriting the four instructions
to a select_val instruction.
Assembly code such as the above can be produced by code similar to:
Y = Something == SomethingElse,
case Y of
Condition; OtherCondition ->
. . .
end,
. . .,
Y.
Reported-by: http://bugs.erlang.org/browse/ERL-143
Reported-by: José Valim
|
|
It's time that we have a dedicated test suite for beam_bool.
|
|
Two test cases were not actually run. Even if their main purpose is to
ensure that the compiler doesn't crash, we always try to also run the
test case (when practial) to also ensure that the generated code is
correct.
|