blob: 2739ec6b14ef571d8f4e01ef2314eab83e0d05c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
|
#title YARVã¢ã¼ããã¯ãã£
#set author æ¥æ¬ Ruby ã®ä¼ ããã ãããã¡
- 2005-03-03(Thu) 00:31:12 +0900 ããããã¨æ¸ãç´ã
----
* ããã¯ï¼
[[YARV: Yet Another RubyVM|http://www.atdot.net/yarv]] ã® è¨è¨ã¡ã¢ã§ãã
YARV ã¯ãRuby ããã°ã©ã ã®ããã®æ¬¡ã®æ©è½ãæä¾ãã¾ãã
- Compiler
- VM Generator
- VM (Virtual Machine)
- Assembler
- Dis-Assembler
- (experimental) JIT Compiler
- (experimental) AOT Compiler
ç¾å¨ã® YARV 㯠Ruby ã¤ã³ã¿ããªã¿ã®æ¡å¼µã©ã¤ãã©ãªã¨ãã¦å®è£
ãã¦ãã¾ããã
ãã«ãããRuby ã¤ã³ã¿ããªã¿ã®å¿
è¦ãªæ©è½ï¼ãã¼ãµããªãã¸ã§ã¯ã管çãæ¢å
ã®æ¡å¼µã©ã¤ãã©ãªï¼ãªã©ãã»ã¼ãã®ã¾ã¾å©ç¨ã§ãã¾ãã
ãã ããããã¤ãã®ãããã Ruby ã¤ã³ã¿ããªã¿ã«å½ã¦ãªããã°ãªãã¾ããã
ä»å¾ã¯ãRuby æ¬ä½ã®ã¤ã³ã¿ããªã¿é¨åï¼eval.cï¼ãç½®ãæãããã¨ãç®æãã¦
éçºãç¶ç¶ããäºå®ã§ãã
* Compiler (compile.h, compile.c)
ã³ã³ãã¤ã©ã¯ãRuby ã¤ã³ã¿ããªã¿ã®ãã¼ãµã«ãã£ã¦çæãããæ§ææ¨ï¼RNode
ãã¼ã¿ã«ããæ¨ï¼ã YARV å½ä»¤åã«å¤æãã¾ããYARV å½ä»¤ã«ã¤ãã¦ã¯å¾è¿°ãã¾
ãã
ã¨ãã«é£ãããã¨ã¯ãã¦ãã¾ããããã¹ã³ã¼ããªã©ã®éå§æã«ãã¼ã«ã«å¤æ°ã®å
æåãªã©ãè¡ãããã¨ã¯æ§ææ¨ã辿ãå¤æãã¦ããã¾ãã
å¤æä¸ã¯ Ruby ã® Array ãªãã¸ã§ã¯ãã« YARV å½ä»¤ãªãã¸ã§ã¯ããããã³ãªã
ã©ã³ããæ ¼ç´ãã¦ãããæå¾ã«å®è¡ã§ããå½¢ã«å¤æãã¾ããã³ã³ãã¤ã©ã§ã¯ãã³
ã³ãã¤ã«ä¸ã«çæããã¡ã¢ãªé åã®ç®¡çãåé¡ã«ãªããã¨ãããã¾ãããYARV
ã®å ´åãRuby ã¤ã³ã¿ããªã¿ããã¹ã¦é¢åãã¿ã¦ãããã®ã§ãã®é¨åã¯é常ã«æ¥½
ã«ä½ããã¨ãã§ãã¾ããï¼ã¬ã¼ãã¼ã¸ã³ã¬ã¯ã¿ã«ãã£ã¦èªåçã«ã¡ã¢ãªç®¡çãã
ã¦ãããããï¼ã
YARV å½ä»¤ã¯ãå½ä»¤ã示ãèå¥åããªãã©ã³ããªã©ããã¹ã¦ 1 word ï¼ãã·ã³ã§
表ç¾ã§ããèªç¶ãªå¤ãC è¨èªã§ã¯ãã¤ã³ã¿ã®ãµã¤ãºãRuby ã¤ã³ã¿ããªã¿ç¨èªã§
㯠VALUE ã®ãµã¤ãºï¼ã§è¡¨ç¾ããã¾ãããã®ãããYARV å½ä»¤ã¯ããããããã¤ã
ã³ã¼ããã§ã¯ããã¾ããããã®ãããYARV ã®èª¬æãªã©ã§ã¯ãå½ä»¤åãã¨ããç¨
èªã使ã£ã¦ãã¾ãã
1 word ã§ãããããã¡ã¢ãªã®å©ç¨å¹çã¯å¤å°æªããªãã¾ãããã¢ã¯ã»ã¹é度ãª
ã©ãèæ
®ããã¨ãæ¬æ¹å¼ãä¸çªããã¨èãã¦ããã¾ãããã¨ãã°ãªãã©ã³ããã³
ã³ã¹ã¿ã³ããã¼ã«ã«æ ¼ç´ããã¤ã³ããã¯ã¹ã®ã¿ããªãã©ã³ãã§ç¤ºããã¨ãå¯è½ã§
ãããéæ¥ã¢ã¯ã»ã¹ã«ãªã£ã¦ãã¾ãã®ã§æ§è½ã«å½±é¿ãåºããããå´ä¸ãã¾ããã
* VM Generator (rb/insns2vm.rb, insns.def)
rb/insns2vm.rb ã¨ããã¹ã¯ãªããã¯ãinsns.def ã¨ãããã¡ã¤ã«ãèªã¿è¾¼ã¿ã
VM ã®ããã«å¿
è¦ãªãã¡ã¤ã«ãçæãã¾ããå
·ä½çã«ã¯ãå½ä»¤ãå®è¡ããé¨åã
çæãã¾ãããã»ãã«ãã³ã³ãã¤ã«ã«å¿
è¦ãªæ
å ±ãæé©åã«å¿
è¦ãªæ
å ±ããã¢ã»
ã³ãã©ãéã¢ã»ã³ãã©ã«å¿
è¦ãªæ
å ±ã示ããã¡ã¤ã«ãçæãã¾ãã
** å½ä»¤è¨è¿°
insns.def ã«ã¯ãåå½ä»¤ãã©ã®ãããªå½ä»¤ã§ããããè¨è¿°ãã¾ããå
·ä½çã«ã¯æ¬¡
ã®æ
å ±ãè¨è¿°ãã¾ãã
- å½ä»¤ã®åå
- ãã®å½ä»¤ã®ã«ãã´ãªãã³ã¡ã³ãï¼è±èªãæ¥æ¬èªï¼
- ãªãã©ã³ãã®åå
- ãã®å½ä»¤å®è¡åã«ã¹ã¿ãã¯ãããããããå¤
- ãã®å½ä»¤å®è¡å¾ã«ã¹ã¿ãã¯ã«ããã·ã¥ããå¤
- ãã®å½ä»¤ã®ãã¸ãã¯ï¼C è¨èªã§è¨è¿°ï¼
ãã¨ãã°ãã¹ã¿ãã¯ã« self ããã putself ã¨ããå½ä»¤ã¯æ¬¡ã®ããã«è¨è¿°ãã¾
ãã
#code
/**
@c put
@e put self.
@j self ãç½®ãã
*/
DEFINE_INSN
putself
()
()
(VALUE val)
{
val = GET_SELF();
}
#end
ãã®å ´åããªãã©ã³ãã¨ãã¹ã¿ãã¯ãããããããå¤ã¯ç¡ããã¨ã«ãªãã¾ããå½
令çµäºå¾ãself ãã¹ã¿ãã¯ãããã«ç½®ãããããã§ããããã㯠val ã¨ããã
ã¹ã¿ãã¯ã«ããã·ã¥ããå¤ã¨ãã¦å®£è¨ãã¦ãããå¤æ°ã«ä»£å
¥ãã¦ãããã¨ã§ãã
ããå¤æããã¨ã¹ã¿ãã¯ãããã«ç½®ã C ããã°ã©ã ãçæããã¾ãã
ç´°ãããã©ã¼ããã㯠insns.def ã®åé ãåç
§ãã¦ãã ããããããªã«é£ãã
ãªãã¨æãã¾ãã
insnhelper.h ã¨ãããã¡ã¤ã«ã«ãå½ä»¤ãã¸ãã¯ãè¨è¿°ããããã«å¿
è¦ãªãã¯ã
ãå®ç¾©ããã¦ãã¾ããã¾ããVM ã®å
é¨æ§é ã«é¢ããå®ç¾©ã¯ vm.h ã¨ãããã¡ã¤
ã«ã«ããã¾ãã
* VM (Virtual Machine, vm.h, vm.c)
VM ã¯ãå®éã«ã³ã³ãã¤ã«ããçµæçæããã YARV å½ä»¤åãå®è¡ãã¾ããã¾ã
ã«ããã®é¨åã YARV ã®ãã¢ã«ãªããå°æ¥çã«ã¯ eval.c ããã® VM ã§ç½®ãæã
ããã¨èãã¦ãã¾ãã
ç¾å¨ã® Ruby ã¤ã³ã¿ããªã¿ã§å®è¡ã§ãããã¹ã¦ã®ãã¨ãããã® VM ã§å®ç¾ã§ãã
ããã«ä½ã£ã¦ãã¾ãï¼ç¾æ®µéã§ã¯ã¾ã å®å
¨ã§ã¯ããã¾ãããããããªãã¹ãã§ãï¼ã
VM ã¯ãåç´ãªã¹ã¿ãã¯ãã·ã³ã¨ãã¦å®è£
ãã¦ãã¾ããã¹ã¬ããã²ã¨ã¤ã«ã¹ã¿ã
ã¯ã²ã¨ã¤ãä¿æãã¾ããã¹ã¿ãã¯ã®é åã¯ãã¼ãããåå¾ããã®ã§ãæè»ãªé å
è¨å®ãå¯è½ã§ãã
** ã¬ã¸ã¹ã¿
VM 㯠5 ã¤ã®ä»®æ³çãªã¬ã¸ã¹ã¿ã«ãã£ã¦å¶å¾¡ããã¾ãã
- PC (Program Counter)
- SP (Stack Pointer)
- CFP (Control Frame Pointer)
- LFP (Local Frame Pointer)
- DFP (Dynamic Frame Pointer)
PC ã¯ç¾å¨å®è¡ä¸ã®å½ä»¤åã®ä½ç½®ã示ãã¾ããSP ã¯ã¹ã¿ãã¯ãããã®ä½ç½®ã示ã
ã¾ããCFPãLFPãDFP ã¯ãããããã¬ã¼ã ã®æ
å ±ã示ãã¾ãã詳細ã¯å¾è¿°ãã¾ãã
** ã¹ã¿ãã¯ãã¬ã¼ã
obsolete (update soon)
** ãã¬ã¼ã ãã¶ã¤ã³ã«ã¤ãã¦ã®è£è¶³
Lisp ã®å¦çç³»ãªã©ããããããã¨ããããããããã¯ãã¼ã«ã«ãã¬ã¼ã ã¨ã¡ã½
ãããã¼ã«ã«ãã¬ã¼ã ã®ãããªãã®ãç¨æããã®ã¯å¥ç°ã«è¦ããããããã¾ããã
ãããã¬ã¼ã ããå
¥ãåæ§é ã«ãã¦ããã¼ã«ã«å¤æ°ã®ã¢ã¯ã»ã¹ã¯ãã®å
¥ãåãå¤
å´ã«è¾¿ãã°å¿
ããã©ãçããã¨ãã§ããããã§ãï¼ã¤ã¾ããlfp ã¯å¿
è¦ãªãï¼ã
ããããRuby ã§ã¯ããã¤ãç¶æ³ãéãã¾ããã¾ããã¡ã½ãããã¼ã«ã«ãªæ
å ±ã
ãããã¨ãå
·ä½çã«ã¯ãããã¯ã¨selfï¼callee ããã¿ã㨠receiverï¼ã§ããã
ã®æ
å ±ãããããã®ãã¬ã¼ã ã«ããããã®ã¯ç¡é§ã§ãã
ã¾ããRuby2.0 ããã¯ãããã¯ãã¼ã«ã«å¤æ°ã¯ãªããªãã¾ãï¼ãããã¯ãã¼ã«ã«
å¼æ°ã¯æ®ãã®ã§ãæ§é èªä½ã¯ãã¾ãå¤ããã¾ããï¼ããã®ãããã¡ã½ãããã¼ã«
ã«å¤æ°ã¸ã®ã¢ã¯ã»ã¹ãé »çºãããã¨ãäºæ³ããã¾ãã
ãã®ã¨ããã¡ã½ãããã¼ã«ã«å¤æ°ã¸ã®ã¢ã¯ã»ã¹ã®ãã³ã«ãã¬ã¼ã ï¼ã¹ã³ã¼ãï¼ã®
ãªã¹ãããã©ãã®ã¯ç¡é§ã§ããã¨å¤æããæ示çã«ã¡ã½ãããã¼ã«ã«ã¹ã³ã¼ãã¨
ãããã¯ãã¬ã¼ã ãåé¢ãããããã¯ãã¬ã¼ã ããã¯ã¡ã½ãããã¼ã«ã«ãã¬ã¼ã
ã lfpã¬ã¸ã¹ã¿ã«ãã£ã¦å®¹æã«ã¢ã¯ã»ã¹ã§ããããã«ãã¾ããã
** ã¡ã½ããå¼ã³åºãã«ã¤ãã¦
ã¡ã½ããå¼ã³åºãã¯ãYARV å½ä»¤åã§è¨è¿°ãããã¡ã½ããããC ã§è¨è¿°ãããã¡
ã½ãããã«ãã£ã¦ãã£ã¹ãããææ³ãå¤ããã¾ãã
YARV å½ä»¤åã§ãã£ãå ´åãä¸è¿°ããã¹ã¿ãã¯ãã¬ã¼ã ãä½æãã¦å½ä»¤ãç¶ç¶ã
ã¾ããã¨ãã« VM ã®é¢æ°ãå帰å¼ã³åºããããã¨ã¯è¡ãªãã¾ããã
C ã§è¨è¿°ãããã¡ã½ããã ã£ãå ´åãåç´ã«ãã®é¢æ°ãå¼ã³åºãã¾ãï¼ãã ãã
ããã¯ãã¬ã¼ã¹ãæ£ããçæããããã«ã¡ã½ããå¼ã³åºãã®æ
å ±ãä»å ãã¦ãã
è¡ãªãã¾ãï¼ã
ãã®ãããVM ç¨ã¹ã¿ãã¯ãå¥éç¨æãããã®ã®ãããã°ã©ã ã«ãã£ã¦ã¯ãã·ã³
ã¹ã¿ãã¯ã使ãåã£ã¦ãã¾ãå¯è½æ§ãããã¾ãï¼C -> Ruby -> C -> ... ã¨ãã
å¼ã³åºããç¶ããå ´åï¼ãããã¯ãç¾å¨ã§ã¯é¿ããããªãä»æ§ã¨ãªã£ã¦ãã¾ãã
** ä¾å¤
ä¾å¤ã¯ãJava ã® JVM ã¨åæ§ã«ä¾å¤ãã¼ãã«ãç¨æãããã¨ã§å®ç¾ãã¾ããä¾å¤
ãçºçããããå½è©²ãã¬ã¼ã ããä¾å¤ãã¼ãã«ãæ¤æ»ãã¾ããããã§ãä¾å¤ãçº
çããã¨ãã® PC ã®å¤ã«åè´ããã¨ã³ããªããã£ãå ´åããã®ã¨ã³ããªã«å¾ã£ã¦
åä½ãã¾ããããã¨ã³ããªãè¦ã¤ãããªãã£ãå ´åãã¹ã¿ãã¯ãæãæ»ãã¦ã¾ã
åæ§ã«ãã®ã¹ã³ã¼ãã®ä¾å¤ãã¼ãã«ãæ¤æ»ãã¾ãã
ã¾ããbreakãreturnï¼ãããã¯ä¸ï¼ãretry ãªã©ãåæ§ã®ä»çµã¿ã§å®ç¾ãã¾ãã
*** ä¾å¤ãã¼ãã«
ä¾å¤ãã¼ãã«ã¨ã³ããªã¯å
·ä½çã«ã¯æ¬¡ã®æ
å ±ãæ ¼ç´ããã¦ãã¾ãã
- 対象ã¨ãã PC ã®ç¯å²
- 対象ã¨ããä¾å¤ã®ç¨®é¡
- ãã対象ã¨ãªã£ãã¨ãã«ã¸ã£ã³ãããå
ï¼ç¨®é¡ã«ããï¼
- ãã対象ã¨ãªã£ãã¨ãã«èµ·åãããããã¯ã® iseq
*** rescue
rescue ç¯ã¯ãããã¯ã¨ãã¦å®ç¾ãã¦ãã¾ãã$! ã®å¤ãå¯ä¸ã®å¼æ°ã¨ãã¦æã¡ã¾
ãã
#code
begin
rescue A
rescue B
rescue C
end
#end
ã¯ã次ã®ãã㪠Ruby ã¹ã¯ãªããã«å¤æããã¾ãã
#code
{|err|
case err
when A === err
when B === err
when C === err
else
raise # yarv ã®å½ä»¤ã§ã¯ throw
end
}
#end
*** ensure
æ£å¸¸ç³»ï¼ä¾å¤ãçºçããªãã£ãå ´åï¼ã¨ç°å¸¸ç³»ï¼ä¾å¤ãçºçããã¨ããªã©ï¼ã®2
種é¡ã®å½ä»¤åãçæããã¾ããæ£å¸¸ç³»ã§ã¯ããã ã®é£ç¶ããã³ã¼ãé åã¨ãã¦ã³
ã³ãã¤ã«ããã¾ããã¾ããç°å¸¸ç³»ã§ã¯ãããã¯ã¨ãã¦å®è£
ãã¾ããæå¾ã¯å¿
ã
throw å½ä»¤ã§ç· ãããã¨ã«ãªãã¾ãã
*** break, returnï¼ãããã¯ä¸ï¼ãretry
break æããããã¯ä¸ã® return æãretry æ㯠throw å½ä»¤ã¨ãã¦ã³ã³ãã¤ã«
ããã¾ããã©ãã¾ã§æ»ããã¯ãbreak ãããã¯ããä¾å¤ãã¼ãã«ã®ã¨ã³ããªãå¤
æãã¾ãã
** å®æ°ã®æ¤ç´¢
å®æ°ã¨ããååãªã®ã«ãRuby ã§ã¯ã³ã³ãã¤ã«æã«æ±ºå®ãã¾ãããã¨ããããã
ã¤ã¾ã§ãåå®ç¾©å¯è½ã«ãªã£ã¦ãã¾ãã
å®æ°ã¢ã¯ã»ã¹ã®ããã®Rubyè¨è¿°ã¯æ¬¡ã®ããã«ãªãã¾ãã
#code
Ruby表ç¾:
expr::ID::...::ID
#end
ããã¯ãyarvå½ä»¤ã»ããã§ã¯æ¬¡ã®ããã«ãªãã¾ãã
#code
(expr)
getconstant ID
...
getconstant ID
#end
*** å®æ°æ¤ç´¢ãã¹
ãã expr ã nil ã ã£ãå ´åãå®æ°æ¤ç´¢ãã¹ã«å¾ã£ã¦å®æ°ãæ¤ç´¢ãã¾ãããã®
æåã¯ä»å¾ Ruby 2.0 ã«åãã¦å¤æ´ãããå ´åãããã¾ãã
+ ã¯ã©ã¹ãã¢ã¸ã¥ã¼ã«ã®åçãã¹ãé¢ä¿ï¼ããã°ã©ã ã®åé¢ä¸ï¼ãã«ã¼ãã¾ã§è¾¿ã
+ ç¶æ¿é¢ä¿ãã«ã¼ãï¼Objectï¼ã¾ã§è¾¿ã
ãã®ãããã¯ã©ã¹ãã¢ã¸ã¥ã¼ã«ã®åçãã¹ãé¢ä¿ãä¿åããªããã°ãªãã¾ããã
ãã®ããã«ãthread_object ã«ã¯ klass_nest_stack ã¨ãããã®ãç¨æãã¾ããã
ããã¯ãç¾å¨ã®ãã¹ãã®æ
å ±ãä¿åãã¾ãã
ã¡ã½ããå®ç¾©æããã®ç¾å¨ã®ãã¹ãæ
å ±ãã¡ã½ããå®ç¾©æã«ï¼dupãã¦ï¼å ãã
ãã¨ã§ããã®ã¡ã½ããã®å®è¡æããã®ãã¹ãæ
å ±ãåç
§ãããã¨ãå¯è½ã«ãªãã¾
ãã
ãããã¬ãã«ã§ã¯ããã®æ
å ±ã¯ãªããã¨ã«ãªãã¾ãã
ã¯ã©ã¹/ã¢ã¸ã¥ã¼ã«å®ç¾©æå®è¡æã¯ãç¾å¨ã®æ
å ±ãã®ãã®ãåç
§ãããã¨ã«ãªã
ã¾ããããã¯ãã¯ã©ã¹ã¹ã³ã¼ãçªå
¥æããã®æ
å ±ãã¯ã©ã¹å®ç¾©æã«ã³ãã¼ãã¾ã
ï¼ãã§ã«ã³ãã¼ããã¦ããã°ããããè¡ãã¾ããï¼ã
ããã«ãããåçãªãã¹ãæ
å ±ãçµ±ä¸çã«æ±ããã¨ãã§ãã¾ãã
** æé©åææ³
YARV ã§ã¯é«éåãç®çã¨ãã¦ããã®ã§ããã¾ãã¾ãªæé©åææ³ãå©ç¨ãã¦ãã¾
ãã詳細ã¯å²æãã¾ããã以ä¸ã«è¿°ã¹ãæé©åãªã©ãè¡ãªã£ã¦ããã¾ãã
*** threaded code
GCC ã® C è¨èªæ¡å¼µã§ããå¤ã¨ãã¦ã®ã©ãã«ãå©ç¨ã㦠direct threaded code
ãå®ç¾ãã¦ãã¾ãã
*** Peephole optimization
ããã¤ãã®ç°¡åãªæé©åããã¦ãã¾ãã
*** inline method cache
å½ä»¤åã®ä¸ã«ã¡ã½ããæ¤ç´¢çµæãåãè¾¼ã¿ã¾ãã
*** inline constant cache
å½ä»¤åã®ä¸ã«å®æ°æ¤ç´¢çµæãåãè¾¼ã¿ã¾ãã
*** ãããã¯ã¨ Proc ãªãã¸ã§ã¯ãã®åé¢
ãããã¯ä»ãã¡ã½ããå¼ã³åºããè¡ãªãããã¨ãã«ã¯ããã«ã¯ãããã¯ã Proc
ãªãã¸ã§ã¯ãã¨ãã¦çæãã¾ãããããã«ãããå¿
è¦ãªã Proc ãªãã¸ã§ã¯ãã®
çæãæãã¦ãã¾ãã
Proc ã¡ã½ããã¯ãå®éã«å¿
è¦ã«ãªã£ãæç¹ã§ä½ããããã®ã¨ãã«ç°å¢ï¼ã¹ã³ã¼
ãä¸ã«ç¢ºä¿ãããå¤æ°ãªã©ï¼ããã¼ãã«ä¿åãã¾ãã
*** ç¹åå½ä»¤
Fixnum å士ã®å ç®ãªã©ãæ£ç´ã«é¢æ°å¼ã³åºãã«ãã£ã¦è¡ãªãã¨ãã³ã¹ãããã
ãã®ã§ããããã®ããªããã£ããªæä½ãè¡ãªãããã®ã¡ã½ããå¼ã³åºãã¯å°ç¨å½
令ãç¨æãã¾ããã
*** å½ä»¤èå
è¤æ°ã®å½ä»¤ã 1 å½ä»¤ã«å¤æãã¾ããèåå½ä»¤ã¯ opt_insn_unif.def ã®è¨è¿°ã«ã
ãèªåçã«çæããã¾ãã
*** ãªãã©ã³ãèå
è¤æ°ã®ãªãã©ã³ããå«ããå½ä»¤ãçæãã¾ããèåå½ä»¤ã¯ opt_operand.def ã®
è¨è¿°ã«ãã£ã¦èªåçã«çæããã¾ãã
*** stack caching
ã¹ã¿ãã¯ããããä»®æ³ã¬ã¸ã¹ã¿ã«ä¿æããããã«ãã¾ããç¾å¨ã¯ 2 åã®ä»®æ³ã¬
ã¸ã¹ã¿ãæ³å®ãã5ç¶æ
ã®ã¹ã¿ãã¯ãã£ãã·ã³ã°ãè¡ãªãã¾ããã¹ã¿ãã¯ãã£ã
ã·ã³ã°ããå½ä»¤ã¯èªåçã«çæããã¾ãã
*** JIT Compile
æ©æ¢°èªãåãè²¼ããã¾ããé常ã«å®é¨çãªã³ã¼ããã®ããä½ã£ã¦ããã¾ãããã»
ã¨ãã©ã®ããã°ã©ã ã¯åãã¾ããã
*** AOT Compile
YARV å½ä»¤åã C è¨èªã«å¤æãã¾ããã¾ã ååãªæé©åãè¡ãªãã¦ããã¾ãããã
ãããªãã«åãã¾ããrb/aotc.rb ãã³ã³ãã¤ã©ã§ãã
* Assembler (rb/yasm.rb)
YARV å½ä»¤åã®ã¢ã»ã³ãã©ãç¨æãã¾ããã使ãæ¹ã¯ rb/yasm.rb ãåç
§ãã¦ã
ã ããï¼ã¾ã ãä¾ç¤ºãã¦ããçæææ³ã®ãã¹ã¦ããµãã¼ããã¦ããããã§ã¯ãã
ã¾ããï¼ã
* Dis-Assembler (disasm.c)
YARV å½ä»¤åã示ããªãã¸ã§ã¯ã YARVCore::InstructionSequence ã«ã¯ disasm
ã¡ã½ãããããã¾ããããã¯ãå½ä»¤åãéã¢ã»ã³ãã«ããæååãè¿ãã¾ãã
* YARV å½ä»¤ã»ãã
<%= d %>
* ãã®ä»
** ãã¹ã
test/test_* ããã¹ãã±ã¼ã¹ã§ããä¸å¿ããã¹ãªãåãã¯ãã§ããéã«ããã¨ã
ãã®ãã¹ãã«è¨è¿°ããã¦ããä¾ã§ã¯ãã¡ãã¨åä½ããã¨ãããã¨ã§ãã
** ãã³ããã¼ã¯
benchmark/bm_* ã«ãã³ããã¼ã¯ããã°ã©ã ãããã¦ããã¾ãã
** ä»å¾ã®äºå®
ã¾ã ã¾ã ãããªããã°ãããªããã¨ãæªå®è£
é¨åãããããããã¾ããã§ãã£ã¦
ãããªããã°ãªãã¾ãããä¸çªå¤§ããªç®æ¨ã¯ eval.c ãç½®ãæãããã¨ã§ããã
ãã
*** Verifier
YARV å½ä»¤åã¯ããã¹ããã£ã¦ãåããã¦ãã¾ãããå±éºã§ããå¯è½æ§ãããã¾
ãããã®ãããã¹ã¿ãã¯ã®å©ç¨ç¶æ
ããã¡ãã¨äºåã«æ¤è¨¼ãããããªããªãã¡ã¤
ã¢ãç¨æããªããã°ãªããªãã¨èãã¦ãã¾ãã
*** Compiled File ã®æ§æ³
Ruby ããã°ã©ã ããã®å½ä»¤ã»ããã«ã·ãªã¢ã©ã¤ãºãããã¼ã¿æ§é ããã¡ã¤ã«ã«
åºåã§ããããã«ãããã¨èãã¦ãã¾ãããããå©ç¨ãã¦ä¸åº¦ã³ã³ãã¤ã«ããå½
令åããã¡ã¤ã«ã«ä¿åãã¦ããã°ã次åãã¼ãæã«ã¯ã³ã³ãã¤ã«ã®æéãã³ã¹ã
ãçããã¨ãã§ãã¾ãã
**** å
¨ä½æ§æ
次ã®ãããªãã¡ã¤ã«æ§æãèãã¦ãã¾ãããã¾ã æªå®ã§ãã
#code
u4 : 4 byte unsigned storage
u2 : 2 byte unsigned storage
u1 : 1 byte unsigned storage
every storages are little endian :-)
CompiledFile{
u4 magic;
u2 major;
u2 minor;
u4 character_code;
u4 constants_pool_count;
ConstantEntry constants_pool[constants_pool_count];
u4 block_count;
blockEntry blocks[block_count];
u4 method_count;
MethodEntry methods[method_count];
}
#end
Java classfile ã®ãã¯ãªã
|