changeset 32:3dbaff8febef draft

commit
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Mon, 27 Feb 2012 16:07:25 +0900
parents ca5104bbc3eb
children 150f0fc56205
files presen/cbc.md presen/presentation.html
diffstat 2 files changed, 115 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/presen/cbc.md	Mon Feb 27 14:52:26 2012 +0900
+++ b/presen/cbc.md	Mon Feb 27 16:07:25 2012 +0900
@@ -144,12 +144,6 @@
 ---
 
 
-CbC の実装
-========
-
----
-
-
 CbC の実装 : Tail Call Elimination
 ========
 <li>CbC-GCC の軽量継続は最適化の1つ, <font color=red>Tail Call Celimination(末尾除去)</font>により実装されている.</li>
@@ -323,17 +317,14 @@
 - conv1 プログラムでは計算と継続を交互に繰り返し行なう。
 - しかし状態のいくつかへは関数ポインタとして保存させておき継続を行う。
 <pre>
-__code g(int i,stack sp) { // Caller
+\_\_code g(int i,stack sp) { // Caller
     struct f_g0_interface *c = 
         (struct f_g0_interface *)(sp -= sizeof(struct f_g0_interface));
-
     c->ret = g_h1;
     c->i_ = i;
-
     goto h(i+3,sp);
 }
-
-__code h(int i,stack sp) {
+\_\_code h(int i,stack sp) {
     struct f_g0_interface *c = (struct f_g0_interface *)sp;
     goto (c->ret)(i+4,sp);
 }
@@ -404,8 +395,29 @@
 ---
 
 
+引数の並びに上書きコピー
+========
+<li>以下の呼び出しを行うと、スタックの書き換えがおこる</li>
+<pre>
+void funcA(int a, int b) {
+  funcB(b, a);
+}
+</pre>
+
+<table width=100%>
+<tr>
+<td style="margin:auto; text-align:center;">
+<img src="./pix/cs_prog.png">
+</td>
+</tr>
+</table>
+
+
+---
+
 最適化の比較
 ========
+
 <table width=100% border=1>
   <caption>それぞれの最適化により吐かれたアセンブラコード</caption>
   <tr>
--- a/presen/presentation.html	Mon Feb 27 14:52:26 2012 +0900
+++ b/presen/presentation.html	Mon Feb 27 16:07:25 2012 +0900
@@ -359,34 +359,6 @@
         <div class="slide">
           <div class="inner">
             
-            <header><h1>CbC の実装</h1></header>
-            
-            
-          </div>
-          <div class="presenter_notes">
-            <header><h1>Presenter Notes</h1></header>
-            <section>
-            
-            </section>
-          </div>
-          <footer>
-            
-            <aside class="source">
-              Source: <a href="./cbc.md">./cbc.md</a>
-            </aside>
-            
-            <aside class="page_number">
-              8/21
-            </aside>
-          </footer>
-        </div>
-      </div>
-      
-      <!-- slide source: ./cbc.md -->
-      <div class="slide-wrapper">
-        <div class="slide">
-          <div class="inner">
-            
             <header><h1>CbC の実装 : Tail Call Elimination</h1></header>
             
             
@@ -435,7 +407,7 @@
             </aside>
             
             <aside class="page_number">
-              9/21
+              8/21
             </aside>
           </footer>
         </div>
@@ -478,7 +450,7 @@
             </aside>
             
             <aside class="page_number">
-              10/21
+              9/21
             </aside>
           </footer>
         </div>
@@ -515,7 +487,7 @@
             </aside>
             
             <aside class="page_number">
-              11/21
+              10/21
             </aside>
           </footer>
         </div>
@@ -559,7 +531,7 @@
             </aside>
             
             <aside class="page_number">
-              12/21
+              11/21
             </aside>
           </footer>
         </div>
@@ -612,7 +584,7 @@
             </aside>
             
             <aside class="page_number">
-              13/21
+              12/21
             </aside>
           </footer>
         </div>
@@ -647,7 +619,7 @@
             </aside>
             
             <aside class="page_number">
-              14/21
+              13/21
             </aside>
           </footer>
         </div>
@@ -681,7 +653,7 @@
             </aside>
             
             <aside class="page_number">
-              15/21
+              14/21
             </aside>
           </footer>
         </div>
@@ -721,7 +693,7 @@
             </aside>
             
             <aside class="page_number">
-              16/21
+              15/21
             </aside>
           </footer>
         </div>
@@ -742,20 +714,20 @@
 <pre>
 __code g(int i,stack sp) { // Caller
     struct f_g0_interface <em>c = 
-        (struct f_g0_interface </em>)(sp -= sizeof(struct f_g0_interface));</p>
-<p>c-&gt;ret = g_h1;
-c-&gt;i_ = i;</p>
-<p>goto h(i+3,sp);
-}</p>
-</li>
-</ul>
-<p>__code h(int i,stack sp) {
+        (struct f_g0_interface </em>)(sp -= sizeof(struct f_g0_interface));
+    c-&gt;ret = g_h1;
+    c-&gt;i_ = i;
+    goto h(i+3,sp);
+}
+__code h(int i,stack sp) {
     struct f_g0_interface <em>c = (struct f_g0_interface </em>)sp;
     goto (c-&gt;ret)(i+4,sp);
 }
 </pre></p>
-<ul>
-<li>関数ポインタへの継続はインライン展開されない。</li>
+</li>
+<li>
+<p>関数ポインタへの継続はインライン展開されない。</p>
+</li>
 </ul></section>
             
           </div>
@@ -772,7 +744,7 @@
             </aside>
             
             <aside class="page_number">
-              17/21
+              16/21
             </aside>
           </footer>
         </div>
@@ -819,7 +791,7 @@
             </aside>
             
             <aside class="page_number">
-              18/21
+              17/21
             </aside>
           </footer>
         </div>
@@ -867,7 +839,7 @@
             </aside>
             
             <aside class="page_number">
-              19/21
+              18/21
             </aside>
           </footer>
         </div>
@@ -903,6 +875,48 @@
             </aside>
             
             <aside class="page_number">
+              19/21
+            </aside>
+          </footer>
+        </div>
+      </div>
+      
+      <!-- slide source: ./cbc.md -->
+      <div class="slide-wrapper">
+        <div class="slide">
+          <div class="inner">
+            
+            <header><h1>引数の並びに上書きコピー</h1></header>
+            
+            
+            <section><p><li>以下の呼び出しを行うと、スタックの書き換えがおこる</li>
+<pre>
+void funcA(int a, int b) {
+  funcB(b, a);
+}
+</pre></p>
+<table width=100%>
+<tr>
+<td style="margin:auto; text-align:center;">
+<img src="file:///Users/aotokage/hg/Papers/2012/nobu-thesis/presen/./pix/cs_prog.png">
+</td>
+</tr>
+</table></section>
+            
+          </div>
+          <div class="presenter_notes">
+            <header><h1>Presenter Notes</h1></header>
+            <section>
+            
+            </section>
+          </div>
+          <footer>
+            
+            <aside class="source">
+              Source: <a href="./cbc.md">./cbc.md</a>
+            </aside>
+            
+            <aside class="page_number">
               20/21
             </aside>
           </footer>
@@ -917,13 +931,14 @@
             <header><h1>最適化の比較</h1></header>
             
             
-            <section><p><table width=100% border=1>
+            <section><table width=100% border=1>
   <caption>それぞれの最適化により吐かれたアセンブラコード</caption>
   <tr>
     <td width=50% style="text-align:center;">CbC-GCC-4.5</td>
     <td width=50% style="text-align:center;">CbC-GCC-4.6</td>
-  </tr></p>
-<p><tr>
+  </tr>
+
+  <tr>
     <td>
       <pre>
 main:
@@ -939,11 +954,11 @@
     movq    24(%rsi), %rdx
     movq    %rax, %rsi
     :
-    jmp     <em>%rdx
+    jmp     *%rdx
     :
     movq    24(%rsi), %rdx
     :
-    jmp     </em>%rdx
+    jmp     *%rdx
       </pre>
     </td>
     <td>
@@ -955,23 +970,28 @@
     :
     movq    24(%rax), %rdx
     :
-    jmp     <em>%rdx
+    jmp     *%rdx
     :
     movq    24(%rax), %rdx
     :
-    jmp     </em>%rdx
+    jmp     *%rdx
       </pre>
     </td>
   </tr>
 <!--
   <tr> 
-    <td></td>\<Element 'br' at 0x10780c6c0>    <td></td>\<Element 'br' at 0x10780c720>  </tr>
---></p>
-<p></table>
+    <td></td>  
+    <td></td>  
+  </tr>
+-->
+
+</table>
 <li>関数を展開してその場で計算する『インライン展開』がより強力になっているのが確認できる</li>
 <!--
 <li>保存していた関数ポインタへの継続はインライン展開は行われない</li>
---></p></section>
+-->
+
+---</section>
             
           </div>
           <div class="presenter_notes">
@@ -993,28 +1013,6 @@
         </div>
       </div>
       
-      <!-- slide source:  -->
-      <div class="slide-wrapper">
-        <div class="slide">
-          <div class="inner">
-            
-            
-          </div>
-          <div class="presenter_notes">
-            <header><h1>Presenter Notes</h1></header>
-            <section>
-            
-            </section>
-          </div>
-          <footer>
-            
-            <aside class="page_number">
-              /21
-            </aside>
-          </footer>
-        </div>
-      </div>
-      
     </div>
   </div>
   
@@ -1066,13 +1064,13 @@
       
       
       <tr id="toc-row-8">
-        <th><a href="#slide8">CbC の実装</a></th>
+        <th><a href="#slide8">CbC の実装 : Tail Call Elimination</a></th>
         <td><a href="#slide8">8</a></td>
       </tr>
       
       
       <tr id="toc-row-9">
-        <th><a href="#slide9">CbC の実装 : Tail Call Elimination</a></th>
+        <th><a href="#slide9">CbC の実装: Tail Call Elimination</a></th>
         <td><a href="#slide9">9</a></td>
       </tr>
       
@@ -1084,61 +1082,61 @@
       
       
       <tr id="toc-row-11">
-        <th><a href="#slide11">CbC の実装: Tail Call Elimination</a></th>
+        <th><a href="#slide11">性能評価</a></th>
         <td><a href="#slide11">11</a></td>
       </tr>
       
       
       <tr id="toc-row-12">
-        <th><a href="#slide12">性能評価</a></th>
+        <th><a href="#slide12">最適化の比較</a></th>
         <td><a href="#slide12">12</a></td>
       </tr>
       
       
       <tr id="toc-row-13">
-        <th><a href="#slide13">最適化の比較</a></th>
+        <th><a href="#slide13">GCC の最適化</a></th>
         <td><a href="#slide13">13</a></td>
       </tr>
       
       
       <tr id="toc-row-14">
-        <th><a href="#slide14">GCC の最適化</a></th>
+        <th><a href="#slide14">アップデートに合わせる有用性</a></th>
         <td><a href="#slide14">14</a></td>
       </tr>
       
       
       <tr id="toc-row-15">
-        <th><a href="#slide15">アップデートに合わせる有用性</a></th>
+        <th><a href="#slide15">まとめ</a></th>
         <td><a href="#slide15">15</a></td>
       </tr>
       
       
       <tr id="toc-row-16">
-        <th><a href="#slide16">まとめ</a></th>
+        <th><a href="#slide16">conv1 プログラム</a></th>
         <td><a href="#slide16">16</a></td>
       </tr>
       
       
       <tr id="toc-row-17">
-        <th><a href="#slide17">conv1 プログラム</a></th>
+        <th><a href="#slide17">CbC の実装: 環境付き継続</a></th>
         <td><a href="#slide17">17</a></td>
       </tr>
       
       
       <tr id="toc-row-18">
-        <th><a href="#slide18">CbC の実装: 環境付き継続</a></th>
+        <th><a href="#slide18">CbC 引数渡し</a></th>
         <td><a href="#slide18">18</a></td>
       </tr>
       
       
       <tr id="toc-row-19">
-        <th><a href="#slide19">CbC 引数渡し</a></th>
+        <th><a href="#slide19">GCC でのコンパイルの仕組み</a></th>
         <td><a href="#slide19">19</a></td>
       </tr>
       
       
       <tr id="toc-row-20">
-        <th><a href="#slide20">GCC でのコンパイルの仕組み</a></th>
+        <th><a href="#slide20">引数の並びに上書きコピー</a></th>
         <td><a href="#slide20">20</a></td>
       </tr>