diff --git a/ujit.rb b/ujit.rb index 06de98e7cf..79eed46ff3 100644 --- a/ujit.rb +++ b/ujit.rb @@ -16,7 +16,7 @@ module UJIT # Sort the blocks by increasing addresses 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" cs.disasm(block.code, 0).each do |i| diff --git a/ujit_codegen.c b/ujit_codegen.c index 9ecf636dc3..a38ecf18bb 100644 --- a/ujit_codegen.c +++ b/ujit_codegen.c @@ -179,7 +179,7 @@ ujit_gen_block(ctx_t* ctx, block_t* block) 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)); // Call the code generation function diff --git a/ujit_core.c b/ujit_core.c index 0cb228e1f3..8d6680fc85 100644 --- a/ujit_core.c +++ b/ujit_core.c @@ -218,7 +218,7 @@ block_t* gen_block_version(blockid_t blockid, const ctx_t* start_ctx) ujit_gen_block(ctx, block); // 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 (;;) { @@ -249,7 +249,7 @@ block_t* gen_block_version(blockid_t blockid, const ctx_t* start_ctx) ujit_gen_block(ctx, block); // Keep track of the new block version - add_block_version(blockid, block); + add_block_version(block->blockid, block); // Patch the last branch address last_branch->dst_addrs[0] = cb_get_ptr(cb, block->start_pos); diff --git a/ujit_iface.c b/ujit_iface.c index 7c553f4b3c..3eb134a3bc 100644 --- a/ujit_iface.c +++ b/ujit_iface.c @@ -329,7 +329,7 @@ ujit_install_entry(VALUE mod, VALUE iseq) return iseq; } -/* Get the address of the UJIT::Block */ +/* Get the address of the the code associated with a UJIT::Block */ static VALUE block_address(VALUE self) { @@ -425,21 +425,23 @@ rb_ujit_init(void) ujit_init_core(); ujit_init_codegen(); + // UJIT Ruby module VALUE mUjit = rb_define_module("UJIT"); rb_define_module_function(mUjit, "install_entry", ujit_install_entry, 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); rb_define_method(cUjitBlock, "address", block_address, 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_end_index", iseq_end_index, 0); + // UJIT disassembler interface #if HAVE_LIBCAPSTONE cUjitDisasm = rb_define_class_under(mUjit, "Disasm", rb_cObject); rb_define_alloc_func(cUjitDisasm, ujit_disasm_init); rb_define_method(cUjitDisasm, "disasm", ujit_disasm, 2); - cUjitDisasmInsn = rb_struct_define_under(cUjitDisasm, "Insn", "address", "mnemonic", "op_str", NULL); #endif