llrb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.gitmodules +4 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +5 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +56 -0
  8. data/README.md +311 -0
  9. data/Rakefile +30 -0
  10. data/bin/bm_app_fib +41 -0
  11. data/bin/bm_empty_method +33 -0
  12. data/bin/bm_loop_while +27 -0
  13. data/bin/bm_plus +33 -0
  14. data/bin/console +14 -0
  15. data/bin/loop_while.rb +5 -0
  16. data/bin/setup +8 -0
  17. data/ext/llrb/cfg.h +124 -0
  18. data/ext/llrb/compiler.c +987 -0
  19. data/ext/llrb/compiler/funcs.h +164 -0
  20. data/ext/llrb/compiler/stack.h +43 -0
  21. data/ext/llrb/cruby.h +42 -0
  22. data/ext/llrb/cruby/ccan/build_assert/build_assert.h +40 -0
  23. data/ext/llrb/cruby/ccan/check_type/check_type.h +63 -0
  24. data/ext/llrb/cruby/ccan/container_of/container_of.h +142 -0
  25. data/ext/llrb/cruby/ccan/list/list.h +773 -0
  26. data/ext/llrb/cruby/ccan/str/str.h +16 -0
  27. data/ext/llrb/cruby/internal.h +1774 -0
  28. data/ext/llrb/cruby/iseq.h +252 -0
  29. data/ext/llrb/cruby/method.h +213 -0
  30. data/ext/llrb/cruby/node.h +520 -0
  31. data/ext/llrb/cruby/probes_helper.h +43 -0
  32. data/ext/llrb/cruby/ruby_assert.h +54 -0
  33. data/ext/llrb/cruby/ruby_atomic.h +233 -0
  34. data/ext/llrb/cruby/thread_pthread.h +54 -0
  35. data/ext/llrb/cruby/vm_core.h +1646 -0
  36. data/ext/llrb/cruby/vm_debug.h +37 -0
  37. data/ext/llrb/cruby/vm_exec.h +182 -0
  38. data/ext/llrb/cruby/vm_opts.h +57 -0
  39. data/ext/llrb/cruby_extra/id.h +220 -0
  40. data/ext/llrb/cruby_extra/insns.inc +113 -0
  41. data/ext/llrb/cruby_extra/insns_info.inc +796 -0
  42. data/ext/llrb/cruby_extra/probes.h +80 -0
  43. data/ext/llrb/extconf.rb +102 -0
  44. data/ext/llrb/llrb.c +148 -0
  45. data/ext/llrb/optimizer.cc +118 -0
  46. data/ext/llrb/parser.c +191 -0
  47. data/ext/llrb/profiler.c +336 -0
  48. data/ext/llrb_insn_checkkeyword.c +20 -0
  49. data/ext/llrb_insn_checkmatch.c +28 -0
  50. data/ext/llrb_insn_concatarray.c +23 -0
  51. data/ext/llrb_insn_concatstrings.c +21 -0
  52. data/ext/llrb_insn_defined.c +9 -0
  53. data/ext/llrb_insn_getclassvariable.c +10 -0
  54. data/ext/llrb_insn_getinstancevariable.c +44 -0
  55. data/ext/llrb_insn_getlocal.c +14 -0
  56. data/ext/llrb_insn_getlocal_level0.c +8 -0
  57. data/ext/llrb_insn_getlocal_level1.c +8 -0
  58. data/ext/llrb_insn_getspecial.c +14 -0
  59. data/ext/llrb_insn_invokeblock.c +39 -0
  60. data/ext/llrb_insn_invokesuper.c +47 -0
  61. data/ext/llrb_insn_opt_aref.c +25 -0
  62. data/ext/llrb_insn_opt_aset.c +28 -0
  63. data/ext/llrb_insn_opt_div.c +32 -0
  64. data/ext/llrb_insn_opt_eq.c +57 -0
  65. data/ext/llrb_insn_opt_ge.c +28 -0
  66. data/ext/llrb_insn_opt_gt.c +38 -0
  67. data/ext/llrb_insn_opt_le.c +29 -0
  68. data/ext/llrb_insn_opt_lt.c +38 -0
  69. data/ext/llrb_insn_opt_ltlt.c +27 -0
  70. data/ext/llrb_insn_opt_minus.c +36 -0
  71. data/ext/llrb_insn_opt_mod.c +32 -0
  72. data/ext/llrb_insn_opt_mult.c +30 -0
  73. data/ext/llrb_insn_opt_neq.c +103 -0
  74. data/ext/llrb_insn_opt_plus.c +48 -0
  75. data/ext/llrb_insn_opt_send_without_block.c +45 -0
  76. data/ext/llrb_insn_opt_str_freeze.c +12 -0
  77. data/ext/llrb_insn_putspecialobject.c +23 -0
  78. data/ext/llrb_insn_send.c +49 -0
  79. data/ext/llrb_insn_setclassvariable.c +19 -0
  80. data/ext/llrb_insn_setconstant.c +23 -0
  81. data/ext/llrb_insn_setinstancevariable.c +48 -0
  82. data/ext/llrb_insn_setlocal.c +16 -0
  83. data/ext/llrb_insn_setlocal_level0.c +9 -0
  84. data/ext/llrb_insn_setlocal_level1.c +10 -0
  85. data/ext/llrb_insn_setspecial.c +15 -0
  86. data/ext/llrb_insn_splatarray.c +13 -0
  87. data/ext/llrb_insn_throw.c +11 -0
  88. data/ext/llrb_insn_trace.c +37 -0
  89. data/ext/llrb_push_result.c +14 -0
  90. data/ext/llrb_self_from_cfp.c +12 -0
  91. data/ext/llrb_set_pc.c +8 -0
  92. data/lib/llrb.rb +2 -0
  93. data/lib/llrb/jit.rb +76 -0
  94. data/lib/llrb/start.rb +2 -0
  95. data/lib/llrb/version.rb +3 -0
  96. data/llrb.gemspec +48 -0
  97. data/wercker.yml +31 -0
  98. metadata +227 -0
