Mercurial > hg > Papers > 2012 > nobu-thesis
annotate presen/presentation.html @ 34:3922a95e99a8 draft
commit presen
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 27 Feb 2012 18:34:32 +0900 |
parents | 3dbaff8febef |
children | 01238ec569ea |
rev | line source |
---|---|
27 | 1 <!DOCTYPE html> |
2 <!-- | |
3 Copyright 2010 Google Inc. | |
4 | |
5 Licensed under the Apache License, Version 2.0 (the "License"); | |
6 you may not use this file except in compliance with the License. | |
7 You may obtain a copy of the License at | |
8 | |
9 http://www.apache.org/licenses/LICENSE-2.0 | |
10 | |
11 Unless required by applicable law or agreed to in writing, software | |
12 distributed under the License is distributed on an "AS IS" BASIS, | |
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 See the License for the specific language governing permissions and | |
15 limitations under the License. | |
16 | |
17 Original slides: Marcin Wichary (mwichary@google.com) | |
18 Modifications: Ernest Delgado (ernestd@google.com) | |
19 Alex Russell (slightlyoff@chromium.org) | |
20 | |
21 landslide modifications: Adam Zapletal (adamzap@gmail.com) | |
22 Nicolas Perriault (nperriault@gmail.com) | |
23 --> | |
24 <html> | |
25 <head> | |
26 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
27 <meta http-equiv="X-UA-Compatible" content="chrome=1"> | |
28 | 28 <title>Continuation based C の <br> GCC 4.6による実装</title> |
27 | 29 <!-- Styles --> |
30 | |
31 <link rel="stylesheet" media="print" href="file:///Library/Python/2.7/site-packages/landslide-1.0.1-py2.7.egg/landslide/themes/default/css/print.css"> | |
32 <link rel="stylesheet" media="screen, projection" href="file:///Library/Python/2.7/site-packages/landslide-1.0.1-py2.7.egg/landslide/themes/tango/css/screen.css"> | |
33 | |
34 | |
35 | |
36 <link rel="stylesheet" href="file:///Users/aotokage/hg/Papers/2012/nobu-thesis/presen/presen.css"> | |
37 | |
38 | |
39 <!-- /Styles --> | |
40 <!-- Javascripts --> | |
41 | |
42 <script type="text/javascript" src="file:///Library/Python/2.7/site-packages/landslide-1.0.1-py2.7.egg/landslide/themes/default/js/slides.js"></script> | |
43 | |
44 | |
45 <!-- /Javascripts --> | |
46 </head> | |
47 <body> | |
48 <div id="blank"></div> | |
49 <div class="presentation"> | |
50 <div id="current_presenter_notes"> | |
51 <div id="presenter_note"></div> | |
52 </div> | |
53 <div class="slides"> | |
54 | |
55 <!-- slide source: ./cbc.md --> | |
56 <div class="slide-wrapper"> | |
57 <div class="slide"> | |
58 <div class="inner"> | |
59 | |
28 | 60 <header><h1>Continuation based C の <br> GCC 4.6による実装</h1></header> |
27 | 61 |
62 | |
63 </div> | |
64 <div class="presenter_notes"> | |
65 <header><h1>Presenter Notes</h1></header> | |
66 <section> | |
67 | |
68 </section> | |
69 </div> | |
70 <footer> | |
71 | |
72 <aside class="source"> | |
73 Source: <a href="./cbc.md">./cbc.md</a> | |
74 </aside> | |
75 | |
76 <aside class="page_number"> | |
30 | 77 1/21 |
27 | 78 </aside> |
79 </footer> | |
80 </div> | |
81 </div> | |
82 | |
83 <!-- slide source: ./cbc.md --> | |
84 <div class="slide-wrapper"> | |
85 <div class="slide has_notes"> | |
86 <div class="inner"> | |
87 | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
88 <header><h2>研究の背景と成果</h2></header> |
27 | 89 |
90 | |
91 <section><p class="notes">plop</p> | |
92 <ul> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
93 <li>当研究室ではコードセグメント単位で記述するプログラミング言語Continuation based C (以下CbC)という言語を提案している。</li> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
94 <li>CbC のコンパイラは Micro-C 版 と GCC ベース(以下 CbC-GCC)のコンパイラが開発されている。</li> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
95 <li>しかし, CbC-GCC はいくつかのバグがあり機能の修正の余地があった。</li> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
96 <li>また、GCC の最新の機能を使用するためにも CbC-GCC は GCC のアップデートに合わせていく必要がある。</li> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
97 </ul> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
98 <h2>本研究では CbC-GCC のアップデートを行い、より良いコードを生成する CbC の処理系を開発した。</h2></section> |
27 | 99 |
100 </div> | |
101 <div class="presenter_notes"> | |
102 <header><h1>Presenter Notes</h1></header> | |
103 <section> | |
104 | |
105 </section> | |
106 </div> | |
107 <footer> | |
108 | |
109 <aside class="source"> | |
110 Source: <a href="./cbc.md">./cbc.md</a> | |
111 </aside> | |
112 | |
113 <aside class="page_number"> | |
30 | 114 2/21 |
27 | 115 </aside> |
116 </footer> | |
117 </div> | |
118 </div> | |
119 | |
120 <!-- slide source: ./cbc.md --> | |
121 <div class="slide-wrapper"> | |
122 <div class="slide"> | |
123 <div class="inner"> | |
124 | |
125 <header><h1>Continuation based C</h1></header> | |
126 | |
127 | |
128 <section><h2>コードセグメント単位での記述と継続を基本としたプログラミング言語</h2> | |
129 <li>コーセグメント:CbC におけるプログラムの基本単位</li> | |
130 | |
131 <ul> | |
132 <li>C の関数よりも細かな単位</li> | |
133 <li>C から関数コールとループ制御が取り除かれた形</li> | |
134 <li>コードセグメントの末尾処理で別のコードセグメントへ継続(goto)することで CbC のプログラムは続いていく。</li> | |
135 </ul> | |
136 | |
137 <table width=100% > | |
138 <td style="margin-left:auto; margin-right: auto; text-align: center;"> | |
139 <img src="file:///Users/aotokage/hg/Papers/2012/nobu-thesis/presen/./pix/codesegment.png" style="height:14em;"> | |
140 </td> | |
141 </table></section> | |
142 | |
143 </div> | |
144 <div class="presenter_notes"> | |
145 <header><h1>Presenter Notes</h1></header> | |
146 <section> | |
147 | |
148 </section> | |
149 </div> | |
150 <footer> | |
151 | |
152 <aside class="source"> | |
153 Source: <a href="./cbc.md">./cbc.md</a> | |
154 </aside> | |
155 | |
156 <aside class="page_number"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
157 3/21 |
27 | 158 </aside> |
159 </footer> | |
160 </div> | |
161 </div> | |
162 | |
163 <!-- slide source: ./cbc.md --> | |
164 <div class="slide-wrapper"> | |
165 <div class="slide"> | |
166 <div class="inner"> | |
167 | |
168 <header><h1>Continuation based C</h1></header> | |
169 | |
170 | |
171 <section><h2>継続:現在の処理を実行していく為の情報</h2> | |
172 <p><table width=100% border=1> | |
173 <tr> | |
174 <td><h2>Cの継続</h2></td> | |
175 <td><h2>CbCの継続(軽量継続)</h2></td> | |
176 </tr> | |
177 <tr> | |
178 <td> | |
179 <ul> | |
180 <li>続く命令のアドレス</li> | |
181 <li>命令に必要なデータ</li> | |
182 <li>スタックに積まれている値(環境)</li> | |
183 </ul> | |
184 </td> | |
185 <td> | |
186 <ul> | |
187 <li>Cの継続から環境を除外</li> | |
188 <li>続く命令とその命令に必要なデータのみ</li> | |
189 </ul> | |
190 </td> | |
191 </tr> | |
192 <t> | |
193 <td style="margin-left:auto; margin-right: auto; text-align: center;"> | |
194 <img class="scale" src="file:///Users/aotokage/hg/Papers/2012/nobu-thesis/presen/./pix/func_call.png" style="height: 18em;"> | |
195 </td> | |
196 <td style="margin-left:auto; margin-right: auto; text-align: center;"> | |
197 <img class="scale" src="./pix/cs_stack.png" style="height: 18em;"> | |
198 </td> | |
199 </tr> | |
200 </table></p></section> | |
201 | |
202 </div> | |
203 <div class="presenter_notes"> | |
204 <header><h1>Presenter Notes</h1></header> | |
205 <section> | |
206 | |
207 </section> | |
208 </div> | |
209 <footer> | |
210 | |
211 <aside class="source"> | |
212 Source: <a href="./cbc.md">./cbc.md</a> | |
213 </aside> | |
214 | |
215 <aside class="page_number"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
216 4/21 |
27 | 217 </aside> |
218 </footer> | |
219 </div> | |
220 </div> | |
221 | |
222 <!-- slide source: ./cbc.md --> | |
223 <div class="slide-wrapper"> | |
224 <div class="slide"> | |
225 <div class="inner"> | |
226 | |
227 <header><h1>Continuation based C</h1></header> | |
228 | |
229 | |
230 <section><p><table width=100% border=1> | |
231 <caption>階乗を求める CbC のプログラム</caption> | |
232 <td> | |
233 <pre> | |
234 __code print_factorial(int prod) | |
235 { | |
236 printf("factorial = %d\n",prod); | |
237 exit(0); | |
238 } | |
239 __code factorial0(int prod, int x) | |
240 { | |
241 if ( x >= 1) { | |
242 goto factorial0(prod<em>x, x-1); | |
243 }else{ | |
244 goto print_factorial(prod); | |
245 } | |
246 } | |
247 __code factorial(int x) | |
248 { | |
249 goto factorial0(1, x); | |
250 } | |
251 int main(int argc, char </em>*argv) | |
252 { | |
253 int i; | |
254 i = atoi(argv[1]); | |
255 goto factorial(i); | |
256 } | |
257 </pre> | |
258 </td> | |
259 <td> | |
260 <li>__code によるコードセグメントの宣言</li> | |
261 <li>goto によるコードセグメントへの継続</li> | |
31 | 262 <li>call ではなく jmp で処理を移る</li> |
27 | 263 </td> |
264 </table></p></section> | |
265 | |
266 </div> | |
267 <div class="presenter_notes"> | |
268 <header><h1>Presenter Notes</h1></header> | |
269 <section> | |
270 | |
271 </section> | |
272 </div> | |
273 <footer> | |
274 | |
275 <aside class="source"> | |
276 Source: <a href="./cbc.md">./cbc.md</a> | |
277 </aside> | |
278 | |
279 <aside class="page_number"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
280 5/21 |
27 | 281 </aside> |
282 </footer> | |
283 </div> | |
284 </div> | |
285 | |
286 <!-- slide source: ./cbc.md --> | |
287 <div class="slide-wrapper"> | |
288 <div class="slide"> | |
289 <div class="inner"> | |
290 | |
291 <header><h1>CbC の実装 : Tail Call Elimination</h1></header> | |
292 | |
293 | |
294 <section><p><li>CbC-GCC の軽量継続は最適化の1つ, <font color=red>Tail Call Celimination(末尾除去)</font>により実装されている.</li></p> | |
295 <h2>Tail Call Elimination</h2> | |
296 <p><li>関数呼び出しを call ではなく jmp 命令で行う最適化</li> | |
31 | 297 <li>例えば、以下の場合関数 g は jmp 命令で関数 f へと処理が移る</li></p> |
298 <table width=100% border=1> | |
27 | 299 <tr> |
300 <td width=50%> | |
301 <pre> | |
302 void f(int a, int b) { | |
303 printf("f: a=%d b=%d\n",a,b); | |
304 return ; | |
305 } | |
306 | |
307 void g(int a, int b){ | |
308 printf("g: a=%d b=%d\n",a,b); | |
309 f(a,b); | |
310 return; | |
311 } | |
312 | |
313 int main() { | |
314 g(3,4); | |
315 return 0; | |
316 } | |
317 </pre> | |
318 </td> | |
319 <td> | |
320 <img src="file:///Users/aotokage/hg/Papers/2012/nobu-thesis/presen/./pix/continuation.png" style="height:80%;"> | |
321 </td> | |
322 </tr> | |
323 </table></section> | |
324 | |
325 </div> | |
326 <div class="presenter_notes"> | |
327 <header><h1>Presenter Notes</h1></header> | |
328 <section> | |
329 | |
330 </section> | |
331 </div> | |
332 <footer> | |
333 | |
334 <aside class="source"> | |
335 Source: <a href="./cbc.md">./cbc.md</a> | |
336 </aside> | |
337 | |
338 <aside class="page_number"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
339 6/21 |
27 | 340 </aside> |
341 </footer> | |
342 </div> | |
343 </div> | |
344 | |
345 <!-- slide source: ./cbc.md --> | |
346 <div class="slide-wrapper"> | |
347 <div class="slide"> | |
348 <div class="inner"> | |
349 | |
350 <header><h1>CbC の実装: Tail Call Elimination</h1></header> | |
351 | |
352 | |
353 <section><h2>Tail Call Elimination の条件</h2> | |
354 <p><ul> | |
355 <li>caller側とcallee側の戻値の型の一致している。</li> | |
356 <li>関数呼び出しがリターン直前に行われている。</li> | |
357 <li>呼出先関数の引数に用いられるスタックサイズが呼出元のそれより少ない。</li> | |
358 <li>引数の並びのコピーに上書きがない。</li> | |
359 </ul></p> | |
360 <h2>条件回避の為の実装</h2> | |
361 <p><ul> | |
362 <li>コードセグメントの型はvoid型で統一する。</li> | |
363 <li>gotoの直後に自動で return を置く。</li> | |
364 <li>スタックサイズは固定にする。</li> | |
365 <li>引数は一旦、一時変数にコピーする。</li> | |
366 </ul></p></section> | |
367 | |
368 </div> | |
369 <div class="presenter_notes"> | |
370 <header><h1>Presenter Notes</h1></header> | |
371 <section> | |
372 | |
373 </section> | |
374 </div> | |
375 <footer> | |
376 | |
377 <aside class="source"> | |
378 Source: <a href="./cbc.md">./cbc.md</a> | |
379 </aside> | |
380 | |
381 <aside class="page_number"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
382 7/21 |
27 | 383 </aside> |
384 </footer> | |
385 </div> | |
386 </div> | |
387 | |
388 <!-- slide source: ./cbc.md --> | |
389 <div class="slide-wrapper"> | |
390 <div class="slide"> | |
391 <div class="inner"> | |
392 | |
28 | 393 <header><h1>CbC の実装: Tail Call Elimination</h1></header> |
394 | |
27 | 395 |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
396 <section><h2>Tail Call Elimination の条件をチェックする関数</h2> |
28 | 397 <ul> |
398 <li>今までの実装では Tail Call Elimination の条件をクリアする為に専用の関数を用意していた。</li> | |
399 <li>この専用関数は元々ある GCC コードを元に作成している為, アップデートに合わせて修正していく | |
400 必要があった。</li> | |
401 <li>しかし, 今回の実装でその関数を無くし, Tail Call Elimination のフラグを強制的に立たせる実装に変更。</li> | |
29 | 402 <li>専用関数がなくなったことで今後より楽なアップデートを行なっていくことができるようになった。</li> |
28 | 403 </ul></section> |
27 | 404 |
405 </div> | |
406 <div class="presenter_notes"> | |
407 <header><h1>Presenter Notes</h1></header> | |
408 <section> | |
409 | |
410 </section> | |
411 </div> | |
412 <footer> | |
413 | |
414 <aside class="source"> | |
415 Source: <a href="./cbc.md">./cbc.md</a> | |
416 </aside> | |
417 | |
418 <aside class="page_number"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
419 8/21 |
27 | 420 </aside> |
421 </footer> | |
422 </div> | |
423 </div> | |
424 | |
425 <!-- slide source: ./cbc.md --> | |
426 <div class="slide-wrapper"> | |
427 <div class="slide"> | |
428 <div class="inner"> | |
429 | |
430 <header><h1>性能評価</h1></header> | |
431 | |
432 | |
29 | 433 <section><li>conv1: 演算と継続を交互に繰り返すプログラム</li> |
27 | 434 |
435 <table width=100%> | |
436 <caption>各コンパイラにより生成されたコードの速度比較</caption> | |
437 <td style="margin:auto; text-align:center;"> | |
438 <img src="file:///Users/aotokage/hg/Papers/2012/nobu-thesis/presen/./pix/conv1_for_resume.png" style="height:15em"> | |
439 </td> | |
440 <td> | |
441 <img src="./pix/conv1_mac_for_presen.png" style="height:15em"> | |
442 </td> | |
443 </table> | |
444 | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
445 <li>GCC-4.5 では動かなかったプログラムが GCC-4.6 では問題なく動いている。</li> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
446 |
29 | 447 <li>引数 2、3 の結果はほぼ同じ</li> |
27 | 448 |
31 | 449 <li>引数 1 の結果では 32bit, 64bit 共に GCC-4.6 の方が 1.5倍以上早い</li></section> |
27 | 450 |
451 </div> | |
452 <div class="presenter_notes"> | |
453 <header><h1>Presenter Notes</h1></header> | |
454 <section> | |
455 | |
456 </section> | |
457 </div> | |
458 <footer> | |
459 | |
460 <aside class="source"> | |
461 Source: <a href="./cbc.md">./cbc.md</a> | |
462 </aside> | |
463 | |
464 <aside class="page_number"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
465 9/21 |
27 | 466 </aside> |
467 </footer> | |
468 </div> | |
469 </div> | |
470 | |
471 <!-- slide source: ./cbc.md --> | |
472 <div class="slide-wrapper"> | |
473 <div class="slide"> | |
474 <div class="inner"> | |
475 | |
476 <header><h1>最適化の比較</h1></header> | |
477 | |
478 | |
479 <section><p><table width=100% border=1> | |
29 | 480 <caption>それぞれの最適化にかかった conv1プログラムの挙動(引数 1)</caption> |
27 | 481 <tr> |
482 <td>最適化</td> | |
483 <td style="text-align:center;">状態遷移</td> | |
484 </tr> | |
485 <tr> | |
486 <td>最適化無し</td> | |
487 <td style="margin:auto; text-align:center;"> | |
488 <img src="file:///Users/aotokage/hg/Papers/2012/nobu-thesis/presen/./pix/state_conv1_noopt.png"> | |
489 </td> | |
490 <tr> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
491 <td>GCC-4.5<br>の最適化<br>(-O2)</td> |
27 | 492 <td style="margin:auto; text-align:center;"> |
493 <img src="./pix/state_conv1_45.png"> | |
494 </td> | |
495 </tr> | |
496 <tr> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
497 <td>GCC-4.6<br>の最適化<br>(-O2)</td> |
27 | 498 <td style="margin:auto; text-align:center;"> |
499 <img src="./pix/state_conv1_46.png"> | |
500 </td> | |
501 </tr> | |
502 </table></p></section> | |
503 | |
504 </div> | |
505 <div class="presenter_notes"> | |
506 <header><h1>Presenter Notes</h1></header> | |
507 <section> | |
508 | |
509 </section> | |
510 </div> | |
511 <footer> | |
512 | |
513 <aside class="source"> | |
514 Source: <a href="./cbc.md">./cbc.md</a> | |
515 </aside> | |
516 | |
517 <aside class="page_number"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
518 10/21 |
27 | 519 </aside> |
520 </footer> | |
521 </div> | |
522 </div> | |
523 | |
524 <!-- slide source: ./cbc.md --> | |
525 <div class="slide-wrapper"> | |
526 <div class="slide"> | |
527 <div class="inner"> | |
528 | |
29 | 529 <header><h1>GCC の最適化</h1></header> |
530 | |
531 | |
532 <section><ul> | |
30 | 533 <li>最適化無しに比べると GCC-4.5、 GGC-4.6 共にコードセグメントの数が減っている。</l></li> |
31 | 534 <li>これは、最適化の 1 つ『インライン展開』により各コードセグメントの計算がまとめて行われ、 |
535 継続する数を減らされている為。</li> | |
30 | 536 <li>GCC-4.5 でもインライン展開はされていたが、GCC-4.6 はより良い最適化がかけられている。</li> |
537 </ul></section> | |
29 | 538 |
539 </div> | |
540 <div class="presenter_notes"> | |
541 <header><h1>Presenter Notes</h1></header> | |
542 <section> | |
543 | |
544 </section> | |
545 </div> | |
546 <footer> | |
547 | |
548 <aside class="source"> | |
549 Source: <a href="./cbc.md">./cbc.md</a> | |
550 </aside> | |
551 | |
552 <aside class="page_number"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
553 11/21 |
30 | 554 </aside> |
555 </footer> | |
556 </div> | |
557 </div> | |
558 | |
559 <!-- slide source: ./cbc.md --> | |
560 <div class="slide-wrapper"> | |
561 <div class="slide"> | |
562 <div class="inner"> | |
563 | |
31 | 564 <header><h1>アップデートに合わせる有用性</h1></header> |
30 | 565 |
566 | |
567 <section><ul> | |
568 <li>今回の『インライン展開』のように GCC の最適化は日々改良されていく。</li> | |
569 <li>また、既存の最適化の改良だけでなく新たな最適化の追加等も行われていく。</li> | |
570 <li>それらの恩恵を受ける為にも GCC のアップデートに合わせていく事は今後も重要である。</li> | |
571 </ul></section> | |
572 | |
573 </div> | |
574 <div class="presenter_notes"> | |
575 <header><h1>Presenter Notes</h1></header> | |
576 <section> | |
577 | |
578 </section> | |
579 </div> | |
580 <footer> | |
581 | |
582 <aside class="source"> | |
583 Source: <a href="./cbc.md">./cbc.md</a> | |
584 </aside> | |
585 | |
586 <aside class="page_number"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
587 12/21 |
29 | 588 </aside> |
589 </footer> | |
590 </div> | |
591 </div> | |
592 | |
593 <!-- slide source: ./cbc.md --> | |
594 <div class="slide-wrapper"> | |
595 <div class="slide"> | |
596 <div class="inner"> | |
597 | |
598 <header><h1>まとめ</h1></header> | |
599 | |
600 | |
601 <section><ul> | |
30 | 602 <li>今回 CbC-GCC を GCC-4.6 へとアップデートを行った。</li> |
603 <li>アップデートに伴い最適化の強制付与や環境付き継続の部分の実装の修正を行った。</li> | |
604 <li>アップデートにかけたことで, より良い最適化がかかることを確認できた。</li> | |
605 <li>GCC ベースの CbC コンパイラは今後 GCC のアップデートに合わせていくだけとなる。</li> | |
29 | 606 </ul> |
607 <h2>今後の課題</h2> | |
608 <ul> | |
609 <li>LLVM ベースの CbC コンパイラの開発</li> | |
610 <li>google Go 言語への実装の検討</li> | |
611 </ul></section> | |
612 | |
613 </div> | |
614 <div class="presenter_notes"> | |
615 <header><h1>Presenter Notes</h1></header> | |
616 <section> | |
617 | |
618 </section> | |
619 </div> | |
620 <footer> | |
621 | |
622 <aside class="source"> | |
623 Source: <a href="./cbc.md">./cbc.md</a> | |
624 </aside> | |
625 | |
626 <aside class="page_number"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
627 13/21 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
628 </aside> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
629 </footer> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
630 </div> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
631 </div> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
632 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
633 <!-- slide source: ./cbc.md --> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
634 <div class="slide-wrapper"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
635 <div class="slide"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
636 <div class="inner"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
637 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
638 <header><h1>jmp と call</h1></header> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
639 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
640 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
641 <section><p><table width=100%> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
642 <caption>インライン展開無しの conv1 プログラム実行結果</caption> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
643 <td style="text-align:center;"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
644 <img src="file:///Users/aotokage/hg/Papers/2012/nobu-thesis/presen/./pix/fno_inline.png"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
645 </td> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
646 </table></p> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
647 <li>引数 0 は C の関数で書かれたプログラム</li> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
648 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
649 <li>引数 3 は引数 0 のプログラムをただ CbC に書き直したもの</li></section> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
650 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
651 </div> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
652 <div class="presenter_notes"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
653 <header><h1>Presenter Notes</h1></header> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
654 <section> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
655 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
656 </section> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
657 </div> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
658 <footer> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
659 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
660 <aside class="source"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
661 Source: <a href="./cbc.md">./cbc.md</a> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
662 </aside> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
663 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
664 <aside class="page_number"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
665 14/21 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
666 </aside> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
667 </footer> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
668 </div> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
669 </div> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
670 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
671 <!-- slide source: ./cbc.md --> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
672 <div class="slide-wrapper"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
673 <div class="slide"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
674 <div class="inner"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
675 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
676 <header><h1>構文の追加</h1></header> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
677 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
678 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
679 <section><h2>リカーシブタイプの宣言に使う"__rectype"</h2> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
680 <ul> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
681 <li>関数宣言時、以下のように引数に自分自身を指す型を入れたい。 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
682 <pre> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
683 __code func(int, func*); |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
684 <pre></li> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
685 <li>上記の宣言ではエラーがでる。その為、以下のような宣言になる。 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
686 <pre> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
687 __code func(int, __code (*)()); |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
688 </pre></li> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
689 <li>しかし、これでは正しい情報をコンパイラに渡せていない。関数ポインタの引数に型情報が入っていないからである。 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
690 <pre> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
691 __code func(int, __code (<em>)(int, __code(</em>)(int, __code(*)(int, ...)))) |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
692 </pre></li> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
693 <li>だが、正しい情報を渡そうとすると上記のように再帰してしまい、宣言できない。</li> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
694 <li>そこで __rectype という構文を追加して宣言中の関数自身を指すようにした。 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
695 <pre> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
696 __code func(int, rectype*); |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
697 </pre></li> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
698 </ul></section> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
699 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
700 </div> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
701 <div class="presenter_notes"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
702 <header><h1>Presenter Notes</h1></header> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
703 <section> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
704 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
705 </section> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
706 </div> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
707 <footer> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
708 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
709 <aside class="source"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
710 Source: <a href="./cbc.md">./cbc.md</a> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
711 </aside> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
712 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
713 <aside class="page_number"> |
32 | 714 15/21 |
30 | 715 </aside> |
716 </footer> | |
717 </div> | |
718 </div> | |
719 | |
720 <!-- slide source: ./cbc.md --> | |
721 <div class="slide-wrapper"> | |
722 <div class="slide"> | |
723 <div class="inner"> | |
724 | |
725 <header><h1>conv1 プログラム</h1></header> | |
726 | |
727 | |
728 <section><ul> | |
729 <li>conv1 プログラムでは計算と継続を交互に繰り返し行なう。</li> | |
730 <li> | |
731 <p>しかし状態のいくつかへは関数ポインタとして保存させておき継続を行う。 | |
732 <pre> | |
733 __code g(int i,stack sp) { // Caller | |
734 struct f_g0_interface <em>c = | |
32 | 735 (struct f_g0_interface </em>)(sp -= sizeof(struct f_g0_interface)); |
736 c->ret = g_h1; | |
737 c->i_ = i; | |
738 goto h(i+3,sp); | |
739 } | |
740 __code h(int i,stack sp) { | |
30 | 741 struct f_g0_interface <em>c = (struct f_g0_interface </em>)sp; |
742 goto (c->ret)(i+4,sp); | |
743 } | |
744 </pre></p> | |
32 | 745 </li> |
746 <li> | |
747 <p>関数ポインタへの継続はインライン展開されない。</p> | |
748 </li> | |
30 | 749 </ul></section> |
750 | |
751 </div> | |
752 <div class="presenter_notes"> | |
753 <header><h1>Presenter Notes</h1></header> | |
754 <section> | |
755 | |
756 </section> | |
757 </div> | |
758 <footer> | |
759 | |
760 <aside class="source"> | |
761 Source: <a href="./cbc.md">./cbc.md</a> | |
762 </aside> | |
763 | |
764 <aside class="page_number"> | |
32 | 765 16/21 |
29 | 766 </aside> |
767 </footer> | |
768 </div> | |
769 </div> | |
770 | |
771 <!-- slide source: ./cbc.md --> | |
772 <div class="slide-wrapper"> | |
773 <div class="slide"> | |
774 <div class="inner"> | |
775 | |
776 <header><h1>CbC の実装: 環境付き継続</h1></header> | |
777 | |
778 | |
779 <section><ul> | |
780 <li>環境付き継続: C との互換を取るための機能。継続を行った C の関数に戻ることができる。 </li> | |
781 <li>_CbC_return、 _CbC_environment キーワードを使うことで使える。</li> | |
782 <li> | |
783 <p>以下の使い方の場合、戻値 1 を返す。 | |
784 <pre> | |
785 <strong>code c1(</strong>code ret(int,void <em>),void </em>env) { | |
786 goto ret(1,env); | |
787 } | |
788 int main() { | |
789 goto c1(<strong>return, </strong>environment); | |
790 } | |
791 </pre></p> | |
792 </li> | |
793 <li> | |
794 <p>今回この環境付き継続をスレッドセーフの実装へと修正した。</p> | |
795 </li> | |
796 </ul></section> | |
797 | |
798 </div> | |
799 <div class="presenter_notes"> | |
800 <header><h1>Presenter Notes</h1></header> | |
801 <section> | |
802 | |
803 </section> | |
804 </div> | |
805 <footer> | |
806 | |
807 <aside class="source"> | |
808 Source: <a href="./cbc.md">./cbc.md</a> | |
809 </aside> | |
810 | |
811 <aside class="page_number"> | |
32 | 812 17/21 |
29 | 813 </aside> |
814 </footer> | |
815 </div> | |
816 </div> | |
817 | |
818 <!-- slide source: ./cbc.md --> | |
819 <div class="slide-wrapper"> | |
820 <div class="slide"> | |
821 <div class="inner"> | |
822 | |
823 <header><h1>CbC 引数渡し</h1></header> | |
824 | |
825 | |
826 <section><p><li>CbC では引数渡しにできるだけレジスタを用いるようにしている.</li> | |
827 <table border=1 width=100%> | |
828 <caption><small>fastcall属性有・無の実行速度</small></caption> | |
829 <tr> | |
830 <td width=50% style="text-align:center;">fastcall無し</td> | |
831 </tr> | |
832 <tr> | |
833 <td style="margin:auto; text-align:center;"> | |
834 <img src="file:///Users/aotokage/hg/Papers/2012/nobu-thesis/presen/./pix/linux_conv_nofastcall.png" style="height:15em;"> | |
835 </td> | |
836 </tr> | |
837 <tr> | |
838 <td width=50% style="text-align:center;">fastcall有り</td> | |
839 <tr> | |
840 <td> | |
841 <img src="./pix/linux_conv_fastcall.png" style="height:15em;"> | |
842 </td> | |
843 </tr> | |
844 </table></p></section> | |
845 | |
846 </div> | |
847 <div class="presenter_notes"> | |
848 <header><h1>Presenter Notes</h1></header> | |
849 <section> | |
850 | |
851 </section> | |
852 </div> | |
853 <footer> | |
854 | |
855 <aside class="source"> | |
856 Source: <a href="./cbc.md">./cbc.md</a> | |
857 </aside> | |
858 | |
859 <aside class="page_number"> | |
32 | 860 18/21 |
29 | 861 </aside> |
862 </footer> | |
863 </div> | |
864 </div> | |
865 | |
866 <!-- slide source: ./cbc.md --> | |
867 <div class="slide-wrapper"> | |
868 <div class="slide"> | |
869 <div class="inner"> | |
870 | |
871 <header><h1>GCC でのコンパイルの仕組み</h1></header> | |
872 | |
873 | |
874 <section><table width=100%> | |
875 <td style="margin:auto; text-align:center;"> | |
876 <img src="file:///Users/aotokage/hg/Papers/2012/nobu-thesis/presen/./pix/ir.png" style="height:15em"> | |
877 </td> | |
878 </table> | |
879 | |
880 <li>CbC の実装では Parser と RTL の生成部分に手が加えられている。</li></section> | |
881 | |
882 </div> | |
883 <div class="presenter_notes"> | |
884 <header><h1>Presenter Notes</h1></header> | |
885 <section> | |
886 | |
887 </section> | |
888 </div> | |
889 <footer> | |
890 | |
891 <aside class="source"> | |
892 Source: <a href="./cbc.md">./cbc.md</a> | |
893 </aside> | |
894 | |
895 <aside class="page_number"> | |
32 | 896 19/21 |
897 </aside> | |
898 </footer> | |
899 </div> | |
900 </div> | |
901 | |
902 <!-- slide source: ./cbc.md --> | |
903 <div class="slide-wrapper"> | |
904 <div class="slide"> | |
905 <div class="inner"> | |
906 | |
907 <header><h1>引数の並びに上書きコピー</h1></header> | |
908 | |
909 | |
910 <section><p><li>以下の呼び出しを行うと、スタックの書き換えがおこる</li> | |
911 <pre> | |
912 void funcA(int a, int b) { | |
913 funcB(b, a); | |
914 } | |
915 </pre></p> | |
916 <table width=100%> | |
917 <tr> | |
918 <td style="margin:auto; text-align:center;"> | |
919 <img src="file:///Users/aotokage/hg/Papers/2012/nobu-thesis/presen/./pix/cs_prog.png"> | |
920 </td> | |
921 </tr> | |
922 </table></section> | |
923 | |
924 </div> | |
925 <div class="presenter_notes"> | |
926 <header><h1>Presenter Notes</h1></header> | |
927 <section> | |
928 | |
929 </section> | |
930 </div> | |
931 <footer> | |
932 | |
933 <aside class="source"> | |
934 Source: <a href="./cbc.md">./cbc.md</a> | |
935 </aside> | |
936 | |
937 <aside class="page_number"> | |
30 | 938 20/21 |
29 | 939 </aside> |
940 </footer> | |
941 </div> | |
942 </div> | |
943 | |
944 <!-- slide source: ./cbc.md --> | |
945 <div class="slide-wrapper"> | |
946 <div class="slide"> | |
947 <div class="inner"> | |
948 | |
27 | 949 <header><h1>最適化の比較</h1></header> |
950 | |
951 | |
32 | 952 <section><table width=100% border=1> |
27 | 953 <caption>それぞれの最適化により吐かれたアセンブラコード</caption> |
954 <tr> | |
955 <td width=50% style="text-align:center;">CbC-GCC-4.5</td> | |
956 <td width=50% style="text-align:center;">CbC-GCC-4.6</td> | |
32 | 957 </tr> |
958 | |
959 <tr> | |
27 | 960 <td> |
961 <pre> | |
962 main: | |
963 call f | |
964 : | |
965 jmp f_g0 | |
966 : | |
967 movq $f_g1, -24(%rdx) | |
968 addl $10, %edi | |
969 movq $g_h1, -48(%rdx) | |
970 jmp g_h1 | |
971 : | |
972 movq 24(%rsi), %rdx | |
973 movq %rax, %rsi | |
974 : | |
32 | 975 jmp *%rdx |
27 | 976 : |
977 movq 24(%rsi), %rdx | |
978 : | |
32 | 979 jmp *%rdx |
27 | 980 </pre> |
981 </td> | |
982 <td> | |
983 <pre> | |
984 main: | |
985 movq $f_g1, main_stack+2000(%rip) | |
986 : | |
987 call g_h1 | |
988 : | |
989 movq 24(%rax), %rdx | |
990 : | |
32 | 991 jmp *%rdx |
27 | 992 : |
993 movq 24(%rax), %rdx | |
994 : | |
32 | 995 jmp *%rdx |
27 | 996 </pre> |
997 </td> | |
998 </tr> | |
999 <!-- | |
1000 <tr> | |
32 | 1001 <td></td> |
1002 <td></td> | |
1003 </tr> | |
1004 --> | |
1005 | |
1006 </table> | |
27 | 1007 <li>関数を展開してその場で計算する『インライン展開』がより強力になっているのが確認できる</li> |
1008 <!-- | |
1009 <li>保存していた関数ポインタへの継続はインライン展開は行われない</li> | |
32 | 1010 --> |
1011 | |
1012 ---</section> | |
27 | 1013 |
1014 </div> | |
1015 <div class="presenter_notes"> | |
1016 <header><h1>Presenter Notes</h1></header> | |
1017 <section> | |
1018 | |
1019 </section> | |
1020 </div> | |
1021 <footer> | |
1022 | |
1023 <aside class="source"> | |
1024 Source: <a href="./cbc.md">./cbc.md</a> | |
1025 </aside> | |
1026 | |
1027 <aside class="page_number"> | |
30 | 1028 21/21 |
27 | 1029 </aside> |
1030 </footer> | |
1031 </div> | |
1032 </div> | |
1033 | |
1034 </div> | |
1035 </div> | |
1036 | |
1037 <div id="toc" class="sidebar hidden"> | |
1038 <h2>Table of Contents</h2> | |
1039 <table> | |
1040 <caption>Table of Contents</caption> | |
1041 | |
1042 <tr id="toc-row-1"> | |
28 | 1043 <th><a href="#slide1">Continuation based C の <br> GCC 4.6による実装</a></th> |
27 | 1044 <td><a href="#slide1">1</a></td> |
1045 </tr> | |
1046 | |
1047 | |
1048 <tr id="toc-row-2" class="sub"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1049 <th><a href="#slide2">研究の背景と成果</a></th> |
27 | 1050 <td><a href="#slide2">2</a></td> |
1051 </tr> | |
1052 | |
1053 | |
1054 | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1055 <tr id="toc-row-3"> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1056 <th><a href="#slide3">Continuation based C</a></th> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1057 <td><a href="#slide3">3</a></td> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1058 </tr> |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1059 |
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1060 |
27 | 1061 <tr id="toc-row-4"> |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1062 <th><a href="#slide4">Continuation based C</a></th> |
27 | 1063 <td><a href="#slide4">4</a></td> |
1064 </tr> | |
1065 | |
1066 | |
1067 <tr id="toc-row-5"> | |
1068 <th><a href="#slide5">Continuation based C</a></th> | |
1069 <td><a href="#slide5">5</a></td> | |
1070 </tr> | |
1071 | |
1072 | |
1073 <tr id="toc-row-6"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1074 <th><a href="#slide6">CbC の実装 : Tail Call Elimination</a></th> |
27 | 1075 <td><a href="#slide6">6</a></td> |
1076 </tr> | |
1077 | |
1078 | |
1079 <tr id="toc-row-7"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1080 <th><a href="#slide7">CbC の実装: Tail Call Elimination</a></th> |
27 | 1081 <td><a href="#slide7">7</a></td> |
1082 </tr> | |
1083 | |
1084 | |
1085 <tr id="toc-row-8"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1086 <th><a href="#slide8">CbC の実装: Tail Call Elimination</a></th> |
27 | 1087 <td><a href="#slide8">8</a></td> |
1088 </tr> | |
1089 | |
1090 | |
1091 <tr id="toc-row-9"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1092 <th><a href="#slide9">性能評価</a></th> |
27 | 1093 <td><a href="#slide9">9</a></td> |
1094 </tr> | |
1095 | |
1096 | |
1097 <tr id="toc-row-10"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1098 <th><a href="#slide10">最適化の比較</a></th> |
27 | 1099 <td><a href="#slide10">10</a></td> |
1100 </tr> | |
1101 | |
1102 | |
1103 <tr id="toc-row-11"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1104 <th><a href="#slide11">GCC の最適化</a></th> |
27 | 1105 <td><a href="#slide11">11</a></td> |
1106 </tr> | |
1107 | |
1108 | |
1109 <tr id="toc-row-12"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1110 <th><a href="#slide12">アップデートに合わせる有用性</a></th> |
27 | 1111 <td><a href="#slide12">12</a></td> |
1112 </tr> | |
1113 | |
1114 | |
1115 <tr id="toc-row-13"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1116 <th><a href="#slide13">まとめ</a></th> |
27 | 1117 <td><a href="#slide13">13</a></td> |
1118 </tr> | |
1119 | |
1120 | |
1121 <tr id="toc-row-14"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1122 <th><a href="#slide14">jmp と call</a></th> |
27 | 1123 <td><a href="#slide14">14</a></td> |
1124 </tr> | |
1125 | |
1126 | |
1127 <tr id="toc-row-15"> | |
34
3922a95e99a8
commit presen
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
1128 <th><a href="#slide15">構文の追加</a></th> |
27 | 1129 <td><a href="#slide15">15</a></td> |
1130 </tr> | |
1131 | |
1132 | |
1133 <tr id="toc-row-16"> | |
32 | 1134 <th><a href="#slide16">conv1 プログラム</a></th> |
27 | 1135 <td><a href="#slide16">16</a></td> |
1136 </tr> | |
1137 | |
1138 | |
1139 <tr id="toc-row-17"> | |
32 | 1140 <th><a href="#slide17">CbC の実装: 環境付き継続</a></th> |
27 | 1141 <td><a href="#slide17">17</a></td> |
1142 </tr> | |
1143 | |
1144 | |
1145 <tr id="toc-row-18"> | |
32 | 1146 <th><a href="#slide18">CbC 引数渡し</a></th> |
27 | 1147 <td><a href="#slide18">18</a></td> |
1148 </tr> | |
1149 | |
1150 | |
28 | 1151 <tr id="toc-row-19"> |
32 | 1152 <th><a href="#slide19">GCC でのコンパイルの仕組み</a></th> |
28 | 1153 <td><a href="#slide19">19</a></td> |
1154 </tr> | |
1155 | |
1156 | |
30 | 1157 <tr id="toc-row-20"> |
32 | 1158 <th><a href="#slide20">引数の並びに上書きコピー</a></th> |
30 | 1159 <td><a href="#slide20">20</a></td> |
1160 </tr> | |
1161 | |
1162 | |
1163 <tr id="toc-row-21"> | |
1164 <th><a href="#slide21">最適化の比較</a></th> | |
1165 <td><a href="#slide21">21</a></td> | |
1166 </tr> | |
1167 | |
1168 | |
27 | 1169 </table> |
1170 </div> | |
1171 | |
1172 <div id="help" class="sidebar hidden"> | |
1173 <h2>Help</h2> | |
1174 <table> | |
1175 <caption>Help</caption> | |
1176 <tr> | |
1177 <th>Table of Contents</th> | |
1178 <td>t</td> | |
1179 </tr> | |
1180 <tr> | |
1181 <th>Exposé</th> | |
1182 <td>ESC</td> | |
1183 </tr> | |
1184 <tr> | |
1185 <th>Full screen slides</th> | |
1186 <td>e</td> | |
1187 </tr> | |
1188 <tr> | |
1189 <th>Presenter View</th> | |
1190 <td>p</td> | |
1191 </tr> | |
1192 <tr> | |
1193 <th>Source Files</th> | |
1194 <td>s</td> | |
1195 </tr> | |
1196 <tr> | |
1197 <th>Slide Numbers</th> | |
1198 <td>n</td> | |
1199 </tr> | |
1200 <tr> | |
1201 <th>Toggle screen blanking</th> | |
1202 <td>b</td> | |
1203 </tr> | |
1204 <tr> | |
1205 <th>Show/hide slide context</th> | |
1206 <td>c</td> | |
1207 </tr> | |
1208 <tr> | |
1209 <th>Notes</th> | |
1210 <td>2</td> | |
1211 </tr> | |
1212 <tr> | |
1213 <th>Help</th> | |
1214 <td>h</td> | |
1215 </tr> | |
1216 </table> | |
1217 </div> | |
1218 <script>main()</script> | |
1219 </body> | |
1220 </html> |