<feed xmlns='http://www.w3.org/2005/Atom'>
<title>otp.git/lib/compiler, branch HansN-patch-1</title>
<subtitle>Mirror of Erlang/OTP repository.
</subtitle>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/'/>
<entry>
<title>Check that messages outside of the heap are not corrupted</title>
<updated>2018-04-06T11:06:52+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2018-04-04T04:46:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=90853d8e7b50be13a3b71f4a1ed6b0407e1f7c2f'/>
<id>90853d8e7b50be13a3b71f4a1ed6b0407e1f7c2f</id>
<content type='text'>
Waiting messages for a process may be stored in a queue
outside of any heap or heap fragment belonging to the process.
This is an optimization added in a recent major release to
avoid garbage collection messages again and again if there
is a long message queue.

Until such message has been matched and accepted by
the remove_message/0 instruction, the message must not be
included in the root set for a garbage collection, as that
would corrupt the message. The loop_rec/2 instruction explicitly
turns off garbage collection of the process as long messages
are being matched.

However, if the compiler were to put references to a message
outside of the heap in an Y register (on the stack) and there
happened to be a GC when the process had been scheduled out,
the message would be corrupted and the runtime system would
crash sooner or later.

To ensure that doesn't happen, teach beam_validator to check
for references on the stack to messages outside of the heap.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Waiting messages for a process may be stored in a queue
outside of any heap or heap fragment belonging to the process.
This is an optimization added in a recent major release to
avoid garbage collection messages again and again if there
is a long message queue.

Until such message has been matched and accepted by
the remove_message/0 instruction, the message must not be
included in the root set for a garbage collection, as that
would corrupt the message. The loop_rec/2 instruction explicitly
turns off garbage collection of the process as long messages
are being matched.

However, if the compiler were to put references to a message
outside of the heap in an Y register (on the stack) and there
happened to be a GC when the process had been scheduled out,
the message would be corrupted and the runtime system would
crash sooner or later.

To ensure that doesn't happen, teach beam_validator to check
for references on the stack to messages outside of the heap.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #1769 from bjorng/bjorn/compiler/beam_utils</title>
<updated>2018-04-05T11:02:21+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bgustavsson@gmail.com</email>
</author>
<published>2018-04-05T11:02:21+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=1328163db6d64d4a8309306cd4caeb43ffd5ecbb'/>
<id>1328163db6d64d4a8309306cd4caeb43ffd5ecbb</id>
<content type='text'>
Fix unsafe optimization of record test</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix unsafe optimization of record test</pre>
</div>
</content>
</entry>
<entry>
<title>Fix unsafe optimization of record test</title>
<updated>2018-04-04T13:34:34+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2018-04-04T13:14:54+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=282fb67730e1bafe722e7149a35e272398f88b34'/>
<id>282fb67730e1bafe722e7149a35e272398f88b34</id>
<content type='text'>
beam_record would make an unsafe optimization for the
not_used_p/4 function added to beam_utils_SUITE in this
commit. The bug is in beam_utils, which would falsely
report that {x,4} was unused when it in fact was used.

The bug was in the function not_used/1. The purpose of
not_used/1 is to return a 'not_used' result unless the
actual result is 'used'. Unfortunately it was not
implemented in that way. It would let a 'transparent'
result slip through, which the caller in this case would
convert to 'killed' (because the register was killed on
all other paths).

Reported-by: Richard Carlsson
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
beam_record would make an unsafe optimization for the
not_used_p/4 function added to beam_utils_SUITE in this
commit. The bug is in beam_utils, which would falsely
report that {x,4} was unused when it in fact was used.

The bug was in the function not_used/1. The purpose of
not_used/1 is to return a 'not_used' result unless the
actual result is 'used'. Unfortunately it was not
implemented in that way. It would let a 'transparent'
result slip through, which the caller in this case would
convert to 'killed' (because the register was killed on
all other paths).

Reported-by: Richard Carlsson
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #1725 from michalmuskala/fun-literals</title>
<updated>2018-04-04T12:10:21+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bgustavsson@gmail.com</email>
</author>
<published>2018-04-04T12:10:21+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=db1447e1423aaaafa02d52ca0b57115631990780'/>
<id>db1447e1423aaaafa02d52ca0b57115631990780</id>
<content type='text'>
Compile external fun expressions to literals

OTP-15003
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Compile external fun expressions to literals

