diff options
| author | Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com> | 2021-03-30 17:05:20 -0400 |
|---|---|---|
| committer | Alan Wu <XrXr@users.noreply.github.com> | 2021-10-20 18:19:32 -0400 |
| commit | 5ec94e0d4ad49cd249312c29cbbe9369637b9b48 (patch) | |
| tree | c908df030df268fb2a6fe7bdd956b5c51288be33 | |
| parent | fe784d1449ac6a9c2280ce1b29b19fa86d108fe9 (diff) | |
Fix issue with version matching logic
| -rw-r--r-- | yjit_core.c | 44 |
1 files 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 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( 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( } 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; |
