Class: RubyVM::YJIT::Block
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | yjit_iface.c |
Overview
Block (block version, code block)
Instance Method Summary
-
#address
Get the address of the code associated with a
Block -
#code
Get the machine code for
Blockas a binary string. -
#id ⇒ unique_id
Returns a unique integer ID for the block.
-
#iseq_end_index
Get the end index in the Instruction Sequence that corresponds to this
Block -
#iseq_start_index
Get the start index in the Instruction Sequence that corresponds to this
Block -
#outgoing_ids ⇒ list
Returns a list of outgoing ids for the current block.
Instance Method Details
#address
Get the address of the code associated with a Block
# File 'yjit_iface.c', line 533
static VALUE
block_address(VALUE self)
{
block_t * block;
TypedData_Get_Struct(self, block_t, &yjit_block_type, block);
return LONG2NUM((intptr_t)block->start_addr);
}
#code
Get the machine code for Block as a binary string
# File 'yjit_iface.c', line 542
static VALUE
block_code(VALUE self)
{
block_t * block;
TypedData_Get_Struct(self, block_t, &yjit_block_type, block);
return (VALUE)rb_str_new(
(const char*)block->start_addr,
block->end_addr - block->start_addr
);
}
#id ⇒ unique_id
Returns a unique integer ID for the block. For example:
blocks = blocks_for(iseq)
blocks.group_by(&:id)
# File 'yjit_iface.c', line 1193
static VALUE
block_id(VALUE self)
{
block_t * block;
TypedData_Get_Struct(self, block_t, &yjit_block_type, block);
return PTR2NUM(block);
}
#iseq_end_index
Get the end index in the Instruction Sequence that corresponds to this Block
# File 'yjit_iface.c', line 567
static VALUE
iseq_end_index(VALUE self)
{
block_t * block;
TypedData_Get_Struct(self, block_t, &yjit_block_type, block);
return INT2NUM(block->end_idx);
}
#iseq_start_index
Get the start index in the Instruction Sequence that corresponds to this Block
# File 'yjit_iface.c', line 556
static VALUE
iseq_start_index(VALUE self)
{
block_t * block;
TypedData_Get_Struct(self, block_t, &yjit_block_type, block);
return INT2NUM(block->blockid.idx);
}
#outgoing_ids ⇒ list
Returns a list of outgoing ids for the current block. This list can be used in conjunction with #id to construct a graph of block objects.
# File 'yjit_iface.c', line 1207
static VALUE
outgoing_ids(VALUE self)
{
block_t * block;
TypedData_Get_Struct(self, block_t, &yjit_block_type, block);
VALUE ids = rb_ary_new();
rb_darray_for(block->outgoing, branch_idx) {
branch_t *out_branch = rb_darray_get(block->outgoing, branch_idx);
for (size_t succ_idx = 0; succ_idx < 2; succ_idx++) {
block_t *succ = out_branch->blocks[succ_idx];
if (succ == NULL)
continue;
rb_ary_push(ids, PTR2NUM(succ));
}
}
return ids;
}