Class: Optimize::IR::Instruction
- Inherits:
-
Struct
- Object
- Struct
- Optimize::IR::Instruction
- Defined in:
- lib/optimize/ir/instruction.rb
Overview
One YARV instruction after decoding. Operands are Ruby values, not object-table indices — the codec resolves indices on decode and re-interns them on encode.
Fields:
opcode - Symbol, e.g. :putobject, :leave
operands - Array of decoded operand values. For TS_VALUE/TS_ID operands,
these are object-table indices (not resolved Ruby objects) to
enable byte-identical round-trip. For TS_ISEQ, the iseq-list
index. For TS_CALLDATA, no entry is stored. For TS_OFFSET,
the raw slot-count offset. For TS_LINDEX/TS_NUM/TS_ISE/etc.,
the raw index/count.
line - Integer source line number (from insns_info; nil if absent)
Instance Attribute Summary collapse
-
#line ⇒ Object
Returns the value of attribute line.
-
#opcode ⇒ Object
Returns the value of attribute opcode.
-
#operands ⇒ Object
Returns the value of attribute operands.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
-
#hash ⇒ Object
Use object identity for Hash keys and Set membership.
- #to_s ⇒ Object
Instance Attribute Details
#line ⇒ Object
Returns the value of attribute line
18 19 20 |
# File 'lib/optimize/ir/instruction.rb', line 18 def line @line end |
#opcode ⇒ Object
Returns the value of attribute opcode
18 19 20 |
# File 'lib/optimize/ir/instruction.rb', line 18 def opcode @opcode end |
#operands ⇒ Object
Returns the value of attribute operands
18 19 20 |
# File 'lib/optimize/ir/instruction.rb', line 18 def operands @operands end |
Instance Method Details
#eql?(other) ⇒ Boolean
32 33 34 |
# File 'lib/optimize/ir/instruction.rb', line 32 def eql?(other) equal?(other) end |
#hash ⇒ Object
Use object identity for Hash keys and Set membership. IR instructions must be compared by identity (not by value) because the same logical opcode+operands combination can appear at multiple positions in a single iseq. Value-based equality would cause Hash collisions and incorrect slot lookups in inst_to_slot_map / catch_table / line_info.
28 29 30 |
# File 'lib/optimize/ir/instruction.rb', line 28 def hash object_id.hash end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/optimize/ir/instruction.rb', line 19 def to_s "#{opcode} #{operands.inspect}" end |