Skip to content

Commit 12f7c55

Browse files
authored
Print opcode count and total size in debug output (#929)
Fixes: #777
1 parent 22cd6ab commit 12f7c55

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

quickjs.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -28814,6 +28814,7 @@ static __maybe_unused void js_dump_function_bytecode(JSContext *ctx, JSFunctionB
2881428814
int i;
2881528815
char atom_buf[ATOM_GET_STR_BUF_SIZE];
2881628816
const char *str;
28817+
const uint8_t *op;
2881728818

2881828819
if (b->filename != JS_ATOM_NULL) {
2881928820
str = JS_AtomGetStr(ctx, atom_buf, sizeof(atom_buf), b->filename);
@@ -28860,7 +28861,11 @@ static __maybe_unused void js_dump_function_bytecode(JSContext *ctx, JSFunctionB
2886028861
}
2886128862
}
2886228863
printf(" stack_size: %d\n", b->stack_size);
28863-
printf(" opcodes:\n");
28864+
printf(" byte_code_len: %d\n", b->byte_code_len);
28865+
op = b->byte_code_buf;
28866+
for (i = 0; op < &b->byte_code_buf[b->byte_code_len]; i++)
28867+
op += short_opcode_info(*op).size;
28868+
printf(" opcodes: %d\n", i);
2886428869
dump_byte_code(ctx, 3, b->byte_code_buf, b->byte_code_len,
2886528870
b->vardefs, b->arg_count,
2886628871
b->vardefs ? b->vardefs + b->arg_count : NULL, b->var_count,

0 commit comments

Comments
 (0)