<feed xmlns='http://www.w3.org/2005/Atom'>
<title>otp.git/lib/compiler, branch OTP_R16B</title>
<subtitle>Mirror of Erlang/OTP repository.
</subtitle>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/'/>
<entry>
<title>Prepare release</title>
<updated>2013-02-25T18:23:54+00:00</updated>
<author>
<name>Erlang/OTP</name>
<email>otp@erlang.org</email>
</author>
<published>2013-02-25T18:23:54+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=05f11890bdfec4bfc3a78e191a87e70a937ffc54'/>
<id>05f11890bdfec4bfc3a78e191a87e70a937ffc54</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Update copyright years</title>
<updated>2013-02-22T16:54:39+00:00</updated>
<author>
<name>Björn-Egil Dahlberg</name>
<email>egil@erlang.org</email>
</author>
<published>2013-02-22T16:54:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=acc8e607aaeedcfb4cf9b6d2e0953a6a12b5b94a'/>
<id>acc8e607aaeedcfb4cf9b6d2e0953a6a12b5b94a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add float_to_binary and binary_to_float</title>
<updated>2013-02-14T14:36:50+00:00</updated>
<author>
<name>Lukas Larsson</name>
<email>lukas@erlang-solutions.com</email>
</author>
<published>2013-02-08T17:23:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=5279b3af4efee5d3e7d9755f0f06bd7b0f5dd05c'/>
<id>5279b3af4efee5d3e7d9755f0f06bd7b0f5dd05c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add new binary conversion bifs</title>
<updated>2013-02-14T14:36:44+00:00</updated>
<author>
<name>Lukas Larsson</name>
<email>lukas@erlang-solutions.com</email>
</author>
<published>2012-09-05T18:43:03+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=b074099cc6bdb81285a17e0248373f199c695719'/>
<id>b074099cc6bdb81285a17e0248373f199c695719</id>
<content type='text'>
Added: binary_to_integer/1,2, integer_to_binary/1,2
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Added: binary_to_integer/1,2, integer_to_binary/1,2
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix unsafe optimization of funs</title>
<updated>2013-02-09T09:55:19+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2013-02-08T16:22:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=5b5964026b1d59ddbfa4c57865110c1699f3e482'/>
<id>5b5964026b1d59ddbfa4c57865110c1699f3e482</id>
<content type='text'>
Commits 53bd4974a101 and 726f6e4c7afe simplified the handling of
match_fail (used to generated exceptions such as 'function_clause')
by first rewriting them to a call to erlang/error{1,2} and later
rewriting them to specialized BEAM instructions (to reduce the
code size).

There was one flaw, though, which only was exposed when more
aggressive optimizations were added in c3b60f86c622. Here is an
example to explain it:

t(V) -&gt;
    fun(get) -&gt; V end.

The following BEAM code will be initially generated for the fun:

{function, '-t/1-fun-0-', 2, 5}.
  {label,1}.
    {line,[{location,"t.erl",5}]}.
    {func_info,{atom,t},{atom,'-t/1-fun-0-'},2}.
  {label,2}.
    {test,is_eq_exact,{f,2},[{x,0},{atom,get}]}.
    {move,{x,1},{x,0}}.
    return.
  {label,2}.
    {test_heap,2,1}.
    {put_list,{x,0},nil,{x,1}}.
    {move,{atom,function_clause},{x,0}}.
    {line,[{location,"t.erl",5}]}.
    {call_ext_only,2,{extfunc,erlang,error,2}}.

Translating back to Erlang code, that would be roughly:

'-t/1-fun-0-'(get, V) -&gt; V;
'-t/1-fun-0-'(Arg1, _) -&gt; erlang:error(function_clause, [Arg1]).

Note that the second argument (the free variable V) is not included
in the call to erlang:error/2.

The beam_except pass will simplify the code to:

{function, '-t/1-fun-0-', 2, 8}.
  {label,1}.
    {line,[{location,"t.erl",5}]}.
    {func_info,{atom,t},{atom,'-t/1-fun-0-'},2}.
  {label,2}.
    {test,is_eq_exact,{f,1},[{x,0},{atom,get}]}.
    {move,{x,1},{x,0}}.
    return.

