summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yjit_core.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/yjit_core.c b/yjit_core.c
index eae43c38f7..088b0593d1 100644
--- a/yjit_core.c
+++ b/yjit_core.c
@@ -816,6 +816,19 @@ yjit_free_block(block_t *block)
yjit_unlink_method_lookup_dependency(block);
yjit_block_assumptions_free(block);
+ // Remove this block from the predecessor's targets
+ rb_darray_for(block->incoming, incoming_idx) {
+ // Branch from the predecessor to us
+ branch_t* pred_branch = rb_darray_get(block->incoming, incoming_idx);
+
+ // If this is us, nullify the target block
+ for (size_t succ_idx = 0; succ_idx < 2; succ_idx++) {
+ if (pred_branch->blocks[succ_idx] == block) {
+ pred_branch->blocks[succ_idx] = NULL;
+ }
+ }
+ }
+
// For each outgoing branch
rb_darray_for(block->outgoing, branch_idx) {
branch_t* out_branch = rb_darray_get(block->outgoing, branch_idx);