1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix compiled iseq count stat

This commit is contained in:
Maxime Chevalier-Boisvert 2021-02-16 11:15:29 -05:00 committed by Alan Wu
parent c02517bacb
commit 48736599ac
3 changed files with 9 additions and 4 deletions

View file

@ -164,13 +164,16 @@ add_block_version(blockid_t blockid, block_t* block)
const rb_iseq_t *iseq = block->blockid.iseq;
struct rb_iseq_constant_body *body = iseq->body;
// Ensure ujit_blocks is initialized
// Ensure ujit_blocks is initialized for this iseq
if (rb_darray_size(body->ujit_blocks) == 0) {
// Initialize ujit_blocks to be as wide as body->iseq_encoded
// TODO: add resize API for dary
while ((unsigned)rb_darray_size(body->ujit_blocks) < body->iseq_size) {
(void)rb_darray_append(&body->ujit_blocks, NULL);
}
// First block compiled for this iseq
rb_compiled_iseq_count++;
}
block_t *first_version = get_first_version(iseq, blockid.idx);

View file

@ -29,10 +29,12 @@ bool rb_ujit_enabled;
static int64_t vm_insns_count = 0;
int64_t rb_ujit_exec_insns_count = 0;
static int64_t exit_op_count[VM_INSTRUCTION_SIZE] = { 0 };
static int64_t compiled_iseq_count = 0;
int64_t rb_compiled_iseq_count = 0;
// Machine code blocks (executable memory)
extern codeblock_t *cb;
extern codeblock_t *ocb;
// Hash table of encoded instructions
extern st_table *rb_encoded_insn_data;
@ -312,7 +314,6 @@ rb_ujit_compile_iseq(const rb_iseq_t *iseq)
int first_opcode = opcode_at_pc(iseq, &encoded[0]);
map_addr2insn(code_ptr, first_opcode);
encoded[0] = (VALUE)code_ptr;
compiled_iseq_count++;
}
RB_VM_LOCK_LEAVE();
@ -540,7 +541,7 @@ print_ujit_stats(void)
double total_insns_count = vm_insns_count + rb_ujit_exec_insns_count;
double ratio = rb_ujit_exec_insns_count / total_insns_count;
fprintf(stderr, "compiled_iseq_count: %10" PRId64 "\n", compiled_iseq_count);
fprintf(stderr, "compiled_iseq_count: %10" PRId64 "\n", rb_compiled_iseq_count);
fprintf(stderr, "main_block_code_size: %6.1f MiB\n", ((double)cb->write_pos) / 1048576.0);
fprintf(stderr, "side_block_code_size: %6.1f MiB\n", ((double)ocb->write_pos) / 1048576.0);
fprintf(stderr, "vm_insns_count: %10" PRId64 "\n", vm_insns_count);

View file

@ -22,6 +22,7 @@ struct rb_callcache;
RUBY_EXTERN struct rb_ujit_options rb_ujit_opts;
RUBY_EXTERN int64_t rb_ujit_exec_insns_count;
RUBY_EXTERN int64_t rb_compiled_iseq_count;
void cb_write_pre_call_bytes(codeblock_t* cb);
void cb_write_post_call_bytes(codeblock_t* cb);