<feed xmlns='http://www.w3.org/2005/Atom'>
<title>otp.git/lib/compiler/src, branch OTP-19.3.6.2</title>
<subtitle>Mirror of Erlang/OTP repository.
</subtitle>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/'/>
<entry>
<title>compiler: Do not spawn process when dialyzing</title>
<updated>2017-01-11T08:34:58+00:00</updated>
<author>
<name>Hans Bolinder</name>
<email>hasse@erlang.org</email>
</author>
<published>2016-12-15T08:47:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=657760e18087b0cdbaecc5e96e46f6f66bc9497a'/>
<id>657760e18087b0cdbaecc5e96e46f6f66bc9497a</id>
<content type='text'>
Memory consumption is reduced during the compilation phase by keeping
the Core parse tree shared. In particular the file annotation takes a
lot of memory when not shared.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Memory consumption is reduced during the compilation phase by keeping
the Core parse tree shared. In particular the file annotation takes a
lot of memory when not shared.
</pre>
</div>
</content>
</entry>
<entry>
<title>Update copyright-year</title>
<updated>2016-12-07T12:15:31+00:00</updated>
<author>
<name>Erlang/OTP</name>
<email>otp@erlang.org</email>
</author>
<published>2016-12-07T12:15:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=3eddb0f762de248d3230b38bc9d478bfbc8e7331'/>
<id>3eddb0f762de248d3230b38bc9d478bfbc8e7331</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Suppress warnings from v3_kernel when inlining is turned on</title>
<updated>2016-11-18T09:52:33+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2016-11-17T15:21:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=d8afbc245f28c37c2417c86c9a2d9d27266fe37f'/>
<id>d8afbc245f28c37c2417c86c9a2d9d27266fe37f</id>
<content type='text'>
v3_kernel may produce unwanted and confusing warnings for code that
has been inlined with the new inliner (cerl_inline).  Consider this
code:

-compile(inline).

compute1(X) -&gt;
    add(X, 0).

compute2(X, Y) -&gt;
    add(X, Y).

add(1, 0) -&gt;
    1;
add(1, Y) -&gt;       %% "this clause cannot match..."
    1 + Y;
add(X, Y) -&gt;
    X + Y.

v3_kernel warns because add/2 has been inlined into compute1/1 and only
the first clause in add/2 will match. But the other clauses are needed
when add/2 is inlined into compute2/2, so the user cannot do anything
to eliminate the warning (short of manually inlining add/2, defeating the
purpose of the 'inline' option).

The warning would be reasonable if compute2/2 didn't exist, but it would
be too complicated for the compiler to figure whether a warning make
sense or not.

Therefore, suppress all warnings generated by v3_kernel if cerl_inline
has been run.

ERL-301
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
v3_kernel may produce unwanted and confusing warnings for code that
has been inlined with the new inliner (cerl_inline).  Consider this
code:

-compile(inline).

compute1(X) -&gt;
    add(X, 0).

compute2(X, Y) -&gt;
    add(X, Y).

add(1, 0) -&gt;
    1;
add(1, Y) -&gt;       %% "this clause cannot match..."
    1 + Y;
add(X, Y) -&gt;
    X + Y.

v3_kernel warns because add/2 has been inlined into compute1/1 and only
the first clause in add/2 will match. But the other clauses are needed
when add/2 is inlined into compute2/2, so the user cannot do anything
to eliminate the warning (short of manually inlining add/2, defeating the
purpose of the 'inline' option).

The warning would be reasonable if compute2/2 didn't exist, but it would
be too complicated for the compiler to figure whether a warning make
sense or not.

Therefore, suppress all warnings generated by v3_kernel if cerl_inline
has been run.

ERL-301
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't copy funs into guards</title>
<updated>2016-10-27T06:14:08+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2016-10-02T12:21:13+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=89bf3f5bef9d9f5fb4a0003d6da028900d0f32fc'/>
<id>89bf3f5bef9d9f5fb4a0003d6da028900d0f32fc</id>
<content type='text'>
Funs must not be created in guards. The instruction for creating
a fun clobbers all X registers, which is a bad thing to do in
a guard.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Funs must not be created in guards. The instruction for creating
a fun clobbers all X registers, which is a bad thing to do in
a guard.
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't let inline_list_funcs degrade optimizations</title>
<updated>2016-10-24T04:41:59+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2016-10-24T04:32:20+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=8052922d105d236c6cf071333107181fc82c191d'/>
<id>8052922d105d236c6cf071333107181fc82c191d</id>
<content type='text'>
83199af0263 refactored sys_core_fold to break out the code for the
inline_lists_funcs option to its own module. Unfortunately, it also
accidentally turned off compile-time evaluation of calls to BIFs with
wholly or partial constant arguments.

