adjuststack
Summary
adjuststack accepts a single integer argument and removes that many
elements from the top of the stack.
TracePoint
adjuststack cannot dispatch any TracePoint events.
Usage
x = [true]
x[0] ||= nil
x[0]
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(3,4)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] x@0
# 0000 duparray [true] ( 1)[Li]
# 0002 setlocal_WC_0 x@0
# 0004 getlocal_WC_0 x@0 ( 2)[Li]
# 0006 putobject_INT2FIX_0_
# 0007 dupn 2
# 0009 opt_aref <calldata!mid:[], argc:1, ARGS_SIMPLE>[CcCr]
# 0011 dup
# 0012 branchif 21
# 0014 pop
# 0015 putnil
# 0016 opt_aset <calldata!mid:[]=, argc:2, ARGS_SIMPLE>[CcCr]
# 0018 pop
# 0019 jump 23
# 0021 adjuststack 3
# 0023 getlocal_WC_0 x@0 ( 3)[Li]
# 0025 putobject_INT2FIX_0_
# 0026 opt_aref <calldata!mid:[], argc:1, ARGS_SIMPLE>[CcCr]
# 0028 leave
anytostring
Summary
anytostring ensures that the value on top of the stack is a string.
It pops two values off the stack. If the first value is a string it pushes it back on the stack. If the first value is not a string, it uses Ruby’s built in string coercion to coerce the second value to a string and then pushes that back on the stack.
This is used in conjunction with objtostring as a fallback for when an object’s to_s
method does not return a string
TracePoint
anytostring cannot dispatch any TracePoint events
Usage
"#{5}"
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,6)> (catch: FALSE)
# 0000 putobject "" ( 1)[Li]
# 0002 putobject 5
# 0004 dup
# 0005 objtostring <calldata!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>
# 0007 anytostring
# 0008 concatstrings 2
# 0010 leave
branchif
Summary
branchif has one argument: the jump index. It pops one value off the stack:
the jump condition.
If the value popped off the stack is true, branchif jumps to
the jump index and continues executing there.
TracePoint
branchif does not dispatch any events.
Usage
x = true
x ||= "foo"
puts x
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(3,6)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] x@0
# 0000 putobject true ( 1)[Li]
# 0002 setlocal_WC_0 x@0
# 0004 getlocal_WC_0 x@0 ( 2)[Li]
# 0006 dup
# 0007 branchif 15
# 0009 pop
# 0010 putstring "foo"
# 0012 dup
# 0013 setlocal_WC_0 x@0
# 0015 pop
# 0016 putself ( 3)[Li]
# 0017 getlocal_WC_0 x@0
# 0019 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0021 leave
branchnil
Summary
branchnil has one argument: the jump index. It pops one value off the stack:
the jump condition.
If the value popped off the stack is nil, branchnil jumps to
the jump index and continues executing there.
TracePoint
There is no trace point for branchnil.
Usage
x = nil
if x&.to_s
puts "hi"
end
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(4,3)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] x@0
# 0000 putnil ( 1)[Li]
# 0001 setlocal_WC_0 x@0
# 0003 getlocal_WC_0 x@0 ( 2)[Li]
# 0005 dup
# 0006 branchnil 10
# 0008 opt_send_without_block <calldata!mid:to_s, argc:0, ARGS_SIMPLE>
# 0010 branchunless 18
# 0012 putself ( 3)[Li]
# 0013 putstring "hi"
# 0015 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0017 leave
# 0018 putnil
# 0019 leave
branchunless
Summary
branchunless has one argument, the jump index
and pops one value off the stack, the jump condition.
If the value popped off the stack is false or nil,
branchunless jumps to the jump index and continues executing there.
TracePoint
branchunless does not dispatch any events.
Usage
if 2 + 3
puts "foo"
end
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(3,3)> (catch: FALSE)
# 0000 putobject 2 ( 1)[Li]
# 0002 putobject 3
# 0004 opt_plus <calldata!mid:+, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 branchunless 14
# 0008 putself ( 2)[Li]
# 0009 putstring "foo"
# 0011 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0013 leave
# 0014 putnil
# 0015 leave
concatarray
Summary
concatarray concatenates the two Arrays on top of the stack.
It coerces the two objects at the top of the stack into Arrays by calling
to_a if necessary, and makes sure to dup the first Array if it was
already an Array, to avoid mutating it when concatenating.
TracePoint
concatarray can dispatch the line and call events.
Usage
[1, *2]
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,7)> (catch: FALSE)
# 0000 duparray [1] ( 1)[Li]
# 0002 putobject 2
# 0004 concatarray
# 0005 leave
concatstrings
Summary
concatstrings just pops a number of strings from the stack joins them together
into a single string and pushes that string back on the stack.
This does no coercion and so is always used in conjunction with objtostring
and anytostring to ensure the stack contents are always strings
TracePoint
concatstrings can dispatch the line and call events.
Usage
"#{5}"
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,6)> (catch: FALSE)
# 0000 putobject "" ( 1)[Li]
# 0002 putobject 5
# 0004 dup
# 0005 objtostring <calldata!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>
# 0007 anytostring
# 0008 concatstrings 2
# 0010 leave
defined
Summary
defined checks if the top value of the stack is defined. If it is, it
pushes its value onto the stack. Otherwise it pushes nil.
TracePoint
defined cannot dispatch any TracePoint events.
Usage
defined?(x)
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,11)> (catch: FALSE)
# 0000 putself ( 1)[Li]
# 0001 defined func, :x, "method"
# 0005 leave
definemethod
Summary
definemethod defines a method on the class of the current value of self.
It accepts two arguments. The first is the name of the method being defined.
The second is the instruction sequence representing the body of the method.
TracePoint
definemethod does not dispatch any events.
Usage
def value = "value"
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,19)> (catch: FALSE)
# 0000 definemethod :value, value ( 1)[Li]
# 0003 putobject :value
# 0005 leave
#
# == disasm: #<ISeq:value@<compiled>:1 (1,0)-(1,19)> (catch: FALSE)
# 0000 putstring "value" ( 1)[Ca]
# 0002 leave [Re]
dup
Summary
dup copies the top value of the stack and pushes it onto the stack.
TracePoint
dup does not dispatch any events.
Usage
$global = 5
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,11)> (catch: FALSE)
# 0000 putobject 5 ( 1)[Li]
# 0002 dup
# 0003 setglobal :$global
# 0005 leave
dup_hash
Summary
duphash pushes a hash onto the stack
TracePoint
duphash can dispatch the line event.
Usage
{ a: 1 }
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,8)> (catch: FALSE)
# 0000 duphash {:a=>1} ( 1)[Li]
# 0002 leave
duparray
Summary
duparray copies a literal Array and pushes it onto the stack.
TracePoint
duparray can dispatch the line event.
Usage
[true]
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,6)> (catch: FALSE)
# 0000 duparray [true] ( 1)[Li]
# 0002 leave
dupn
Summary
dupn duplicates the top n stack elements.
TracePoint
dupn does not dispatch any TracePoint events.
Usage
Object::X ||= true
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,18)> (catch: FALSE)
# 0000 opt_getinlinecache 9, <is:0> ( 1)[Li]
# 0003 putobject true
# 0005 getconstant :Object
# 0007 opt_setinlinecache <is:0>
# 0009 dup
# 0010 defined constant-from, :X, true
# 0014 branchunless 25
# 0016 dup
# 0017 putobject true
# 0019 getconstant :X
# 0021 dup
# 0022 branchif 32
# 0024 pop
# 0025 putobject true
# 0027 dupn 2
# 0029 swap
# 0030 setconstant :X
# 0032 swap
# 0033 pop
# 0034 leave
expandarray
Summary
expandarray looks at the top of the stack, and if the value is an array
it replaces it on the stack with num elements of the array, or nil if
the elements are missing.
TracePoint
expandarray does not dispatch any events.
Usage
x, = [true, false, nil]
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,23)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] x@0
# 0000 duparray [true, false, nil] ( 1)[Li]
# 0002 dup
# 0003 expandarray 1, 0
# 0006 setlocal_WC_0 x@0
# 0008 leave
getconstant
Summary
getconstant performs a constant lookup and pushes the value of the
constant onto the stack.
TracePoint
getconstant does not dispatch any events.
Usage
Constant
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,8)> (catch: FALSE)
# 0000 opt_getinlinecache 9, <is:0> ( 1)[Li]
# 0003 putobject true
# 0005 getconstant :Constant
# 0007 opt_setinlinecache <is:0>
# 0009 leave
getglobal
Summary
getglobal pushes the value of a global variables onto the stack.
TracePoint
getglobal does not dispatch any events.
Usage
$$
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,2)> (catch: FALSE)
# 0000 getglobal :$$ ( 1)[Li]
# 0002 leave
getlocal
Summary
getlocal fetches the value of a local variable from a frame determined by
the level and index arguments. The level is the number of frames back to
look and the index is the index in the local table. It pushes the value it
finds onto the stack.
TracePoint
getlocal does not dispatch any events.
Usage
value = 5
tap { tap { value } }
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,21)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] value@0
# 0000 putobject 5 ( 1)[Li]
# 0002 setlocal_WC_0 value@0
# 0004 putself ( 2)[Li]
# 0005 send <calldata!mid:tap, argc:0, FCALL>, block in <compiled>
# 0008 leave
#
# == disasm: #<ISeq:block in <compiled>@<compiled>:2 (2,4)-(2,21)> (catch: FALSE)
# 0000 putself ( 2)[LiBc]
# 0001 send <calldata!mid:tap, argc:0, FCALL>, block (2 levels) in <compiled>
# 0004 leave [Br]
#
# == disasm: #<ISeq:block (2 levels) in <compiled>@<compiled>:2 (2,10)-(2,19)> (catch: FALSE)
# 0000 getlocal value@0, 2 ( 2)[LiBc]
# 0003 leave [Br]
getlocal_wc_0
Summary
getlocal_WC_0 is a specialized version of the getlocal instruction. It
fetches the value of a local variable from the current frame determined by
the index given as its only argument.
TracePoint
getlocal_WC_0 does not dispatch any events.
Usage
value = 5
value
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,5)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] value@0
# 0000 putobject 5 ( 1)[Li]
# 0002 setlocal_WC_0 value@0
# 0004 getlocal_WC_0 value@0 ( 2)[Li]
# 0006 leave
getlocal_wc_1
Summary
getlocal_WC_1 is a specialized version of the getlocal instruction. It
fetches the value of a local variable from the parent frame determined by
the index given as its only argument.
TracePoint
getlocal_WC_1 does not dispatch any events.
Usage
value = 5
self.then { value }
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,19)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] value@0
# 0000 putobject 5 ( 1)[Li]
# 0002 setlocal_WC_0 value@0
# 0004 putself ( 2)[Li]
# 0005 send <calldata!mid:then, argc:0, FCALL>, block in <compiled>
# 0008 leave
#
# == disasm: #<ISeq:block in <compiled>@<compiled>:2 (2,10)-(2,19)> (catch: FALSE)
# 0000 getlocal_WC_1 value@0 ( 2)[LiBc]
# 0002 leave [Br]
intern
Summary
intern converts top element from stack to a symbol.
TracePoint
There is no trace point for intern.
Usage
:"#{"foo"}"
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,11)> (catch: FALSE)
# 0000 putstring "foo" ( 1)[Li]
# 0002 intern
# 0003 leave
invokeblock
Summary
invokeblock invokes the block passed to a method during a yield.
TracePoint
Usage
def foo; yield; end
# == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,19)> (catch: FALSE)
# 0000 definemethod :foo, foo ( 1)[Li]
# 0003 putobject :foo
# 0005 leave
#
# == disasm: #<ISeq:foo@-e:1 (1,0)-(1,19)> (catch: FALSE)
# 0000 invokeblock <calldata!argc:0, ARGS_SIMPLE>( 1)[LiCa]
# 0002 leave [Re]
# ~~~
## jump
### Summary
`jump` has one argument, the jump index, which it uses to set the next
instruction to execute.
### TracePoint
There is no trace point for `jump`.
### Usage
~~~ruby
y = 0
if y == 0
puts "0"
else
puts "2"
end
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(6,3)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] y@0
# 0000 putobject_INT2FIX_0_ ( 1)[Li]
# 0001 setlocal_WC_0 y@0
# 0003 getlocal_WC_0 y@0 ( 2)[Li]
# 0005 putobject_INT2FIX_0_
# 0006 opt_eq <calldata!mid:==, argc:1, ARGS_SIMPLE>[CcCr]
# 0008 branchunless 16
# 0010 putself ( 3)[Li]
# 0011 putstring "0"
# 0013 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0015 leave ( 5)
# 0016 putself [Li]
# 0017 putstring "2"
# 0019 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0021 leave
leave
Summary
leave exits the current frame.
TracePoint
leave does not dispatch any events.
Usage
;;
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,2)> (catch: FALSE)
# 0000 putnil ( 1)
# 0001 leave
newarray
Summary
newarray puts a new array initialized with size values from the stack.
TracePoint
newarray dispatches a line event.
Usage
["string"]
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,10)> (catch: FALSE)
# 0000 putstring "string" ( 1)[Li]
# 0002 newarray 1
# 0004 leave
newhash
Summary
newhash puts a new hash onto the stack, using num elements from the
stack. num needs to be even.
TracePoint
newhash does not dispatch any events.
Usage
def foo(key, value)
{ key => value }
end
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(3,3)> (catch: FALSE)
# 0000 definemethod :foo, foo ( 1)[Li]
# 0003 putobject :foo
# 0005 leave
#
# == disasm: #<ISeq:foo@<compiled>:1 (1,0)-(3,3)> (catch: FALSE)
# local table (size: 2, argc: 2 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 2] key@0<Arg> [ 1] value@1<Arg>
# 0000 getlocal_WC_0 key@0 ( 2)[LiCa]
# 0002 getlocal_WC_0 value@1
# 0004 newhash 2
# 0006 leave ( 3)[Re]
newrange
Summary
newrange creates a Range. It takes one arguments, which is 0 if the end
is included or 1 if the end value is excluded.
TracePoint
newrange does not dispatch any events.
Usage
x = 0
y = 1
p (x..y), (x...y)
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(3,17)> (catch: FALSE)
# local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 2] x@0 [ 1] y@1
# 0000 putobject_INT2FIX_0_ ( 1)[Li]
# 0001 setlocal_WC_0 x@0
# 0003 putobject_INT2FIX_1_ ( 2)[Li]
# 0004 setlocal_WC_0 y@1
# 0006 putself ( 3)[Li]
# 0007 getlocal_WC_0 x@0
# 0009 getlocal_WC_0 y@1
# 0011 newrange 0
# 0013 getlocal_WC_0 x@0
# 0015 getlocal_WC_0 y@1
# 0017 newrange 1
# 0019 opt_send_without_block <calldata!mid:p, argc:2, FCALL|ARGS_SIMPLE>
# 0021 leave
nop
Summary
nop is a no-operation instruction. It is used to pad the instruction
sequence so there is a place for other instructions to jump to.
TracePoint
nop does not dispatch any events.
Usage
raise rescue true
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,17)> (catch: TRUE)
# == catch table
# | catch type: rescue st: 0000 ed: 0003 sp: 0000 cont: 0004
# | == disasm: #<ISeq:rescue in <compiled>@<compiled>:1 (1,6)-(1,17)> (catch: TRUE)
# | local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# | [ 1] $!@0
# | 0000 getlocal_WC_0 $!@0 ( 1)
# | 0002 putobject StandardError
# | 0004 checkmatch 3
# | 0006 branchunless 11
# | 0008 putobject true
# | 0010 leave
# | 0011 getlocal_WC_0 $!@0
# | 0013 throw 0
# | catch type: retry st: 0003 ed: 0004 sp: 0000 cont: 0000
# |------------------------------------------------------------------------
# 0000 putself ( 1)[Li]
# 0001 opt_send_without_block <calldata!mid:raise, argc:0, FCALL|VCALL|ARGS_SIMPLE>
# 0003 nop
# 0004 leave
objtostring
Summary
objtostring pops a value from the stack, calls to_s on that value and then pushes
the result back to the stack.
It has fast paths for String, Symbol, Module, Class, Nil, True, False & Number.
For everything else it calls to_s
TracePoint
objtostring cannot dispatch any TracePoint events.
Usage
"#{5}"
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,6)> (catch: FALSE)
# 0000 putobject "" ( 1)[Li]
# 0002 putobject 5
# 0004 dup
# 0005 objtostring <calldata!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>
# 0007 anytostring
# 0008 concatstrings 2
# 0010 leave
opt_and
Summary
opt_and is a specialization of the opt_send_without_block instruction
that occurs when the & operator is used. In CRuby, there are fast paths
for if both operands are integers.
TracePoint
opt_and can dispatch both the c_call and c_return events.
Usage
2 & 3
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,5)> (catch: FALSE)
# 0000 putobject 2 ( 1)[Li]
# 0002 putobject 3
# 0004 opt_and <calldata!mid:&, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_aref
Summary
opt_aref is a specialization of the opt_send_without_block instruction
that occurs when the [] operator is used. In CRuby, there are fast paths
if the receiver is an integer, array, or hash.
TracePoint
opt_aref can dispatch both the c_call and c_return events.
Usage
7[2]
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,4)> (catch: FALSE)
# 0000 putobject 7 ( 1)[Li]
# 0002 putobject 2
# 0004 opt_aref <calldata!mid:[], argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_aref_with
Summary
opt_aref_with is a specialization of the opt_aref instruction that
occurs when the [] operator is used with a string argument known at
compile time. In CRuby, there are fast paths if the receiver is a hash.
TracePoint
opt_aref_with does not dispatch any events.
Usage
{ 'test' => true }['test']
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,26)> (catch: FALSE)
# 0000 duphash {"test"=>true} ( 1)[Li]
# 0002 opt_aref_with "test", <calldata!mid:[], argc:1, ARGS_SIMPLE>
# 0005 leave
opt_aset
Summary
opt_aset is an instruction for setting the hash value by the key in recv[obj] = set format
TracePoint
There is no trace point for opt_aset.
Usage
{}[:key] = value
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,16)> (catch: FALSE)
# 0000 putnil ( 1)[Li]
# 0001 newhash 0
# 0003 putobject :key
# 0005 putself
# 0006 opt_send_without_block <calldata!mid:value, argc:0, FCALL|VCALL|ARGS_SIMPLE>
# 0008 setn 3
# 0010 opt_aset <calldata!mid:[]=, argc:2, ARGS_SIMPLE>[CcCr]
# 0012 pop
# 0013 leave
opt_aset_with
Summary
opt_aset_with is an instruction for setting the hash value by the known
string key in the recv[obj] = set format.
TracePoint
There is no trace point for opt_aset_with.
Usage
{}["key"] = value
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,17)> (catch: FALSE)
# 0000 newhash 0 ( 1)[Li]
# 0002 putself
# 0003 opt_send_without_block <calldata!mid:value, argc:0, FCALL|VCALL|ARGS_SIMPLE>
# 0005 swap
# 0006 topn 1
# 0008 opt_aset_with "key", <calldata!mid:[]=, argc:2, ARGS_SIMPLE>
# 0011 pop
# 0012 leave
opt_case_dispatch
Summary
opt_case_dispatch is a branch instruction that moves the control flow for
case statements.
It has two arguments: the cdhash and an else_offset index. It pops one value off
the stack: a hash key. opt_case_dispatch looks up the key in the cdhash
and jumps to the corresponding index value, if there is one.
If there is no value in the cdhash, opt_case_dispatch jumps to the else_offset index.
The cdhash is a Ruby hash used for handling optimized case statements.
The keys are the conditions of when clauses in the case statement,
and the values are the labels to which to jump. This optimization can be
applied only when the keys can be directly compared.
TracePoint
There is no trace point for opt_case_dispatch.
Usage
case 1
when 1
puts "foo"
else
puts "bar"
end
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,49)> (catch: FALSE)
# 0000 putobject_INT2FIX_0_ ( 1)[Li]
# 0001 dup
# 0002 opt_case_dispatch <cdhash>, 12
# 0005 putobject_INT2FIX_1_
# 0006 topn 1
# 0008 opt_send_without_block <calldata!mid:===, argc:1, FCALL|ARGS_SIMPLE>
# 0010 branchif 19
# 0012 pop
# 0013 putself
# 0014 putstring "bar"
# 0016 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0018 leave
# 0019 pop
# 0020 putself
# 0021 putstring "foo"
# 0023 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0025 leave
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(6,3)> (catch: FALSE)
# 0000 putobject_INT2FIX_1_ ( 1)[Li]
# 0001 dup
# 0002 opt_case_dispatch <cdhash>, 12
# 0005 putobject_INT2FIX_1_ ( 2)
# 0006 topn 1
# 0008 opt_send_without_block <calldata!mid:===, argc:1, FCALL|ARGS_SIMPLE>
# 0010 branchif 19
# 0012 pop ( 5)
# 0013 putself [Li]
# 0014 putstring "bar"
# 0016 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0018 leave
# 0019 pop ( 2)
# 0020 putself ( 3)[Li]
# 0021 putstring "foo"
# 0023 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0025 leave ( 5)
opt_div
Summary
opt_div is a specialization of the opt_send_without_block instruction
that occurs when the / operator is used. In CRuby, there are fast paths
for if both operands are integers, or if both operands are floats.
TracePoint
opt_div can dispatch both the c_call and c_return events.
Usage
2 / 3
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,5)> (catch: FALSE)
# 0000 putobject 2 ( 1)[Li]
# 0002 putobject 3
# 0004 opt_div <calldata!mid:/, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_empty_p
Summary
opt_empty_p is an optimization applied when the method empty? is called
on a String, Array or a Hash. This optimization can be applied because Ruby
knows how to calculate the length of these objects using internal C macros.
TracePoint
opt_empty_p can dispatch c_call and c_return events.
Usage
"".empty?
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,9)> (catch: FALSE)
# 0000 putstring "" ( 1)[Li]
# 0002 opt_empty_p <calldata!mid:empty?, argc:0, ARGS_SIMPLE>[CcCr]
# 0004 leave
opt_eq
Summary
opt_eq is a specialization of the opt_send_without_block instruction
that occurs when the == operator is used. Fast paths exist within CRuby when
both operands are integers, floats, symbols or strings.
TracePoint
opt_eq can dispatch both the c_call and c_return events.
Usage
2 == 2
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,6)> (catch: FALSE)
# 0000 putobject 2 ( 1)[Li]
# 0002 putobject 2
# 0004 opt_eq <calldata!mid:==, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_ge
Summary
opt_ge is a specialization of the opt_send_without_block instruction
that occurs when the >= operator is used. Fast paths exist within CRuby when
both operands are integers or floats.
TracePoint
opt_ge can dispatch both the c_call and c_return events.
Usage
4 >= 3
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,6)> (catch: FALSE)
# 0000 putobject 4 ( 1)[Li]
# 0002 putobject 3
# 0004 opt_ge <calldata!mid:>=, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_getinlinecache
Summary
opt_getinlinecache is a wrapper around a series of getconstant
instructions that allows skipping past them if the inline cache is currently
set.
TracePoint
opt_getinlinecache does not dispatch any events.
Usage
Constant
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,8)> (catch: FALSE)
# 0000 opt_getinlinecache 9, <is:0> ( 1)[Li]
# 0003 putobject true
# 0005 getconstant :Constant
# 0007 opt_setinlinecache <is:0>
# 0009 leave
opt_gt
Summary
opt_gt is a specialization of the opt_send_without_block instruction
that occurs when the > operator is used. Fast paths exist within CRuby when
both operands are integers or floats.
TracePoint
opt_gt can dispatch both the c_call and c_return events.
Usage
4 > 3
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,5)> (catch: FALSE)
# 0000 putobject 4 ( 1)[Li]
# 0002 putobject 3
# 0004 opt_gt <calldata!mid:>, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_le
Summary
opt_le is a specialization of the opt_send_without_block instruction
that occurs when the <= operator is used. Fast paths exist within CRuby when
both operands are integers or floats.
TracePoint
opt_le can dispatch both the c_call and c_return events.
Usage
3 <= 4
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,6)> (catch: FALSE)
# 0000 putobject 3 ( 1)[Li]
# 0002 putobject 4
# 0004 opt_le <calldata!mid:<=, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_length
Summary
opt_length is a specialization of opt_send_without_block, when the
length method is called on a Ruby type with a known size. In CRuby there
are fast paths when the receiver is either a String, Hash or Array.
TracePoint
opt_length can dispatch c_call and c_return events.
Usage
"".length
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,9)> (catch: FALSE)
# 0000 putstring "" ( 1)[Li]
# 0002 opt_length <calldata!mid:length, argc:0, ARGS_SIMPLE>[CcCr]
# 0004 leave
opt_lt
Summary
opt_lt is a specialization of the opt_send_without_block instruction
that occurs when the < operator is used. Fast paths exist within CRuby when
both operands are integers or floats.
TracePoint
opt_lt can dispatch both the c_call and c_return events.
Usage
3 < 4
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,5)> (catch: FALSE)
# 0000 putobject 3 ( 1)[Li]
# 0002 putobject 4
# 0004 opt_lt <calldata!mid:<, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_ltlt
Summary
opt_ltlt is a specialization of the opt_send_without_block instruction
that occurs when the << operator is used. Fast paths exists when the
receiver is either a String or an Array
TracePoint
opt_ltlt can dispatch both the c_call and c_return events.
Usage
"" << 2
# == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,7)> (catch: FALSE)
# 0000 putstring "" ( 1)[Li]
# 0002 putobject 2
# 0004 opt_ltlt <calldata!mid:<<, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,7)> (catch: FALSE)
# 0000 putstring "" ( 1)[Li]
# 0002 putobject 2
# 0004 opt_ltlt <calldata!mid:<<, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_minus
Summary
opt_minus is a specialization of the opt_send_without_block instruction
that occurs when the - operator is used. In CRuby, there are fast paths
for if both operands are integers or both operands are floats.
TracePoint
opt_minus can dispatch both the c_call and c_return events.
Usage
3 - 2
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,5)> (catch: FALSE)
# 0000 putobject 3 ( 1)[Li]
# 0002 putobject 2
# 0004 opt_minus <calldata!mid:-, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_mod
Summary
opt_mod is a specialization of the opt_send_without_block instruction
that occurs when the % operator is used. In CRuby, there are fast paths
for if both operands are integers or both operands are floats.
TracePoint
opt_eq can dispatch both the c_call and c_return events.
Usage
4 % 2
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,5)> (catch: FALSE)
# 0000 putobject 4 ( 1)[Li]
# 0002 putobject 2
# 0004 opt_mod <calldata!mid:%, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_mult
Summary
opt_mult is a specialization of the opt_send_without_block instruction
that occurs when the * operator is used. In CRuby, there are fast paths
for if both operands are integers or floats.
TracePoint
opt_mult can dispatch both the c_call and c_return events.
Usage
3 * 2
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,5)> (catch: FALSE)
# 0000 putobject 3 ( 1)[Li]
# 0002 putobject 2
# 0004 opt_mult <calldata!mid:*, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_neq
Summary
opt_neq is an optimisation that tests whether two values at the top of
the stack are not equal by testing their equality and performing a logical
NOT on the result.
This allows opt_neq to use the fast paths optimized in opt_eq when both
operands are Integers, Floats, Symbols or Strings.
TracePoint
opt_neq can dispatch both the c_call and c_return events.
Usage
2 != 2
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,6)> (catch: FALSE)
# 0000 putobject 2 ( 1)[Li]
# 0002 putobject 2
# 0004 opt_neq <calldata!mid:==, argc:1, ARGS_SIMPLE>, <calldata!mid:!=, argc:1, ARGS_SIMPLE>[CcCr]
# 0007 leave
opt_newarray_max
Summary
opt_newarray_max is an instruction that represents calling max on an
array literal. It is used to optimize quick comparisons of array elements.
TracePoint
opt_newarray_max does not dispatch any events.
Usage
[1, x = 2].max
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,14)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] x@0
# 0000 putobject_INT2FIX_1_ ( 1)[Li]
# 0001 putobject 2
# 0003 dup
# 0004 setlocal_WC_0 x@0
# 0006 opt_newarray_max 2
# 0008 leave
opt_newarray_min
Summary
opt_newarray_min is an instruction that represents calling min on an
array literal. It is used to optimize quick comparisons of array elements.
TracePoint
opt_newarray_min does not dispatch any events.
Usage
[1, x = 2].min
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,14)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] x@0
# 0000 putobject_INT2FIX_1_ ( 1)[Li]
# 0001 putobject 2
# 0003 dup
# 0004 setlocal_WC_0 x@0
# 0006 opt_newarray_min 2
# 0008 leave
opt_nil_p
Summary
opt_nil_p is an optimization applied when the method nil? is called. It
returns true immediately when the receiver is nil and defers to the nil?
method in other cases
TracePoint
opt_nil_p can dispatch c_call and c_return events.
Usage
"".nil?
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,7)> (catch: FALSE)
# 0000 putstring "" ( 1)[Li]
# 0002 opt_nil_p <calldata!mid:nil?, argc:0, ARGS_SIMPLE>[CcCr]
# 0004 leave
opt_not
Summary
opt_not negates the value on top of the stack.
TracePoint
opt_not can dispatch both the c_call and c_return events.
Usage
!true
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,5)> (catch: FALSE)
# 0000 putobject true ( 1)[Li]
# 0002 opt_not <calldata!mid:!, argc:0, ARGS_SIMPLE>[CcCr]
# 0004 leave
opt_or
Summary
opt_or is a specialization of the opt_send_without_block instruction
that occurs when the | operator is used. In CRuby, there are fast paths
for if both operands are integers.
TracePoint
opt_or can dispatch both the c_call and c_return events.
Usage
2 | 3
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,5)> (catch: FALSE)
# 0000 putobject 2 ( 1)[Li]
# 0002 putobject 3
# 0004 opt_or <calldata!mid:|, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_plus
Summary
opt_plus is a specialization of the opt_send_without_block instruction
that occurs when the + operator is used. In CRuby, there are fast paths
for if both operands are integers, floats, strings, or arrays.
TracePoint
opt_plus can dispatch both the c_call and c_return events.
Usage
2 + 3
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,5)> (catch: FALSE)
# 0000 putobject 2 ( 1)[Li]
# 0002 putobject 3
# 0004 opt_plus <calldata!mid:+, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_regexpmatch2
Summary
opt_regexpmatch2 is a specialization of the opt_send_without_block
instruction that occurs when the =~ operator is used.
TracePoint
opt_regexpmatch2 can dispatch both the c_call and c_return events.
Usage
/a/ =~ "a"
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,10)> (catch: FALSE)
# 0000 putobject /a/ ( 1)[Li]
# 0002 putstring "a"
# 0004 opt_regexpmatch2 <calldata!mid:=~, argc:1, ARGS_SIMPLE>[CcCr]
# 0006 leave
opt_send_without_block
Summary
opt_send_without_block is a specialization of the send instruction that
occurs when a method is being called without a block.
TracePoint
opt_send_without_block does not dispatch any events.
Usage
puts "Hello, world!"
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,20)> (catch: FALSE)
# 0000 putself ( 1)[Li]
# 0001 putstring "Hello, world!"
# 0003 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0005 leave
opt_setinlinecache
Summary
opt_setinlinecache is the final instruction after a series of
getconstant instructions that populates the inline cache associated with
an opt_getinlinecache instruction.
TracePoint
opt_setinlinecache does not dispatch any events.
Usage
Constant
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,8)> (catch: FALSE)
# 0000 opt_getinlinecache 9, <is:0> ( 1)[Li]
# 0003 putobject true
# 0005 getconstant :Constant
# 0007 opt_setinlinecache <is:0>
# 0009 leave
opt_size
Summary
opt_size is a specialization of opt_send_without_block, when the
size method is called on a Ruby type with a known size. In CRuby there
are fast paths when the receiver is either a String, Hash or Array.
TracePoint
opt_size can dispatch c_call and c_return events.
Usage
"".size
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,7)> (catch: FALSE)
# 0000 putstring "" ( 1)[Li]
# 0002 opt_size <calldata!mid:size, argc:0, ARGS_SIMPLE>[CcCr]
# 0004 leave
opt_str_freeze
Summary
opt_str_freeze pushes a frozen known string value with no interpolation
onto the stack.
TracePoint
opt_str_freeze does not dispatch any events.
Usage
"hello".freeze
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,14)> (catch: FALSE)
# 0000 opt_str_freeze "hello", <calldata!mid:freeze, argc:0, ARGS_SIMPLE>( 1)[Li]
# 0003 leave
opt_str_uminus
Summary
opt_str_uminus pushes a frozen known string value with no interpolation
onto the stack.
TracePoint
opt_str_uminus does not dispatch any events.
Usage
-"string"
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,9)> (catch: FALSE)
# 0000 opt_str_uminus "string", <calldata!mid:-@, argc:0, ARGS_SIMPLE>( 1)[Li]
# 0003 leave
opt_succ
Summary
opt_succ is a specialization of the opt_send_without_block instruction
when the method being called is succ. Fast paths exist within CRuby when
the receiver is either a String or a Fixnum.
TracePoint
opt_succ can dispatch c_call and c_return events.
Usage
"".succ
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,7)> (catch: FALSE)
# 0000 putstring "" ( 1)[Li]
# 0002 opt_succ <calldata!mid:succ, argc:0, ARGS_SIMPLE>[CcCr]
# 0004 leave
pop
Summary
pop pops the top value off the stack.
TracePoint
pop does not dispatch any events.
Usage
a ||= 2
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,7)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] a@0
# 0000 getlocal_WC_0 a@0 ( 1)[Li]
# 0002 dup
# 0003 branchif 11
# 0005 pop
# 0006 putobject 2
# 0008 dup
# 0009 setlocal_WC_0 a@0
# 0011 leave
putnil
Summary
putnil pushes a global nil object onto the stack.
TracePoint
putnil can dispatch the line event.
Usage
nil
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,3)> (catch: FALSE)
# 0000 putnil ( 1)[Li]
# 0001 leave
putobject
Summary
putobject pushes a known value onto the stack.
TracePoint
putobject can dispatch the line event.
Usage
5
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,1)> (catch: FALSE)
# 0000 putobject 5 ( 1)[Li]
# 0002 leave
putobject_int2fix_0
Summary
putobject_INT2FIX_0_ pushes 0 on the stack.
It is a specialized instruction resulting from the operand
unification optimization. It is the equivalent to putobject 0.
TracePoint
putobject can dispatch the line event.
Usage
0
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,1)> (catch: FALSE)
# 0000 putobject_INT2FIX_0_ ( 1)[Li]
# 0001 leave
putobject_int2fix_1
Summary
putobject_INT2FIX_1_ pushes 1 on the stack.
It is a specialized instruction resulting from the operand
unification optimization. It is the equivalent to putobject 1.
TracePoint
putobject can dispatch the line event.
Usage
1
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,1)> (catch: FALSE)
# 0000 putobject_INT2FIX_1_ ( 1)[Li]
# 0001 leave
putself
Summary
putself pushes the current value of self onto the stack.
TracePoint
putself can dispatch the line event.
Usage
puts "Hello, world!"
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,20)> (catch: FALSE)
# 0000 putself ( 1)[Li]
# 0001 putstring "Hello, world!"
# 0003 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0005 leave
putstring
Summary
putstring pushes a string literal onto the stack.
TracePoint
putstring can dispatch the line event.
Usage
"foo"
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,5)> (catch: FALSE)
# 0000 putstring "foo" ( 1)[Li]
# 0002 leave
send
Summary
send invokes a method with a block.
TracePoint
send does not dispatch any events.
Usage
"hello".tap { |i| p i }
# == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,23)> (catch: FALSE)
# 0000 putstring "hello" ( 1)[Li]
# 0002 send <calldata!mid:tap, argc:0>, block in <main>
# 0005 leave
#
# == disasm: #<ISeq:block in <main>@-e:1 (1,12)-(1,23)> (catch: FALSE)
# local table (size: 1, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] i@0<Arg>
# 0000 putself ( 1)[LiBc]
# 0001 getlocal_WC_0 i@0
# 0003 opt_send_without_block <calldata!mid:p, argc:1, FCALL|ARGS_SIMPLE>
# 0005 leave [Br]
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,23)> (catch: FALSE)
# 0000 putstring "hello" ( 1)[Li]
# 0002 send <calldata!mid:tap, argc:0>, block in <compiled>
# 0005 leave
#
# == disasm: #<ISeq:block in <compiled>@<compiled>:1 (1,12)-(1,23)> (catch: FALSE)
# local table (size: 1, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] i@0<Arg>
# 0000 putself ( 1)[LiBc]
# 0001 getlocal_WC_0 i@0
# 0003 opt_send_without_block <calldata!mid:p, argc:1, FCALL|ARGS_SIMPLE>
# 0005 leave [Br]
setglobal
Summary
setglobal sets the value of a global variable.
TracePoint
setglobal does not dispatch any events.
Usage
$global = 5
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,11)> (catch: FALSE)
# 0000 putobject 5 ( 1)[Li]
# 0002 dup
# 0003 setglobal :$global
# 0005 leave
setlocal
Summary
setlocal sets the value of a local variable on a frame determined by the
level and index arguments. The level is the number of frames back to
look and the index is the index in the local table. It pops the value it is
setting off the stack.
TracePoint
setlocal does not dispatch any events.
Usage
value = 5
tap { tap { value = 10 } }
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,26)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] value@0
# 0000 putobject 5 ( 1)[Li]
# 0002 setlocal_WC_0 value@0
# 0004 putself ( 2)[Li]
# 0005 send <calldata!mid:tap, argc:0, FCALL>, block in <compiled>
# 0008 leave
#
# == disasm: #<ISeq:block in <compiled>@<compiled>:2 (2,4)-(2,26)> (catch: FALSE)
# 0000 putself ( 2)[LiBc]
# 0001 send <calldata!mid:tap, argc:0, FCALL>, block (2 levels) in <compiled>
# 0004 leave [Br]
#
# == disasm: #<ISeq:block (2 levels) in <compiled>@<compiled>:2 (2,10)-(2,24)> (catch: FALSE)
# 0000 putobject 10 ( 2)[LiBc]
# 0002 dup
# 0003 setlocal value@0, 2
# 0006 leave [Br]
setlocal_wc_0
Summary
setlocal_WC_0 is a specialized version of the setlocal instruction. It
sets the value of a local variable on the current frame to the value at the
top of the stack as determined by the index given as its only argument.
TracePoint
setlocal_WC_0 does not dispatch any events.
Usage
value = 5
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,9)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] value@0
# 0000 putobject 5 ( 1)[Li]
# 0002 dup
# 0003 setlocal_WC_0 value@0
# 0005 leave
setlocal_wc_1
Summary
setlocal_WC_1 is a specialized version of the setlocal instruction. It
sets the value of a local variable on the parent frame to the value at the
top of the stack as determined by the index given as its only argument.
TracePoint
setlocal_WC_1 does not dispatch any events.
Usage
value = 5
self.then { value = 10 }
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,24)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] value@0
# 0000 putobject 5 ( 1)[Li]
# 0002 setlocal_WC_0 value@0
# 0004 putself ( 2)[Li]
# 0005 send <calldata!mid:then, argc:0, FCALL>, block in <compiled>
# 0008 leave
#
# == disasm: #<ISeq:block in <compiled>@<compiled>:2 (2,10)-(2,24)> (catch: FALSE)
# 0000 putobject 10 ( 2)[LiBc]
# 0002 dup
# 0003 setlocal_WC_1 value@0
# 0005 leave [Br]
setn
Summary
setn is an instruction for set Nth stack entry to stack top
TracePoint
# setn does not dispatch any events.
Usage
{}[:key] = 'val'
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,16)> (catch: FALSE)
# 0000 putnil ( 1)[Li]
# 0001 newhash 0
# 0003 putobject :key
# 0005 putstring "val"
# 0007 setn 3
# 0009 opt_aset <calldata!mid:[]=, argc:2, ARGS_SIMPLE>[CcCr]
# 0011 pop
# 0012 leave
splatarray
Summary
splatarray calls to_a on an array to splat.
It coerces the array object at the top of the stack into Array by calling
to_a. It pushes a duplicate of the array if there is a flag, and the original
array, if there isn’t one.
TracePoint
splayarray does not dispatch any events.
Usage
x = *(5)
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,8)> (catch: FALSE)
# local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# [ 1] x@0
# 0000 putobject 5 ( 1)[Li]
# 0002 splatarray true
# 0004 dup
# 0005 setlocal_WC_0 x@0
# 0007 leave
swap
Summary
swap swaps the top two elements in the stack.
TracePoint
swap does not dispatch any events.
Usage
!!defined?([[]])
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,16)> (catch: TRUE)
# == catch table
# | catch type: rescue st: 0001 ed: 0003 sp: 0000 cont: 0005
# | == disasm: #<ISeq:defined guard in <compiled>@<compiled>:0 (0,0)-(-1,-1)> (catch: FALSE)
# | local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
# | [ 1] $!@0
# | 0000 putnil
# | 0001 leave
# |------------------------------------------------------------------------
# 0000 putnil ( 1)[Li]
# 0001 putobject "expression"
# 0003 swap
# 0004 pop
# 0005 opt_not <calldata!mid:!, argc:0, ARGS_SIMPLE>[CcCr]
# 0007 opt_not <calldata!mid:!, argc:0, ARGS_SIMPLE>[CcCr]
# 0009 leave
topn
Summary
topn has one argument: n. It gets the nth element from the top of the
stack and pushes it on the stack.
TracePoint
topn does not dispatch any events.
Usage
case 3
when 1..5
puts "foo"
end
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,36)> (catch: FALSE)
# 0000 putobject 3 ( 1)[Li]
# 0002 putobject 1..5
# 0004 topn 1
# 0006 opt_send_without_block <calldata!mid:===, argc:1, FCALL|ARGS_SIMPLE>
# 0008 branchif 13
# 0010 pop
# 0011 putnil
# 0012 leave
# 0013 pop
# 0014 putself
# 0015 putstring "foo"
# 0017 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0019 leave
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(4,3)> (catch: FALSE)
# 0000 putobject 3 ( 1)[Li]
# 0002 putobject 1..5 ( 2)
# 0004 topn 1
# 0006 opt_send_without_block <calldata!mid:===, argc:1, FCALL|ARGS_SIMPLE>
# 0008 branchif 13
# 0010 pop ( 1)
# 0011 putnil
# 0012 leave ( 3)
# 0013 pop ( 2)
# 0014 putself ( 3)[Li]
# 0015 putstring "foo"
# 0017 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
# 0019 leave
toregexp
Summary
toregexp is generated when string interpolation is used inside a regex
literal //. It pops a defined number of values from the stack, combines
them into a single string and coerces that string into a Regexp object,
which it pushes back onto the stack
TracePoint
toregexp cannot dispatch any TracePoint events.
Usage
"/#{true}/"
# == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,9)> (catch: FALSE)
# 0000 putobject "" ( 1)[Li]
# 0002 putobject true
# 0004 dup
# 0005 objtostring <calldata!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>
# 0007 anytostring
# 0008 toregexp 0, 2
# 0011 leave
# == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,11)> (catch: FALSE)
# 0000 putobject "/" ( 1)[Li]
# 0002 putobject true
# 0004 dup
# 0005 objtostring <calldata!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>
# 0007 anytostring
# 0008 putobject "/"
# 0010 concatstrings 3
# 0012 leave