diff options
author | Alan Wu <[email protected]> | 2021-04-07 15:27:05 -0400 |
---|---|---|
committer | Alan Wu <[email protected]> | 2021-10-20 18:19:33 -0400 |
commit | 515fb988fe3c3ad28fdcaea4f043ea6a445c5213 (patch) | |
tree | 85168fefe3b4222796a3f21c8dc456dcbc8dddfc /yjit_codegen.c | |
parent | 543bdde6c21f071e673aa8090086e1045ee4f2d9 (diff) |
YJIT: add comments to disassembly
Introduce a new macro `ADD_COMMENT(cb, comment)` that records a comment
for the current write position in the code block.
Co-authored-by: Maxime Chevalier-Boisvert <[email protected]>
Co-authored-by: Aaron Patterson <[email protected]>
Diffstat (limited to 'yjit_codegen.c')
-rw-r--r-- | yjit_codegen.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/yjit_codegen.c b/yjit_codegen.c index fd029b3287..7ff59b94a1 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -216,9 +216,16 @@ _counted_side_exit(uint8_t *existing_side_exit, int64_t *counter) return start; } +// Comments for generated machine code +#define ADD_COMMENT(cb, comment) rb_darray_append(&yjit_code_comments, ((struct yjit_comment){(cb)->write_pos, (comment)})) +yjit_comment_array_t yjit_code_comments; + #else + #define GEN_COUNTER_INC(cb, counter_name) ((void)0) #define COUNTED_EXIT(side_exit, counter_name) side_exit +#define ADD_COMMENT(cb, comment) ((void)0) + #endif // if RUBY_DEBUG /* @@ -323,6 +330,9 @@ yjit_gen_block(ctx_t* ctx, block_t* block, rb_execution_context_t* ec) // Note that the increment happens even when the output takes side exit. GEN_COUNTER_INC(cb, exec_instruction); + // Add a comment for the name of the YARV instruction + ADD_COMMENT(cb, insn_name(opcode)); + // Call the code generation function bool continue_generating = p_desc->gen_fn(&jit, ctx); @@ -751,6 +761,7 @@ gen_getinstancevariable(jitstate_t* jit, ctx_t* ctx) // Guard that self is embedded // TODO: BT and JC is shorter + ADD_COMMENT(cb, "guard embedded getivar"); x86opnd_t flags_opnd = member_opnd(REG0, struct RBasic, flags); test(cb, flags_opnd, imm_opnd(ROBJECT_EMBED)); jit_chain_guard(JCC_JZ, jit, ctx, GETIVAR_MAX_DEPTH, side_exit); @@ -772,6 +783,7 @@ gen_getinstancevariable(jitstate_t* jit, ctx_t* ctx) // Guard that self is *not* embedded // See ROBJECT_IVPTR() from include/ruby/internal/core/robject.h + ADD_COMMENT(cb, "guard extended getivar"); x86opnd_t flags_opnd = member_opnd(REG0, struct RBasic, flags); test(cb, flags_opnd, imm_opnd(ROBJECT_EMBED)); jit_chain_guard(JCC_JNZ, jit, ctx, GETIVAR_MAX_DEPTH, side_exit); |