mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix bug, block added with wrong blockid.
This commit is contained in:
parent
b0b1bc1684
commit
63e85de33a
4 changed files with 8 additions and 6 deletions
2
ujit.rb
2
ujit.rb
|
@ -16,7 +16,7 @@ module UJIT
|
||||||
|
|
||||||
# Sort the blocks by increasing addresses
|
# Sort the blocks by increasing addresses
|
||||||
blocks.sort_by(&:address).each_with_index do |block, i|
|
blocks.sort_by(&:address).each_with_index do |block, i|
|
||||||
str << "== BLOCK #{i+1}/#{blocks.length} ISEQ RANGE: [#{block.iseq_start_index},#{block.iseq_end_index}[ ".ljust(80, "=")
|
str << "== BLOCK #{i+1}/#{blocks.length}: #{block.code.length} BYTES, ISEQ RANGE [#{block.iseq_start_index},#{block.iseq_end_index}[ ".ljust(80, "=")
|
||||||
str << "\n"
|
str << "\n"
|
||||||
|
|
||||||
cs.disasm(block.code, 0).each do |i|
|
cs.disasm(block.code, 0).each do |i|
|
||||||
|
|
|
@ -179,7 +179,7 @@ ujit_gen_block(ctx_t* ctx, block_t* block)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr, "compiling %s\n", insn_name(opcode));
|
//fprintf(stderr, "compiling %d: %s\n", insn_idx, insn_name(opcode));
|
||||||
//print_str(cb, insn_name(opcode));
|
//print_str(cb, insn_name(opcode));
|
||||||
|
|
||||||
// Call the code generation function
|
// Call the code generation function
|
||||||
|
|
|
@ -218,7 +218,7 @@ block_t* gen_block_version(blockid_t blockid, const ctx_t* start_ctx)
|
||||||
ujit_gen_block(ctx, block);
|
ujit_gen_block(ctx, block);
|
||||||
|
|
||||||
// Keep track of the new block version
|
// Keep track of the new block version
|
||||||
add_block_version(blockid, block);
|
add_block_version(block->blockid, block);
|
||||||
|
|
||||||
// For each successor block to compile
|
// For each successor block to compile
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -249,7 +249,7 @@ block_t* gen_block_version(blockid_t blockid, const ctx_t* start_ctx)
|
||||||
ujit_gen_block(ctx, block);
|
ujit_gen_block(ctx, block);
|
||||||
|
|
||||||
// Keep track of the new block version
|
// Keep track of the new block version
|
||||||
add_block_version(blockid, block);
|
add_block_version(block->blockid, block);
|
||||||
|
|
||||||
// Patch the last branch address
|
// Patch the last branch address
|
||||||
last_branch->dst_addrs[0] = cb_get_ptr(cb, block->start_pos);
|
last_branch->dst_addrs[0] = cb_get_ptr(cb, block->start_pos);
|
||||||
|
|
|
@ -329,7 +329,7 @@ ujit_install_entry(VALUE mod, VALUE iseq)
|
||||||
return iseq;
|
return iseq;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the address of the UJIT::Block */
|
/* Get the address of the the code associated with a UJIT::Block */
|
||||||
static VALUE
|
static VALUE
|
||||||
block_address(VALUE self)
|
block_address(VALUE self)
|
||||||
{
|
{
|
||||||
|
@ -425,21 +425,23 @@ rb_ujit_init(void)
|
||||||
ujit_init_core();
|
ujit_init_core();
|
||||||
ujit_init_codegen();
|
ujit_init_codegen();
|
||||||
|
|
||||||
|
// UJIT Ruby module
|
||||||
VALUE mUjit = rb_define_module("UJIT");
|
VALUE mUjit = rb_define_module("UJIT");
|
||||||
rb_define_module_function(mUjit, "install_entry", ujit_install_entry, 1);
|
rb_define_module_function(mUjit, "install_entry", ujit_install_entry, 1);
|
||||||
rb_define_module_function(mUjit, "blocks_for", ujit_blocks_for, 1);
|
rb_define_module_function(mUjit, "blocks_for", ujit_blocks_for, 1);
|
||||||
|
|
||||||
|
// UJIT::Block (block version, code block)
|
||||||
cUjitBlock = rb_define_class_under(mUjit, "Block", rb_cObject);
|
cUjitBlock = rb_define_class_under(mUjit, "Block", rb_cObject);
|
||||||
rb_define_method(cUjitBlock, "address", block_address, 0);
|
rb_define_method(cUjitBlock, "address", block_address, 0);
|
||||||
rb_define_method(cUjitBlock, "code", block_code, 0);
|
rb_define_method(cUjitBlock, "code", block_code, 0);
|
||||||
rb_define_method(cUjitBlock, "iseq_start_index", iseq_start_index, 0);
|
rb_define_method(cUjitBlock, "iseq_start_index", iseq_start_index, 0);
|
||||||
rb_define_method(cUjitBlock, "iseq_end_index", iseq_end_index, 0);
|
rb_define_method(cUjitBlock, "iseq_end_index", iseq_end_index, 0);
|
||||||
|
|
||||||
|
// UJIT disassembler interface
|
||||||
#if HAVE_LIBCAPSTONE
|
#if HAVE_LIBCAPSTONE
|
||||||
cUjitDisasm = rb_define_class_under(mUjit, "Disasm", rb_cObject);
|
cUjitDisasm = rb_define_class_under(mUjit, "Disasm", rb_cObject);
|
||||||
rb_define_alloc_func(cUjitDisasm, ujit_disasm_init);
|
rb_define_alloc_func(cUjitDisasm, ujit_disasm_init);
|
||||||
rb_define_method(cUjitDisasm, "disasm", ujit_disasm, 2);
|
rb_define_method(cUjitDisasm, "disasm", ujit_disasm, 2);
|
||||||
|
|
||||||
cUjitDisasmInsn = rb_struct_define_under(cUjitDisasm, "Insn", "address", "mnemonic", "op_str", NULL);
|
cUjitDisasmInsn = rb_struct_define_under(cUjitDisasm, "Insn", "address", "mnemonic", "op_str", NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue