ruby-changes:68863
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:14:58 +0900 (JST)
Subject: [ruby-changes:68863] 5ec94e0d4a (master): Fix issue with version matching logic
https://git.ruby-lang.org/ruby.git/commit/?id=5ec94e0d4a From 5ec94e0d4ad49cd249312c29cbbe9369637b9b48 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Tue, 30 Mar 2021 17:05:20 -0400 Subject: Fix issue with version matching logic --- yjit_core.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/yjit_core.c b/yjit_core.c index 0954d50c57..fbdc5f1c72 100644 --- a/yjit_core.c +++ b/yjit_core.c @@ -390,22 +390,22 @@ branch_stub_hit(uint32_t branch_idx, uint32_t target_idx, rb_execution_context_t https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L390 RUBY_ASSERT(cb->write_pos <= branch->end_pos); } - // Limit the number of block versions - ctx_t generic_ctx = DEFAULT_CTX; - generic_ctx.stack_size = target_ctx->stack_size; - generic_ctx.sp_offset = target_ctx->sp_offset; - if (target_ctx->chain_depth == 0) { // guard chains implement limits individually - if (get_num_versions(target) >= MAX_VERSIONS - 1) { - //fprintf(stderr, "version limit hit in branch_stub_hit\n"); - target_ctx = &generic_ctx; - } - } - - // Try to find a compiled version of this block + // Try to find an existing compiled version of this block block_t* p_block = find_block_version(target, target_ctx); // If this block hasn't yet been compiled if (!p_block) { + // Limit the number of block versions + ctx_t generic_ctx = DEFAULT_CTX; + generic_ctx.stack_size = target_ctx->stack_size; + generic_ctx.sp_offset = target_ctx->sp_offset; + if (target_ctx->chain_depth == 0) { // guard chains implement limits individually + if (get_num_versions(target) >= MAX_VERSIONS - 1) { + //fprintf(stderr, "version limit hit in branch_stub_hit\n"); + target_ctx = &generic_ctx; + } + } + p_block = gen_block_version(target, target_ctx, ec); } @@ -558,16 +558,6 @@ void gen_direct_jump( https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L558 uint32_t start_pos; uint32_t end_pos; - // Limit the number of block versions - ctx_t generic_ctx = DEFAULT_CTX; - generic_ctx.stack_size = ctx->stack_size; - generic_ctx.sp_offset = ctx->sp_offset; - if (get_num_versions(target0) >= MAX_VERSIONS - 1) - { - //fprintf(stderr, "version limit hit in gen_direct_jump\n"); - ctx = &generic_ctx; - } - block_t* p_block = find_block_version(target0, ctx); // If the version already exists @@ -584,6 +574,16 @@ void gen_direct_jump( https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L574 } else { + // Limit the number of block versions + ctx_t generic_ctx = DEFAULT_CTX; + generic_ctx.stack_size = ctx->stack_size; + generic_ctx.sp_offset = ctx->sp_offset; + if (get_num_versions(target0) >= MAX_VERSIONS - 1) + { + //fprintf(stderr, "version limit hit in gen_direct_jump\n"); + ctx = &generic_ctx; + } + // The target block will follow next // It will be compiled in gen_block_version() dst_addr0 = NULL; -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/