Class: Heapviz::Slot
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#page_body_address ⇒ Object
readonly
Returns the value of attribute page_body_address.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #<=>(o) ⇒ Object
- #gc_root? ⇒ Boolean
- #has_flags? ⇒ Boolean
-
#initialize(json) ⇒ Slot
constructor
A new instance of Slot.
- #pinned? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(json) ⇒ Slot
Returns a new instance of Slot.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/heapviz/slot.rb', line 10 def initialize(json) attrs = JSON.parse(json) @type = attrs.fetch("type") if !gc_root? @address = attrs.fetch("address").to_i(16) @size = attrs.fetch("slot_size") end @flags = attrs.fetch("flags", {}) @page_body_address = @address & ~Heap::HEAP_PAGE_ALIGN_MASK end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
8 9 10 |
# File 'lib/heapviz/slot.rb', line 8 def address @address end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
8 9 10 |
# File 'lib/heapviz/slot.rb', line 8 def flags @flags end |
#page_body_address ⇒ Object (readonly)
Returns the value of attribute page_body_address.
8 9 10 |
# File 'lib/heapviz/slot.rb', line 8 def page_body_address @page_body_address end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
8 9 10 |
# File 'lib/heapviz/slot.rb', line 8 def size @size end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/heapviz/slot.rb', line 8 def type @type end |
Instance Method Details
#<=>(o) ⇒ Object
35 36 37 |
# File 'lib/heapviz/slot.rb', line 35 def <=>(o) address <=> o.address end |
#gc_root? ⇒ Boolean
23 24 25 |
# File 'lib/heapviz/slot.rb', line 23 def gc_root? @type == "ROOT" end |
#has_flags? ⇒ Boolean
31 32 33 |
# File 'lib/heapviz/slot.rb', line 31 def has_flags? !gc_root? end |
#pinned? ⇒ Boolean
27 28 29 |
# File 'lib/heapviz/slot.rb', line 27 def pinned? @flags.fetch('pinned', false) end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/heapviz/slot.rb', line 39 def to_s "{address: 0x#{address.to_s(16)}, type: #{type}, flags: #{flags}}" end |