List of YARV instructions
Ruby 1.9 compiles Ruby scripts into sequences of these instructions.
Note: These are not public API; may changed in future Ruby versions.
| No. | Pops | Parameters | Pushes | Description | LOC | Comments |
|---|---|---|---|---|---|---|
| 1 | nop | nop | 1 | |||
| 2 | getlocal lindex_t idx | val | get local variable value (which is pointed by idx). | 1 | ||
| 3 | val | setlocal lindex_t idx | set local variable value (which is pointed by idx) as val. | 1 | ||
| 4 | getspecial key, rb_num_t type | val | get special local variable ($~, $_, ..) value. | 1 | ||
| 5 | obj | setspecial key | set special local variable ($~, $_, ...) value as obj. | 1 | ||
| 6 | getdynamic dindex_t idx, rb_num_t level | val | get block local variable(which is pointed by idx and level). | 6 | ||
| 7 | val | setdynamic dindex_t idx, rb_num_t level | set block local variable(which is pointed by 'idx') as val. | 6 | ||
| 8 | getinstancevariable ID id, IC ic | val | get instance variable id of obj. | 1 | ||
| 9 | val | setinstancevariable ID id, IC ic | set instance variable id of obj as val. | 1 | ||
| 10 | getclassvariable ID id | val | get class variable id of klass as val. | 2 | ||
| 11 | val | setclassvariable ID id | set class variable id of klass as val. | 2 | ||
| 12 | klass | getconstant ID id | val | 1 | ||
| 13 | cbase, val | setconstant ID id | 3 | |||
| 14 | getglobal GENTRY entry | val | get global variable id. | 1 | ||
| 15 | val | setglobal GENTRY entry | set global variable id as val. | 1 | ||
| 16 | putnil | val | put nil to stack. | 1 | ||
| 17 | putself | val | put self. | 1 | ||
| 18 | putobject val | val | put some object. | 1 | ||
| 19 | putspecialobject rb_num_t value_type | val | put special object. "value_type" is for expansion. | 13 | ||
| 20 | putiseq ISEQ iseq | ret | put iseq value. | 1 | ||
| 21 | putstring str | val | put string val. string will be copied. | 1 | ||
| 22 | ... | concatstrings rb_num_t num | val | put concatenate strings | 8 | |
| 23 | val | tostring | val | to_str | 1 | |
| 24 | ... | toregexp rb_num_t opt, rb_num_t cnt | val | to Regexp | 9 | |
| 25 | ... | newarray rb_num_t num | val | put new array. | 2 | |
| 26 | duparray ary | val | dup array | 1 | ||
| 27 | ary, ... | expandarray rb_num_t num, rb_num_t flag | ... | expand array to num objects. | 1 | |
| 28 | ary2st, ary1 | concatarray | ary | concat two arrays | 16 | |
| 29 | ary | splatarray flag | obj | splat array | 5 | |
| 30 | ary, obj | checkincludearray flag | result, obj | check value is included in ary | 27 | |
| 31 | ... | newhash rb_num_t num | val | put new Hash. | 9 | |
| 32 | high, low | newrange rb_num_t flag | val | put new Range object.(Range.new(low, high, flag)) | 1 | |
| 33 | val | pop | pop from stack. | 2 | ||
| 34 | val | dup | val2, val1 | duplicate stack top. | 1 | |
| 35 | ... | dupn rb_num_t n | ... | duplicate stack top n elements | 6 | |
| 36 | obj, val | swap | val, obj | swap top 2 vals | 1 | |
| 37 | val, ... | reput | val | for stack caching. | 1 | |
| 38 | ... | topn rb_num_t n | val | get nth stack value from stack top | 1 | |
| 39 | val, ... | setn rb_num_t n | val | set Nth stack entry to stack top | 1 | |
| 40 | ... | adjuststack rb_num_t n | ... | empt current stack | 1 | |
| 41 | v | defined rb_num_t type, obj, needstr | val | defined? | 100 | |
| 42 | trace rb_num_t nf | trace | 3 | |||
| 43 | super, cbase | defineclass ID id, ISEQ class_iseq, rb_num_t define_type | val | 80 | ||
| 44 | ... | send ID op_id, rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag, IC ic | val | obj.send(id, args..) # args.size => num | 13 | |
| 45 | ... | invokesuper rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag | val | super(args) # args.size => num | 19 | |
| 46 | ... | invokeblock rb_num_t num, rb_num_t flag | val | yield(args) # args.size => num, flag shows expand argument or not | 5 | |
| 47 | val | leave | val | return from this scope. | 10 | |
| 48 | val | finish | val | return from this vm loop | 6 | |
| 49 | throwobj | throw rb_num_t throw_state | val | longjump | 4 | |
| 50 | jump OFFSET dst | set PC to (PC + dst). | 2 | |||
| 51 | val | branchif OFFSET dst | if val is not false or nil, set PC to (PC + dst). | 4 | ||
| 52 | val | branchunless OFFSET dst | if val is false or nil, set PC to (PC + dst). | 4 | ||
| 53 | getinlinecache OFFSET dst, IC ic | val | inline cache | 8 | ||
| 54 | onceinlinecache OFFSET dst, IC ic | val | inline cache (once) | 16 | ||
| 55 | val | setinlinecache IC ic | val | set inline cache | 6 | |
| 56 | key, ... | opt_case_dispatch CDHASH hash, OFFSET else_offset | case dispatcher | 23 | ||
| 57 | opt_checkenv | check environment | 6 | |||
| 58 | obj, recv | opt_plus IC ic | val | optimized X+Y. | 63 | |
| 59 | obj, recv | opt_minus IC ic | val | optimized X-Y. | 36 | |
| 60 | obj, recv | opt_mult IC ic | val | optimized X*Y. | 40 | |
| 61 | obj, recv | opt_div IC ic | val | optimized X/Y. | 51 | |
| 62 | obj, recv | opt_mod IC ic | val | optimized X%Y. | 66 | |
| 63 | obj, recv | opt_eq IC ic | val | optimized X==Y. | 8 | |
| 64 | obj, recv | opt_neq IC ic, IC ic_eq | val | optimized X!=Y. | 18 | |
| 65 | obj, recv | opt_lt IC ic | val | optimized X<Y. | 37 | |
| 66 | obj, recv | opt_le IC ic | val | optimized X<=Y. | 17 | |
| 67 | obj, recv | opt_gt IC ic | val | optimized X>Y. | 37 | |
| 68 | obj, recv | opt_ge IC ic | val | optimized X>=Y. | 16 | |
| 69 | obj, recv | opt_ltlt IC ic | val | << | 21 | |
| 70 | obj, recv | opt_aref IC ic | val | [] | 17 | |
| 71 | set, obj, recv | opt_aset IC ic | val | recv[obj] = set | 21 | |
| 72 | recv | opt_length IC ic | val | optimized length | 20 | |
| 73 | recv | opt_size IC ic | val | optimized size | 20 | |
| 74 | recv | opt_succ IC ic | val | optimized succ | 34 | |
| 75 | recv | opt_not IC ic | val | optimized not | 10 | |
| 76 | obj | opt_regexpmatch1 r | val | optimized regexp match | 1 | |
| 77 | obj1, obj2 | opt_regexpmatch2 | val | optimized regexp match 2 | 6 | |
| 78 | opt_call_c_function rb_insn_func_t funcptr | call native compiled method | 10 | |||
| 79 | bitblt | ret | BLT | 1 | ||
| 80 | answer | ret | The Answer to Life, the Universe, and Everything | 1 |