summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2021-02-05 15:49:02 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:28 -0400
commit21c4dd037d3f9c20dda281883b8d43fc2226d550 (patch)
tree5b84fbf3315f6eac671593e8699a822fa569828b
parentd2ad0a1175a83392710a4248dc541492ba151e61 (diff)
Fix bug unnecessarily causing version limit hit
-rw-r--r--ujit_core.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ujit_core.c b/ujit_core.c
index 6daab05a46..d7b0d65e69 100644
--- a/ujit_core.c
+++ b/ujit_core.c
@@ -148,6 +148,9 @@ int ctx_diff(const ctx_t* src, const ctx_t* dst)
// Add a block version to the map
static void add_block_version(blockid_t blockid, block_t* block)
{
+ // Function entry blocks must have stack size 0
+ RUBY_ASSERT(!(block->blockid.idx == 0 && block->ctx.stack_size > 0));
+
// If there exists a version for this block id
block_t* first_version = NULL;
st_lookup(version_tbl, (st_data_t)&blockid, (st_data_t*)&first_version);
@@ -266,6 +269,9 @@ block_t* gen_block_version(blockid_t blockid, const ctx_t* start_ctx)
rb_bug("invalid target for last branch");
}
+ // Use the context from the branch
+ *ctx = last_branch->target_ctxs[0];
+
// Allocate a new block version object
block = calloc(1, sizeof(block_t));
block->blockid = last_branch->targets[0];