Instruction | Operands | Example | Meaning | ||||||
---|---|---|---|---|---|---|---|---|---|
adjuststack |
The number of values to pop | foo[0] ||= 1 |
Pops n values off the stack and discards them | ||||||
anytostring |
A calldata instance |
"foo #{bar}" |
The anytostring instruction is always immediately by a dup then an objtostring instruction:dup objtostring anytostring anytostring peeks the top two values on the stack, which are necessarily the results of dup followed by objtostring . If the top of the stack (i.e., the result of objtostring ) is a String , no action is taken. Otherwise, the top of stack is popped off and the next value down (i.e., the original object -- result of dup ) is converted to an internal String representation using rb_any_to_s , and that new String is pushed onto the stack |
||||||
concatarray |
[foo, bar, *baz] |
Pops an Array off the stack, then pops an object off the stack to splat into the Array , then pushes the newly concatenated Array onto the stack. If the object to splat is not an Array , then to to_a will be called on it to make an Array . If the result of to_a is not an Array , then a TypeError will be raised |
|||||||
concatstrings |
The number of elements to take from the stop of stack | "foo #{bar} baz" |
Pops n values off the stack and concatenates them into a String , which is then pushed onto the stack. This is only used for string interpolation. Otherwise, putstring is used for non-frozen strings and putobject is used for frozen strings |
||||||
getclassvariable |
Two operands: - The name of the class variable as a Symbol - An inline cache |
@@foo |
Retrieves the class variable value corresponding to the class variable name operand and the class reference in the VM_ENV_DATA_INDEX_ME_CREF field of the environment data and pushes the class variable value on the stack.The inline cache is used to speed up class variable access. The cache entry is keyed on the class reference value and the global class variable serial number. If either the current class reference doesn't match or global class variable serial number changes, the cache is invalidated. The cache entry value is the storage location for global variables for the class Cache Hit: If the cache hits, then the class variable is looked up on the class and pushed onto the stack. Cache Miss: If the cache is empty, then the class hierarchy for the class reference is searched to find where class variables are stored. This could be a large space (e.g., many included modules in Rails), which is why there's a cache in the first place. When the class variable is found the inline cache is updated with the class variable storage location and the class variable value is pushed onto the stack |
||||||
getinstancevariable |
|||||||||
dup |
$foo = 1 |
Dupes the top value on the stack and pushes onto the stack | |||||||
duparray |
[1, 2, 3] |
Dupes and pushes an Array onto the stack. Often used to push an Array literal onto the stack |
|||||||
duphash |
{ a: 1, b: 2, c: 3 } |
Dupes and pushes a Hash onto the stack. Often used to push a Hash literal onto the stack |
|||||||
dupn |
The number of values to dupe | Foo::Bar ||= true |
Dups n values from the top of the stack and pushes them onto the stack | ||||||
expandarray |
Two operands: - An integer that specifies how many values to push on the stack - An integer flag used to indicate if the assignment used the * operator and the direction of the array |
foo, *bar = 1, 2, 3 |
Used to spread an Array for multi-assignement. Pops a value off the stack and converts it to an Array with to_ary if necessary, then spreads the Array , pushing N elements (from the first operand) onto the stack. If the Array is smaller than N, then nil will be pushed for N - array.size elements. If the splat flag is specified, reassemble array.size - N elements into a new Array and push that onto the stack. If the postarg flag is set, then the values being pushed onto the stack are done in reverse order |
||||||
getblockparam |
Two operands: - The index of the block param - The level of the frame to look for the block param in (i.e., how many parent frames to traverse to find the correct environment pointer) |
def foo(x, y, &block) = block |
Looks up the frame corresponding to the level operand and then retrieves the value at the index offset. If the value is already a Proc , it is pushed onto the stack. Otherwise, the value is reified to a Proc with rb_vm_bh_to_procval and the new Proc is pushed onto the stack |
||||||
getblockparamproxy |
Two operands: - The index of the block param - The level of the frame to look for the block param in (i.e., how many parent frames to traverse to find the correct environment pointer) |
def foo(x, y, &block) = block.call |
A specialized version of getblockparam that avoids allocating a Proc if it determines that the only thing being done with the block parameter is to call call on it. Looks up the frame corresponding to the level operand and then retrieves the value at the index offset. If the value is already a Proc or was reified to a Proc , it is pushed onto the stack. Otherwise, a proxy object that can jump directly to the block iseq is pushed onto the stack |
||||||
getlocal |
Two operands: - The index of the local variable - The level of the frame to look for the local variable in (i.e., how many parent frames to traverse to find the correct environment pointer) |
foo = 0; tap { tap { foo } } |
Looks up the frame corresponding to the level operand and then retrieves the value at the index offset then pushes that value onto the stack | ||||||
getlocal_WC_0 |
The index of the local variable in the current frame (level = 0 ) |
foo = 0; foo |
A specialized version of the getlocal instruction that always accesses locals from the current frame (level = 0 ). It works the same way as getlocal index, 0 , looking up the local at the index in the current frame and pushing that value onto the stack, but saves memory by not reserving space for the level operand |
||||||
getlocal_WC_1 |
The index of the local variable in the parent frame (level = 1 ) |
foo = 0; tap { foo } |
A specialized version of the getlocal instruction that always accesses locals from the parent frame (level = 1 ). It works the same way as getlocal index, 1 , looking up the local at the index in the parent frame and pushing that value onto the stack, but saves memory by not reserving space for the level operand |
||||||
getspecial |
Two operands: - The index of the special variable to access: 0 - VM_SVAR_LASTLINE 1 - VM_SVAR_BACKREF 2.. - an index into the others field in the vm_svar struct (offset by 2 )- (optional) Index into the MatchData object to return (requires the first operand to be 1 )It's a tagged value with the tag as the least significant bit (LSB). If the LSB is 0 , then the value is 2 times index of the capture group (e.g., $2 -> getspecial 1, 4 )If the LSB is 1 , then the value is twice plus the ordinal value of the ASCII character value of the global variable to return (e.g., $& -> getspecial 1, 77 ) |
lastlinegetspecial 0, 0 :foo if /abc/ backref getspecial 1, <X> :[$1, $2, $3, $4, $&, $', $+] others (flip flop) getspecial <X>, 0 foo if (value == 1) .. (value == 3) |
Looks up a special variable based on the operands from the environment data section of the stack and pushes the value onto the stack | ||||||
intern |
:"#{foo}" %I[foo #{bar}] |
Pops a value off the stack and converts it into a Symbol , which is then pushed onto the stack. The top of stack value will always be a String because the intern instruction must always be preceded by either anytostring or concatstrings |
|||||||
leave |
Pop a frame off the frame stack and return the value on top of the stack | ||||||||
newarray |
The number of elements to take from the top of the stack | [foo, bar, baz] |
Pops n values off the stack and inserts them into a new Array , which is then pushed onto the stack |
||||||
newarraykwsplat |
The number of elements to take from the top of the stack | [1, 2, **{ foo: "bar" }] |
Pops n values off the stack and inserts them into a new Array , which is then pushed onto the stack. Unlike newarray , however, the last element of the array will be a Hash that the ** operator is being used on. It's used to create an Array from positional arguments and a Hash from the keyword arguments |
||||||
newhash |
The number of elements to take from the top of the stack; must be an even number | { foo: foo, bar: bar } |
Pops n values off the top of the stack and treats them as (key, value) pairs for the creation of a Hash , which is then pushed onto the stack. The even numbered elements are the keys, while the odd numbered elements are the values. The value matched to a key will always be at position i + 1 . |
||||||
newrange |
A flag that indicates if the Range is inclusive or exclusive of the upper bound |
foo..bar |
Pops 2 values off the stack to create a new Range object. The top value on the stack is the upper bound and the next popped value is the lower bound of the Range . The Range is then pushed onto the stack |
||||||
objtostring |
A calldata instance |
"foo #{bar}" |
Pops a value off the stack and calls to_s on it to convert it to a string, which is then pushed onto the the stack. This is used when an object is used as part of interpolation (String , Symbol , Regexp , heredocs, etc.) |
||||||
opt_and |
A calldata instance that will always contain the following values:- mid : :& - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo & 3 |
Optimized implementation of the & method used when & is called in the infix position with a single positional argument and no block |
||||||
opt_aref |
A calldata instance that will always contain the following values:- mid : :[] - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo[1] |
Optimized implementation of the [] method used when [] is called directly on the receiver without a block |
||||||
opt_aref_with |
A calldata instance that will always contain the following values:- mid : :[] - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
x = "abc"; x[0] |
Optimized implementation of the String#[] method used when [] is called directly on a String without a block. Works just like opt_aref , but is used when the receiver is known to be a String . |
||||||
opt_aset |
A calldata instance that will always contain the following values:- mid : :[]= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo[1] = 2 |
Optimized implementation of the []= method used when []= is called directly on the receiver without a block |
||||||
opt_aset_with |
A calldata instance that will always contain the following values:- mid : :[]= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
`x = "abc"; x[0] = "d" | Optimized implementation of the String#[]= method used when []= is called directly on a String without a block. Works just like opt_aset , but is used when the receiver is known to be a String . |
||||||
opt_div |
A calldata instance that will always contain the following values:- mid : :/ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo / 3 |
Optimized implementation of the / method used when / is called in the infix position with a single positional argument and no block |
||||||
opt_empty_p |
A calldata instance that will always contain the following values:- mid : :empty? - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.empty? |
Optimized implementation of the empty? method used when called directly without a block |
||||||
opt_eq |
A calldata instance that will always contain the following values:- mid : :== - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo == 3 |
Optimized implementation of the == method used when == is called in the infix position with a single positional argument and no block |
||||||
opt_ge |
A calldata instance that will always contain the following values:- mid : :>= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo >= 3 |
Optimized implementation of the >= method used when >= is called in the infix position with a single positional argument and no block |
||||||
opt_gt |
A calldata instance that will always contain the following values:- mid : :> - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo > 3 |
Optimized implementation of the > method used when > is called in the infix position with a single positional argument and no block |
||||||
opt_le |
A calldata instance that will always contain the following values:- mid : :<= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo <= 3 |
Optimized implementation of the <= method used when <= is called in the infix position with a single positional argument and no block |
||||||
opt_length |
A calldata instance that will always contain the following values:- mid : :length - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.length |
Optimized implementation of the length method used when called directly without a block |
||||||
opt_lt |
A calldata instance that will always contain the following values:- mid : :< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo < 3 |
Optimized implementation of the < method used when < is called in the infix position with a single positional argument and no block |
||||||
opt_ltlt |
A calldata instance that will always contain the following values:- mid : :<< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
array << 1 |
Optimized implementation of the << method used when << is called in the infix position with a single positional argument and no block |
||||||
opt_minus |
A calldata instance that will always contain the following values:- mid : :- - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo - 3 |
Optimized implementation of the - method used when - is called in the infix position with a single positional argument and no block |
||||||
opt_mod |
A calldata instance that will always contain the following values:- mid : :% - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo % 3 |
Optimized implementation of the % method used when % is called in the infix position with a single positional argument and no block |
||||||
opt_mult |
A calldata instance that will always contain the following values:- mid : :* - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo * 3 |
Optimized implementation of the * method used when * is called in the infix position with a single positional argument and no block |
||||||
opt_neq |
A calldata instance that will always contain the following values:- mid : :!= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo != 3 |
Optimized implementation of the != method used when != is called in the infix position with a single positional argument and no block |
||||||
opt_newarray_max |
The number of elements to take from the top of the stack | [foo, bar].max |
CRuby < 3.3.0: Used whenever Array#max is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes the maximum value in the Array onto the stack |
||||||
opt_newarray_min |
The number of elements to take from the top of the stack | [foo, bar].min |
CRuby < 3.3.0: Used whenever Array#min is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes the minimum value in the Array onto the stack |
||||||
opt_newarray_send |
The number of elements to take from the top of the stack | [foo, bar].hash |
CRuby >= 3.3.0: Used whenever a special method (e.g., Array#hash , Array#max , Array#min ) is called on an Array literal. Pops N elements off the stack and pushes the result of the specialized operation onto the stack. Introduced in CRuby 3.3.0, this instruction supplants the older opt_newarray_max and opt_newarray_min instructions |
||||||
opt_nil_p |
A calldata instance that will always contain the following values:- mid : :nil? - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.nil? |
Optimized implementation of the nil? method used when called directly without a block |
||||||
opt_not |
A calldata instance that will always contain the following values:- mid : :! - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
!foo |
Optimized implementation of the unary ! method used when + is called in the prefix position |
||||||
opt_or |
A calldata instance that will always contain the following values:- mid : :| - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo | 3 |
Optimized implementation of the | method used when | is called in the infix position with a single positional argument and no block |
||||||
opt_plus |
A calldata instance that will always contain the following values:- mid : :+ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo + 3 |
Optimized implementation of the + method used when + is called in the infix position with a single positional argument and no block |
||||||
opt_regexpmatch2 |
A calldata instance that will always contain the following values:- mid : :=~ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo =~ "abc" |
Optimized implementation of the =~ method used when =~ is called in the infix position with a single positional argument and no block |
||||||
opt_reverse |
A calldata instance that will always contain the following values:- mid : :reverse - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.reverse |
Optimized implementation of the reverse method used when called directly without a block |
||||||
opt_send_without_block |
A calldata instance |
"abc".valid_encoding? |
A specialized version of the send instruction for cases where the compiler can determine that a method is never called with a block at a given call site. It is equivalent to using send without setting the optional block instruction sequence operand, but saves memory by not reserving space for an optional operand |
||||||
opt_size |
A calldata instance that will always contain the following values:- mid : :size - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.size |
Optimized implementation of the size method used when called directly without a block |
||||||
opt_str_freeze |
A calldata instance that will always contain the following values:- mid : :freeze - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
"foo".freeze |
Used when String#freeze is called on an unfrozen string literal. It's a peephole optimization to reduce:putstring send <calldata!mid:freeze, argc:0, ARGS_SIMPLE> |
||||||
opt_str_uminus |
A calldata instance that will always contain the following values:- mid : :-@ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
-"foo" |
Used whenever String#-@ is called on an unfrozen string. It's a peephole optimization to reduce:putstring send <calldata!mid:-@, argc:0, ARGS_SIMPLE> |
||||||
opt_succ |
A calldata instance that will always contain the following values:- mid : :succ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.succ |
Optimized implementation of the succ method used when called directly without a block |
||||||
pop |
foo ||= 1 |
Pops a single value off the stack and discards it | |||||||
putnil |
nil |
Pushes nil onto the stack |
|||||||
putobject |
The value | 5 |
Push an arbitrary value onto the stack | ||||||
putobject_INT2FIX_0 |
0 |
Pushes the number 0 onto the stack |
|||||||
putobject_INT2FIX_1 |
1 |
Pushes the number 1 onto the stack |
|||||||
putself |
class Foo; def bar; self; end; end |
Looks up the receiver (self ) in the current frame and pushes it onto the stack |
|||||||
putstring |
The unfrozen string | "foo" |
Pushes an unfrozen string onto the stack | ||||||
send |
Two operands: - A calldata instance- (optional) A pointer to an instruction sequence corresponding to a block; nil if no block is provided |
[1, 2].map(&:even?) |
Used for general method invocation. Uses the calldata struct to look up a method to invoke. The arguments to the function must already be pushed onto the stack before the send instruction. The send call will add a new frame to the frame stack. The return value for the function will be written to the stack slot holding the receiver at the time the function is called by the leave instruction |
||||||
setblockparam |
Two operands: - The index of the block param - The level of the frame to look for the block param in (i.e., how many parent frames to traverse to find the correct environment pointer) |
def foo(&bar); bar = -> { 3 }; end |
|||||||
setclassvariable |
|||||||||
setinstancevariable |
|||||||||
setlocal |
Two operands: - The index of the local variable - The level of the frame to look for the local variable in (i.e., how many parent frames to traverse to find the correct environment pointer) |
value = 5; tap { tap { value = 10 } } |
Pops a value off the stack, then looks up the frame corresponding to the level operand and sets the value at the index offset to the popped value | ||||||
setlocal_WC_0 |
The index of the local variable in the current frame (level = 0 ) |
value = 5 |
A specialized version of the setlocal instruction that always sets the local in the current frame (level = 0 ). It works the same way as setlocal index, 0 , looking up the value at the index in the current frame and setting that value to whatever is popped off the stack, but saves memory by not reserving space for the level operand |
||||||
setlocal_WC_1 |
The index of the local variable in the parent frame (level = 1 ) |
value = 5; tap { value = 10 } |
A specialized version of the setlocal instruction that always sets the local in the parent frame (level = 1 ). It works the same way as setlocal index, 1 , looking up the value at the index in the parent frame and setting that value to whatever is popped off the stack, but saves memory by not reserving space for the level operand |
||||||
setn |
The index from top of the stack to copy | {}[:key] = "value" |
Changes the value at the top of the stack to be the same value as the one at the provided index offset from the top of the stack. NB: this does not push a new value onto the stack -- it modifies the value at the top of the stack | ||||||
setspecial |
An index into the others field in the vm_svar struct (offset by 2 ) |
foo if (bar == 1) .. (bar == 2) |
Pops a value off the stack and updates the flip flop state value (i.e., the others field in vm_svar ) in the special variable storage area with the popped value |
||||||
splatarray |
A flag that indicates whether the object on the top of the stack should be duped before converting to an array | foo(*bar) |
Used when the * operator is being used to splat into an object (e.g., local assignment, an array literal, or passing arguments to a method). Peeks the value at the top of the stack. If it's an Array no further action is taken, otherwise the value is popped, converted to an Array with to_a , and the new Array is pushed onto the stack. If the flag operand indicates the value should be duped, then the duped object is pushed onto the stack before the new Array |
||||||
swap |
defined?([[]]) |
Swaps the positions of two values at the top of the stack. NB: this does not push any new values onto the stack | |||||||
topn |
The index from the top of the stack to dupe | Foo::Bar += 1 |
Dupes the value at the provided index offset from the top of the stack and pushes it onto the stack | ||||||
toregexp |
Two operands: - An integer that represents the regexp options - The number of values to pop off the stack |
/foo #{bar} baz/i |
Pops n values off the stack and joins them together in a newly created Regexp , using the supplied options during Regexp creation. The Regexp is then pushed onto the stack |
||||||
getclassvariable |
Two operands: - The name of the class variable as a Symbol - An inline cache |
@@foo Retrieves the class variable value corresponding to the class variable name operand and the class reference in the VM_ENV_DATA_INDEX_ME_CREF field of the environment data and pushes the class variable value on the stack.The inline cache is used to speed up class variable access. The cache entry is keyed on the class reference value and the global class variable serial number. If either the current class reference doesn't match or global class variable serial number changes, the cache is invalidated. The cache entry value is the storage location for global variables for the class Cache Hit: If the cache hits, then the class variable is looked up on the class and pushed onto the stack. Cache Miss: If the cache is empty, then the class hierarchy for the class reference is searched to find where class variables are stored. This could be a large space (e.g., many included modules in Rails), which is why there's a cache in the first place. When the class variable is found the inline cache is updated and the class variable value is pushed onto the stack n the |
|||||||
getinstancevariable |
|||||||||
dup |
$foo = 1 |
Dupes the top value on the stack and pushes onto t | |||||||
duparray |
[1, 2, 3] |
Dupes and pushes an Array onto the stack. Often used to push an Array literal onto |
|||||||
duphash |
{ a: 1, b: 2, c: 3 } |
Dupes and pushes a Hash onto the stack. Often used to push a Hash literal onto |
|||||||
dupn |
The number of values to dupe | Foo::Bar ||= true |
Dups n values from the top of the stack and pushes them ont | ||||||
expandarray |
Two operands: - An integer that specifies how many values to push on the stack - An integer flag used to indicate if the assignment used the * operator and the direction of the array |
foo, *bar = 1, 2, 3 |
Used to spread an Array for multi-assignement. Pops a value off the stack and converts it to an Array with to_ary if necessary, then spreads the Array , pushing N elements (from the first operand) onto the stack. If the Array is smaller than N, then nil will be pushed for N - array.size elements. If the splat flag is specified, reassemble array.size - N elements into a new Array and push that onto the stack. If the postarg flag is set, then the values being pushed onto the stack are done in r |
||||||
getblockparam |
Two operands: - The index of the block param - The level of the frame to look for the block param in (i.e., how many parent frames to traverse to find the correct environment pointer) |
def foo(x, y, &block) = block |
Looks up the frame corresponding to the level operand and then retrieves the value at the index offset. If the value is already a Proc , it is pushed onto the stack. Otherwise, the value is reified to a Proc with rb_vm_bh_to_procval and the new Proc is pushed o |
||||||
getblockparamproxy |
Two operands: - The index of the block param - The level of the frame to look for the block param in (i.e., how many parent frames to traverse to find the correct environment pointer) |
def foo(x, y, &block) = block.call |
A specialized version of getblockparam that avoids allocating a Proc if it determines that the only thing being done with the block parameter is to call call on it. Looks up the frame corresponding to the level operand and then retrieves the value at the index offset. If the value is already a Proc or was reified to a Proc , it is pushed onto the stack. Otherwise, a proxy object that can jump directly to the block iseq is pushed |
||||||
getlocal |
Two operands: - The index of the local variable - The level of the frame to look for the local variable in (i.e., how many parent frames to traverse to find the correct environment pointer) |
foo = 0; tap { tap { foo } } |
Looks up the frame corresponding to the level operand and then retrieves the value at the index offset then pushes that value | ||||||
getlocal_WC_0 |
The index of the local variable in the current frame (level = 0 ) |
foo = 0; foo |
A specialized version of the getlocal instruction that always accesses locals from the current frame (level = 0 ). It works the same way as getlocal index, 0 , looking up the local at the index in the current frame and pushing that value onto the stack, but saves memory by not reserving space for the |
||||||
getlocal_WC_1 |
The index of the local variable in the parent frame (level = 1 ) |
foo = 0; tap { foo } |
A specialized version of the getlocal instruction that always accesses locals from the parent frame (level = 1 ). It works the same way as getlocal index, 1 , looking up the local at the index in the parent frame and pushing that value onto the stack, but saves memory by not reserving space for th |
||||||
getspecial |
Two operands: - The index of the special variable to access: 0 - VM_SVAR_LASTLINE 1 - VM_SVAR_BACKREF 2.. - an index into the others field in the vm_svar struct (offset by 2 )- (optional) Index into the MatchData object to return (requires the first operand to be 1 )It's a tagged value with the tag as the least significant bit (LSB). If the LSB is 0 , then the value is 2 times index of the capture group (e.g., $2 -> getspecial 1, 4 )If the LSB is 1 , then the value is twice plus the ordinal value of the ASCII character value of the global variable to return (e.g., $& -> getspecial 1, 77 ) |
lastlinegetspecial 0, 0 :foo if /abc/ backref getspecial 1, <X> :[$1, $2, $3, $4, $&, $', $+] others (flip flop) getspecial <X>, 0 foo if (value == 1) .. (value == 3) |
Looks up a special variable based on the operands from the environment data section of the stack and pushes the va | ||||||
intern |
:"#{foo}" %I[foo #{bar}] |
Pops a value off the stack and converts it into a Symbol , which is then pushed onto the stack. The top of stack value will always be a String because the intern instruction must always be preceded by either anytostring |
|||||||
leave |
Pop a frame off the frame stack and return the value | ||||||||
newarray |
The number of elements to take from the top of the stack | [foo, bar, baz] |
Pops n values off the stack and inserts them into a new Array , which is then |
||||||
newarraykwsplat |
The number of elements to take from the top of the stack | [1, 2, **{ foo: "bar" }] |
Pops n values off the stack and inserts them into a new Array , which is then pushed onto the stack. Unlike newarray , however, the last element of the array will be a Hash that the ** operator is being used on. It's used to create an Array from positional arguments and a Hash from |
||||||
newhash |
The number of elements to take from the top of the stack; must be an even number | { foo: foo, bar: bar } |
Pops n values off the top of the stack and treats them as (key, value) pairs for the creation of a Hash , which is then pushed onto the stack. The even numbered elements are the keys, while the odd numbered elements are the values. The value matched to a key will always |
||||||
newrange |
A flag that indicates if the Range is inclusive or exclusive of the upper bound |
foo..bar |
Pops 2 values off the stack to create a new Range object. The top value on the stack is the upper bound and the next popped value is the lower bound of the Range . The Range is th |
||||||
objtostring |
A calldata instance |
"foo #{bar}" |
Pops a value off the stack and calls to_s on it to convert it to a string, which is then pushed onto the the stack. This is used when an object is used as part of interpolation (String , Symbol , |
||||||
opt_and |
A calldata instance that will always contain the following values:- mid : :& - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo & 3 |
Optimized implementation of the & method used when & is called in the infix position with a single positi |
||||||
opt_aref |
A calldata instance that will always contain the following values:- mid : :[] - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo[1] |
Optimized implementation of the [] method used when [] is called directly on t |
||||||
opt_aref_with |
A calldata instance that will always contain the following values:- mid : :[] - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
x = "abc"; x[0] |
Optimized implementation of the String#[] method used when [] is called directly on a String without a block. Works just like opt_aref , but is used when the receive |
||||||
opt_aset |
A calldata instance that will always contain the following values:- mid : :[]= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo[1] = 2 |
Optimized implementation of the []= method used when []= is called directly on |
||||||
opt_aset_with |
A calldata instance that will always contain the following values:- mid : :[]= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
`x = "abc"; x[0] = "d" | Optimized implementation of the String#[]= method used when []= is called directly on a String without a block. Works just like opt_aset , but is used when the recei |
||||||
opt_div |
A calldata instance that will always contain the following values:- mid : :/ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo / 3 |
Optimized implementation of the / method used when / is called in the infix position with a single p |
||||||
opt_empty_p |
A calldata instance that will always contain the following values:- mid : :empty? - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.empty? |
Optimized implementation of the empty? method used when |
||||||
opt_eq |
A calldata instance that will always contain the following values:- mid : :== - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo == 3 |
Optimized implementation of the == method used when == is called in the infix position with a single |
||||||
opt_ge |
A calldata instance that will always contain the following values:- mid : :>= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo >= 3 |
Optimized implementation of the >= method used when >= is called in the infix position with a singl |
||||||
opt_gt |
A calldata instance that will always contain the following values:- mid : :> - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo > 3 |
Optimized implementation of the > method used when > is called in the infix position with a sing |
||||||
opt_le |
A calldata instance that will always contain the following values:- mid : :<= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo <= 3 |
Optimized implementation of the <= method used when <= is called in the infix position with a sin |
||||||
opt_length |
A calldata instance that will always contain the following values:- mid : :length - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.length |
Optimized implementation of the length method used |
||||||
opt_lt |
A calldata instance that will always contain the following values:- mid : :< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo < 3 |
Optimized implementation of the < method used when < is called in the infix position with a s |
||||||
opt_ltlt |
A calldata instance that will always contain the following values:- mid : :<< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
array << 1 |
Optimized implementation of the << method used when << is called in the infix position with a |
||||||
opt_minus |
A calldata instance that will always contain the following values:- mid : :- - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo - 3 |
Optimized implementation of the - method used when - is called in the infix position with a |
||||||
opt_mod |
A calldata instance that will always contain the following values:- mid : :% - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo % 3 |
Optimized implementation of the % method used when % is called in the infix position with |
||||||
opt_mult |
A calldata instance that will always contain the following values:- mid : :* - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo * 3 |
Optimized implementation of the * method used when * is called in the infix position with |
||||||
opt_neq |
A calldata instance that will always contain the following values:- mid : :!= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo != 3 |
Optimized implementation of the != method used when != is called in the infix position wit |
||||||
opt_newarray_max |
The number of elements to take from the top of the stack | [foo, bar].max |
CRuby < 3.3.0: Used whenever Array#max is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes the |
||||||
opt_newarray_min |
The number of elements to take from the top of the stack | [foo, bar].min |
CRuby < 3.3.0: Used whenever Array#min is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes th |
||||||
opt_newarray_send |
The number of elements to take from the top of the stack | [foo, bar].hash |
CRuby >= 3.3.0: Used whenever a special method (e.g., Array#hash , Array#max , Array#min ) is called on an Array literal. Pops N elements off the stack and pushes the result of the specialized operation onto the stack. Introduced in CRuby 3.3.0, this instruction supplants the older `opt_new |
||||||
opt_nil_p |
A calldata instance that will always contain the following values:- mid : :nil? - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.nil? |
Optimized implementation of the nil? m |
||||||
opt_not |
A calldata instance that will always contain the following values:- mid : :! - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
!foo |
Optimized implementation of the unary ! metho |
||||||
opt_or |
A calldata instance that will always contain the following values:- mid : :| - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo | 3 |
Optimized implementation of the | method used when | is called in the infix positi |
||||||
opt_plus |
A calldata instance that will always contain the following values:- mid : :+ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo + 3 |
Optimized implementation of the + method used when + is called in the infix posit |
||||||
opt_regexpmatch2 |
A calldata instance that will always contain the following values:- mid : :=~ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo =~ "abc" |
Optimized implementation of the =~ method used when =~ is called in the infix posi |
||||||
opt_reverse |
A calldata instance that will always contain the following values:- mid : :reverse - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.reverse |
Optimized implementation of the `rever | ||||||
opt_send_without_block |
A calldata instance |
"abc".valid_encoding? |
A specialized version of the send instruction for cases where the compiler can determine that a method is never called with a block at a given call site. It is equivalent to using send without setting the optional block instruction sequence operand, but saves |
||||||
opt_size |
A calldata instance that will always contain the following values:- mid : :size - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.size |
Optimized implementation of the ` | ||||||
opt_str_freeze |
A calldata instance that will always contain the following values:- mid : :freeze - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
"foo".freeze |
Used when String#freeze is called on an unfrozen string literal. It's a peephole optimization to reduce:putstring <b |
||||||
opt_str_uminus |
A calldata instance that will always contain the following values:- mid : :-@ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
-"foo" |
Used whenever String#-@ is called on an unfrozen string. It's a peephole optimization to reduce:`putstri |
||||||
opt_succ |
A calldata instance that will always contain the following values:- mid : :succ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.succ |
Optimized implementation of th | ||||||
pop |
foo ||= 1 |
||||||||
putnil |
nil |
||||||||
putobject |
The value | 5 |
|||||||
putobject_INT2FIX_0 |
0 |
||||||||
putobject_INT2FIX_1 |
1 |
||||||||
putself |
class Foo; def bar; self; end; end |
Looks up the rece | |||||||
putstring |
The unfrozen string | "foo" |
|||||||
send |
Two operands: - A calldata instance- (optional) A pointer to an instruction sequence corresponding to a block; nil if no block is provided |
[1, 2].map(&:even?) |
Used for general method invocation. Uses the calldata struct to look up a method to invoke. The arguments to the function must already be pushed onto the stack before the send instruction. The send call will add a new frame to the frame stack. The return value for the function will be written to the stack slot holding the recei |
||||||
setblockparam |
Two operands: - The index of the block param - The level of the frame to look for the block param in (i.e., how many parent frames to traverse to find the correct environment pointer) |
def foo(&bar); bar = -> { 3 }; end |
|||||||
setclassvariable |
|||||||||
setinstancevariable |
|||||||||
setlocal |
Two operands: - The index of the local variable - The level of the frame to look for the local variable in (i.e., how many parent frames to traverse to find the correct environment pointer) |
value = 5; tap { tap { value = 10 } } |
Pops a value off the stack, then looks up the frame corresponding to the level | ||||||
setlocal_WC_0 |
The index of the local variable in the current frame (level = 0 ) |
value = 5 |
A specialized version of the setlocal instruction that always sets the local in the current frame (level = 0 ). It works the same way as setlocal index, 0 , looking up the value at the index in the current frame and setting that value to whatever is popped off the |
||||||
setlocal_WC_1 |
The index of the local variable in the parent frame (level = 1 ) |
value = 5; tap { value = 10 } |
A specialized version of the setlocal instruction that always sets the local in the parent frame (level = 1 ). It works the same way as setlocal index, 1 , looking up the value at the index in the parent frame and setting that value to whatever is popped off the |
||||||
setn |
The index from top of the stack to copy | {}[:key] = "value" |
Changes the value at the top of the stack to be the same value as the one at the provided index offset from the top of the stack. NB: this does not push a n | ||||||
setspecial |
An index into the others field in the vm_svar struct (offset by 2 ) |
foo if (bar == 1) .. (bar == 2) |
Pops a value off the stack and updates the flip flop state value (i.e., the others field |
||||||
splatarray |
A flag that indicates whether the object on the top of the stack should be duped before converting to an array | foo(*bar) |
Used when the * operator is being used to splat into an object (e.g., local assignment, an array literal, or passing arguments to a method). Peeks the value at the top of the stack. If it's an Array no further action is taken, otherwise the value is popped, converted to an Array with to_a , and the new Array is pushed onto the stack. If the flag operand indicates the value should be du |
||||||
swap |
defined?([[]]) |
Swaps the positions of two values at | |||||||
topn |
The index from the top of the stack to dupe | Foo::Bar += 1 |
Dupes the value at the | ||||||
toregexp |
Two operands: - An integer that represents the regexp options - The number of values to pop off the stack |
/foo #{bar} baz/i |
Pops n values off the stack and joins them together in a newly created Regexp , using the supplied |
||||||
getblockparamproxy |
Two operands: - The index of the block param - The level of the frame to look for the block param in (i.e., how many parent frames to traverse to find the correct environment pointer) |
def foo(x, y, &block) = block.call |
A specialized version of getblockparam that avoids allocating a Proc if it determines that the only thing being done with the block parameter is to call call on it. Looks up the frame corresponding to the level operand and then retrieves the value at the index offset. If the value is already a Proc or was reified to a Proc , it is pushed onto the stack. Otherwise, a proxy object that can jump directly to the block iseq is pushed onto the stack |
||||||
getlocal |
Two operands: - The index of the local variable - The level of the frame to look for the local variable in (i.e., how many parent frames to traverse to find the correct environment pointer) |
foo = 0; tap { tap { foo } } |
Looks up the frame corresponding to the level operand and then retrieves the value at the index offset then pushes that value onto the stack | ||||||
getlocal_WC_0 |
The index of the local variable in the current frame (level = 0 ) |
foo = 0; foo |
A specialized version of the getlocal instruction that always accesses locals from the current frame (level = 0 ). It works the same way as getlocal index, 0 , looking up the local at the index in the current frame and pushing that value onto the stack, but saves memory by not reserving space for the level operand |
||||||
getlocal_WC_1 |
The index of the local variable in the parent frame (level = 1 ) |
foo = 0; tap { foo } |
A specialized version of the getlocal instruction that always accesses locals from the parent frame (level = 1 ). It works the same way as getlocal index, 1 , looking up the local at the index in the parent frame and pushing that value onto the stack, but saves memory by not reserving space for the level operand |
||||||
getspecial |
Two operands: - The index of the special variable to access: 0 - VM_SVAR_LASTLINE 1 - VM_SVAR_BACKREF 2.. - an index into the others field in the vm_svar struct (offset by 2 )- (optional) Index into the MatchData object to return (requires the first operand to be 1 )It's a tagged value with the tag as the least significant bit (LSB). If the LSB is 0 , then the value is 2 times index of the capture group (e.g., $2 -> getspecial 1, 4 )If the LSB is 1 , then the value is twice plus the ordinal value of the ASCII character value of the global variable to return (e.g., $& -> getspecial 1, 77 ) |
lastlinegetspecial 0, 0 :foo if /abc/ backref getspecial 1, <X> :[$1, $2, $3, $4, $&, $', $+] others (flip flop) getspecial <X>, 0 foo if (value == 1) .. (value == 3) |
Looks up a special variable based on the operands from the environment data section of the stack and pushes the value onto the stack | ||||||
intern |
:"#{foo}" %I[foo #{bar}] |
Pops a value off the stack and converts it into a Symbol , which is then pushed onto the stack. The top of stack value will always be a String because the intern instruction must always be preceded by either anytostring or concatstrings |
|||||||
leave |
Pop a frame off the frame stack and return the value on top of the stack | ||||||||
newarray |
The number of elements to take from the top of the stack | [foo, bar, baz] |
Pops n values off the stack and inserts them into a new Array , which is then pushed onto the stack |
||||||
newarraykwsplat |
The number of elements to take from the top of the stack | [1, 2, **{ foo: "bar" }] |
Pops n values off the stack and inserts them into a new Array , which is then pushed onto the stack. Unlike newarray , however, the last element of the array will be a Hash that the ** operator is being used on. It's used to create an Array from positional arguments and a Hash from the keyword arguments |
||||||
newhash |
The number of elements to take from the top of the stack; must be an even number | { foo: foo, bar: bar } |
Pops n values off the top of the stack and treats them as (key, value) pairs for the creation of a Hash , which is then pushed onto the stack. The even numbered elements are the keys, while the odd numbered elements are the values. The value matched to a key will always be at position i + 1 . |
||||||
newrange |
A flag that indicates if the Range is inclusive or exclusive of the upper bound |
foo..bar |
Pops 2 values off the stack to create a new Range object. The top value on the stack is the upper bound and the next popped value is the lower bound of the Range . The Range is then pushed onto the stack |
||||||
objtostring |
A calldata instance |
"foo #{bar}" |
Pops a value off the stack and calls to_s on it to convert it to a string, which is then pushed onto the the stack. This is used when an object is used as part of interpolation (String , Symbol , Regexp , heredocs, etc.) |
||||||
opt_and |
A calldata instance that will always contain the following values:- mid : :& - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo & 3 |
Optimized implementation of the & method used when & is called in the infix position with a single positional argument and no block |
||||||
opt_aref |
A calldata instance that will always contain the following values:- mid : :[] - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo[1] |
Optimized implementation of the [] method used when [] is called directly on the receiver without a block |
||||||
opt_aref_with |
A calldata instance that will always contain the following values:- mid : :[] - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
x = "abc"; x[0] |
Optimized implementation of the String#[] method used when [] is called directly on a String without a block. Works just like opt_aref , but is used when the receiver is known to be a String . |
||||||
opt_aset |
A calldata instance that will always contain the following values:- mid : :[]= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo[1] = 2 |
Optimized implementation of the []= method used when []= is called directly on the receiver without a block |
||||||
opt_aset_with |
A calldata instance that will always contain the following values:- mid : :[]= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
`x = "abc"; x[0] = "d" | Optimized implementation of the String#[]= method used when []= is called directly on a String without a block. Works just like opt_aset , but is used when the receiver is known to be a String . |
||||||
opt_div |
A calldata instance that will always contain the following values:- mid : :/ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo / 3 |
Optimized implementation of the / method used when / is called in the infix position with a single positional argument and no block |
||||||
opt_empty_p |
A calldata instance that will always contain the following values:- mid : :empty? - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.empty? |
Optimized implementation of the empty? method used when called directly without a block |
||||||
opt_eq |
A calldata instance that will always contain the following values:- mid : :== - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo == 3 |
Optimized implementation of the == method used when == is called in the infix position with a single positional argument and no block |
||||||
opt_ge |
A calldata instance that will always contain the following values:- mid : :>= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo >= 3 |
Optimized implementation of the >= method used when >= is called in the infix position with a single positional argument and no block |
||||||
opt_gt |
A calldata instance that will always contain the following values:- mid : :> - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo > 3 |
Optimized implementation of the > method used when > is called in the infix position with a single positional argument and no block |
||||||
opt_le |
A calldata instance that will always contain the following values:- mid : :<= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo <= 3 |
Optimized implementation of the <= method used when <= is called in the infix position with a single positional argument and no block |
||||||
opt_length |
A calldata instance that will always contain the following values:- mid : :length - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.length |
Optimized implementation of the length method used when called directly without a block |
||||||
opt_lt |
A calldata instance that will always contain the following values:- mid : :< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo < 3 |
Optimized implementation of the < method used when < is called in the infix position with a single positional argument and no block |
||||||
opt_ltlt |
A calldata instance that will always contain the following values:- mid : :<< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
array << 1 |
Optimized implementation of the << method used when << is called in the infix position with a single positional argument and no block |
||||||
opt_minus |
A calldata instance that will always contain the following values:- mid : :- - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo - 3 |
Optimized implementation of the - method used when - is called in the infix position with a single positional argument and no block |
||||||
opt_mod |
A calldata instance that will always contain the following values:- mid : :% - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo % 3 |
Optimized implementation of the % method used when % is called in the infix position with a single positional argument and no block |
||||||
opt_mult |
A calldata instance that will always contain the following values:- mid : :* - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo * 3 |
Optimized implementation of the * method used when * is called in the infix position with a single positional argument and no block |
||||||
opt_neq |
A calldata instance that will always contain the following values:- mid : :!= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo != 3 |
Optimized implementation of the != method used when != is called in the infix position with a single positional argument and no block |
||||||
opt_newarray_max |
The number of elements to take from the top of the stack | [foo, bar].max |
CRuby < 3.3.0: Used whenever Array#max is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes the maximum value in the Array onto the stack |
||||||
opt_newarray_min |
The number of elements to take from the top of the stack | [foo, bar].min |
CRuby < 3.3.0: Used whenever Array#min is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes the minimum value in the Array onto the stack |
||||||
opt_newarray_send |
The number of elements to take from the top of the stack | [foo, bar].hash |
CRuby >= 3.3.0: Used whenever a special method (e.g., Array#hash , Array#max , Array#min ) is called on an Array literal. Pops N elements off the stack and pushes the result of the specialized operation onto the stack. Introduced in CRuby 3.3.0, this instruction supplants the older opt_newarray_max and opt_newarray_min instructions |
||||||
opt_nil_p |
A calldata instance that will always contain the following values:- mid : :nil? - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.nil? |
Optimized implementation of the nil? method used when called directly without a block |
||||||
opt_not |
A calldata instance that will always contain the following values:- mid : :! - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
!foo |
Optimized implementation of the unary ! method used when + is called in the prefix position |
||||||
opt_or |
A calldata instance that will always contain the following values:- mid : :| - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo | 3 |
Optimized implementation of the | method used when | is called in the infix position with a single positional argument and no block |
||||||
opt_plus |
A calldata instance that will always contain the following values:- mid : :+ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo + 3 |
Optimized implementation of the + method used when + is called in the infix position with a single positional argument and no block |
||||||
opt_regexpmatch2 |
A calldata instance that will always contain the following values:- mid : :=~ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo =~ "abc" |
Optimized implementation of the =~ method used when =~ is called in the infix position with a single positional argument and no block |
||||||
opt_reverse |
A calldata instance that will always contain the following values:- mid : :reverse - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.reverse |
Optimized implementation of the reverse method used when called directly without a block |
||||||
opt_send_without_block |
A calldata instance |
"abc".valid_encoding? |
A specialized version of the send instruction for cases where the compiler can determine that a method is never called with a block at a given call site. It is equivalent to using send without setting the optional block instruction sequence operand, but saves memory by not reserving space for an optional operand |
||||||
opt_size |
A calldata instance that will always contain the following values:- mid : :size - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.size |
Optimized implementation of the size method used when called directly without a block |
||||||
opt_str_freeze |
A calldata instance that will always contain the following values:- mid : :freeze - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
"foo".freeze |
Used when String#freeze is called on an unfrozen string literal. It's a peephole optimization to reduce:putstring send <calldata!mid:freeze, argc:0, ARGS_SIMPLE> |
||||||
opt_str_uminus |
A calldata instance that will always contain the following values:- mid : :-@ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
-"foo" |
Used whenever String#-@ is called on an unfrozen string. It's a peephole optimization to reduce:putstring send <calldata!mid:-@, argc:0, ARGS_SIMPLE> |
||||||
opt_succ |
A calldata instance that will always contain the following values:- mid : :succ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.succ |
Optimized implementation of the succ method used when called directly without a block |
||||||
pop |
foo ||= 1 |
Pops a single value off the stack and discards it | |||||||
putnil |
nil |
Pushes nil onto the stack |
|||||||
putobject |
The value | 5 |
Push an arbitrary value onto the stack | ||||||
putobject_INT2FIX_0 |
0 |
Pushes the number 0 onto the stack |
|||||||
putobject_INT2FIX_1 |
1 |
Pushes the number 1 onto the stack |
|||||||
putself |
class Foo; def bar; self; end; end |
Looks up the receiver (self ) in the current frame and pushes it onto the stack |
|||||||
putstring |
The unfrozen string | "foo" |
Pushes an unfrozen string onto the stack | ||||||
send |
Two operands: - A calldata instance- (optional) A pointer to an instruction sequence corresponding to a block; nil if no block is provided |
[1, 2].map(&:even?) |
Used for general method invocation. Uses the calldata struct to look up a method to invoke. The arguments to the function must already be pushed onto the stack before the send instruction. The send call will add a new frame to the frame stack. The return value for the function will be written to the stack slot holding the receiver at the time the function is called by the leave instruction |
||||||
setblockparam |
Two operands: - The index of the block param - The level of the frame to look for the block param in (i.e., how many parent frames to traverse to find the correct environment pointer) |
def foo(&bar); bar = -> { 3 }; end |
|||||||
setclassvariable |
|||||||||
setinstancevariable |
|||||||||
setlocal |
Two operands: - The index of the local variable - The level of the frame to look for the local variable in (i.e., how many parent frames to traverse to find the correct environment pointer) |
value = 5; tap { tap { value = 10 } } |
Pops a value off the stack, then looks up the frame corresponding to the level operand and sets the value at the index offset to the popped value | ||||||
setlocal_WC_0 |
The index of the local variable in the current frame (level = 0 ) |
value = 5 |
A specialized version of the setlocal instruction that always sets the local in the current frame (level = 0 ). It works the same way as setlocal index, 0 , looking up the value at the index in the current frame and setting that value to whatever is popped off the stack, but saves memory by not reserving space for the level operand |
||||||
setlocal_WC_1 |
The index of the local variable in the parent frame (level = 1 ) |
value = 5; tap { value = 10 } |
A specialized version of the setlocal instruction that always sets the local in the parent frame (level = 1 ). It works the same way as setlocal index, 1 , looking up the value at the index in the parent frame and setting that value to whatever is popped off the stack, but saves memory by not reserving space for the level operand |
||||||
setn |
The index from top of the stack to copy | {}[:key] = "value" |
Changes the value at the top of the stack to be the same value as the one at the provided index offset from the top of the stack. NB: this does not push a new value onto the stack -- it modifies the value at the top of the stack | ||||||
setspecial |
An index into the others field in the vm_svar struct (offset by 2 ) |
foo if (bar == 1) .. (bar == 2) |
Pops a value off the stack and updates the flip flop state value (i.e., the others field in vm_svar ) in the special variable storage area with the popped value |
||||||
splatarray |
A flag that indicates whether the object on the top of the stack should be duped before converting to an array | foo(*bar) |
Used when the * operator is being used to splat into an object (e.g., local assignment, an array literal, or passing arguments to a method). Peeks the value at the top of the stack. If it's an Array no further action is taken, otherwise the value is popped, converted to an Array with to_a , and the new Array is pushed onto the stack. If the flag operand indicates the value should be duped, then the duped object is pushed onto the stack before the new Array |
||||||
swap |
defined?([[]]) |
Swaps the positions of two values at the top of the stack. NB: this does not push any new values onto the stack | |||||||
topn |
The index from the top of the stack to dupe | Foo::Bar += 1 |
Dupes the value at the provided index offset from the top of the stack and pushes it onto the stack | ||||||
toregexp |
Two operands: - An integer that represents the regexp options - The number of values to pop off the stack |
/foo #{bar} baz/i |
Pops n values off the stack and joins them together in a newly created Regexp , using the supplied options during Regexp creation. The Regexp is then pushed onto the stack |
||||||
getlocal_WC_0 |
The index of the local variable in the current frame (level = 0 ) |
foo = 0; foo |
A specialized version of the getlocal instruction that always accesses locals from the current frame (level = 0 ). It works the same way as getlocal index, 0 , looking up the local at the index in the current frame and pushing that value onto the stack, but saves memory by not reserving space for the level operand |
||||||
getlocal_WC_1 |
The index of the local variable in the parent frame (level = 1 ) |
foo = 0; tap { foo } |
A specialized version of the getlocal instruction that always accesses locals from the parent frame (level = 1 ). It works the same way as getlocal index, 1 , looking up the local at the index in the parent frame and pushing that value onto the stack, but saves memory by not reserving space for the level operand |
||||||
getspecial |
Two operands: - The index of the special variable to access: 0 - VM_SVAR_LASTLINE 1 - VM_SVAR_BACKREF 2.. - an index into the others field in the vm_svar struct (offset by 2 )- (optional) Index into the MatchData object to return (requires the first operand to be 1 )It's a tagged value with the tag as the least significant bit (LSB). If the LSB is 0 , then the value is 2 times index of the capture group (e.g., $2 -> getspecial 1, 4 )If the LSB is 1 , then the value is twice plus the ordinal value of the ASCII character value of the global variable to return (e.g., $& -> getspecial 1, 77 ) |
lastlinegetspecial 0, 0 :foo if /abc/ backref getspecial 1, <X> :[$1, $2, $3, $4, $&, $', $+] others (flip flop) getspecial <X>, 0 foo if (value == 1) .. (value == 3) |
Looks up a special variable based on the operands from the environment data section of the stack and pushes the value onto the stack | ||||||
intern |
:"#{foo}" %I[foo #{bar}] |
Pops a value off the stack and converts it into a Symbol , which is then pushed onto the stack. The top of stack value will always be a String because the intern instruction must always be preceded by either anytostring or concatstrings |
|||||||
leave |
Pop a frame off the frame stack and return the value on top of the stack | ||||||||
newarray |
The number of elements to take from the top of the stack | [foo, bar, baz] |
Pops n values off the stack and inserts them into a new Array , which is then pushed onto the stack |
||||||
newarraykwsplat |
The number of elements to take from the top of the stack | [1, 2, **{ foo: "bar" }] |
Pops n values off the stack and inserts them into a new Array , which is then pushed onto the stack. Unlike newarray , however, the last element of the array will be a Hash that the ** operator is being used on. It's used to create an Array from positional arguments and a Hash from the keyword arguments |
||||||
newhash |
The number of elements to take from the top of the stack; must be an even number | { foo: foo, bar: bar } |
Pops n values off the top of the stack and treats them as (key, value) pairs for the creation of a Hash , which is then pushed onto the stack. The even numbered elements are the keys, while the odd numbered elements are the values. The value matched to a key will always be at position i + 1 . |
||||||
newrange |
A flag that indicates if the Range is inclusive or exclusive of the upper bound |
foo..bar |
Pops 2 values off the stack to create a new Range object. The top value on the stack is the upper bound and the next popped value is the lower bound of the Range . The Range is then pushed onto the stack |
||||||
objtostring |
A calldata instance |
"foo #{bar}" |
Pops a value off the stack and calls to_s on it to convert it to a string, which is then pushed onto the the stack. This is used when an object is used as part of interpolation (String , Symbol , Regexp , heredocs, etc.) |
||||||
opt_and |
A calldata instance that will always contain the following values:- mid : :& - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo & 3 |
Optimized implementation of the & method used when & is called in the infix position with a single positional argument and no block |
||||||
opt_aref |
A calldata instance that will always contain the following values:- mid : :[] - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo[1] |
Optimized implementation of the [] method used when [] is called directly on the receiver without a block |
||||||
opt_aref_with |
A calldata instance that will always contain the following values:- mid : :[] - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
x = "abc"; x[0] |
Optimized implementation of the String#[] method used when [] is called directly on a String without a block. Works just like opt_aref , but is used when the receiver is known to be a String . |
||||||
opt_aset |
A calldata instance that will always contain the following values:- mid : :[]= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo[1] = 2 |
Optimized implementation of the []= method used when []= is called directly on the receiver without a block |
||||||
opt_aset_with |
A calldata instance that will always contain the following values:- mid : :[]= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
`x = "abc"; x[0] = "d" | Optimized implementation of the String#[]= method used when []= is called directly on a String without a block. Works just like opt_aset , but is used when the receiver is known to be a String . |
||||||
opt_div |
A calldata instance that will always contain the following values:- mid : :/ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo / 3 |
Optimized implementation of the / method used when / is called in the infix position with a single positional argument and no block |
||||||
opt_empty_p |
A calldata instance that will always contain the following values:- mid : :empty? - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.empty? |
Optimized implementation of the empty? method used when called directly without a block |
||||||
opt_eq |
A calldata instance that will always contain the following values:- mid : :== - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo == 3 |
Optimized implementation of the == method used when == is called in the infix position with a single positional argument and no block |
||||||
opt_ge |
A calldata instance that will always contain the following values:- mid : :>= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo >= 3 |
Optimized implementation of the >= method used when >= is called in the infix position with a single positional argument and no block |
||||||
opt_gt |
A calldata instance that will always contain the following values:- mid : :> - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo > 3 |
Optimized implementation of the > method used when > is called in the infix position with a single positional argument and no block |
||||||
opt_le |
A calldata instance that will always contain the following values:- mid : :<= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo <= 3 |
Optimized implementation of the <= method used when <= is called in the infix position with a single positional argument and no block |
||||||
opt_length |
A calldata instance that will always contain the following values:- mid : :length - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.length |
Optimized implementation of the length method used when called directly without a block |
||||||
opt_lt |
A calldata instance that will always contain the following values:- mid : :< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo < 3 |
Optimized implementation of the < method used when < is called in the infix position with a single positional argument and no block |
||||||
opt_ltlt |
A calldata instance that will always contain the following values:- mid : :<< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
array << 1 |
Optimized implementation of the << method used when << is called in the infix position with a single positional argument and no block |
||||||
opt_minus |
A calldata instance that will always contain the following values:- mid : :- - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo - 3 |
Optimized implementation of the - method used when - is called in the infix position with a single positional argument and no block |
||||||
opt_mod |
A calldata instance that will always contain the following values:- mid : :% - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo % 3 |
Optimized implementation of the % method used when % is called in the infix position with a single positional argument and no block |
||||||
opt_mult |
A calldata instance that will always contain the following values:- mid : :* - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo * 3 |
Optimized implementation of the * method used when * is called in the infix position with a single positional argument and no block |
||||||
opt_neq |
A calldata instance that will always contain the following values:- mid : :!= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo != 3 |
Optimized implementation of the != method used when != is called in the infix position with a single positional argument and no block |
||||||
opt_newarray_max |
The number of elements to take from the top of the stack | [foo, bar].max |
CRuby < 3.3.0: Used whenever Array#max is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes the maximum value in the Array onto the stack |
||||||
opt_newarray_min |
The number of elements to take from the top of the stack | [foo, bar].min |
CRuby < 3.3.0: Used whenever Array#min is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes the minimum value in the Array onto the stack |
||||||
opt_newarray_send |
The number of elements to take from the top of the stack | [foo, bar].hash |
CRuby >= 3.3.0: Used whenever a special method (e.g., Array#hash , Array#max , Array#min ) is called on an Array literal. Pops N elements off the stack and pushes the result of the specialized operation onto the stack. Introduced in CRuby 3.3.0, this instruction supplants the older opt_newarray_max and opt_newarray_min instructions |
||||||
opt_nil_p |
A calldata instance that will always contain the following values:- mid : :nil? - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.nil? |
Optimized implementation of the nil? method used when called directly without a block |
||||||
opt_not |
A calldata instance that will always contain the following values:- mid : :! - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
!foo |
Optimized implementation of the unary ! method used when + is called in the prefix position |
||||||
opt_or |
A calldata instance that will always contain the following values:- mid : :| - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo | 3 |
Optimized implementation of the | method used when | is called in the infix position with a single positional argument and no block |
||||||
opt_plus |
A calldata instance that will always contain the following values:- mid : :+ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo + 3 |
Optimized implementation of the + method used when + is called in the infix position with a single positional argument and no block |
||||||
opt_regexpmatch2 |
A calldata instance that will always contain the following values:- mid : :=~ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo =~ "abc" |
Optimized implementation of the =~ method used when =~ is called in the infix position with a single positional argument and no block |
||||||
opt_reverse |
A calldata instance that will always contain the following values:- mid : :reverse - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.reverse |
Optimized implementation of the reverse method used when called directly without a block |
||||||
opt_send_without_block |
A calldata instance |
"abc".valid_encoding? |
A specialized version of the send instruction for cases where the compiler can determine that a method is never called with a block at a given call site. It is equivalent to using send without setting the optional block instruction sequence operand, but saves memory by not reserving space for an optional operand |
||||||
opt_size |
A calldata instance that will always contain the following values:- mid : :size - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.size |
Optimized implementation of the size method used when called directly without a block |
||||||
opt_str_freeze |
A calldata instance that will always contain the following values:- mid : :freeze - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
"foo".freeze |
Used when String#freeze is called on an unfrozen string literal. It's a peephole optimization to reduce:putstring send <calldata!mid:freeze, argc:0, ARGS_SIMPLE> |
||||||
opt_str_uminus |
A calldata instance that will always contain the following values:- mid : :-@ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
-"foo" |
Used whenever String#-@ is called on an unfrozen string. It's a peephole optimization to reduce:putstring send <calldata!mid:-@, argc:0, ARGS_SIMPLE> |
||||||
opt_succ |
A calldata instance that will always contain the following values:- mid : :succ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.succ |
Optimized implementation of the succ method used when called directly without a block |
||||||
pop |
foo ||= 1 |
Pops a single value off the stack and discards it | |||||||
putnil |
nil |
Pushes nil onto the stack |
|||||||
putobject |
The value | 5 |
Push an arbitrary value onto the stack | ||||||
putobject_INT2FIX_0 |
0 |
Pushes the number 0 onto the stack |
|||||||
putobject_INT2FIX_1 |
1 |
Pushes the number 1 onto the stack |
|||||||
putself |
class Foo; def bar; self; end; end |
Looks up the receiver (self ) in the current frame and pushes it onto the stack |
|||||||
putstring |
The unfrozen string | "foo" |
Pushes an unfrozen string onto the stack | ||||||
send |
Two operands: - A calldata instance- (optional) A pointer to an instruction sequence corresponding to a block; nil if no block is provided |
[1, 2].map(&:even?) |
Used for general method invocation. Uses the calldata struct to look up a method to invoke. The arguments to the function must already be pushed onto the stack before the send instruction. The send call will add a new frame to the frame stack. The return value for the function will be written to the stack slot holding the receiver at the time the function is called by the leave instruction |
||||||
setblockparam |
Two operands: - The index of the block param - The level of the frame to look for the block param in (i.e., how many parent frames to traverse to find the correct environment pointer) |
def foo(&bar); bar = -> { 3 }; end |
|||||||
setclassvariable |
|||||||||
setinstancevariable |
|||||||||
setlocal |
Two operands: - The index of the local variable - The level of the frame to look for the local variable in (i.e., how many parent frames to traverse to find the correct environment pointer) |
value = 5; tap { tap { value = 10 } } |
Pops a value off the stack, then looks up the frame corresponding to the level operand and sets the value at the index offset to the popped value | ||||||
setlocal_WC_0 |
The index of the local variable in the current frame (level = 0 ) |
value = 5 |
A specialized version of the setlocal instruction that always sets the local in the current frame (level = 0 ). It works the same way as setlocal index, 0 , looking up the value at the index in the current frame and setting that value to whatever is popped off the stack, but saves memory by not reserving space for the level operand |
||||||
setlocal_WC_1 |
The index of the local variable in the parent frame (level = 1 ) |
value = 5; tap { value = 10 } |
A specialized version of the setlocal instruction that always sets the local in the parent frame (level = 1 ). It works the same way as setlocal index, 1 , looking up the value at the index in the parent frame and setting that value to whatever is popped off the stack, but saves memory by not reserving space for the level operand |
||||||
setn |
The index from top of the stack to copy | {}[:key] = "value" |
Changes the value at the top of the stack to be the same value as the one at the provided index offset from the top of the stack. NB: this does not push a new value onto the stack -- it modifies the value at the top of the stack | ||||||
setspecial |
An index into the others field in the vm_svar struct (offset by 2 ) |
foo if (bar == 1) .. (bar == 2) |
Pops a value off the stack and updates the flip flop state value (i.e., the others field in vm_svar ) in the special variable storage area with the popped value |
||||||
splatarray |
A flag that indicates whether the object on the top of the stack should be duped before converting to an array | foo(*bar) |
Used when the * operator is being used to splat into an object (e.g., local assignment, an array literal, or passing arguments to a method). Peeks the value at the top of the stack. If it's an Array no further action is taken, otherwise the value is popped, converted to an Array with to_a , and the new Array is pushed onto the stack. If the flag operand indicates the value should be duped, then the duped object is pushed onto the stack before the new Array |
||||||
swap |
defined?([[]]) |
Swaps the positions of two values at the top of the stack. NB: this does not push any new values onto the stack | |||||||
topn |
The index from the top of the stack to dupe | Foo::Bar += 1 |
Dupes the value at the provided index offset from the top of the stack and pushes it onto the stack | ||||||
toregexp |
Two operands: - An integer that represents the regexp options - The number of values to pop off the stack |
/foo #{bar} baz/i |
Pops n values off the stack and joins them together in a newly created Regexp , using the supplied options during Regexp creation. The Regexp is then pushed onto the stack |
||||||
opt_ge |
A calldata instance that will always contain the following values:- mid : :>= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo >= 3 |
Optimized implementation of the >= method used when >= is called in the infix position with a single positional argument and no block |
||||||
opt_gt |
A calldata instance that will always contain the following values:- mid : :> - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo > 3 |
Optimized implementation of the > method used when > is called in the infix position with a single positional argument and no block |
||||||
opt_le |
A calldata instance that will always contain the following values:- mid : :<= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo <= 3 |
Optimized implementation of the <= method used when <= is called in the infix position with a single positional argument and no block |
||||||
opt_length |
A calldata instance that will always contain the following values:- mid : :length - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.length |
Optimized implementation of the length method used when called directly without a block |
||||||
opt_lt |
A calldata instance that will always contain the following values:- mid : :< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo < 3 |
Optimized implementation of the < method used when < is called in the infix position with a single positional argument and no block |
||||||
opt_ltlt |
A calldata instance that will always contain the following values:- mid : :<< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
array << 1 |
Optimized implementation of the << method used when << is called in the infix position with a single positional argument and no block |
||||||
opt_minus |
A calldata instance that will always contain the following values:- mid : :- - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo - 3 |
Optimized implementation of the - method used when - is called in the infix position with a single positional argument and no block |
||||||
opt_mod |
A calldata instance that will always contain the following values:- mid : :% - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo % 3 |
Optimized implementation of the % method used when % is called in the infix position with a single positional argument and no block |
||||||
opt_mult |
A calldata instance that will always contain the following values:- mid : :* - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo * 3 |
Optimized implementation of the * method used when * is called in the infix position with a single positional argument and no block |
||||||
opt_neq |
A calldata instance that will always contain the following values:- mid : :!= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo != 3 |
Optimized implementation of the != method used when != is called in the infix position with a single positional argument and no block |
||||||
opt_newarray_max |
The number of elements to take from the top of the stack | [foo, bar].max |
CRuby < 3.3.0: Used whenever Array#max is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes the maximum value in the Array onto the stack |
||||||
opt_newarray_min |
The number of elements to take from the top of the stack | [foo, bar].min |
CRuby < 3.3.0: Used whenever Array#min is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes the minimum value in the Array onto the stack |
||||||
opt_newarray_send |
The number of elements to take from the top of the stack | [foo, bar].hash |
CRuby >= 3.3.0: Used whenever a special method (e.g., Array#hash , Array#max , Array#min ) is called on an Array literal. Pops N elements off the stack and pushes the result of the specialized operation onto the stack. Introduced in CRuby 3.3.0, this instruction supplants the older opt_newarray_max and opt_newarray_min instructions |
||||||
opt_nil_p |
A calldata instance that will always contain the following values:- mid : :nil? - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.nil? |
Optimized implementation of the nil? method used when called directly without a block |
||||||
opt_not |
A calldata instance that will always contain the following values:- mid : :! - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
!foo |
Optimized implementation of the unary ! method used when + is called in the prefix position |
||||||
opt_or |
A calldata instance that will always contain the following values:- mid : :| - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo | 3 |
Optimized implementation of the | method used when | is called in the infix position with a single positional argument and no block |
||||||
opt_plus |
A calldata instance that will always contain the following values:- mid : :+ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo + 3 |
Optimized implementation of the + method used when + is called in the infix position with a single positional argument and no block |
||||||
opt_regexpmatch2 |
A calldata instance that will always contain the following values:- mid : :=~ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo =~ "abc" |
Optimized implementation of the =~ method used when =~ is called in the infix position with a single positional argument and no block |
||||||
opt_reverse |
A calldata instance that will always contain the following values:- mid : :reverse - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.reverse |
Optimized implementation of the reverse method used when called directly without a block |
||||||
opt_send_without_block |
A calldata instance |
"abc".valid_encoding? |
A specialized version of the send instruction for cases where the compiler can determine that a method is never called with a block at a given call site. It is equivalent to using send without setting the optional block instruction sequence operand, but saves memory by not reserving space for an optional operand |
||||||
opt_size |
A calldata instance that will always contain the following values:- mid : :size - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.size |
Optimized implementation of the size method used when called directly without a block |
||||||
opt_str_freeze |
A calldata instance that will always contain the following values:- mid : :freeze - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
"foo".freeze |
Used when String#freeze is called on an unfrozen string literal. It's a peephole optimization to reduce:putstring send <calldata!mid:freeze, argc:0, ARGS_SIMPLE> |
||||||
opt_str_uminus |
A calldata instance that will always contain the following values:- mid : :-@ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
-"foo" |
Used whenever String#-@ is called on an unfrozen string. It's a peephole optimization to reduce:putstring send <calldata!mid:-@, argc:0, ARGS_SIMPLE> |
||||||
opt_succ |
A calldata instance that will always contain the following values:- mid : :succ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.succ |
Optimized implementation of the succ method used when called directly without a block |
||||||
pop |
foo ||= 1 |
Pops a single value off the stack and discards it | |||||||
putnil |
nil |
Pushes nil onto the stack |
|||||||
putobject |
The value | 5 |
Push an arbitrary value onto the stack | ||||||
putobject_INT2FIX_0 |
0 |
Pushes the number 0 onto the stack |
|||||||
putobject_INT2FIX_1 |
1 |
Pushes the number 1 onto the stack |
|||||||
putself |
class Foo; def bar; self; end; end |
Looks up the receiver (self ) in the current frame and pushes it onto the stack |
|||||||
putstring |
The unfrozen string | "foo" |
Pushes an unfrozen string onto the stack | ||||||
send |
Two operands: - A calldata instance- (optional) A pointer to an instruction sequence corresponding to a block; nil if no block is provided |
[1, 2].map(&:even?) |
Used for general method invocation. Uses the calldata struct to look up a method to invoke. The arguments to the function must already be pushed onto the stack before the send instruction. The send call will add a new frame to the frame stack. The return value for the function will be written to the stack slot holding the receiver at the time the function is called by the leave instruction |
||||||
setblockparam |
Two operands: - The index of the block param - The level of the frame to look for the block param in (i.e., how many parent frames to traverse to find the correct environment pointer) |
def foo(&bar); bar = -> { 3 }; end |
|||||||
setclassvariable |
|||||||||
setinstancevariable |
|||||||||
setlocal |
Two operands: - The index of the local variable - The level of the frame to look for the local variable in (i.e., how many parent frames to traverse to find the correct environment pointer) |
value = 5; tap { tap { value = 10 } } |
Pops a value off the stack, then looks up the frame corresponding to the level operand and sets the value at the index offset to the popped value | ||||||
setlocal_WC_0 |
The index of the local variable in the current frame (level = 0 ) |
value = 5 |
A specialized version of the setlocal instruction that always sets the local in the current frame (level = 0 ). It works the same way as setlocal index, 0 , looking up the value at the index in the current frame and setting that value to whatever is popped off the stack, but saves memory by not reserving space for the level operand |
||||||
setlocal_WC_1 |
The index of the local variable in the parent frame (level = 1 ) |
value = 5; tap { value = 10 } |
A specialized version of the setlocal instruction that always sets the local in the parent frame (level = 1 ). It works the same way as setlocal index, 1 , looking up the value at the index in the parent frame and setting that value to whatever is popped off the stack, but saves memory by not reserving space for the level operand |
||||||
setn |
The index from top of the stack to copy | {}[:key] = "value" |
Changes the value at the top of the stack to be the same value as the one at the provided index offset from the top of the stack. NB: this does not push a new value onto the stack -- it modifies the value at the top of the stack | ||||||
setspecial |
An index into the others field in the vm_svar struct (offset by 2 ) |
foo if (bar == 1) .. (bar == 2) |
Pops a value off the stack and updates the flip flop state value (i.e., the others field in vm_svar ) in the special variable storage area with the popped value |
||||||
splatarray |
A flag that indicates whether the object on the top of the stack should be duped before converting to an array | foo(*bar) |
Used when the * operator is being used to splat into an object (e.g., local assignment, an array literal, or passing arguments to a method). Peeks the value at the top of the stack. If it's an Array no further action is taken, otherwise the value is popped, converted to an Array with to_a , and the new Array is pushed onto the stack. If the flag operand indicates the value should be duped, then the duped object is pushed onto the stack before the new Array |
||||||
swap |
defined?([[]]) |
Swaps the positions of two values at the top of the stack. NB: this does not push any new values onto the stack | |||||||
topn |
The index from the top of the stack to dupe | Foo::Bar += 1 |
Dupes the value at the provided index offset from the top of the stack and pushes it onto the stack | ||||||
toregexp |
Two operands: - An integer that represents the regexp options - The number of values to pop off the stack |
/foo #{bar} baz/i |
Pops n values off the stack and joins them together in a newly created Regexp , using the supplied options during Regexp creation. The Regexp is then pushed onto the stack |
||||||
opt_empty_p |
A calldata instance that will always contain the following values:- mid : :empty? - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.empty? |
Optimized implementation of the empty? method used when called directly without a block |
||||||
opt_eq |
A calldata instance that will always contain the following values:- mid : :== - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo == 3 |
Optimized implementation of the == method used when == is called in the infix position with a single positional argument and no block |
||||||
opt_ge |
A calldata instance that will always contain the following values:- mid : :>= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo >= 3 |
Optimized implementation of the >= method used when >= is called in the infix position with a single positional argument and no block |
||||||
opt_gt |
A calldata instance that will always contain the following values:- mid : :> - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo > 3 |
Optimized implementation of the > method used when > is called in the infix position with a single positional argument and no block |
||||||
opt_le |
A calldata instance that will always contain the following values:- mid : :<= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo <= 3 |
Optimized implementation of the <= method used when <= is called in the infix position with a single positional argument and no block |
||||||
opt_length |
A calldata instance that will always contain the following values:- mid : :length - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.length |
Optimized implementation of the length method used when called directly without a block |
||||||
opt_lt |
A calldata instance that will always contain the following values:- mid : :< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo < 3 |
Optimized implementation of the < method used when < is called in the infix position with a single positional argument and no block |
||||||
opt_ltlt |
A calldata instance that will always contain the following values:- mid : :<< - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
array << 1 |
Optimized implementation of the << method used when << is called in the infix position with a single positional argument and no block |
||||||
opt_minus |
A calldata instance that will always contain the following values:- mid : :- - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo - 3 |
Optimized implementation of the - method used when - is called in the infix position with a single positional argument and no block |
||||||
opt_mod |
A calldata instance that will always contain the following values:- mid : :% - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo % 3 |
Optimized implementation of the % method used when % is called in the infix position with a single positional argument and no block |
||||||
opt_mult |
A calldata instance that will always contain the following values:- mid : :* - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo * 3 |
Optimized implementation of the * method used when * is called in the infix position with a single positional argument and no block |
||||||
opt_neq |
A calldata instance that will always contain the following values:- mid : :!= - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo != 3 |
Optimized implementation of the != method used when != is called in the infix position with a single positional argument and no block |
||||||
opt_newarray_max |
The number of elements to take from the top of the stack | [foo, bar].max |
CRuby < 3.3.0: Used whenever Array#max is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes the maximum value in the Array onto the stack |
||||||
opt_newarray_min |
The number of elements to take from the top of the stack | [foo, bar].min |
CRuby < 3.3.0: Used whenever Array#min is called on an Array literal. Supplanted by opt_newarray_send in CRuby 3.3.0. Pops N elements off the stack and pushes the minimum value in the Array onto the stack |
||||||
opt_newarray_send |
The number of elements to take from the top of the stack | [foo, bar].hash |
CRuby >= 3.3.0: Used whenever a special method (e.g., Array#hash , Array#max , Array#min ) is called on an Array literal. Pops N elements off the stack and pushes the result of the specialized operation onto the stack. Introduced in CRuby 3.3.0, this instruction supplants the older opt_newarray_max and opt_newarray_min instructions |
||||||
opt_nil_p |
A calldata instance that will always contain the following values:- mid : :nil? - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.nil? |
Optimized implementation of the nil? method used when called directly without a block |
||||||
opt_not |
A calldata instance that will always contain the following values:- mid : :! - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
!foo |
Optimized implementation of the unary ! method used when + is called in the prefix position |
||||||
opt_or |
A calldata instance that will always contain the following values:- mid : :| - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo | 3 |
Optimized implementation of the | method used when | is called in the infix position with a single positional argument and no block |
||||||
opt_plus |
A calldata instance that will always contain the following values:- mid : :+ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo + 3 |
Optimized implementation of the + method used when + is called in the infix position with a single positional argument and no block |
||||||
opt_regexpmatch2 |
A calldata instance that will always contain the following values:- mid : :=~ - argc : 1 - flag : VM_CALL_ARGS_SIMPLE |
foo =~ "abc" |
Optimized implementation of the =~ method used when =~ is called in the infix position with a single positional argument and no block |
||||||
opt_reverse |
A calldata instance that will always contain the following values:- mid : :reverse - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.reverse |
Optimized implementation of the reverse method used when called directly without a block |
||||||
opt_send_without_block |
A calldata instance |
"abc".valid_encoding? |
A specialized version of the send instruction for cases where the compiler can determine that a method is never called with a block at a given call site. It is equivalent to using send without setting the optional block instruction sequence operand, but saves memory by not reserving space for an optional operand |
||||||
opt_size |
A calldata instance that will always contain the following values:- mid : :size - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.size |
Optimized implementation of the size method used when called directly without a block |
||||||
opt_str_freeze |
A calldata instance that will always contain the following values:- mid : :freeze - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
"foo".freeze |
Used when String#freeze is called on an unfrozen string literal. It's a peephole optimization to reduce:putstring send <calldata!mid:freeze, argc:0, ARGS_SIMPLE> |
||||||
opt_str_uminus |
A calldata instance that will always contain the following values:- mid : :-@ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
-"foo" |
Used whenever String#-@ is called on an unfrozen string. It's a peephole optimization to reduce:putstring send <calldata!mid:-@, argc:0, ARGS_SIMPLE> |
||||||
opt_succ |
A calldata instance that will always contain the following values:- mid : :succ - argc : 0 - flag : VM_CALL_ARGS_SIMPLE |
foo.succ |
Optimized implementation of the succ method used when called directly without a block |
||||||
pop |
foo ||= 1 |
Pops a single value off the stack and discards it | |||||||
putnil |
nil |
Pushes nil onto the stack |
|||||||
putobject |
The value | 5 |
Push an arbitrary value onto the stack | ||||||
putobject_INT2FIX_0 |
0 |
Pushes the number 0 onto the stack |
|||||||
putobject_INT2FIX_1 |
1 |
Pushes the number 1 onto the stack |
|||||||
putself |
class Foo; def bar; self; end; end |
Looks up the receiver (self ) in the current frame and pushes it onto the stack |
|||||||
putstring |
The unfrozen string | "foo" |
Pushes an unfrozen string onto the stack | ||||||
send |
Two operands: - A calldata instance- (optional) A pointer to an instruction sequence corresponding to a block; nil if no block is provided |
[1, 2].map(&:even?) |
Used for general method invocation. Uses the calldata struct to look up a method to invoke. The arguments to the function must already be pushed onto the stack before the send instruction. The send call will add a new frame to the frame stack. The return value for the function will be written to the stack slot holding the receiver at the time the function is called by the leave instruction |
||||||
setblockparam |
Two operands: - The index of the block param - The level of the frame to look for the block param in (i.e., how many parent frames to traverse to find the correct environment pointer) |
def foo(&bar); bar = -> { 3 }; end |
|||||||
setclassvariable |
|||||||||
setinstancevariable |
|||||||||
setlocal |
Two operands: - The index of the local variable - The level of the frame to look for the local variable in (i.e., how many parent frames to traverse to find the correct environment pointer) |
value = 5; tap { tap { value = 10 } } |
Pops a value off the stack, then looks up the frame corresponding to the level operand and sets the value at the index offset to the popped value | ||||||
setlocal_WC_0 |
The index of the local variable in the current frame (level = 0 ) |
value = 5 |
A specialized version of the setlocal instruction that always sets the local in the current frame (level = 0 ). It works the same way as setlocal index, 0 , looking up the value at the index in the current frame and setting that value to whatever is popped off the stack, but saves memory by not reserving space for the level operand |
||||||
setlocal_WC_1 |
The index of the local variable in the parent frame (level = 1 ) |
value = 5; tap { value = 10 } |
A specialized version of the setlocal instruction that always sets the local in the parent frame (level = 1 ). It works the same way as setlocal index, 1 , looking up the value at the index in the parent frame and setting that value to whatever is popped off the stack, but saves memory by not reserving space for the level operand |
||||||
setn |
The index from top of the stack to copy | {}[:key] = "value" |
Changes the value at the top of the stack to be the same value as the one at the provided index offset from the top of the stack. NB: this does not push a new value onto the stack -- it modifies the value at the top of the stack | ||||||
setspecial |
An index into the others field in the vm_svar struct (offset by 2 ) |
foo if (bar == 1) .. (bar == 2) |
Pops a value off the stack and updates the flip flop state value (i.e., the others field in vm_svar ) in the special variable storage area with the popped value |
||||||
splatarray |
A flag that indicates whether the object on the top of the stack should be duped before converting to an array | foo(*bar) |
Used when the * operator is being used to splat into an object (e.g., local assignment, an array literal, or passing arguments to a method). Peeks the value at the top of the stack. If it's an Array no further action is taken, otherwise the value is popped, converted to an Array with to_a , and the new Array is pushed onto the stack. If the flag operand indicates the value should be duped, then the duped object is pushed onto the stack before the new Array |
||||||
swap |
defined?([[]]) |
Swaps the positions of two values at the top of the stack. NB: this does not push any new values onto the stack | |||||||
topn |
The index from the top of the stack to dupe | Foo::Bar += 1 |
Dupes the value at the provided index offset from the top of the stack and pushes it onto the stack | ||||||
toregexp |
Two operands: - An integer that represents the regexp options - The number of values to pop off the stack |
/foo #{bar} baz/i |
Pops n values off the stack and joins them together in a newly created Regexp , using the supplied options during Regexp creation. The Regexp is then pushed onto the stack |
CRuby uses a custom DSL to generate the C code that implements the handling of each of the YARV instructions. The instruction definitions in the DSL can be found in insns.def.
A sample instruction (here, opt_plus
) is:
DEFINE_INSN
opt_plus
(CALL_DATA cd)
(VALUE recv, VALUE obj)
(VALUE val)
{
val = vm_opt_plus(recv, obj);
if (val == Qundef) {
CALL_SIMPLE_METHOD();
}
}
The format is the same for all instructions. Going line by line, we have:
Code | Meaning |
---|---|
opt_plus |
Name of the instruction |
CALL_DATA cd) |
Instruction operands |
(VALUE recv, VALUE obj) |
The objects to be popped off the stack (e.g., the left- and right-hand sides of + ) |
(VALUE val) |
The objects that are pushed onto the stack |
After that, we have the C code used to implement the body of the instruction. |