Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source "https://rubygems.org"

gem 'github-pages'
gem 'jekyll', '~>3.1.6'
70 changes: 33 additions & 37 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
GEM
remote: https://rubygems.org/
specs:
RedCloth (4.2.9)
activesupport (4.2.6)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
Expand All @@ -14,47 +13,44 @@ GEM
execjs
coffee-script-source (1.10.0)
colorator (0.1)
ethon (0.8.1)
ethon (0.9.0)
ffi (>= 1.3.0)
execjs (2.6.0)
execjs (2.7.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.10)
ffi (1.9.13)
gemoji (2.1.0)
github-pages (69)
RedCloth (= 4.2.9)
github-pages (86)
github-pages-health-check (= 1.1.0)
jekyll (= 3.0.3)
jekyll (= 3.1.6)
jekyll-coffeescript (= 1.0.1)
jekyll-feed (= 0.4.0)
jekyll-feed (= 0.5.1)
jekyll-gist (= 1.4.0)
jekyll-github-metadata (= 1.11.0)
jekyll-mentions (= 1.1.2)
jekyll-github-metadata (= 2.0.2)
jekyll-mentions (= 1.1.3)
jekyll-paginate (= 1.1.0)
jekyll-redirect-from (= 0.10.0)
jekyll-sass-converter (= 1.3.0)
jekyll-seo-tag (= 1.3.3)
jekyll-seo-tag (= 2.0.0)
jekyll-sitemap (= 0.10.0)
jekyll-textile-converter (= 0.1.0)
jemoji (= 0.6.2)
kramdown (= 1.10.0)
kramdown (= 1.11.1)
liquid (= 3.0.6)
listen (= 3.0.6)
mercenary (~> 0.3)
rdiscount (= 2.1.8)
redcarpet (= 3.3.3)
rouge (= 1.10.1)
rouge (= 1.11.1)
terminal-table (~> 1.4)
github-pages-health-check (1.1.0)
addressable (~> 2.3)
net-dns (~> 0.8)
octokit (~> 4.0)
public_suffix (~> 1.4)
typhoeus (~> 0.7)
html-pipeline (2.4.0)
html-pipeline (2.4.1)
activesupport (>= 2, < 5)
nokogiri (>= 1.4)
i18n (0.7.0)
jekyll (3.0.3)
jekyll (3.1.6)
colorator (~> 0.1)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 1.1)
Expand All @@ -65,58 +61,57 @@ GEM
safe_yaml (~> 1.0)
jekyll-coffeescript (1.0.1)
coffee-script (~> 2.2)
jekyll-feed (0.4.0)
jekyll-feed (0.5.1)
jekyll-gist (1.4.0)
octokit (~> 4.2)
jekyll-github-metadata (1.11.0)
jekyll-github-metadata (2.0.2)
jekyll (~> 3.1)
octokit (~> 4.0)
jekyll-mentions (1.1.2)
jekyll-mentions (1.1.3)
html-pipeline (~> 2.3)
jekyll (~> 3.0)
jekyll-paginate (1.1.0)
jekyll-redirect-from (0.10.0)
jekyll (>= 2.0)
jekyll-sass-converter (1.3.0)
sass (~> 3.2)
jekyll-seo-tag (1.3.3)
jekyll (~> 3.0)
jekyll-seo-tag (2.0.0)
jekyll (~> 3.1)
jekyll-sitemap (0.10.0)
jekyll-textile-converter (0.1.0)
RedCloth (~> 4.0)
jekyll-watch (1.3.1)
listen (~> 3.0)
jekyll-watch (1.4.0)
listen (~> 3.0, < 3.1)
jemoji (0.6.2)
gemoji (~> 2.0)
html-pipeline (~> 2.2)
jekyll (>= 3.0)
json (1.8.3)
kramdown (1.10.0)
kramdown (1.11.1)
liquid (3.0.6)
listen (3.0.6)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9.7)
mercenary (0.3.6)
mini_portile2 (2.0.0)
minitest (5.8.4)
mini_portile2 (2.1.0)
minitest (5.9.0)
multipart-post (2.0.0)
net-dns (0.8.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
octokit (4.3.0)
sawyer (~> 0.7.0, >= 0.5.3)
pkg-config (1.1.7)
public_suffix (1.5.3)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rdiscount (2.1.8)
redcarpet (3.3.3)
rouge (1.10.1)
rouge (1.11.1)
safe_yaml (1.0.4)
sass (3.4.22)
sawyer (0.7.0)
addressable (>= 2.3.5, < 2.5)
faraday (~> 0.8, < 0.10)
terminal-table (1.5.2)
terminal-table (1.6.0)
thread_safe (0.3.5)
typhoeus (0.8.0)
ethon (>= 0.8.0)
Expand All @@ -128,6 +123,7 @@ PLATFORMS

DEPENDENCIES
github-pages
jekyll (~> 3.1.6)

BUNDLED WITH
1.11.2
1.12.5
3 changes: 0 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@ github_username: rust-lang

# Build settings
highlighter: rouge
markdown: redcarpet
redcarpet:
extensions: ["with_toc_data", "smart"]

root: http://blog.rust-lang.org
1 change: 1 addition & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<meta name="description" content="{{ site.description }}">
<link rel="alternate" type="application/rss+xml" title="The Rust Programming Language Blog" href="http://blog.rust-lang.org/feed.xml" />
<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">
<link rel="stylesheet" href="{{ "/css/center-img.css" | prepend: site.baseurl }}">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">

<meta name="twitter:card" content="summary" />
Expand Down
40 changes: 10 additions & 30 deletions _posts/2016-04-19-MIR.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ compiler internals. Over the past year or so, we have been steadily
working on a plan to change our internal compiler pipeline, as shown
here:

<center>
![Compiler Flowchart][flow]
</center>
![Compiler Flowchart][flow]{:class="center"}

That is, we are introducing a new intermediate representation (IR) of
your program that we call **MIR**: MIR stands for *mid-level* IR, because
Expand Down Expand Up @@ -262,9 +260,7 @@ of that cycle.
Here is the running example from the previous section, expressed as a
control-flow graph:

<center>
![Control-flow-graph][cfg]
</center>
![Control-flow-graph][cfg]{:class="center"}

Building a control-flow graph is typically a first step for any kind
of flow-sensitive analysis. It's also a natural match for LLVM IR,
Expand Down Expand Up @@ -345,9 +341,7 @@ break:
Of course, the actual MIR is based on a control-flow-graph, so it
would look something like this:

<center>
![Loop-break control-flow graph][loop-break]
</center>
![Loop-break control-flow graph][loop-break]{:class="center"}

### Explicit drops and panics

Expand Down Expand Up @@ -394,18 +388,14 @@ control-flow-graph to show explicitly where the `iterator` value gets
freed. Take a look at the new graph, and in particular what happens
when a `None` variant is found:

<center>
![Drop control-flow graph][drop]
</center>
![Drop control-flow graph][drop]{:class="center"}

Here we see that, when the loop exits normally, we will drop the
iterator once it has finished. But what about if a panic occurs? Any
of the function calls we see here could panic, after all. To account
for that, we introduce panic edges into the graph:

<center>
![Panic control-flow graph][drop-unwind]
</center>
![Panic control-flow graph][drop-unwind]{:class="center"}

Here we have introduced `panic` edges onto each of the function
calls. By looking at these edges, you can see that if the call to
Expand Down Expand Up @@ -522,19 +512,15 @@ like the current overwriting semantics. So this means that the MIR for
`send_if` might look like this (for simplicity, I'll ignore unwinding
edges).

<center>
![Non-zeroing drop example][nzd]
</center>
![Non-zeroing drop example][nzd]{:class="center"}

We can then transform this graph by identifying each place where
`data` is moved or dropped and checking whether any of those places
can reach one another. In this case, the `send_to_other_thread(data)` block can
reach `drop(data)`. This indicates that we will need to introduce a
flag, which can be done rather mechanically:

<center>
![Non-zeroing drop with flags][nzd-flags]
</center>
![Non-zeroing drop with flags][nzd-flags]{:class="center"}

Finally, we can apply standard compiler techniques to optimize this
flag (but in this case, the flag is needed, and so the final result
Expand All @@ -558,26 +544,20 @@ fn send_if2(data: Vec<Data>) {

This would generate MIR like:

<center>
![Control-flow graph for send_if2][send_if2]
</center>
![Control-flow graph for send_if2][send_if2]{:class="center"}

As before, we still generate the drops of `data` in all cases, at
least to start. Since there are still moves that can later reach a
drop, we could now introduce a stack flag variable, just as before:

<center>
![send_if2 with flags][send_if2-flags]
</center>
![send_if2 with flags][send_if2-flags]{:class="center"}

But in this case, if we apply constant propagation, we can see that at
each point where we test `data_is_owned`, we know statically whether
it is true or false, which would allow us to remove the stack flag and
optimize the graph above, yielding this result:

<center>
![Optimized send_if2][send_if2-opt]
</center>
![Optimized send_if2][send_if2-opt]{:class="center"}

### Conclusion

Expand Down
Loading