ruby-changes:68631
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:11:10 +0900 (JST)
Subject: [ruby-changes:68631] 2cb376a53f (master): Started refactoring opt_send_without_block with codegen-time checks
https://git.ruby-lang.org/ruby.git/commit/?id=2cb376a53f From 2cb376a53f2f165415f36fba4b2230bcbd1e3848 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Thu, 15 Oct 2020 15:15:31 -0400 Subject: Started refactoring opt_send_without_block with codegen-time checks --- ujit_compile.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/ujit_compile.c b/ujit_compile.c index e4aafde936..820d845fc6 100644 --- a/ujit_compile.c +++ b/ujit_compile.c @@ -463,13 +463,16 @@ gen_opt_minus(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_compile.c#L463 bool gen_opt_send_without_block(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx) { + // Definitions relevant to the call cache are in vm_callinfo.h + struct rb_call_data * cd = (struct rb_call_data *)ctx_get_arg(ctx, 0); int32_t argc = (int32_t)vm_ci_argc(cd->ci); const struct rb_callcache *cc = cd->cc; // Callee method ID ID mid = vm_ci_mid(cd->ci); - //fprintf(stderr, "jitting call to \"%s\", argc: %lu\n", rb_id2name(mid), argc); + + //printf("jitting call to \"%s\", argc: %lu\n", rb_id2name(mid), argc); // Don't JIT calls with keyword splat if (vm_ci_flag(cd->ci) & VM_CALL_KW_SPLAT) @@ -477,12 +480,29 @@ gen_opt_send_without_block(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_compile.c#L480 return false; } - // Don't jit calls that aren't simple + // Don't JIT calls that aren't simple if (!(vm_ci_flag(cd->ci) & VM_CALL_ARGS_SIMPLE)) { return false; } + // Don't JIT if the inline cache is not set + if (cd->cc == vm_cc_empty()) + { + //printf("call cache is empty\n"); + return false; + } + + /* + // Don't JIT if this is not a C call + if (cd->cc->call_ != vm_call_cfunc_with_frame) + { + return false; + } + */ + + + // TODO: stop if the inline cache isn't filled // TODO: stop if this isn't a C call @@ -496,6 +516,8 @@ gen_opt_send_without_block(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_compile.c#L516 + + return false; /* @@ -528,12 +550,13 @@ gen_opt_send_without_block(codeblock_t* cb, codeblock_t* ocb, ctx_t* ctx) https://github.com/ruby/ruby/blob/trunk/ujit_compile.c#L550 mov(cb, recv_opnd, RDX); - //print_int(cb, recv_opnd); // Pointer to the klass field of the receiver x86opnd_t klass_opnd = mem_opnd(64, RDX, offsetof(struct RBasic, klass)); - + // IDEA: Aaron suggested we could possibly treat a changed + // class pointer as a cache miss + // Check if we have a cache hit cmp(cb, R9, klass_opnd); jne_ptr(cb, side_exit); //print_int(cb, klass_opnd); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/