annotate presen/slide.pdf.html @ 94:19df48819b8d

update
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 19 Feb 2019 15:02:16 +0900
parents 9c5bf7231557
children 77fb6e9e3c08
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]">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 <meta name="author" content="Takahiro Shimizu, Shinji Kono" >
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">
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 Takahiro Shimizu, Shinji Kono
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 琉球大学
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>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 <li>現在開発されているPerl6の実装にRakudoがあり, RakudoはNQP(Perl6のサブセット)で記述されたPerl6, NQPで記述されたNQPコンパイラ, NQPを解釈するVMで構成されている</li>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
81 <li>NQPコンパイラはRakudoのVMであるMoarVM用のバイトコードを生成する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
82 <li>MoarVMはこのバイトコードを解釈, 実行する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
83 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
84
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
85 <p><img src="fig/perl6nqp.svg" alt="" /></p>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
86
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
87
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 </div>
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 class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
92 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
93 <h2 id="研究目的-1">研究目的</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
94 <ul>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 <li>Continuation based C (CbC)という言語は継続を基本とするC言語であり, 言語処理系に応用出来ると考えられる</li>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
96 <li>スクリプト言語などは, バイトコードを扱うが, この実行にcae文や, ラベルgotoなどを利用している。
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
97 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
98 <li>この部分はCbCの機能で書き換える事が可能である</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
99 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
100 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
101 <li>命令実行処理部分をモジュール化することで、各命令ごとの最適化や、 命令ディスパッチ部分の最適化を行う事が可能であると考える。</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
102 <li>従って, CbC一部用いてPerl6にC処理系であるMoarVMの書き換えを行い, 処理を検討する.</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 </div>
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 class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 <h2 id="continuation-based-c-cbc">Continuation Based C (CbC)</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 <li>Continuation Based C (CbC) はCodeGearを単位として用いたプログラミング言語である.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 <li>CodeGearはCの通常の関数呼び出しとは異なり,スタックに値を積まず, 次のCodeGearにgoto文によって遷移する.</li>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
115 <li>CodeGear同士の移動は、 状態遷移として捉える事が出来る</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
116 <li>(図をいれる)</li>
85
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
117 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
118
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
119
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
120
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
121 </div>
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 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
124 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
125 <h2 id="continuation-based-c-cbc-1">Continuation Based C (CbC)</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
126
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
127 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
128 <li>CodeGearはCの関数宣言の型名の代わりに<code>__code</code>と書く事で宣言出来る</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 81
diff changeset
129 <li>CodeGearの引数は, 各CodeGearの入出力として利用する</li>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
130 <li>gotoしてしまうと、元のCodeGearに戻る事が出来ない</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
133 <pre><code>__code cg1(TEST testin){
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 TEST testout;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 testout.number = testin.number + 1;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 testout.string = "Hello";
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 goto cg2(testout);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 __code cg2(TEST testin){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 printf("number = %d\t string= %s\n",testin.number,testin.string);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 int main(){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 TEST test = {0,0};
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 goto cg1(test);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 <h2 id="言語処理系の応用">言語処理系の応用</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 <ul>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
158 <li>スクリプト言語は入力として与えられたソースコードを、 直接評価せずにバイトコードにコンパイルする形式が主流となっている</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
159 <li>その為スクリプト言語の実装は大きく2つで構成されている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
160 <ul>
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>バイトコードを解釈する仮想機械</li>
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>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 <h2 id="rakudo">Rakudo</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 <li>Rakudoとは現在のPerl6の主力な実装である.</li>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
176 <li>Rakudoは次の構成になっている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
177 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
178 <li>実行環境のVM</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
179 <li>Perl6のサブセットであるNQP(NotQuitPerl)</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
180 <li>NQPで記述されたPerl6(Rakudo)</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
181 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
182 </li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 <h2 id="moarvm">MoarVM</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 <li>Perl6専用のVMであり, Cで記述されている</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 <li>レジスタマシンとして実装されている.</li>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
196 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
197
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
198
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
199
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
200 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
201
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
202 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
203 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
204 <h2 id="moarvmのバイトコード">MoarVMのバイトコード</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
205
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
206 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
207 <li>MoarVMは16ビットのバイナリを命令バイトコードとして利用している</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
208 <li>命令にはその後に16ビットごとにオペランド(引数)を取るものがある</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
209 </ul>
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 <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
212 set loc_2_obj, loc_3_obj
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
213 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
214
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
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
217 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
218
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
219 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
220 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
221 <h2 id="moarvmのバイトコードインタプリタ">MoarVMのバイトコードインタプリタ</h2>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
222 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
223 <li>バイトコードは連続したメモリに確保されている</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
224 <li>その為次の処理を繰り返す必要がある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
225 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
226 <li>16ビットごとで読み込み</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
227 <li>読み込んだビットから、命令に対応する処理を呼び出し</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
228 <li>その処理を実行する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
229 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
230 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
231 <li>この処理をバイトコードディスパッチと呼び、 実行する部分をバイトコードインタプリタと呼ぶ</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
232 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
233
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
234
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
235
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
236 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
237
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
238 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
239 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
240 <h2 id="moarvmのバイトコードインタプリタ-1">MoarVMのバイトコードインタプリタ</h2>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
241
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
242 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
243 <li>MoarVMは関数 <code>MVM_interp_run</code> でバイトコードに応じた処理を実行する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
244 <li>マクロDISPATCHで, ラベルgotoかcase文に変換が行われる
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
246 <li>バイトコードは数値として見る事が出来る為、 case文に対応する事が出来る</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 <li>この中の <code>OP</code> で宣言されたブロックがそれぞれバイトコードに対応する処理となっている.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 <li><code>cur_op</code>は次のバイトコード列が登録されており, マクロ <code>NEXT</code> で決められた方法で次のバイトコードに対応した処理に遷移する.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 <pre><code>DISPATCH(NEXT_OP) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 OP(const_i64):
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 GET_REG(cur_op, 0).i64 = MVM_BC_get_I64(cur_op, 2);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 cur_op += 10;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 goto NEXT;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 <h2 id="mvm_interp_runで使用されているマクロ">MVM_interp_runで使用されているマクロ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 <pre><code>DISPATCH(NEXT_OP) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 OP(const_i64):
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
275 <li>マクロ <code>OP</code> 及び <code>NEXT</code> は次の様に定義している</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 <pre><code> #define OP(name) OP_ ## name
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 #define NEXT *LABELS[NEXT_OP]
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 <li>マクロ<code>DISPATCH</code>は, ラベルgotoが利用できる場合は無視される</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 <li>マクロ <code>OP</code> が, 対応するバイトコード命令を, ラベル列に変換する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 <pre><code> OP_const_i16:
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 OP_const_i32:
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 MVM_exception_throw_adhoc(tc, "const_iX NYI");
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 OP_const_i64:
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 <h2 id="mvm_interp_runで使用されているマクロ-1">MVM_interp_runで使用されているマクロ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 <li>次のバイトコード命令に遷移するマクロ <code>NEXT</code> は, ラベルgotoが使用可能な場合次の様に記述されている</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 <li><code>NEXT</code>自体はラベルテーブルにアクセスし, ラベルを取り出す</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 <li>次のバイトコードを取り出すのは, <code>NEXT_OP</code> というマクロが担っている</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 <pre><code>#define NEXT_OP (op = *(MVMuint16 *)(cur_op), cur_op += 2, op)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 #define NEXT *LABELS[NEXT_OP]
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 <li>マクロ <code>NEXT</code> は次の様に展開される</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 <pre><code>goto *LABELS[(op = *(MVMuint16 *)(cur_op), cur_op += 2, op)];
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 <h2 id="mvm_interp_runのラベルテーブル">MVM_interp_runのラベルテーブル</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
327 <li>利用するCコンパイラが、ラベルgotoをサポートしている場合に実行される</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
328 <li>配列<code>LABELS</code>にアクセスし, ラベル情報を取得する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
329 <li>ラベル情報を取得出来ると、 そのラベルに対してラベルgotoを利用する</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
331
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 <pre><code>static const void * const LABELS[] = {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 &amp;&amp;OP_no_op,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 &amp;&amp;OP_const_i8,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 &amp;&amp;OP_const_i16,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 &amp;&amp;OP_const_i32,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 &amp;&amp;OP_const_i64,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 &amp;&amp;OP_const_n32,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 &amp;&amp;OP_const_n64,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 &amp;&amp;OP_const_s,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 &amp;&amp;OP_set,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 &amp;&amp;OP_extend_u8,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 &amp;&amp;OP_extend_u16,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 &amp;&amp;OP_extend_u32,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 &amp;&amp;OP_extend_i8,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 &amp;&amp;OP_extend_i16,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 <h2 id="mvm_interp_run">MVM_interp_run</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
356
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
358 <li>Cの実装の場合, switch文に展開される可能性がある
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
360 <li>命令ディスパッチが書かれているCソース・ファイルの指定の場所にのみ処理を記述せざるを得ない</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
361 <li>1ファイルあたりの記述量が膨大になり, 命令のモジュール化ができない</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 </li>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
364 <li>高速化手法の、 Threaded Codeの実装を考えた場合, この命令に対応して大幅に処理系の実装を変更する必要がある.</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 <li>デバッグ時には今どの命令を実行しているか, ラベルテーブルを利用して参照せざるを得ず, 手間がかかる.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
369
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 <h2 id="cbcmoarvmのバイトコードディスパッチ">CbCMoarVMのバイトコードディスパッチ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 <ul>
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
377 <li>CbCのCodeGearは関数よりも小さな単位である</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 92
diff changeset
378 <li>その為、 従来は関数化出来なかった単位をCodeGearに変換する事が出来る</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 <li>CbCをMoarVMに適応すると, ラベルなどで制御していた命令に対応する処理をCodeGearで記述する事が可能である</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 <li>オリジナルでは, マクロ <code>NEXT</code> が担当していた, 次のバイトコードへの移動は, NEXT相当のCodeGear <code>cbc_next</code>で処理を行う</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 <li>CodeGearの入出力として, MoarVMなどの情報をまとめた構造体を利用する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 <pre><code>__code cbc_next(INTERP i){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 __code (*c)(INTERP)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 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
387 goto c(i);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 __code cbc_const_i64(INTERP i){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 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
392 i-&gt;cur_op += 10;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 goto cbc_next(i);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
397
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
398
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
399
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 <h2 id="codegearの入出力インターフェイス">CodeGearの入出力インターフェイス</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 <li>MoarVMではレジスタの集合や命令列などをMVM_interp_runのローカル変数として利用し, 各命令実行箇所で参照している</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 <li>CodeGearに書き換えた場合, このローカル変数にはアクセスする事が不可能となる.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 <li>その為, 入出力としてMoarVMの情報をまとめた構造体interpのポインタであるINTERPを受け渡し, これを利用してアクセスする</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 <pre><code>typedef struct interp {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 MVMuint16 op;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 MVMuint8 *cur_op;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 MVMuint8 *bytecode_start;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 MVMRegister *reg_base;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 /* Points to the current compilation unit
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 . */
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 MVMCompUnit *cu;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 /* The current call site we’re
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 constructing. */
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 MVMCallsite *cur_callsite;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 MVMThreadContext *tc;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 } INTER,*INTERP;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
427
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
430
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 <h2 id="cbcmoarvmのcodegearテーブル">CbCMoarVMのCodeGearテーブル</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 <li>CodeGearテーブルは引数としてINTERを受け取るCodeGearの配列として定義する</li>
92
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 85
diff changeset
437 <li>テーブルとして宣言することで、 バイトコードの数をそのままテーブルに反映させる事が可能である</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
439
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 <pre><code>__code (* CODES[])(INTERP) = {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 cbc_no_op,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 cbc_const_i8,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 cbc_const_i16,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 cbc_const_i32,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 cbc_const_i64,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 cbc_const_n32,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
447 cbc_const_n64,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 cbc_const_s,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 cbc_set,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
450 cbc_extend_u8,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 cbc_extend_u16,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
453
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
454
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
455
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
457
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 <h2 id="cbcmoarvmの利点">CbCMoarVMの利点</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
461
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 <ul>
94
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
463 <li>バイトコードインタプリタの箇所をモジュール化する事が可能となった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
464 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
465 <li>CodeGearの再利用性や記述生が高まる</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
466 <li>CodeGearは関数の様に扱えるの為、 命令ディスパッチの最適化につながる実装が可能となった</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
467 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
468 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
469 <li>デバッグ時にラベルではなくCodeGearにbreakpointを設定可能となった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
470 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
471 <li>デバッグが安易となる</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
472 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
473 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 93
diff changeset
474 <li>CPUがキャッシュに収まる範囲の命令の場合、 通常のMoarVMよりも高速に動作する</li>
81
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 </ul>
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
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
480
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 <h2 id="cbcmoarvmの欠点">CbCMoarVMの欠点</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 <li>MoarVMのオリジナルの更新頻度が高い為, 追従していく必要がある</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 <li>CodeGear側からCに戻る際に手順が複雑となる</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 <li>CodeGearを単位として用いる事で複雑なプログラミングが要求される.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
491
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
494
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 <h2 id="moarvmのトレース">MoarVMのトレース</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 <li>トレース時には次の様なデバッグ情報の表示を利用する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 <li>デバッガに, breakpointで停止した際のcur_opの値を表示する様に設定する.</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 <pre><code>Breakpoint 1, dummy () at src/core/interp.c:46
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 46 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 #1 0x00007ffff75608fe in MVM_interp_run (tc=0x604a20,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 initial_invoke=0x7ffff76c7168 &lt;toplevel_initial_invoke&gt;, invoke_data=0x67ff10)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 at src/core/interp.c:119
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 119 goto NEXT;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 $1 = 159
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 Breakpoint 1, dummy () at src/core/interp.c:46
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 46 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 #1 0x00007ffff75689da in MVM_interp_run (tc=0x604a20,
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 initial_invoke=0x7ffff76c7168 &lt;toplevel_initial_invoke&gt;, invoke_data=0x67ff10)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 at src/core/interp.c:1169
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 1169 goto NEXT;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 $2 = 162
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
522
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
524
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
525 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
526 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
527 <h2 id="cbcmoarvmのデバッグ">CbCMoarVMのデバッグ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
528
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 <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
530 61 goto NEXT(i);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 $1 = (void (*)(INTERP)) 0x7ffff7566f53 &lt;cbc_takeclosure&gt;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 $2 = 162
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
533
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 Breakpoint 2, cbc_next (i=0x7fffffffdc30) at src/core/cbc-interp.cbc:61
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 61 goto NEXT(i);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 $3 = (void (*)(INTERP)) 0x7ffff7565f86 &lt;cbc_checkarity&gt;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 $4 = 140
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
538
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 Breakpoint 2, cbc_next (i=0x7fffffffdc30) at src/core/cbc-interp.cbc:61
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 61 goto NEXT(i);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 $5 = (void (*)(INTERP)) 0x7ffff7579d06 &lt;cbc_paramnamesused&gt;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 $6 = 558
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
543
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
544
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
546
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
547
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
548
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 <h2 id="moarvmのデバッグ">MoarVMのデバッグ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
554
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
555 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 <li>cur_opのみをPerlスクリプトなどを用いて抜き出し, 並列にログを取得したオリジナルと差分を図る</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 <li>この際に差異が発生したバイトコードを確認し, その前の状態で確認していく</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
559
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 <pre><code>25 : 25 : cbc_unless_i
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 247 : 247 : cbc_null
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 54 : 54 : cbc_return_o
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 140 : 140 : cbc_checkarity
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 558 : 558 : cbc_paramnamesused
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 159 : 159 : cbc_getcode
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 391 : 391 : cbc_decont
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 127 : 127 : cbc_prepargs
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 *139 : 162
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 cbc_invoke_o:cbc_takeclosure
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
570 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
572
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
573
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
577 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 <h2 id="現在のcbcmoarvm">現在のCbCMoarVM</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
581 <li>現在はNQP, Rakudoのセルフビルドが達成でき, オリジナルと同等のテスト達成率を持っている</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 <li>moarの起動時のオプションとして <code>--cbc</code> を与えることによりCbCで動き, そうでない場合は通常のCで記述された箇所で実行される</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
583 <li>Perl6の実行バイナリperl6, NQPの実行バイナリnqp は, それぞれmoarを起動するシェルスクリプトである為, <code>--cbc</code> オプションをシェルスクリプト内に書き加えることで, Perl6, NQPがそれぞれCbCで起動する</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
585
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
586 <pre><code>#!/bin/sh
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 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
588 --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
589 /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
590 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
591
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
593
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 <h2 id="threadedcodeの実装">ThreadedCodeの実装</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
599
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 <li>MoarVM内のバイトコードに対応する処理が分離出来たことにより, バイトコードに該当するCodeGearを書き連ねることによってThreadedCodeが実装可能となる</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
603
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
604
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
605
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
607
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
608 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
610 <h2 id="cbcmoarvmと通常のmoarvmの比較">CbCMoarVMと通常のMoarVMの比較</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
611
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 <li>CbCMoarVMと通常のMoarVMの速度比較を行った</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
614 <li>対象として, 単純なループで数値をインクリメントする例題と, フィボナッチ数列を求める例題を選択した</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 <li>NQPで実装し, 速度を計測した</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
617
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
618 <pre><code>#! nqp
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
619
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
620 my $count := 100_000_000;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
621
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
622 my $i := 0;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
623
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
624 while ++$i &lt;= $count {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
625 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
626 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
627
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 <pre><code>#! nqp
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
629
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
630 sub fib($n) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
631 $n &lt; 2 ?? $n !! fib($n-1) + fib($n - 2);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
632 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
633
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
634 my $N := 30;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
635
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
636 my $z := fib($N);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
637
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 say("fib($N) = " ~ fib($N));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
639
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
640 </code></pre>
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="フィボナッチの例題">フィボナッチの例題</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>オリジナル
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 <li>1.379 sec</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 <li>1.350 sec</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 <li>1.346 sec</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
655 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
657 <li>CbCMoarVM
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
658 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
659 <li>1.636 sec</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 <li>1.804 sec</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
661 <li>1.787 sec</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
662 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 <li>フィボナッチの例題ではCbCMoarVMが劣る結果となった</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
666
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
667
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
668
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
670
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
671 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
672 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 <h2 id="単純ループ">単純ループ</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
674
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
676 <li>オリジナル
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
677 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
678 <li>7.499 sec</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
679 <li>7.844 sec</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 <li>6.746 sec</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
682 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 <li>CbCMoarVM
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
684 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 <li>6.135 sec</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
686 <li>6.362 sec</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
687 <li>6.074 sec</li>
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 </li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
690 <li>単純ループではCbCMoarVMの方が高速に動作する場合もある</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
691 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
692
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
693
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
694
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
695 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
696
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
698 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699 <h2 id="基本ブロックとcodegear">基本ブロックとCodeGear</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
700
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
701 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 <li>コンパイラなどでは, 関数あるいはループの先頭から, 別の関数呼び出し, あるいはジャンプするまでの間のコードを基本ブロックと呼ぶ</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 <li>基本ブロックは入力に影響を受けず, 基本ブロックが決定したタイミングである決定的な処理を行う</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 <li>予め実行する基本ブロックが確定していれば, その部分のみ抜き出してコンパイルする事が可能である</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 <li>CbCのCodeGearは, この基本ブロックとみなす事が可能である</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
706 <li>その為, NQPの例題の様に, 予め実行する基本ブロックが確定すれば, その部分の処理が可能となる</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 <li>これを行うことで, CbCを用いてMoarVMのThreadedCode実装が可能となる</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
708 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
709
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
710 <pre><code>__code cbc_const_i64(INTERP i,__code cbc_next(INTERP i)){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 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
712 i-&gt;cur_op += 10;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
713 goto cbc_next(i);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
714 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
715
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
716 goto cbc_const_i64_16(i,cbc_gt_i_01);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
717
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
718 __code cbc_gt_i_01(INTERP i){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
719 goto cbc_gt_i(i,cbc_unless_i_01);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
721
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 __code cbc_unless_i_01(INTERP i){
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
723 goto cbc_unless_i(i,cbc_osrpoint_01);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
725 </code></pre>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
726
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
727
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
728
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
729 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
730
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
731 <div class='slide'>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
732 <!-- _S9SLIDE_ -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
733 <h2 id="まとめと今後の課題">まとめと今後の課題</h2>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
734 <ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
735 <li>継続と基本としたC言語 Continuation Based Cを用いてPerl6の処理系の一部を書き直した</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
736 <li>CbCの持つCodeGearによって, 本来はモジュール化出来ない箇所をモジュール化する事が出来た</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 <li>MoarVMの速度改善にはThreadedCodeが期待でき, CodeGearベースの命令ディスパッチとThreadedCodeは相性が良いと考えられる</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
738 <li>今後は実行するバイトコードによりThreadedCode箇所と通常の配列を読み取り, 次のCodeGearを計算する処理を両立させていく</li>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
739 </ul>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
740
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
741
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
742 </div>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
743
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
744
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
745 </div><!-- presentation -->
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
746 </body>
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
747 </html>