OTP-15003
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #1761 from bjorng/bjorn/compiler/fix-atom-leak/ERL-563/OTP-14968</title>
<updated>2018-03-26T11:22:15+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bgustavsson@gmail.com</email>
</author>
<published>2018-03-26T11:22:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=bebf113ecd2d6a27808fc952e1f14db78515efb3'/>
<id>bebf113ecd2d6a27808fc952e1f14db78515efb3</id>
<content type='text'>
Stop the compiler from overflowing the atom table</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Stop the compiler from overflowing the atom table</pre>
</div>
</content>
</entry>
<entry>
<title>Compile external fun expressions to literals</title>
<updated>2018-03-26T10:07:10+00:00</updated>
<author>
<name>Michał Muskała</name>
<email>michal@muskala.eu</email>
</author>
<published>2018-02-25T13:19:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=63e1c58d27ab695a19897423fc75e607f69ff51b'/>
<id>63e1c58d27ab695a19897423fc75e607f69ff51b</id>
<content type='text'>
The expressions fun M:F/A, when all elements are literals are also
treated as a literal. Since they have consistent representation and
don't depend on the code currently loaded in the VM, this is safe.
This can provide significant performance improvements in code using such
functions extensively - a full function call to erlang:make_fun/3 is
replaced by a single move instruction and no register shuffling or
saving registers to stack is necessary. Additionally, compound data
types that contain such external functions as elements can be treated as
literals too.

The commit also changes the representation of external funs to be a
valid Erlang syntax and adds support for literal external funs to core
Erlang.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The expressions fun M:F/A, when all elements are literals are also
treated as a literal. Since they have consistent representation and
don't depend on the code currently loaded in the VM, this is safe.
This can provide significant performance improvements in code using such
functions extensively - a full function call to erlang:make_fun/3 is
replaced by a single move instruction and no register shuffling or
saving registers to stack is necessary. Additionally, compound data
types that contain such external functions as elements can be treated as
literals too.

The commit also changes the representation of external funs to be a
valid Erlang syntax and adds support for literal external funs to core
Erlang.
</pre>
</div>
</content>
</entry>
<entry>
<title>Avoid overflowing the atom table</title>
<updated>2018-03-24T06:32:26+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2018-03-20T06:34:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=a5e80861faedc84d373ccda95ae6f8c7aff11bcf'/>
<id>a5e80861faedc84d373ccda95ae6f8c7aff11bcf</id>
<content type='text'>
Use integer variable names instead of atoms in v3_core, sys_core_fold,
and v3_kernel to avoid overflowing the atom table.

It is a deliberate design decision to calculate the first free integer
variable name (in sys_core_fold and v3_kernel) instead of somehow
passing it from one pass to another. I don't want that kind of
dependency between compiler passes. Also note that the next free
variable name is not easily available after running the inliner.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use integer variable names instead of atoms in v3_core, sys_core_fold,
and v3_kernel to avoid overflowing the atom table.

It is a deliberate design decision to calculate the first free integer
variable name (in sys_core_fold and v3_kernel) instead of somehow
passing it from one pass to another. I don't want that kind of
dependency between compiler passes. Also note that the next free
variable name is not easily available after running the inliner.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add cerl_trees:next_free_variable_name/1</title>
<updated>2018-03-23T14:13:58+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2018-03-23T10:51:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=9d2f5cde19cffca9a00b8fad8075bf160cc872d3'/>
<id>9d2f5cde19cffca9a00b8fad8075bf160cc872d3</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>cerl_inline: Fix a name capture bug</title>
<updated>2018-03-23T13:57:30+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2018-03-22T11:38:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=43a91c5e461e3fbec924e332f42fd69b81be34b2'/>
<id>43a91c5e461e3fbec924e332f42fd69b81be34b2</id>
<content type='text'>
The way variables created by make_template() are used, it is necessary
that the names are unique in the entire function.  This has not
happened to cause any problems in the past because all other compiler
passes created atom variable names, not integer variable names. If
other passes start to create integer variable names, this bug is
exposed.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The way variables created by make_template() are used, it is necessary
that the names are unique in the entire function.  This has not
happened to cause any problems in the past because all other compiler
passes created atom variable names, not integer variable names. If
other passes start to create integer variable names, this bug is
exposed.
</pre>
</div>
</content>
</entry>
<entry>
<title>Allow the match context identifier to be any term</title>
<updated>2018-03-23T13:35:29+00:00</updated>
<author>
<name>Björn Gustavsson</name>
<email>bjorn@erlang.org</email>
</author>
<published>2018-03-20T06:27:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/otp.git/commit/?id=e48f59aff695e55c0150664a6cc4f441c1636a16'/>
<id>e48f59aff695e55c0150664a6cc4f441c1636a16</id>
<content type='text'>
During compilation, the bs_save2 and bs_restore2 instructions contain a match
context reference. That reference is the variable name that holds the match context.
beam_clean assumes that the reference always is an atom, which is not a safe assumption
since integers are legal variable names in Core Erlang.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
During compilation, the bs_save2 and bs_restore2 instructions contain a match
context reference. That reference is the variable name that holds the match context.
beam_clean assumes that the reference always is an atom, which is not a safe assumption
since integers are legal variable names in Core Erlang.
</pre>
</div>
</content>
</entry>
</feed>