For example, the code for the following funtion gets much worse
when inline_list_funcs is used:

b() -&gt;
    R0 = #r{},
    R1 = setelement(1+2, R0, "deux"),
    R2 = setelement(1+3, R1, "trois"),
    R3 = setelement(1+5, R2, "cinq"),
    R4 = setelement(1+2, R3, "DEUX"),
    R4.

ERL-285
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
83199af0263 refactored sys_core_fold to break out the code for the
inline_lists_funcs option to its own module. Unfortunately, it also
accidentally turned off compile-time evaluation of calls to BIFs with
wholly or partial constant arguments.

For example, the code for the following funtion gets much worse
when inline_list_funcs is used:

b() -&gt;
    R0 = #r{},
    R1 = setelement(1+2, R0, "deux"),
    R2 = setelement(1+3, R1, "trois"),
    R3 = setelement(1+5, R2, "cinq"),
    R4 = setelement(1+2, R3, "DEUX"),
    R4.

ERL-285
</pre>
</div>
</content>
</entry>
<entry>
<title>beam_bsm: Eliminate unsafe optimization</title>
<updated>2016-10-06T05:10:37+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2016-10-06T04:01:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=67808ef46f8f429652ddebb81b0b5c3c603f8655'/>
<id>67808ef46f8f429652ddebb81b0b5c3c603f8655</id>
<content type='text'>
The following code causes a compiler failure:

first_after(Data, Offset) -&gt;
    case byte_size(Data) &gt; Offset of
	false -&gt;
	    {First, Rest} = {ok, ok},
	    ok;
	true -&gt;
	    &lt;&lt;_:Offset/binary, Rest/binary&gt;&gt; = Data,
	    %% 'Rest' saved in y(0) before the call.
	    {First, _} = match_first(Data, Rest),
	    %% When beam_bsm sees the code, the following line
            %% which uses y(0) has been optimized away.
	    {First, Rest} = {First, Rest},
	    First
    end.

match_first(_, &lt;&lt;First:1/binary, Rest/binary&gt;&gt;) -&gt;
    {First, Rest}.

Here is the error message from beam_validator:

t: function first_after/2+15:
  Internal consistency check failed - please report this bug.
  Instruction: {call,2,{f,7}}
  Error:       {multiple_match_contexts,[{x,1},0]}:

Basically, what happens is that at time of code generation,
the variable 'Rest' is needed after the call to match_first/2
and is therefore saved in y(0). When beam_bsm (a late optimization
pass) sees the code, the use of y(0) following the call
to match_first/2 has been optimized away. beam_bsm therefore
assumes that the delayed sub-binary creation is safe. (Actually,
it is safe, but beam_validator does not realize it.)

The bug was caused by two separate commits:

e199e2471a reduced the number of special cases to handle in BEAM
optimization passed by breaking apart the tail-recursive call
instructions (call_only and call_last) into separate instructions.
Unfortunately, the special handling for tail calls was lost, which
resulted in worse code (i.e. the delayed sub-binary creation
optimization could not be applied).

e1aa422290 tried to compensate, but did so in a way that was not
always safe.

Teaching beam_validator that this kind of code is safe would be
expensive.

Instead, we will undo the damage caused by the two
commits. Re-introduce the special handling of tail-recursive calls in
beam_bsm that was lost in the first commit. (Effectively) revert the
change in the second commit.

ERL-268
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The following code causes a compiler failure:

first_after(Data, Offset) -&gt;
    case byte_size(Data) &gt; Offset of
	false -&gt;
	    {First, Rest} = {ok, ok},
	    ok;
	true -&gt;
	    &lt;&lt;_:Offset/binary, Rest/binary&gt;&gt; = Data,
	    %% 'Rest' saved in y(0) before the call.
	    {First, _} = match_first(Data, Rest),
	    %% When beam_bsm sees the code, the following line
            %% which uses y(0) has been optimized away.
	    {First, Rest} = {First, Rest},
	    First
    end.

match_first(_, &lt;&lt;First:1/binary, Rest/binary&gt;&gt;) -&gt;
    {First, Rest}.

Here is the error message from beam_validator:

t: function first_after/2+15:
  Internal consistency check failed - please report this bug.
  Instruction: {call,2,{f,7}}
  Error:       {multiple_match_contexts,[{x,1},0]}:

