annotate presen/slide.pdf.html @ 114:dbb1f18a47a6

update
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 19 Feb 2019 20:21:45 +0900
parents 327fc13703d9
children a13edfadfb4b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 <!DOCTYPE html>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 <html>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 <head>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 <meta http-equiv="content-type" content="text/html;charset=utf-8">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 <title>CbCによるPerl6処理系</title>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 <meta name="generator" content="Slide Show (S9) v4.0.1 on Ruby 2.5.1 (2018-03-29) [x86_64-darwin17]">
100
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
13 <meta name="author" content="清水隆博" >
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 <!-- style sheet links -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 <link rel="stylesheet" href="s6/themes/screen.css" media="screen">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 <link rel="stylesheet" href="s6/themes/print.css" media="print">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 <link rel="stylesheet" href="s6/themes/blank.css" media="screen,projection">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 <!-- JS -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 <script src="s6/js/jquery-1.11.3.min.js"></script>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 <script src="s6/js/jquery.slideshow.js"></script>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 <script src="s6/js/jquery.slideshow.counter.js"></script>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 <script src="s6/js/jquery.slideshow.controls.js"></script>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 <script src="s6/js/jquery.slideshow.footer.js"></script>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 <script src="s6/js/jquery.slideshow.autoplay.js"></script>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 <!-- prettify -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 <link rel="stylesheet" href="scripts/prettify.css">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 <script src="scripts/prettify.js"></script>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 <style>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 .slide {page-break-after: always;}
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 </style>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 </head>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 <body>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 <div class="layout">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 <div id="header"></div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 <div id="footer">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 <div align="right">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 <img src="s6/images/logo.svg" width="200px">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 <div class="presentation">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 <div class='slide cover'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 <table width="90%" height="90%" border="0" align="center">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 <tr>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 <td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 <div align="center">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 <h1><font color="#808db5">CbCによるPerl6処理系</font></h1>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 </td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 </tr>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 <tr>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 <td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 <div align="left">
100
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
65 清水隆博
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
66 並列信頼研
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 <hr style="color:#ffcc00;background-color:#ffcc00;text-align:left;border:none;width:100%;height:0.2em;">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 </td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 </tr>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 </table>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 <h2 id="研究目的">研究目的</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 <ul>
105
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
80 <li>Continuation based C (CbC)という言語は継続を基本とするC言語であり, 言語処理系に応用出来ると考えられる</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
81 <li>スクリプト言語などは, バイトコードを扱うが, この実行にcae文や, ラベルgotoなどを利用している。
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
82 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
83 <li>この部分はCbCの機能で書き換える事が可能である</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
84 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
85 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
86 <li>命令実行処理部分をモジュール化することで、各命令ごとの最適化や、 命令ディスパッチ部分の最適化を行う事が可能であると考える。</li>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
87 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
88
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
89
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
90
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
91 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
93 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
94 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
95 <h2 id="研究目的-1">研究目的</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
96 <ul>
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
97 <li>現在開発されているPerl6の実装にRakudoがある</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
98 <li>Rakudoはバイトコードを生成する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
99 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
100 <li>このバイトコードはMoarVMという専用の仮想機械が評価する</li>
110
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 108
diff changeset
101 <li>MoarVMはC言語で記述されている為、 Cと互換性のある言語であるCbCで書き直す事が可能である</li>
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
102 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
103 </li>
105
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
104 <li>本研究では, CbC用いてPerl6にC処理系であるMoarVMの一部書き換えを行い, 命令のモジュール化を検討する.</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 <h2 id="continuation-based-c-cbc">Continuation Based C (CbC)</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 <li>Continuation Based C (CbC) はCodeGearを単位として用いたプログラミング言語である.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 <li>CodeGearはCの通常の関数呼び出しとは異なり,スタックに値を積まず, 次のCodeGearにgoto文によって遷移する.</li>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
117 <li>CodeGear同士の移動は、 状態遷移として捉える事が出来る</li>
85
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
118 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
119
100
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
120 <p><img src="fig/cbc_sample.svg" /></p>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
121
85
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
122
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
124 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
126 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
127 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
128 <h2 id="continuation-based-c-cbc-1">Continuation Based C (CbC)</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
129
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
130 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
131 <li>CodeGearはCの関数宣言の型名の代わりに<code>__code</code>と書く事で宣言出来る</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
132 <li>CodeGearの引数は, 各CodeGearの入出力として利用する</li>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
133 <li>gotoしてしまうと、元のCodeGearに戻る事が出来ない</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
136 <pre><code>__code cg1(TEST testin){
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 TEST testout;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 testout.number = testin.number + 1;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 testout.string = "Hello";
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 goto cg2(testout);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 __code cg2(TEST testin){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 printf("number = %d\t string= %s\n",testin.number,testin.string);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 int main(){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 TEST test = {0,0};
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 goto cg1(test);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 <!-- _S9SLIDE_ -->
105
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
159 <h2 id="スクリプト言語処理系">スクリプト言語処理系</h2>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 <ul>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
161 <li>スクリプト言語は入力として与えられたソースコードを、 直接評価せずにバイトコードにコンパイルする形式が主流となっている</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
162 <li>その為スクリプト言語の実装は大きく2つで構成されている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
163 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
164 <li>バイトコードに変換するフロントエンド部分</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
165 <li>バイトコードを解釈する仮想機械</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
166 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
167 </li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169
100
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
170 <p><img src="fig/bytecode_sample_generally_lang.svg" width="80%" /></p>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 96
diff changeset
171
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 <h2 id="rakudo">Rakudo</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 <li>Rakudoとは現在のPerl6の主力な実装である.</li>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
181 <li>Rakudoは次の構成になっている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
182 <ul>
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
183 <li>実行環境のVM (MoarVM)</li>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
184 <li>Perl6のサブセットであるNQP(NotQuitPerl)</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
185 <li>NQPで記述されたPerl6(Rakudo)</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
186 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
187 </li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 <h2 id="moarvm">MoarVM</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 <li>Perl6専用のVMであり, Cで記述されている</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 <li>レジスタマシンとして実装されている.</li>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
201 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
202
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
203
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
204
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
205 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
206
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
207 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
208 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
209 <h2 id="moarvmのバイトコード">MoarVMのバイトコード</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
210
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
211 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
212 <li>MoarVMは16ビットのバイナリを命令バイトコードとして利用している</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
213 <li>命令にはその後に16ビットごとにオペランド(引数)を取るものがある</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
214 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
215
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
216 <pre><code>add_i loc_3_int, loc_0_int, loc_1_int
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
217 set loc_2_obj, loc_3_obj
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
218 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
219
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
220
111
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
221 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
222
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
223 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
224 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
225 <h2 id="moarvmのバイトコード-1">MoarVMのバイトコード</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
226
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
227 <pre><code>sub test_func(int $left, int $right){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
228 my int $sum := $left + $right;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
229 ++$sum;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
230 return $sum;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
231 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
232
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
233 my $arg1 := 1;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
234 my $arg2 := 8;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
235
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
236 say(test_func($arg1,$arg2));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
237
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
238 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
239
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
240
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
241
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
242 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
243
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
244 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
245 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
246 <h2 id="moarvmのバイトコード-2">MoarVMのバイトコード</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
247
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
248 <p><img src="fig/code_to_bytecode.svg" width="80%" style="text-align:center;padding-left: 100px;" /></p>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
249
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 110
diff changeset
250
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
251
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
252 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
253
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
254 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
255 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
256 <h2 id="moarvmのバイトコードインタプリタ">MoarVMのバイトコードインタプリタ</h2>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
257 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
258 <li>バイトコードは連続したメモリに確保されている</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
259 <li>その為次の処理を繰り返す必要がある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
260 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
261 <li>16ビットごとで読み込み</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
262 <li>読み込んだビットから、命令に対応する処理を呼び出し</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
263 <li>その処理を実行する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
264 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
265 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
266 <li>この処理をバイトコードディスパッチと呼び、 実行する部分をバイトコードインタプリタと呼ぶ</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
267 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
268
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
269
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
270
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
271 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
272
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
273 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
274 <!-- _S9SLIDE_ -->
106
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
275 <h2 id="mvm_interp_runの内部処理">MVM_interp_runの内部処理</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
276
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
277 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
278 <li>MoarVMは関数 <code>MVM_interp_run</code> でバイトコードに応じた処理を実行する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
279 <li>gccやclangを利用してコンパイルした場合、 ラベルgotoで命令ディスパッチが実行される</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
280 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
281
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
282 <p><img src="fig/origin_label_goto.svg" width="30%" style="text-align:center;padding-left: 300px;" /></p>
106
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
283
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
284
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
285
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
286 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
287
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
288 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 105
diff changeset
289 <!-- _S9SLIDE_ -->
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
290 <h2 id="moarvmのバイトコードインタプリタ-1">MoarVMのバイトコードインタプリタ</h2>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
291
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
292 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
293 <li>マクロDISPATCHで, ラベルgotoかcase文に変換が行われる
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
295 <li>バイトコードは数値として見る事が出来る為、 case文に対応する事が出来る</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 <li>この中の <code>OP</code> で宣言されたブロックがそれぞれバイトコードに対応する処理となっている.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 <pre><code>DISPATCH(NEXT_OP) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 OP(const_i64):
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 GET_REG(cur_op, 0).i64 = MVM_BC_get_I64(cur_op, 2);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 cur_op += 10;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 goto NEXT;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 <h2 id="mvm_interp_runで使用されているマクロ">MVM_interp_runで使用されているマクロ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 <pre><code>DISPATCH(NEXT_OP) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 OP(const_i64):
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 <ul>
107
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
323 <li>マクロ <code>OP</code> は次の様に定義している</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 <pre><code> #define OP(name) OP_ ## name
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 <ul>
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
330 <li>マクロ <code>OP</code> が, バイトコードの名前をC言語のラベルに変換する</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 <pre><code> OP_const_i16:
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
334 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
335
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
336 <pre><code> #OP_const_i16
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 <h2 id="mvm_interp_runで使用されているマクロ-1">MVM_interp_runで使用されているマクロ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
347 <pre><code> OP(const_i64):
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
348 GET_REG(cur_op, 0).i64 = MVM_BC_get_I64(cur_op, 2);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
349 cur_op += 10;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
350 goto NEXT;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
351 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
352
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
353 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
354 <li><code>cur_op</code>は次のバイトコード列が登録されており, マクロ <code>NEXT</code> で決められた方法で次のバイトコードに対応した処理に遷移する.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
355 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
356
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
357
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
358
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
359 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
360
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
361 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
362 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
363 <h2 id="mvm_interp_runで使用されているマクロ-2">MVM_interp_runで使用されているマクロ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
364
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
365 <pre><code> OP(const_i64):
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
366 GET_REG(cur_op, 0).i64 = MVM_BC_get_I64(cur_op, 2);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
367 cur_op += 10;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
368 goto NEXT;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
369 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
370
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 <ul>
107
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
372 <li>次の命令に移動する <code>NEXT</code>はラベルテーブルにアクセスし, ラベルを取り出す
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
373 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
374 <li>取り出したNEXTはラベルなので、 ラベルgotoの拡張が実装されている場合はgoto文でジャンプ出来る</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
375 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
376 </li>
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
377 <li>次の命令に対応する数値は, <code>NEXT_OP</code> というマクロで取り出す</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 <pre><code>#define NEXT_OP (op = *(MVMuint16 *)(cur_op), cur_op += 2, op)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 #define NEXT *LABELS[NEXT_OP]
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
386
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 <h2 id="mvm_interp_runのラベルテーブル">MVM_interp_runのラベルテーブル</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
394 <li>利用するCコンパイラが、ラベルgotoをサポートしている場合に実行される</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
395 <li>配列<code>LABELS</code>にアクセスし, ラベル情報を取得する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
396 <li>ラベル情報を取得出来ると、 そのラベルに対してラベルgotoを利用する</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
398
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 <pre><code>static const void * const LABELS[] = {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 &amp;&amp;OP_no_op,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 &amp;&amp;OP_const_i8,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 &amp;&amp;OP_const_i16,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 &amp;&amp;OP_const_i32,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 &amp;&amp;OP_const_i64,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 &amp;&amp;OP_const_n32,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 &amp;&amp;OP_const_n64,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 &amp;&amp;OP_const_s,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 &amp;&amp;OP_set,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 &amp;&amp;OP_extend_u8,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 &amp;&amp;OP_extend_u16,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 &amp;&amp;OP_extend_u32,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 &amp;&amp;OP_extend_i8,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 &amp;&amp;OP_extend_i16,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
415
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
416
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 <h2 id="mvm_interp_run">MVM_interp_run</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
425 <li>Cの実装の場合, switch文に展開される可能性がある
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 <ul>
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
427 <li>命令ディスパッチが書かれているCソースファイルの指定の場所にのみ処理を記述せざるを得ない</li>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
428 <li>1ファイルあたりの記述量が膨大になり, 命令のモジュール化ができない</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 </li>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
431 <li>高速化手法の、 Threaded Codeの実装を考えた場合, この命令に対応して大幅に処理系の実装を変更する必要がある.</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 <li>デバッグ時には今どの命令を実行しているか, ラベルテーブルを利用して参照せざるを得ず, 手間がかかる.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
435
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
436
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
438
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 <!-- _S9SLIDE_ -->
95
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
441 <h2 id="cbcでの変換">CbCでの変換</h2>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
442
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
444 <li>CbCのCodeGearは関数よりも小さな単位である</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
445 <li>その為、 従来は関数化出来なかった単位をCodeGearに変換する事が出来る</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 <li>CbCをMoarVMに適応すると, ラベルなどで制御していた命令に対応する処理をCodeGearで記述する事が可能である</li>
95
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
447 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
448
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
449
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
450
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
451 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
452
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
453 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
454 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
455 <h2 id="cbcmoarvmのバイトコードディスパッチ">CbCMoarVMのバイトコードディスパッチ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
456
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
457 <ul>
107
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 106
diff changeset
458 <li>オリジナルでは, マクロ <code>NEXT</code> が担当していた、 次のバイトコードへの移動は, NEXT相当のCodeGear <code>cbc_next</code>で処理を行う</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 <li>CodeGearの入出力として, MoarVMなどの情報をまとめた構造体を利用する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
461
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 <pre><code>__code cbc_next(INTERP i){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
463 __code (*c)(INTERP)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 c = CODES[(i-&gt;op = *(MVMuint16 *)(i-&gt;cur_op), i-&gt;cur_op += 2, i-&gt;op)]; // c = NEXT(i)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 goto c(i);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
467
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 __code cbc_const_i64(INTERP i){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 GET_REG(i-&gt;cur_op, 0,i).i64 = MVM_BC_get_I64(i-&gt;cur_op, 2);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 i-&gt;cur_op += 10;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 goto cbc_next(i);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
473
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
475
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
476
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
477
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 <h2 id="codegearの入出力インターフェイス">CodeGearの入出力インターフェイス</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 <li>MoarVMではレジスタの集合や命令列などをMVM_interp_runのローカル変数として利用し, 各命令実行箇所で参照している</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 <li>CodeGearに書き換えた場合, このローカル変数にはアクセスする事が不可能となる.</li>
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
487 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
488
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
489
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
490
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
491 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
492
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
493 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
494 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
495 <h2 id="codegearの入出力インターフェイス-1">CodeGearの入出力インターフェイス</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
496 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
497 <li>入出力としてMoarVMの情報をまとめた構造体interpのポインタであるINTERPを受け渡し, これを利用してアクセスする</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 <pre><code>typedef struct interp {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 MVMuint16 op;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 MVMuint8 *cur_op;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 MVMuint8 *bytecode_start;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 MVMRegister *reg_base;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 /* Points to the current compilation unit
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 . */
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 MVMCompUnit *cu;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 /* The current call site we’re
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 constructing. */
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 MVMCallsite *cur_callsite;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 MVMThreadContext *tc;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 } INTER,*INTERP;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 <h2 id="cbcmoarvmのcodegearテーブル">CbCMoarVMのCodeGearテーブル</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
522
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
524 <li>CodeGearテーブルは引数としてINTERを受け取るCodeGearの配列として定義する</li>
95
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
525 <li>テーブルとして宣言することで、 バイトコードの値をそのままテーブルに反映させる事が可能である</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
526 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
527
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
528 <pre><code>__code (* CODES[])(INTERP) = {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 cbc_no_op,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 cbc_const_i8,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 cbc_const_i16,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 cbc_const_i32,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 cbc_const_i64,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 cbc_const_n32,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 cbc_const_n64,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 cbc_const_s,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 cbc_set,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
538 cbc_extend_u8,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 cbc_extend_u16,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
541
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
542
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
543
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
545
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 <!-- _S9SLIDE_ -->
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
548 <h2 id="cbcmoarvmの状態遷移">CbCMoarVMの状態遷移</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
549
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
550 <p><img src="fig/cbc_next.svg" width="80%" style="text-align:center;padding-left: 120px;" /></p>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
551
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
552
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
553
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
554 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
555
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
556 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
557 <!-- _S9SLIDE_ -->
96
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
558 <h2 id="moarvmとcbcmoarvmのトレース">MoarVMとCbCMoarVMのトレース</h2>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
559
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 <ul>
96
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
561 <li>MoarVMのデバッグ時には、 次の命令が何であるかは直接は判断出来なかった</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
563
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 <pre><code>Breakpoint 1, dummy () at src/core/interp.c:46
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 46 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 #1 0x00007ffff75689da in MVM_interp_run (tc=0x604a20,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 initial_invoke=0x7ffff76c7168 &lt;toplevel_initial_invoke&gt;, invoke_data=0x67ff10)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 at src/core/interp.c:1169
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 1169 goto NEXT;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
570 $2 = 162
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 </code></pre>
96
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
572 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
573 <li>CbCMoarVMの場合は、 次に実行する命令名を確認する事が出来る</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
574 </ul>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 <pre><code>Breakpoint 2, cbc_next (i=0x7fffffffdc30) at src/core/cbc-interp.cbc:61
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
577 61 goto NEXT(i);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 $1 = (void (*)(INTERP)) 0x7ffff7566f53 &lt;cbc_takeclosure&gt;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 $2 = 162
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
581
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
582
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
583
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
585
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
586 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 <h2 id="moarvmのデバッグ">MoarVMのデバッグ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
589
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 <li>cur_opのみをPerlスクリプトなどを用いて抜き出し, 並列にログを取得したオリジナルと差分を図る</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 <li>この際に差異が発生したバイトコードを確認し, その前の状態で確認していく</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 <pre><code>25 : 25 : cbc_unless_i
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 247 : 247 : cbc_null
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 54 : 54 : cbc_return_o
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 140 : 140 : cbc_checkarity
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 558 : 558 : cbc_paramnamesused
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 159 : 159 : cbc_getcode
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 391 : 391 : cbc_decont
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 127 : 127 : cbc_prepargs
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
603 *139 : 162
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 cbc_invoke_o:cbc_takeclosure
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
606
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
607
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
608
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
610
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 <h2 id="現在のcbcmoarvm">現在のCbCMoarVM</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
614
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 <ul>
95
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
616 <li>現在はNQP, Rakudoのセルフビルドが達成でき, オリジナルと同等のテスト達成率を持っている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
617 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
618 <li>その為、 NQP, Rakudoの実行コマンドであるnqp perl6が起動する様になった</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
619 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
620 </li>
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
621 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
622
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
623
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
624
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
625 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
626
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
627 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
628 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
629 <h2 id="現在のcbcmoarvm-1">現在のCbCMoarVM</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
630 <ul>
95
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
631 <li>moarの起動時のオプションとして <code>--cbc</code> を与えることによりCbCかオリジナルを選択可能である</li>
108
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 107
diff changeset
632 <li><code>--cbc</code> オプションをmoarの起動時に設定することでCbCで書き換えたインタプリタが起動する</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
634
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 <pre><code>#!/bin/sh
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
636 exec /mnt/dalmore-home/one/src/Perl6/Optimize/llvm/build_perl6/bin/moar --cbc \
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 --libpath=/mnt/dalmore-home/one/src/Perl6/Optimize/llvm/build_perl6/share/nqp/lib \
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 /mnt/dalmore-home/one/src/Perl6/Optimize/llvm/build_perl6/share/nqp/lib/nqp.moarvm "$@"
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
639 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
640
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
641
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
642
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
643 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
644
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
646 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 <h2 id="cbcmoarvmと通常のmoarvmの比較">CbCMoarVMと通常のMoarVMの比較</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
648
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 <li>CbCMoarVMと通常のMoarVMの速度比較を行った</li>
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
651 <li>NQPで実装した2種類の例題を用いた
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
652 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
653 <li>単純なループで数値をインクリメントする例題</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
654 <li>再帰呼び出しを用いてフィボナッチ数列を求める例題</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
655 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
656 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
657 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
658
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
659
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
660
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
661 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
662
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
663 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
664 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
665 <h2 id="フィボナッチの例題">フィボナッチの例題</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
666
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
667 <pre><code>#! nqp
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
668
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
669 sub fib($n) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
670 $n &lt; 2 ?? $n !! fib($n-1) + fib($n - 2);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
671 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
672
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
673 my $N := 30;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
674 my $z := fib($N);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
675 say("fib($N) = " ~ fib($N));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
676 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
677
112
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
678
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
679
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
680 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
681
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
682 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
683 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
684 <h2 id="フィボナッチの例題-1">フィボナッチの例題</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
685
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
686 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
687 <li>フィボナッチの例題ではCbCMoarVMが劣る結果となった</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
689
104
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
690 <table style="border: 2px solid #595959;">
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
691 <tbody>
104
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
692 <tr style="border: 2px solid #595959;">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
693 <td style="border: 2px solid #595959;">[単位 sec]</td>
105
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
694 <td style="border: 2px solid #595959;"></td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
695 <td style="border: 2px solid #595959;"></td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
696 <td style="border: 2px solid #595959;"></td>
104
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
697 </tr>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
698 <tr style="border: 2px solid #595959;">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
699 <td style="border: 2px solid #595959;">MoarVM</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
700 <td style="border: 2px solid #595959;">1.379</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
701 <td style="border: 2px solid #595959;">1.350</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
702 <td style="border: 2px solid #595959;">1.346</td>
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
703 </tr>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
704 <tr>
104
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
705 <td style="border: 2px solid #595959;">CbCMoarVM</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
706 <td style="border: 2px solid #595959;">1.636</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
707 <td style="border: 2px solid #595959;">1.804</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
708 <td style="border: 2px solid #595959;">1.787</td>
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
709 </tr>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
710 </tbody>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
711 </table>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
712
104
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
713 <style type="text/css">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
714 table , td, th {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
715 border-collapse: collapse;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
716 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
717 td, th {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
718 padding: 12px;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
719 width: 120px;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
720 height: 40px;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
721 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
722 th {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
723 background: #f0e6cc;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
724 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
725 .even {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
726 background: #fbf8f0;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
727 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
728 .odd {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
729 background: #fefcf9;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
730 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
731 </style>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
732
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
733
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
734
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
735 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
736
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
737 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
738 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
739 <h2 id="単純ループ">単純ループ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
740
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
741 <pre><code>#! nqp
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
742
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
743 my $count := 100_000_000;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
744
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
745 my $i := 0;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
746
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
747 while ++$i &lt;= $count {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
748 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
749 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
750
112
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
751
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
752
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
753 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
754
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
755 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
756 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
757 <h2 id="単純ループ-1">単純ループ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
758
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 <ul>
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
760 <li>単純ループの場合は1.5secほど高速化した</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
761 <li>これは実行する命令コードが、 CPUのキャッシュに収まった為であると考えられる</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
762 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
763
104
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
764 <table style="border: 2px solid #595959;">
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
765 <tbody>
104
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
766 <tr style="border: 2px solid #595959;">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
767 <td style="border: 2px solid #595959;">[単位 sec]</td>
105
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
768 <td style="border: 2px solid #595959;"></td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
769 <td style="border: 2px solid #595959;"></td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
770 <td style="border: 2px solid #595959;"></td>
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
771 </tr>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
772 <tr>
104
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
773 <td style="border: 2px solid #595959;">MoarVM</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
774 <td style="border: 2px solid #595959;">7.499</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
775 <td style="border: 2px solid #595959;">7.844</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
776 <td style="border: 2px solid #595959;">7.822</td>
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
777 </tr>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
778 <tr>
104
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
779 <td style="border: 2px solid #595959;">CbCMoarVM</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
780 <td style="border: 2px solid #595959;">6.135</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
781 <td style="border: 2px solid #595959;">6.362</td>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 102
diff changeset
782 <td style="border: 2px solid #595959;">6.074</td>
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
783 </tr>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
784 </tbody>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
785 </table>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
786
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
787
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
788
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
789 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
790
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
791 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
792 <!-- _S9SLIDE_ -->
95
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
793 <h2 id="cbcmoarvmの利点">CbCMoarVMの利点</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
794 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
795 <li>バイトコードインタプリタの箇所をモジュール化する事が可能となった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
796 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
797 <li>CodeGearの再利用性や記述生が高まる</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
798 <li>CodeGearは関数の様に扱える為、 命令ディスパッチの最適化につながる実装が可能となった</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
799 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
800 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
801 <li>デバッグ時にラベルではなくCodeGearにbreakpointを設定可能となった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
802 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
803 <li>デバッグが安易となる</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
804 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
805 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
806 <li>CPUがキャッシュに収まる範囲の命令の場合、 通常のMoarVMよりも高速に動作する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
807 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
808
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
809
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
810
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
811 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
812
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
813 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
814 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
815 <h2 id="cbcmoarvmの欠点">CbCMoarVMの欠点</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
816
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
817 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
818 <li>MoarVMのオリジナルの更新頻度が高い為, 追従していく必要がある</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
819 <li>CodeGear側からCに戻る際に手順が複雑となる</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
820 <li>CodeGearを単位として用いる事で複雑なプログラミングが要求される.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
821 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
822
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
823
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
824
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
825 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
826
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
827 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 94
diff changeset
828 <!-- _S9SLIDE_ -->
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
829 <h2 id="まとめ">まとめ</h2>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
830 <ul>
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
831 <li>継続と基本としたC言語 Continuation Based Cを用いてPerl6の処理系の一部を書き直した
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
832 <ul>
105
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
833 <li>CodeGearによって, 本来はモジュール化出来ない箇所をモジュール化が可能となった</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 104
diff changeset
834 <li>デバッグが通常のディスパッチと比較して安易になった</li>
102
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
835 <li>CPUキャッシュに収まるループなどの命令の場合は、 通常のMoarVMよりも高速に動作する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
836 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
837 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 100
diff changeset
838 <li>今後はCodeGearの特性を活用し、 直接次の命令を実行する処理を実装する</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
839 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
840
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
841 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
842
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
843
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
844 </div><!-- presentation -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
845 </body>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
846 </html>