@@ -0,0 +1,113 @@
1
+ // Generated from v2_4_1 (820605b). This MUST be changed if you want to run this on trunk ruby.
2
+ // TODO: Maybe we can generate this on gem build time.
3
+ /** -*-c-*-
4
+ This file contains YARV instructions list.
5
+
6
+ ----
7
+ This file is auto generated by insns2vm.rb
8
+ DO NOT TOUCH!
9
+
10
+ If you want to fix something, you must edit 'template/insns.inc.tmpl'
11
+ or tool/insns2vm.rb
12
+ */
13
+
14
+
15
+ /* BIN : Basic Instruction Name */
16
+ #define BIN(n) YARVINSN_##n
17
+
18
+ enum ruby_vminsn_type {
19
+ BIN(nop) = 0,
20
+ BIN(getlocal) = 1,
21
+ BIN(setlocal) = 2,
22
+ BIN(getspecial) = 3,
23
+ BIN(setspecial) = 4,
24
+ BIN(getinstancevariable) = 5,
25
+ BIN(setinstancevariable) = 6,
26
+ BIN(getclassvariable) = 7,
27
+ BIN(setclassvariable) = 8,
28
+ BIN(getconstant) = 9,
29
+ BIN(setconstant) = 10,
30
+ BIN(getglobal) = 11,
31
+ BIN(setglobal) = 12,
32
+ BIN(putnil) = 13,
33
+ BIN(putself) = 14,
34
+ BIN(putobject) = 15,
35
+ BIN(putspecialobject) = 16,
36
+ BIN(putiseq) = 17,
37
+ BIN(putstring) = 18,
38
+ BIN(concatstrings) = 19,
39
+ BIN(tostring) = 20,
40
+ BIN(freezestring) = 21,
41
+ BIN(toregexp) = 22,
42
+ BIN(newarray) = 23,
43
+ BIN(duparray) = 24,
44
+ BIN(expandarray) = 25,
45
+ BIN(concatarray) = 26,
46
+ BIN(splatarray) = 27,
47
+ BIN(newhash) = 28,
48
+ BIN(newrange) = 29,
49
+ BIN(pop) = 30,
50
+ BIN(dup) = 31,
51
+ BIN(dupn) = 32,
52
+ BIN(swap) = 33,
53
+ BIN(reverse) = 34,
54
+ BIN(reput) = 35,
55
+ BIN(topn) = 36,
56
+ BIN(setn) = 37,
57
+ BIN(adjuststack) = 38,
58
+ BIN(defined) = 39,
59
+ BIN(checkmatch) = 40,
60
+ BIN(checkkeyword) = 41,
61
+ BIN(trace) = 42,
62
+ BIN(defineclass) = 43,
63
+ BIN(send) = 44,
64
+ BIN(opt_str_freeze) = 45,
65
+ BIN(opt_newarray_max) = 46,
66
+ BIN(opt_newarray_min) = 47,
67
+ BIN(opt_send_without_block) = 48,
68
+ BIN(invokesuper) = 49,
69
+ BIN(invokeblock) = 50,
70
+ BIN(leave) = 51,
71
+ BIN(throw) = 52,
72
+ BIN(jump) = 53,
73
+ BIN(branchif) = 54,
74
+ BIN(branchunless) = 55,
75
+ BIN(branchnil) = 56,
76
+ BIN(getinlinecache) = 57,
77
+ BIN(setinlinecache) = 58,
78
+ BIN(once) = 59,
79
+ BIN(opt_case_dispatch) = 60,
80
+ BIN(opt_plus) = 61,
81
+ BIN(opt_minus) = 62,
82
+ BIN(opt_mult) = 63,
83
+ BIN(opt_div) = 64,
84
+ BIN(opt_mod) = 65,
85
+ BIN(opt_eq) = 66,
86
+ BIN(opt_neq) = 67,
87
+ BIN(opt_lt) = 68,
88
+ BIN(opt_le) = 69,
89
+ BIN(opt_gt) = 70,
90
+ BIN(opt_ge) = 71,
91
+ BIN(opt_ltlt) = 72,
92
+ BIN(opt_aref) = 73,
93
+ BIN(opt_aset) = 74,
94
+ BIN(opt_aset_with) = 75,
95
+ BIN(opt_aref_with) = 76,
96
+ BIN(opt_length) = 77,
97
+ BIN(opt_size) = 78,
98
+ BIN(opt_empty_p) = 79,
99
+ BIN(opt_succ) = 80,
100
+ BIN(opt_not) = 81,
101
+ BIN(opt_regexpmatch1) = 82,
102
+ BIN(opt_regexpmatch2) = 83,
103
+ BIN(opt_call_c_function) = 84,
104
+ BIN(bitblt) = 85,
105
+ BIN(answer) = 86,
106
+ BIN(getlocal_OP__WC__0) = 87,
107
+ BIN(getlocal_OP__WC__1) = 88,
108
+ BIN(setlocal_OP__WC__0) = 89,
109
+ BIN(setlocal_OP__WC__1) = 90,
110
+ BIN(putobject_OP_INT2FIX_O_0_C_) = 91,
111
+ BIN(putobject_OP_INT2FIX_O_1_C_) = 92,
112
+ VM_INSTRUCTION_SIZE = 93
113
+ };
@@ -0,0 +1,796 @@
1
+ /** -*-c-*-
2
+ This file contains instruction information for yarv instruction sequence.
3
+
4
+ ----
5
+ This file is auto generated by insns2vm.rb
6
+ DO NOT TOUCH!
7
+
8
+ If you want to fix something, you must edit 'template/insns_info.inc.tmpl'
9
+ or tool/insns2vm.rb
10
+ */
11
+
12
+ #define TS_OFFSET 'O'
13
+ #define TS_NUM 'N'
14
+ #define TS_LINDEX 'L'
15
+ #define TS_VALUE 'V'
16
+ #define TS_ID 'I'
17
+ #define TS_GENTRY 'G'
18
+ #define TS_IC 'K'
19
+ #define TS_CALLINFO 'C'
20
+ #define TS_CALLCACHE 'E'
21
+ #define TS_CDHASH 'H'
22
+ #define TS_ISEQ 'S'
23
+ #define TS_VARIABLE '.'
24
+ #define TS_FUNCPTR 'F'
25
+
26
+ static const char *const insn_name_info[] = {
27
+ "nop",
28
+ "getlocal",
29
+ "setlocal",
30
+ "getspecial",
31
+ "setspecial",
32
+ "getinstancevariable",
33
+ "setinstancevariable",
34
+ "getclassvariable",
35
+ "setclassvariable",
36
+ "getconstant",
37
+ "setconstant",
38
+ "getglobal",
39
+ "setglobal",
40
+ "putnil",
41
+ "putself",
42
+ "putobject",
43
+ "putspecialobject",
44
+ "putiseq",
45
+ "putstring",
46
+ "concatstrings",
47
+ "tostring",
48
+ "freezestring",
49
+ "toregexp",
50
+ "newarray",
51
+ "duparray",
52
+ "expandarray",
53
+ "concatarray",
54
+ "splatarray",
55
+ "newhash",
56
+ "newrange",
57
+ "pop",
58
+ "dup",
59
+ "dupn",
60
+ "swap",
61
+ "reverse",
62
+ "reput",
63
+ "topn",
64
+ "setn",
65
+ "adjuststack",
66
+ "defined",
67
+ "checkmatch",
68
+ "checkkeyword",
69
+ "trace",
70
+ "defineclass",
71
+ "send",
72
+ "opt_str_freeze",
73
+ "opt_newarray_max",
74
+ "opt_newarray_min",
75
+ "opt_send_without_block",
76
+ "invokesuper",
77
+ "invokeblock",
78
+ "leave",
79
+ "throw",
80
+ "jump",
81
+ "branchif",
82
+ "branchunless",
83
+ "branchnil",
84
+ "getinlinecache",
85
+ "setinlinecache",
86
+ "once",
87
+ "opt_case_dispatch",
88
+ "opt_plus",
89
+ "opt_minus",
90
+ "opt_mult",
91
+ "opt_div",
92
+ "opt_mod",
93
+ "opt_eq",
94
+ "opt_neq",
95
+ "opt_lt",
96
+ "opt_le",
97
+ "opt_gt",
98
+ "opt_ge",
99
+ "opt_ltlt",
100
+ "opt_aref",
101
+ "opt_aset",
102
+ "opt_aset_with",
103
+ "opt_aref_with",
104
+ "opt_length",
105
+ "opt_size",
106
+ "opt_empty_p",
107
+ "opt_succ",
108
+ "opt_not",
109
+ "opt_regexpmatch1",
110
+ "opt_regexpmatch2",
111
+ "opt_call_c_function",
112
+ "bitblt",
113
+ "answer",
114
+ "getlocal_OP__WC__0",
115
+ "getlocal_OP__WC__1",
116
+ "setlocal_OP__WC__0",
117
+ "setlocal_OP__WC__1",
118
+ "putobject_OP_INT2FIX_O_0_C_",
119
+ "putobject_OP_INT2FIX_O_1_C_",
120
+
121
+ };
122
+
123
+ static const char *const insn_operand_info[] = {
124
+ "",
125
+ "LN",
126
+ "LN",
127
+ "NN",
128
+ "N",
129
+ "IK",
130
+ "IK",
131
+ "I",
132
+ "I",
133
+ "I",
134
+ "I",
135
+ "G",
136
+ "G",
137
+ "",
138
+ "",
139
+ "V",
140
+ "N",
141
+ "S",
142
+ "V",
143
+ "N",
144
+ "",
145
+ "V",
146
+ "NN",
147
+ "N",
148
+ "V",
149
+ "NN",
150
+ "",
151
+ "V",
152
+ "N",
153
+ "N",
154
+ "",
155
+ "",
156
+ "N",
157
+ "",
158
+ "N",
159
+ "",
160
+ "N",
161
+ "N",
162
+ "N",
163
+ "NVV",
164
+ "N",
165
+ "LN",
166
+ "N",
167
+ "ISN",
168
+ "CES",
169
+ "V",
170
+ "N",
171
+ "N",
172
+ "CE",
173
+ "CES",
174
+ "C",
175
+ "",
176
+ "N",
177
+ "O",
178
+ "O",
179
+ "O",
180
+ "O",
181
+ "OK",
182
+ "K",
183
+ "SK",
184
+ "HO",
185
+ "CE",
186
+ "CE",
187
+ "CE",
188
+ "CE",
189
+ "CE",
190
+ "CE",
191
+ "CECE",
192
+ "CE",
193
+ "CE",
194
+ "CE",
195
+ "CE",
196
+ "CE",
197
+ "CE",
198
+ "CE",
199
+ "CEV",
200
+ "CEV",
201
+ "CE",
202
+ "CE",
203
+ "CE",
204
+ "CE",
205
+ "CE",
206
+ "V",
207
+ "CE",
208
+ "F",
209
+ "",
210
+ "",
211
+ "L",
212
+ "L",
213
+ "L",
214
+ "L",
215
+ "",
216
+ "",
217
+
218
+ };
219
+
220
+ static const int insn_len_info[] = {
221
+ 1,
222
+ 3,
223
+ 3,
224
+ 3,
225
+ 2,
226
+ 3,
227
+ 3,
228
+ 2,
229
+ 2,
230
+ 2,
231
+ 2,
232
+ 2,
233
+ 2,
234
+ 1,
235
+ 1,
236
+ 2,
237
+ 2,
238
+ 2,
239
+ 2,
240
+ 2,
241
+ 1,
242
+ 2,
243
+ 3,
244
+ 2,
245
+ 2,
246
+ 3,
247
+ 1,
248
+ 2,
249
+ 2,
250
+ 2,
251
+ 1,
252
+ 1,
253
+ 2,
254
+ 1,
255
+ 2,
256
+ 1,
257
+ 2,
258
+ 2,
259
+ 2,
260
+ 4,
261
+ 2,
262
+ 3,
263
+ 2,
264
+ 4,
265
+ 4,
266
+ 2,
267
+ 2,
268
+ 2,
269
+ 3,
270
+ 4,
271
+ 2,
272
+ 1,
273
+ 2,
274
+ 2,
275
+ 2,
276
+ 2,
277
+ 2,
278
+ 3,
279
+ 2,
280
+ 3,
281
+ 3,
282
+ 3,
283
+ 3,
284
+ 3,
285
+ 3,
286
+ 3,
287
+ 3,
288
+ 5,
289
+ 3,
290
+ 3,
291
+ 3,
292
+ 3,
293
+ 3,
294
+ 3,
295
+ 3,
296
+ 4,
297
+ 4,
298
+ 3,
299
+ 3,
300
+ 3,
301
+ 3,
302
+ 3,
303
+ 2,
304
+ 3,
305
+ 2,
306
+ 1,
307
+ 1,
308
+ 2,
309
+ 2,
310
+ 2,
311
+ 2,
312
+ 1,
313
+ 1,
314
+
315
+ };
316
+
317
+ #ifdef USE_INSN_RET_NUM
318
+ static const int insn_stack_push_num_info[] = {
319
+ 0,
320
+ 1,
321
+ 0,
322
+ 1,
323
+ 0,
324
+ 1,
325
+ 0,
326
+ 1,
327
+ 0,
328
+ 1,
329
+ 0,
330
+ 1,
331
+ 0,
332
+ 1,
333
+ 1,
334
+ 1,
335
+ 1,
336
+ 1,
337
+ 1,
338
+ 1,
339
+ 1,
340
+ 1,
341
+ 1,
342
+ 1,
343
+ 1,
344
+ 1,
345
+ 1,
346
+ 1,
347
+ 1,
348
+ 1,
349
+ 0,
350
+ 2,
351
+ 1,
352
+ 2,
353
+ 1,
354
+ 1,
355
+ 1,
356
+ 1,
357
+ 1,
358
+ 1,
359
+ 1,
360
+ 1,
361
+ 0,
362
+ 1,
363
+ 1,
364
+ 1,
365
+ 1,
366
+ 1,
367
+ 1,
368
+ 1,
369
+ 1,
370
+ 1,
371
+ 1,
372
+ 0,
373
+ 0,
374
+ 0,
375
+ 0,
376
+ 1,
377
+ 1,
378
+ 1,
379
+ 0,
380
+ 1,
381
+ 1,
382
+ 1,
383
+ 1,
384
+ 1,
385
+ 1,
386
+ 1,
387
+ 1,
388
+ 1,
389
+ 1,
390
+ 1,
391
+ 1,
392
+ 1,
393
+ 1,
394
+ 1,
395
+ 1,
396
+ 1,
397
+ 1,
398
+ 1,
399
+ 1,
400
+ 1,
401
+ 1,
402
+ 1,
403
+ 0,
404
+ 1,
405
+ 1,
406
+ 1,
407
+ 1,
408
+ 0,
409
+ 0,
410
+ 1,
411
+ 1,
412
+
413
+ };
414
+ #endif
415
+
416
+ #ifdef USE_INSN_STACK_INCREASE
417
+ static int
418
+ insn_stack_increase(int depth, int insn, VALUE *opes)
419
+ {
420
+ switch(insn){
421
+ case BIN(nop):{
422
+ return depth + 0;
423
+ }
424
+ case BIN(getlocal):{
425
+ return depth + 1;
426
+ }
427
+ case BIN(setlocal):{
428
+ return depth + -1;
429
+ }
430
+ case BIN(getspecial):{
431
+ return depth + 1;
432
+ }
433
+ case BIN(setspecial):{
434
+ return depth + -1;
435
+ }
436
+ case BIN(getinstancevariable):{
437
+ return depth + 1;
438
+ }
439
+ case BIN(setinstancevariable):{
440
+ return depth + -1;
441
+ }
442
+ case BIN(getclassvariable):{
443
+ return depth + 1;
444
+ }
445
+ case BIN(setclassvariable):{
446
+ return depth + -1;
447
+ }
448
+ case BIN(getconstant):{
449
+ return depth + 0;
450
+ }
451
+ case BIN(setconstant):{
452
+ return depth + -2;
453
+ }
454
+ case BIN(getglobal):{
455
+ return depth + 1;
456
+ }
457
+ case BIN(setglobal):{
458
+ return depth + -1;
459
+ }
460
+ case BIN(putnil):{
461
+ return depth + 1;
462
+ }
463
+ case BIN(putself):{
464
+ return depth + 1;
465
+ }
466
+ case BIN(putobject):{
467
+ return depth + 1;
468
+ }
469
+ case BIN(putspecialobject):{
470
+ return depth + 1;
471
+ }
472
+ case BIN(putiseq):{
473
+ return depth + 1;
474
+ }
475
+ case BIN(putstring):{
476
+ return depth + 1;
477
+ }
478
+ case BIN(concatstrings):{
479
+ int inc = 0;
480
+ int num = FIX2INT(opes[0]);
481
+ inc += 1 - num;;
482
+ return depth + inc;
483
+ }
484
+ case BIN(tostring):{
485
+ return depth + 0;
486
+ }
487
+ case BIN(freezestring):{
488
+ return depth + 0;
489
+ }
490
+ case BIN(toregexp):{
491
+ int inc = 0;
492
+ int cnt = FIX2INT(opes[1]);
493
+ inc += 1 - cnt;;
494
+ return depth + inc;
495
+ }
496
+ case BIN(newarray):{
497
+ int inc = 0;
498
+ int num = FIX2INT(opes[0]);
499
+ inc += 1 - num;;
500
+ return depth + inc;
501
+ }
502
+ case BIN(duparray):{
503
+ return depth + 1;
504
+ }
505
+ case BIN(expandarray):{
506
+ int inc = 0;
507
+ int num = FIX2INT(opes[0]);
508
+ int flag = FIX2INT(opes[1]);
509
+ inc += num - 1 + (flag & 1 ? 1 : 0);;
510
+ return depth + inc;
511
+ }
512
+ case BIN(concatarray):{
513
+ return depth + -1;
514
+ }
515
+ case BIN(splatarray):{
516
+ return depth + 0;
517
+ }
518
+ case BIN(newhash):{
519
+ int inc = 0;
520
+ int num = FIX2INT(opes[0]);
521
+ inc += 1 - num;;
522
+ return depth + inc;
523
+ }
524
+ case BIN(newrange):{
525
+ return depth + -1;
526
+ }
527
+ case BIN(pop):{
528
+ return depth + -1;
529
+ }
530
+ case BIN(dup):{
531
+ return depth + 1;
532
+ }
533
+ case BIN(dupn):{
534
+ int inc = 0;
535
+ int n = FIX2INT(opes[0]);
536
+ inc += n;;
537
+ return depth + inc;
538
+ }
539
+ case BIN(swap):{
540
+ return depth + 0;
541
+ }
542
+ case BIN(reverse):{
543
+ int inc = 0;
544
+ inc += 0;;
545
+ return depth + inc;
546
+ }
547
+ case BIN(reput):{
548
+ int inc = 0;
549
+ inc += 0;;
550
+ return depth + inc;
551
+ }
552
+ case BIN(topn):{
553
+ int inc = 0;
554
+ inc += 1;;
555
+ return depth + inc;
556
+ }
557
+ case BIN(setn):{
558
+ int inc = 0;
559
+ inc += 0;
560
+ return depth + inc;
561
+ }
562
+ case BIN(adjuststack):{
563
+ int inc = 0;
564
+ int n = FIX2INT(opes[0]);
565
+ inc -= n;
566
+ return depth + inc;
567
+ }
568
+ case BIN(defined):{
569
+ return depth + 0;
570
+ }
571
+ case BIN(checkmatch):{
572
+ return depth + -1;
573
+ }
574
+ case BIN(checkkeyword):{
575
+ return depth + 1;
576
+ }
577
+ case BIN(trace):{
578
+ return depth + 0;
579
+ }
580
+ case BIN(defineclass):{
581
+ return depth + -1;
582
+ }
583
+ case BIN(send):{
584
+ int inc = 0;
585
+ CALL_INFO ci = (CALL_INFO)(opes[0]);
586
+ inc += - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));;
587
+ return depth + inc;
588
+ }
589
+ case BIN(opt_str_freeze):{
590
+ return depth + 1;
591
+ }
592
+ case BIN(opt_newarray_max):{
593
+ int inc = 0;
594
+ int num = FIX2INT(opes[0]);
595
+ inc += 1 - num;;
596
+ return depth + inc;
597
+ }
598
+ case BIN(opt_newarray_min):{
599
+ int inc = 0;
600
+ int num = FIX2INT(opes[0]);
601
+ inc += 1 - num;;
602
+ return depth + inc;
603
+ }
604
+ case BIN(opt_send_without_block):{
605
+ int inc = 0;
606
+ CALL_INFO ci = (CALL_INFO)(opes[0]);
607
+ inc += -ci->orig_argc;;
608
+ return depth + inc;
609
+ }
610
+ case BIN(invokesuper):{
611
+ int inc = 0;
612
+ CALL_INFO ci = (CALL_INFO)(opes[0]);
613
+ inc += - (int)(ci->orig_argc + ((ci->flag & VM_CALL_ARGS_BLOCKARG) ? 1 : 0));;
614
+ return depth + inc;
615
+ }
616
+ case BIN(invokeblock):{
617
+ int inc = 0;
618
+ CALL_INFO ci = (CALL_INFO)(opes[0]);
619
+ inc += 1 - ci->orig_argc;;
620
+ return depth + inc;
621
+ }
622
+ case BIN(leave):{
623
+ return depth + 0;
624
+ }
625
+ case BIN(throw):{
626
+ return depth + 0;
627
+ }
628
+ case BIN(jump):{
629
+ return depth + 0;
630
+ }
631
+ case BIN(branchif):{
632
+ return depth + -1;
633
+ }
634
+ case BIN(branchunless):{
635
+ return depth + -1;
636
+ }
637
+ case BIN(branchnil):{
638
+ return depth + -1;
639
+ }
640
+ case BIN(getinlinecache):{
641
+ return depth + 1;
642
+ }
643
+ case BIN(setinlinecache):{
644
+ return depth + 0;
645
+ }
646
+ case BIN(once):{
647
+ return depth + 1;
648
+ }
649
+ case BIN(opt_case_dispatch):{
650
+ int inc = 0;
651
+ inc += -1;;
652
+ return depth + inc;
653
+ }
654
+ case BIN(opt_plus):{
655
+ return depth + -1;
656
+ }
657
+ case BIN(opt_minus):{
658
+ return depth + -1;
659
+ }
660
+ case BIN(opt_mult):{
661
+ return depth + -1;
662
+ }
663
+ case BIN(opt_div):{
664
+ return depth + -1;
665
+ }
666
+ case BIN(opt_mod):{
667
+ return depth + -1;
668
+ }
669
+ case BIN(opt_eq):{
670
+ return depth + -1;
671
+ }
672
+ case BIN(opt_neq):{
673
+ return depth + -1;
674
+ }
675
+ case BIN(opt_lt):{
676
+ return depth + -1;
677
+ }
678
+ case BIN(opt_le):{
679
+ return depth + -1;
680
+ }
681
+ case BIN(opt_gt):{
682
+ return depth + -1;
683
+ }
684
+ case BIN(opt_ge):{
685
+ return depth + -1;
686
+ }
687
+ case BIN(opt_ltlt):{
688
+ return depth + -1;
689
+ }
690
+ case BIN(opt_aref):{
691
+ return depth + -1;
692
+ }
693
+ case BIN(opt_aset):{
694
+ return depth + -2;
695
+ }
696
+ case BIN(opt_aset_with):{
697
+ return depth + -1;
698
+ }
699
+ case BIN(opt_aref_with):{
700
+ return depth + 0;
701
+ }
702
+ case BIN(opt_length):{
703
+ return depth + 0;
704
+ }
705
+ case BIN(opt_size):{
706
+ return depth + 0;
707
+ }
708
+ case BIN(opt_empty_p):{
709
+ return depth + 0;
710
+ }
711
+ case BIN(opt_succ):{
712
+ return depth + 0;
713
+ }
714
+ case BIN(opt_not):{
715
+ return depth + 0;
716
+ }
717
+ case BIN(opt_regexpmatch1):{
718
+ return depth + 0;
719
+ }
720
+ case BIN(opt_regexpmatch2):{
721
+ return depth + -1;
722
+ }
723
+ case BIN(opt_call_c_function):{
724
+ return depth + 0;
725
+ }
726
+ case BIN(bitblt):{
727
+ return depth + 1;
728
+ }
729
+ case BIN(answer):{
730
+ return depth + 1;
731
+ }
732
+ case BIN(getlocal_OP__WC__0):{
733
+ return depth + 1;
734
+ }
735
+ case BIN(getlocal_OP__WC__1):{
736
+ return depth + 1;
737
+ }
738
+ case BIN(setlocal_OP__WC__0):{
739
+ return depth + -1;
740
+ }
741
+ case BIN(setlocal_OP__WC__1):{
742
+ return depth + -1;
743
+ }
744
+ case BIN(putobject_OP_INT2FIX_O_0_C_):{
745
+ return depth + 1;
746
+ }
747
+ case BIN(putobject_OP_INT2FIX_O_1_C_):{
748
+ return depth + 1;
749
+ }
750
+
751
+ default:
752
+ rb_bug("insn_sp_increase: unreachable");
753
+ }
754
+ return 0;
755
+ }
756
+ #endif
757
+
758
+ /* some utilities */
759
+
760
+ static int
761
+ insn_len(VALUE insn)
762
+ {
763
+ return insn_len_info[(int)insn];
764
+ }
765
+
766
+ static const char *
767
+ insn_name(VALUE insn)
768
+ {
769
+ return insn_name_info[(int)insn];
770
+ }
771
+
772
+ static const char *
773
+ insn_op_types(VALUE insn)
774
+ {
775
+ return insn_operand_info[(int)insn];
776
+ }
777
+
778
+ static int
779
+ insn_op_type(VALUE insn, long pos)
780
+ {
781
+ int len = insn_len(insn) - 1;
782
+ if(pos < len){
783
+ return insn_operand_info[(int)insn][pos];
784
+ }
785
+ else{
786
+ return 0;
787
+ }
788
+ }
789
+
790
+ #ifdef USE_INSN_RET_NUM
791
+ static int
792
+ insn_ret_num(VALUE insn)
793
+ {
794
+ return insn_stack_push_num_info[(int)insn];
795
+ }
796
+ #endif