The code has been shortened by jumping to the func_info/3 instruction.
Translating back to Erlang:

'-t/1-fun-0-'(get, V) -&gt; V;
'-t/1-fun-0-'(Arg1, Arg2) -&gt; erlang:error(function_clause, [Arg1,Arg2]).

it is clear that both arguments are now included in the
'function_clause' exception, even though the initially generated
code only included the first argument.

That is no problem in this particular case, but for some more complex
funs, optimizing the first version based on variable usage could make
the second version unsafe.

I rejected the following potential solutions:

- Including the free arguments in the call to erlang:error/2:

'-t/1-fun-0-'(get, V) -&gt; V;
'-t/1-fun-0-'(Arg1, Arg2) -&gt; erlang:error(function_clause, [Arg1,Arg2]).

Unfortunately, that is tricky. The free variables are only known
after the second pass in v3_kernel when variable usage has been
calculated. We would need to add a third pass (only for funs) that
would the free arguments to the second argument for erlang:error/2
*and* update the variable usage information.

- Calling beam_except earlier, from within beam_block before any
  optimizations based on variable usages are done.  But means that the
  problem could reappear in some other form in the future when other
  updates are done to the code generator and/or optimization passes.

The solution I have chosen is to modify beam_except to only replace
a call to erlang:error(function_class, Args) if the length of Args
is the same as the arity in the func_info/3 instruction. The code
will be slightly larger. Also, the free variables for funs and list
comprehensions will no longer be included in the function_clause
exception (that could be less confusing, but it also means less
information during debugging).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commits 53bd4974a101 and 726f6e4c7afe simplified the handling of
match_fail (used to generated exceptions such as 'function_clause')
by first rewriting them to a call to erlang/error{1,2} and later
rewriting them to specialized BEAM instructions (to reduce the
code size).

There was one flaw, though, which only was exposed when more
aggressive optimizations were added in c3b60f86c622. Here is an
example to explain it:

t(V) -&gt;
    fun(get) -&gt; V end.

The following BEAM code will be initially generated for the fun:

{function, '-t/1-fun-0-', 2, 5}.
  {label,1}.
    {line,[{location,"t.erl",5}]}.
    {func_info,{atom,t},{atom,'-t/1-fun-0-'},2}.
  {label,2}.
    {test,is_eq_exact,{f,2},[{x,0},{atom,get}]}.
    {move,{x,1},{x,0}}.
    return.
  {label,2}.
    {test_heap,2,1}.
    {put_list,{x,0},nil,{x,1}}.
    {move,{atom,function_clause},{x,0}}.
    {line,[{location,"t.erl",5}]}.
    {call_ext_only,2,{extfunc,erlang,error,2}}.

Translating back to Erlang code, that would be roughly:

'-t/1-fun-0-'(get, V) -&gt; V;
'-t/1-fun-0-'(Arg1, _) -&gt; erlang:error(function_clause, [Arg1]).

Note that the second argument (the free variable V) is not included
in the call to erlang:error/2.

The beam_except pass will simplify the code to:

{function, '-t/1-fun-0-', 2, 8}.
  {label,1}.
    {line,[{location,"t.erl",5}]}.
    {func_info,{atom,t},{atom,'-t/1-fun-0-'},2}.
  {label,2}.
    {test,is_eq_exact,{f,1},[{x,0},{atom,get}]}.
    {move,{x,1},{x,0}}.
    return.

The code has been shortened by jumping to the func_info/3 instruction.
Translating back to Erlang:

'-t/1-fun-0-'(get, V) -&gt; V;
'-t/1-fun-0-'(Arg1, Arg2) -&gt; erlang:error(function_clause, [Arg1,Arg2]).

it is clear that both arguments are now included in the
'function_clause' exception, even though the initially generated
code only included the first argument.

That is no problem in this particular case, but for some more complex
funs, optimizing the first version based on variable usage could make
the second version unsafe.

I rejected the following potential solutions:

- Including the free arguments in the call to erlang:error/2:

'-t/1-fun-0-'(get, V) -&gt; V;
'-t/1-fun-0-'(Arg1, Arg2) -&gt; erlang:error(function_clause, [Arg1,Arg2]).

