comparison presen/index.html @ 74:275073032132

modify
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 03 Jan 2012 19:21:51 +0900
parents 9250ac87c2c7
children 454ddda8d306
comparison
equal deleted inserted replaced
73:9250ac87c2c7 74:275073032132
7 <style type="text/css"> 7 <style type="text/css">
8 tr.srctr { 8 tr.srctr {
9 font-size:28px; 9 font-size:28px;
10 } 10 }
11 td.srctd { 11 td.srctd {
12 height:18em; 12 height:17em;
13 } 13 }
14 pre.srcbox { 14 pre.srcbox {
15 height: 100%; 15 height: 100%;
16 overflow: scroll; 16 overflow: scroll;
17 } 17 }
867 </div> 867 </div>
868 <!-- PAGE --> 868 <!-- PAGE -->
869 <div class="slide"> 869 <div class="slide">
870 <h1>CbCの実装:TCE(末尾除去)の実装について</h1> 870 <h1>CbCの実装:TCE(末尾除去)の実装について</h1>
871 <ul> 871 <ul>
872 <li>以前はexpand_call関数を元にしたexpand_cbc_goto関数を作って条件を回避させていた。</li> 872 <li>以前はexpand_call関数を元にしたexpand_cbc_goto関数を作り条件を回避させていた。</li>
873 <li>だがその方法だとexpand_call関数の修正にも合わせていく必要もあり管理も面倒であった。</li> 873 <li>だがその方法だとexpand_call関数の修正にも合わせていく必要もあり管理も面倒であった。</li>
874 <li>しかしtry_tail_callフラグを落とさせない方法にすることでexpand_cbc_goto関数はいらなくなり、管理が容易くなった。</li> 874 <li>しかしtry_tail_callフラグを落とさせない方法にすることでexpand_cbc_goto関数はいらなくなり、管理が容易くなった。</li>
875 </ul> 875 </ul>
876 </div> 876 </div>
877 <!-- PAGE --> 877 <!-- PAGE -->
878 <div class="slide"> 878 <div class="slide">
879 <h1>CbCの実装</h1> 879 <h1>CbCの実装</h1>
880 <li>CbCの基本機能を実現する為の実装は以上の2つになる。</li>
880 <ul> 881 <ul>
881 <li>シンタックスの追加</li> 882 <li>シンタックスの追加</li>
882 <li>末尾除去によるコードセグメントへjmp命令での処理の移り</li> 883 <li>末尾除去によるコードセグメントへjmp命令での処理の移り</li>
883 </ul> 884 </ul>
884 <li>この2つがGCCにおけるCbC実装の基本の部分となる。</li>
885 <li class="incremental">ここからはCbCの機能の拡張になる。</li> 885 <li class="incremental">ここからはCbCの機能の拡張になる。</li>
886 </div> 886 </div>
887 <!-- PAGE --> 887 <!-- PAGE -->
888 <!-- 888 <!--
889 <div class="slide"> 889 <div class="slide">
939 <h1>CbCの実装:引数渡し</h1> 939 <h1>CbCの実装:引数渡し</h1>
940 <ul> 940 <ul>
941 <li>fastcall属性の付与によりMicro-C版に速度で勝るようになった。</li> 941 <li>fastcall属性の付与によりMicro-C版に速度で勝るようになった。</li>
942 <li></li> 942 <li></li>
943 </ul> 943 </ul>
944
945 <table width=100% border=1 class="center"> 944 <table width=100% border=1 class="center">
946 <caption>引数渡しに使われるレジスタの数(gcc)</caption> 945 <caption>引数渡しに使われるレジスタの数(gcc)</caption>
947 <tr> 946 <tr>
948 <td>arch</td> 947 <td>arch</td>
949 <td>int(整数型)</td> 948 <td>int(整数型)</td>
989 <p><small>__environmentキーワードは関数の環境を保持する。</small></p> 988 <p><small>__environmentキーワードは関数の環境を保持する。</small></p>
990 </div> 989 </div>
991 <!-- PAGE --> 990 <!-- PAGE -->
992 <div class="slide"> 991 <div class="slide">
993 <h1>CbCの実装:環境付き継続</h1> 992 <h1>CbCの実装:環境付き継続</h1>
993 <!--
994 <li><small>生成しているコードと生成する為のコード</small></li> 994 <li><small>生成しているコードと生成する為のコード</small></li>
995 -->
995 <table border=1 width=100%> 996 <table border=1 width=100%>
996 <tr> 997 <tr>
997 <td><small>生成しているコード</small></td> 998 <td><small>生成しているコード</small></td>
998 <td><small>生成する為のコード</small></td> 999 <td><small>生成する為のコード</small></td>
999 </tr> 1000 </tr>
1000 <tr class="srctr"> 1001 <tr class="srctr">
1001 <td width=50% class="srctd"> 1002 <td width=50% class="srctd">
1002 <pre class="srcbox" style="width:25em;"> 1003 <pre class="srcbox" style="width:25em;">
1003 goto c1(__return, __environment); 1004
1004 1005 //goto c1(__return, __environment);
1005 goto c1(({ 1006 goto c1(({
1006 __label__ _cbc_exit0; 1007 __label__ _cbc_exit0;
1007 static int retval; 1008 static int retval;
1008 void _cbc_internal_return(int retval_, void *_envp) { 1009 void _cbc_internal_return(int retval_, void *_envp) {
1009 retval = retval_; 1010 retval = retval_;
1016 _cbc_internal_return; 1017 _cbc_internal_return;
1017 }), __environment); 1018 }), __environment);
1018 </pre> 1019 </pre>
1019 </td> 1020 </td>
1020 <td width=50% class="srctd"> 1021 <td width=50% class="srctd">
1022 <img src="./pix/STATEMENT_LIST_1.png" style="height: 10em;">
1023 </td>
1024 </tr>
1025 </table>
1026 <li><small>retval変数の型は継続を行った関数と同じ戻値の型となる。</small></li>
1027 <!--
1028 <li class="incremental">上記のコードをGCC内で生成すると次のようなTreeができる。</li>
1029 -->
1030 </div>
1031 <!-- PAGE -->
1032 <div class="slide">
1033 <h1>CbCの実装:環境付き継続</h1>
1034 <table border=1 width=100%>
1035 <tr>
1036 <td width=50%><small>生成されるTree</small></td>
1037 <td width=50%><small>生成する為のコード</small></td>
1038 </tr>
1039 <tr class="srctr">
1040 <td class="srctd">
1041 <img src="./pix/STATEMENT_LIST_1.png" style="height: 10em;">
1042 </td>
1043 <td class="srctd">
1021 <pre class="srcbox" style="width:25em;"> 1044 <pre class="srcbox" style="width:25em;">
1045
1022 case RID_CbC_RET: 1046 case RID_CbC_RET:
1023 { 1047 {
1024 tree value, stmt, label, tlab, decl; 1048 tree value, stmt, label, tlab, decl;
1025 c_parser_consume_token (parser); 1049 c_parser_consume_token (parser);
1026 1050
1062 1086
1063 TREE_SIDE_EFFECTS (stmt) = 1; 1087 TREE_SIDE_EFFECTS (stmt) = 1;
1064 expr.value = c_finish_stmt_expr (location, stmt); 1088 expr.value = c_finish_stmt_expr (location, stmt);
1065 expr.original_code = ERROR_MARK; 1089 expr.original_code = ERROR_MARK;
1066 } 1090 }
1091 </pre>
1067 </td> 1092 </td>
1068 </tr> 1093 </tr>
1069 </table> 1094 </table>
1070 <p>retval変数はint型になっているが、実際には継続を行った関数と同じ戻値の型となる。</p>
1071 <li class="incremental">上記のコードをGCC内で生成すると次のようなTreeができる。</li>
1072 </div>
1073 <!-- PAGE -->
1074 <div class="slide">
1075 <h1>CbCの実装:環境付き継続</h1>
1076 <h2>作成されるTree</h2>
1077 <img src="./pix/STATEMENT_LIST_1.png" style="height: 10em;">
1078 <!-- 1095 <!--
1079 <small> 1096 <small>
1080 <pre> 1097 <pre>
1081 ({ 1098 ({
1082 __label__ _cbc_exit0; 1099 __label__ _cbc_exit0;