Get the address of the code associated with a YJIT::Block
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); }
Get the machine code for YJIT::Block
as a binary string
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 ); }
Returns a unique integer ID for the block. For example:
blocks = blocks_for(iseq) blocks.group_by(&:id)
static VALUE block_id(VALUE self) { block_t * block; TypedData_Get_Struct(self, block_t, &yjit_block_type, block); return PTR2NUM(block); }
Get the end index in the Instruction Sequence that corresponds to this YJIT::Block
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); }
Get the start index in the Instruction Sequence that corresponds to this YJIT::Block
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); }
Returns a list of outgoing ids for the current block. This list can be used in conjunction with Block#id
to construct a graph of block objects.
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; }