Unfortunately, that is tricky. The free variables are only known
after the second pass in v3_kernel when variable usage has been
calculated. We would need to add a third pass (only for funs) that
would the free arguments to the second argument for erlang:error/2
*and* update the variable usage information.

- Calling beam_except earlier, from within beam_block before any
  optimizations based on variable usages are done.  But means that the
  problem could reappear in some other form in the future when other
  updates are done to the code generator and/or optimization passes.

The solution I have chosen is to modify beam_except to only replace
a call to erlang:error(function_class, Args) if the length of Args
is the same as the arity in the func_info/3 instruction. The code
will be slightly larger. Also, the free variables for funs and list
comprehensions will no longer be included in the function_clause
exception (that could be less confusing, but it also means less
information during debugging).
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'bjorn/compiler/dialyzer-warnings'</title>
<updated>2013-02-07T08:51:11+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2013-02-07T08:51:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=8e31a2f4999fdb0685a860a136ab9e0dc31b9821'/>
<id>8e31a2f4999fdb0685a860a136ab9e0dc31b9821</id>
<content type='text'>
* bjorn/compiler/dialyzer-warnings:
  compile: Eliminate warnings for unmatched return values
  beam_receive: Eliminate dialyzer warning for unmatched return
  beam_validator: Eliminate dialyzer warnings for unmatched returns
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* bjorn/compiler/dialyzer-warnings:
  compile: Eliminate warnings for unmatched return values
  beam_receive: Eliminate dialyzer warning for unmatched return
  beam_validator: Eliminate dialyzer warnings for unmatched returns
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'nox/fix-seq-opt/OTP-10818'</title>
<updated>2013-02-06T15:55:49+00:00</updated>
<author>
<name>Fredrik Gustafsson</name>
<email>fredrik@erlang.org</email>
</author>
<published>2013-02-06T15:55:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=205a535dc9750d3ed1e930b1dd8a1c4084f5f46f'/>
<id>205a535dc9750d3ed1e930b1dd8a1c4084f5f46f</id>
<content type='text'>
* nox/fix-seq-opt/OTP-10818:
  Add two tests for unused multiple values in effect context
  Forbid multiple values in Core Erlang sequence arguments
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* nox/fix-seq-opt/OTP-10818:
  Add two tests for unused multiple values in effect context
  Forbid multiple values in Core Erlang sequence arguments
</pre>
</div>
</content>
</entry>
<entry>
<title>compile: Eliminate warnings for unmatched return values</title>
<updated>2013-02-06T14:13:03+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2013-02-06T14:00:27+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=a12ad74643bdb143b0811a65db9a7bbd8a7697de'/>
<id>a12ad74643bdb143b0811a65db9a7bbd8a7697de</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>beam_receive: Eliminate dialyzer warning for unmatched return</title>
<updated>2013-02-06T14:05:02+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2013-02-06T06:54:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=e295940555c6d56c6155fdd0a235cf1c7562c9e3'/>
<id>e295940555c6d56c6155fdd0a235cf1c7562c9e3</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>beam_validator: Eliminate dialyzer warnings for unmatched returns</title>
<updated>2013-02-06T14:05:02+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2013-02-06T06:30:37+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=a42c2fd51a6e7f71866228d77eca10435550a5d6'/>
<id>a42c2fd51a6e7f71866228d77eca10435550a5d6</id>
<content type='text'>
The assert_fls/2 and assert_type/3 functions both return the
Vst passed to them, but all callers ignore the return value.
Given the name of the functions, they are not expected to return
anything. Make it so by changing the return value to 'ok'.

There are two calls to bsm_get_context/2 used only to validate
that the match context is valid. Call bsm_validate_context/2
instead.

In bsm_validate_context/2, explicitly match the return value of
bsm_get_context/2 to '_' to make it clear that it is not used.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The assert_fls/2 and assert_type/3 functions both return the
Vst passed to them, but all callers ignore the return value.
Given the name of the functions, they are not expected to return
anything. Make it so by changing the return value to 'ok'.

There are two calls to bsm_get_context/2 used only to validate
that the match context is valid. Call bsm_validate_context/2
instead.

In bsm_validate_context/2, explicitly match the return value of
bsm_get_context/2 to '_' to make it clear that it is not used.
</pre>
</div>
</content>
</entry>
</feed>
