forked from rubinius/rubinius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
2286 lines (1885 loc) · 63.6 KB
/
index.html
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>Instructions - Rubinius</title>
<meta content='text/html;charset=utf-8' http-equiv='content-type'>
<meta content='de' http-equiv='content-language'>
<meta content='Rubinius is an implementation of the Ruby programming language. The Rubinius bytecode virtual machine is written in C++. The bytecode compiler is written in pure Ruby. The vast majority of the core library is also written in Ruby, with some supporting primitives that interact with the VM directly.' name='description'>
<meta content='Less Than Three. <3. http://less.thanthree.com' name='author'>
<link href='/' rel='home'>
<link href='/' rel='start'>
<link href='/doc/de/virtual-machine' rel='prev' title='Virtual Machine'>
<link href='/doc/de/virtual-machine/custom-dispatch-logic' rel='next' title='Custom Dispatch Logic'>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script><![endif]-->
<script src="/javascripts/jquery-1.3.2.js" type="text/javascript"></script>
<script src="/javascripts/paging_keys.js" type="text/javascript"></script>
<script src="/javascripts/application.js" type="text/javascript"></script>
<style>article, aside, dialog, figure, footer, header, hgroup, menu, nav, section { display: block; }</style>
<link href="/stylesheets/blueprint/screen.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/blueprint/print.css" media="print" rel="stylesheet" type="text/css" />
<!--[if IE]><link href="/stylesheets/blueprint/ie.css" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<!--[if IE]><link href="/stylesheets/ie.css" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<link href="/stylesheets/pygments.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<div class='container'>
<div class='span-21 doc_menu'>
<header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a id="blog" href="/blog/">Blog</a></li>
<li><a id="documentation" href="/doc/en/">Documentation</a></li>
<li><a href="/projects/">Projects</a></li>
<li><a href="/roadmap/">Roadmap</a></li>
<li><a href="/releases/">Releases</a></li>
</ul>
</nav>
</header>
</div>
<div class='span-3 last'>
<div id='version'>
<a href="/releases/1.2.3">1.2.3</a>
</div>
</div>
</div>
<div class="container languages">
<nav>
<span class="label">Sprachen:</span>
<ul>
<li><a href="/doc/de/"
class="current"
>de</a></li>
<li><a href="/doc/en/"
>en</a></li>
<li><a href="/doc/es/"
>es</a></li>
<li><a href="/doc/ja/"
>ja</a></li>
<li><a href="/doc/pl/"
>pl</a></li>
<li><a href="/doc/ru/"
>ru</a></li>
</ul>
</nav>
</div>
<div class="container doc_page_nav">
<span class="label">Vorherige:</span>
<a href="/doc/de/virtual-machine">Virtual Machine</a>
<span class="label">Aufwärts:</span>
<a href="/doc/de/">Inhaltsverzeichnis</a>
<span class="label">Nächste:</span>
<a href="/doc/de/virtual-machine/custom-dispatch-logic">Custom Dispatch Logic</a>
</div>
<div class="container documentation">
<h2>Instructions</h2>
<p>The virtual machine instructions are contained in <code>vm/instructions.def</code>. The
documentation below is generated by <code>rakelib/vm.rake</code>.</p>
<h3><a class="instruction" name="noop">noop()</a></h3>
<p>The classic no-op operator. It performs no actions and does not modify the
stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#pop">pop</a></li>
</ul>
<h3><a class="instruction" name="push_nil">push_nil()</a></h3>
<p>The special object <code>nil</code> is pushed onto the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>nil</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="push_true">push_true()</a></h3>
<p>The special value <code>true</code> is pushed onto the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>true</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="push_false">push_false()</a></h3>
<p>The special object <code>false</code> is pushed onto the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>false</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="push_int">push_int(number)</a></h3>
<p>Pushes the value of the integer literal onto the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>number</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h4 id="notes">Notes</h4>
<p>Certain common cases (i.e. -1, 0, 1, and 2) are optimised to avoid the
decoding of the argument.</p>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#meta_push_0">meta_push_0</a></li>
<li><a href="#meta_push_1">meta_push_1</a></li>
<li><a href="#meta_push_2">meta_push_2</a></li>
<li><a href="#meta_push_neg_1">meta_push_neg_1</a></li>
</ul>
<h3><a class="instruction" name="push_self">push_self()</a></h3>
<p>The current <code>self</code> object is pushed onto the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>self</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="set_literal">set_literal(literal)</a></h3>
<p>Used to set the value of a literal. The stack top is set to the literal
indicated by the operand.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>value</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h4 id="notes-1">Notes</h4>
<p>Unlike other literals such as strings and numbers, creating a Regexp
literal (i.e. via the /regex/ syntax) is a two step process to create the
literal slot for the Regexp, create a literal for the string between the
‘/’ delimiters and create a new Regexp object passing it the string. Only
then can the literal value be set, using the set_literal opcode.</p>
<h3><a class="instruction" name="push_literal">push_literal(literal)</a></h3>
<p>The value identified by the operand <em>literal</em> in the current state
literals tuple is retrieved and placed onto the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>literal</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h4 id="notes-2">Notes</h4>
<p>The literals tuple is part of the machine state, and holds all literal
objects defined or used within a particular scope.</p>
<h3><a class="instruction" name="goto">goto(location)</a></h3>
<p>Unconditionally moves the instruction pointer to the position specified by
<em>location</em>.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h4 id="notes-3">Notes</h4>
<p>All goto instructions use absolute addressing. This is absolute movement
rather than a relative one, so the operand must specify the ip starting
from 0 to move to.</p>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#goto_if_true">goto_if_true</a></li>
<li><a href="#goto_if_false">goto_if_false</a></li>
</ul>
<h3><a class="instruction" name="goto_if_false">goto_if_false(location)</a></h3>
<p>Remove the top value on the stack, and if <code>nil</code> or <code>false</code>, set the
instruction pointer to the value specified by <em>location</em>.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>...</td></tr>
<tr><td>...</td><td /></tr>
</tbody>
</table>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#goto">goto</a></li>
<li><a href="#goto_if_true">goto_if_true</a></li>
</ul>
<h3><a class="instruction" name="goto_if_true">goto_if_true(location)</a></h3>
<p>Remove the top value on the stack, and if not <code>nil</code> or <code>false</code>, set the
instruction pointer to the value specified by <em>location</em>.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>...</td></tr>
<tr><td>...</td><td /></tr>
</tbody>
</table>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#goto">goto</a></li>
<li><a href="#goto_if_false">goto_if_false</a></li>
</ul>
<h3><a class="instruction" name="ret">ret()</a></h3>
<p>Return a value to the direct caller</p>
<p>Pops the top value from the stack, and returns to the direct caller of the
current invocation.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>value</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h4 id="notes-4">Notes</h4>
<p>In a method, the <code>return</code> keyword uses this instruction. In a block
though, <code>return</code> uses the raise_return instruction and <code>next</code> uses this
instruction.</p>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#raise_return">raise_return</a></li>
<li><a href="#raise_exc">raise_exc</a></li>
</ul>
<h3><a class="instruction" name="swap_stack">swap_stack()</a></h3>
<p>Swaps the top two values on the stack, so that the second value becomes
the first, and the first value becomes the second.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>s0</td><td>s1</td></tr>
<tr><td>s1</td><td>s0</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="dup_top">dup_top()</a></h3>
<p>Read a value from the top of the stack and push it on the stack again
without removing the original value.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>s0</td><td>s0</td></tr>
<tr><td>...</td><td>s0</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="dup_many">dup_many(count)</a></h3>
<p>Duplicate multiple values on the stack</p>
<p>Read <em>count</em> values from the stack and push them onto the stack again
in order without removing the original values.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td> value1
</td><td> value1
</td></tr>
<tr><td> value2
</td><td> value2
</td></tr>
<tr><td> ...
</td><td> value1
</td></tr>
<tr><td /><td> value2
</td></tr>
<tr><td /><td> ...
</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="pop">pop()</a></h3>
<p>Removes the top value from the stack, discarding it.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>...</td></tr>
<tr><td>...</td><td /></tr>
</tbody>
</table>
<h4 id="notes-5">Notes</h4>
<p>Pop is typically used when the return value of another opcode is not
required.</p>
<h3><a class="instruction" name="pop_many">pop_many(count)</a></h3>
<p>Removes <em>count</em> values from the stack and discard them.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td> value1
</td><td> ...
</td></tr>
<tr><td> value2
</td><td /></tr>
<tr><td> ...
</td><td /></tr>
</tbody>
</table>
<h3><a class="instruction" name="rotate">rotate(count)</a></h3>
<p>Reverses the order on the stack of the top <em>count</em> values.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td> obj1
</td><td> obj3
</td></tr>
<tr><td> obj2
</td><td> obj2
</td></tr>
<tr><td> obj3
</td><td> obj1
</td></tr>
<tr><td> ...
</td><td> ...
</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="move_down">move_down(positions)</a></h3>
<p>The top value on the stack is moved down by the specified number of
<em>positions</em>, with all values above that position shuffling up by one.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td> obj1
</td><td> obj2
</td></tr>
<tr><td> obj2
</td><td> ...
</td></tr>
<tr><td> ...
</td><td> objn
</td></tr>
<tr><td> objn
</td><td> obj1
</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="set_local">set_local(local)</a></h3>
<p>Read the top of the stack and set the local variable identified by operand
<em>local</em> to it. The stack is not modified by this instruction.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>value</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#push_local">push_local</a></li>
</ul>
<h3><a class="instruction" name="push_local">push_local(local)</a></h3>
<p>Retrieves the current value of the local variable referenced by operand
<em>local</em> and push it onto the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>value</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#set_local">set_local</a></li>
</ul>
<h3><a class="instruction" name="push_local_depth">push_local_depth(depth, index)</a></h3>
<p>Pushes the value of a local from an enclosing scope onto the stack</p>
<p>Retrieves the value of a local variable. Operand <em>depth</em> indicates how many
upward enclosing scopes to walk up and then operand <em>index</em> indicates which
local in that context to read. The value is then pushed on the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>value</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h4 id="example">Example</h4>
<pre><code> k = 0
foo.each do |i|
bar.each do |j|
# i is a local variable from enclosing scope at depth 1
# k is a local variable from enclosing scope at depth 2
i = i + j + k
end
end
</code></pre>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#set_local_depth">set_local_depth</a></li>
</ul>
<h3><a class="instruction" name="set_local_depth">set_local_depth(depth, index)</a></h3>
<p>Updates the value of a local variable contained in an enclosing scope</p>
<p>Read a value from the top of thes stack and use it to update a local
variable in an enclosing scope. The <em>depth</em> and <em>index</em> operands
indentify the specific local the same as in <code>push_local_depth</code>.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>value</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h4 id="example-1">Example</h4>
<pre><code> foo.each do |i|
bar.each do |j|
i = i + j # i is a local variable from enclosing scope at depth 1
end
end
</code></pre>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#push_local_depth">push_local_depth</a></li>
</ul>
<h3><a class="instruction" name="passed_arg">passed_arg(index)</a></h3>
<p>Checks if the argument specified by the operand <em>index</em> was passed to
the current invocation. If so, push true, otherwise false.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>boolean</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h4 id="notes-6">Notes</h4>
<p>Arguments are specified via a zero-index, so the first argument is 0.</p>
<h3><a class="instruction" name="push_current_exception">push_current_exception()</a></h3>
<p>Pushes the current exception onto the stack, so that it can be used for
some purpose, such as checking the exception type, setting an exception
variable in a rescue clause, etc.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>exception</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h4 id="example-2">Example</h4>
<pre><code> begin
foo = BAR # BAR is not defined
rescue NameError # push_exception used to check type of exception (via ===)
puts "No BAR"
end
</code></pre>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#raise_exc">raise_exc</a></li>
</ul>
<h3><a class="instruction" name="clear_exception">clear_exception()</a></h3>
<p>Clears any exceptions from the current thread. </p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="push_exception_state">push_exception_state()</a></h3>
<p>Package up the current exception state into an object and push it. This
is used to preserve the exception state around code that might mutate it.
For instance, when handling an ensure while an exception is being raised</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>exc_state</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="restore_exception_state">restore_exception_state()</a></h3>
<p>Pops a value off the stack and set the threads exception state from it.
This instruction is only to be used with a value pushed on the stack
by the push_exception_state instruction.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>exception</td><td>...</td></tr>
<tr><td>...</td><td /></tr>
</tbody>
</table>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#push_exception_state">push_exception_state</a></li>
</ul>
<h3><a class="instruction" name="raise_exc">raise_exc()</a></h3>
<p>Raises an exception</p>
<p>Pops a value off the stack and make it the current exception.
If the value is not an instance of Exception, a TypeError is raised.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>...</td></tr>
<tr><td>...</td><td /></tr>
</tbody>
</table>
<h3><a class="instruction" name="setup_unwind">setup_unwind(ip, type)</a></h3>
<p>Register an unwind handler</p>
<p>Registers what to happen when an exception wants to unwind through the
current invocation. Operand <em>ip</em> specifies where to set the instruction
pointer if used. Operand <em>type</em> is either 0 for if the value should be
used in rescue style (not run when unwinding because of a return caused by
<code>raise_return</code>) or 1 for ensure style (always used). The registrations are
nested within the current invocation and are automatically removed from
the registry when they are used. The <code>pop_unwind</code> instruction can be used
to remove an unused registration.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h4 id="notes-7">Notes</h4>
<p>The registration also contains the value of the stack depth when
created. If the registration is used, then the stack depth is
restored to the value contained in the registration</p>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#pop_unwind">pop_unwind</a></li>
</ul>
<h3><a class="instruction" name="pop_unwind">pop_unwind()</a></h3>
<p>Remove the next unused unwind registration from the current invocation.
This instruction is paired with <code>setup_unwind</code> to remove registrations
when control exits a section of code that registered a handler but didn’t
use it. For example, exiting a begin that had a rescue expression.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#setup_unwind">setup_unwind</a></li>
</ul>
<h3><a class="instruction" name="raise_return">raise_return()</a></h3>
<p>Cause the toplevel enclosing scope to return</p>
<p>Only used in a block, pop a value from the stack and raise a special
internal exception and begin unwinding the stack. The toplevel method
scope will rescue the exception and return the value.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>value</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#ret">ret</a></li>
</ul>
<h3><a class="instruction" name="ensure_return">ensure_return()</a></h3>
<p>Return from a scope but run ensures first</p>
<p>A one use instruction, used only in a method toplevel within a begin
that has an ensure. Use the same internal exception as <code>raise_return</code>
which will coax the ensure registration to run.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>value</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h4>See Also</h4>
<ul class="insn_cross_ref">
<li><a href="#ret">ret</a></li>
<li><a href="#raise_return">raise_return</a></li>
</ul>
<h3><a class="instruction" name="raise_break">raise_break()</a></h3>
<p>Cause the method that yielded the current block to return. Used to
implement the <code>break</code> keyword in a block.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>value</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="reraise">reraise()</a></h3>
<p>Continue unwinding the stack with the current exception. Verify that there
is a current exception, then begin the unwinding process again.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="make_array">make_array(count)</a></h3>
<p>Create an array and populate with values on the stack</p>
<p>Creates a new array, populating its contents by remove the number of
values specidied by operand <em>count</em> and putting them into the array in the
order they were on the stack. The resulting array is pushed onto the
stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td> valueN
</td><td> [value1, value2, ..., valueN]
</td></tr>
<tr><td> ...
</td><td> ...
</td></tr>
<tr><td> value2
</td><td /></tr>
<tr><td> value1
</td><td /></tr>
<tr><td> ...
</td><td /></tr>
</tbody>
</table>
<h3><a class="instruction" name="cast_array">cast_array()</a></h3>
<p>Removes the object on the top of the stack, and:</p>
<ol>
<li>If the input is a tuple, a new array object is created based on the
tuple data.</li>
<li>If the input is an array, it is unmodified.</li>
</ol>
<p>If the input is any other type, call <code>Array.coerce_into_array(value)</code>.
If the return value of the method call is an <code>Array</code>, make it the result.
Otherwise make the result an 1 element <code>Array</code> contain the original value.</p>
<p>The resulting array is then pushed back onto the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>array</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="shift_array">shift_array()</a></h3>
<p>Pops an array off the top of the stack. If the array is empty, it is
pushed back onto the stack, followed by <code>nil</code>.</p>
<p>Otherwise, the array is shifted, then pushed back onto the stack,
followed by the object that was shifted from the front of the array.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td> [value1, value2, ..., valueN]
</td><td> value1
</td></tr>
<tr><td> ...
</td><td> [value2, ..., valueN]
</td></tr>
<tr><td /><td> ...
</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="set_ivar">set_ivar(index)</a></h3>
<p>Pops a value off the stack, and uses it to set the value of the instance
variable identifies by the literal specified by operand <em>index</em>. The
value popped off the stack is then pushed back on again.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>value</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="push_ivar">push_ivar(index)</a></h3>
<p>Pushes the instance variable identified by <em>index</em> onto the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>value</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="push_const">push_const(literal)</a></h3>
<p>Locates the constant indicated by the operand <em>literal</em> from the current
context, and pushes it onto the stack. If the constant cannot be found in
the current context, nothing is pushed onto the stack, and a NameError
exception is raised.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>...</td><td>constant</td></tr>
<tr><td /><td>...</td></tr>
</tbody>
</table>
<h4 id="example-3">Example</h4>
<pre><code> engine = RUBY_ENGINE # RUBY_ENGINE is a constant defined by Rubinius
</code></pre>
<h3><a class="instruction" name="set_const">set_const(index)</a></h3>
<p>Pops an object off the stack, and uses value to set a constant named
by the literal <em>index</em>. The value is pushed back onto the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>value</td><td>value</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h3><a class="instruction" name="set_const_at">set_const_at(index)</a></h3>
<p>Pop a value from the literals table specified by the operand <em>index</em> and
use it as the value of a constant named inside a Module object popped from
the stack. The <em>value</em> is pushed back on the stack.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td> value
</td><td> value
</td></tr>
<tr><td> module
</td><td> ...
</td></tr>
<tr><td> ...
</td><td /></tr>
</tbody>
</table>
<h3><a class="instruction" name="find_const">find_const(index)</a></h3>
<p>Pops <em>module</em> off the stack, and searches within its namespace for the
constant named by the literal specified by the operand <em>index</em>. If found,
it is pushed onto the stack; otherwise, nothing is pushed onto the stack,
and a <code>NameError</code> exception is raised.</p>
<table class="stack_effect">
<thead>
<tr><th>Before</th><th>After</th></tr>
</thead>
<tbody>
<tr><td>module</td><td>constant</td></tr>
<tr><td>...</td><td>...</td></tr>
</tbody>
</table>
<h4 id="example-4">Example</h4>
<pre><code> str = "abc"
enum = Enumerable::Enumerator(str, :each_byte)
</code></pre>
<h3><a class="instruction" name="push_cpath_top">push_cpath_top()</a></h3>