Basically, what happens is that at time of code generation,
the variable 'Rest' is needed after the call to match_first/2
and is therefore saved in y(0). When beam_bsm (a late optimization
pass) sees the code, the use of y(0) following the call
to match_first/2 has been optimized away. beam_bsm therefore
assumes that the delayed sub-binary creation is safe. (Actually,
it is safe, but beam_validator does not realize it.)

The bug was caused by two separate commits:

e199e2471a reduced the number of special cases to handle in BEAM
optimization passed by breaking apart the tail-recursive call
instructions (call_only and call_last) into separate instructions.
Unfortunately, the special handling for tail calls was lost, which
resulted in worse code (i.e. the delayed sub-binary creation
optimization could not be applied).

e1aa422290 tried to compensate, but did so in a way that was not
always safe.

Teaching beam_validator that this kind of code is safe would be
expensive.

Instead, we will undo the damage caused by the two
commits. Re-introduce the special handling of tail-recursive calls in
beam_bsm that was lost in the first commit. (Effectively) revert the
change in the second commit.

ERL-268
</pre>
</div>
</content>
</entry>
<entry>
<title>beam_block: Avoid unsafe inclusion of get_map_elements in blocks</title>
<updated>2016-10-05T11:00:45+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2016-09-26T13:01:19+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=0c599bcad1e7f5f66dd2342ab27791048145e892'/>
<id>0c599bcad1e7f5f66dd2342ab27791048145e892</id>
<content type='text'>
c2035ebb8b restricted the get_map_elements instruction so that it
could only occur at the beginning of a block. It turns out that
including it anywhere in a block is unsafe.

Therefore, never put get_map_elements instruction in blocks.

(Also remove the beam_utils:join_even/2 function since it is no
longer used.)

ERL-266
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
c2035ebb8b restricted the get_map_elements instruction so that it
could only occur at the beginning of a block. It turns out that
including it anywhere in a block is unsafe.

Therefore, never put get_map_elements instruction in blocks.

(Also remove the beam_utils:join_even/2 function since it is no
longer used.)

ERL-266
</pre>
</div>
</content>
</entry>
<entry>
<title>beam_validator: Handle unreachable instructions</title>
<updated>2016-09-13T11:27:28+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2016-09-13T10:35:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=81c5e15544679baeeb8c18b72156b79aa4badebb'/>
<id>81c5e15544679baeeb8c18b72156b79aa4badebb</id>
<content type='text'>
ab03678e introduced an optimization in the beam_z pass that could
introduce unreachable code in BEAM files (a 'jump' instruction is
removed after a 'raise' instruction, but the code following the
target of the 'jump' is not removed).

Since this situation happens very rarely, there is no point in adding
another pass that can remove unreachable code after beam_z. Instead we
will make sure that beam_validator can skip the unreachable code.
Skipping unreachable code is already done in valfun_1/2 (for
historical reasons), but we will also need to do it in val_dsetel/2.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ab03678e introduced an optimization in the beam_z pass that could
introduce unreachable code in BEAM files (a 'jump' instruction is
removed after a 'raise' instruction, but the code following the
target of the 'jump' is not removed).

Since this situation happens very rarely, there is no point in adding
another pass that can remove unreachable code after beam_z. Instead we
will make sure that beam_validator can skip the unreachable code.
Skipping unreachable code is already done in valfun_1/2 (for
historical reasons), but we will also need to do it in val_dsetel/2.
</pre>
</div>
</content>
</entry>
<entry>
<title>sys_core_fold: Don't move a fun into a guard</title>
<updated>2016-09-05T10:56:12+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2016-09-05T10:47:01+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=f9d516285dfec7db4333e919ca71e7eb0e6a41ed'/>
<id>f9d516285dfec7db4333e919ca71e7eb0e6a41ed</id>
<content type='text'>
Moving a fun into a guard may cause code that is not accepted
by beam_validator.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Moving a fun into a guard may cause code that is not accepted
by beam_validator.
</pre>
</div>
</content>
</entry>
<entry>
<title>[ERL-209] Fix ambiguous_catch_try_state inconsistency error</title>
<updated>2016-08-11T13:43:46+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2016-08-11T13:35:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=d39cac954fc76a838763ac1ac03cb71bf8e5d68d'/>
<id>d39cac954fc76a838763ac1ac03cb71bf8e5d68d</id>
<content type='text'>
It is not safe to share code between 'catch' blocks.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It is not safe to share code between 'catch' blocks.
</pre>
</div>
</content>
</entry>
</feed>
