8000 Fix assertions in `invalidate_block_version()`, add small repro (#14) · ruby/ruby@bce6dea · GitHub
[go: up one dir, main page]

Skip to content

Commit bce6dea

Browse files
maximecbXrXr
authored andcommitted
Fix assertions in invalidate_block_version(), add small repro (#14)
* Fix block invalidation assertions * Add Alan's small repro for double invalidation bug
1 parent cfaf601 commit bce6dea

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

bootstraptest/test_yjit.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,28 @@ def alias_then_hash(klass, method_to_redefine)
172172
retval
173173
}
174174

175+
# Code invalidation and opt_getinlinecache
176+
assert_normal_exit %q{
177+
class Foo; end
178+
179+
# Uses the class constant Foo
180+
def use_constant(arg)
181+
[Foo.new, arg]
182+
end
183+
184+
def propagate_type
185+
i = Array.new
186+
i.itself # make it remember that i is on-heap
187+
use_constant(i)
188+
end
189+
190+
propagate_type
191+
propagate_type
192+
use_constant(Foo.new)
193+
class Jo; end # bump global constant state
194+
use_constant(3)
195+
}
196+
175197
# Method redefinition (code invalidation) and GC
176198
assert_equal '7', %q{
177199
def bar()

yjit_core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,11 @@ invalidate_block_version(block_t* block)
888888
{
889889
branch_t* branch = rb_darray_get(block->incoming, incoming_idx);
890890
uint32_t target_idx = (branch->dst_addrs[0] == code_ptr)? 0:1;
891-
RUBY_ASSERT(!branch->blocks[target_idx] || branch->blocks[target_idx] == block);
891+
RUBY_ASSERT(branch->dst_addrs[target_idx] == code_ptr);
892+
RUBY_ASSERT(branch->blocks[target_idx] == block);
893+
894+
// Mark this target as being a stub
895+
branch->blocks[target_idx] = NULL;
892896

893897
// Create a stub for this branch target
894898
branch->dst_addrs[target_idx] = get_branch_target(
@@ -898,9 +902,6 @@ invalidate_block_version(block_t* block)
898902
target_idx
899903
);
900904

901-
// Mark this target as being a stub
902-
branch->blocks[target_idx] = NULL;
903-
904905
// Check if the invalidated block immediately follows
905906
bool target_next = block->start_pos == branch->end_pos;
906907

0 commit comments

Comments
 (0)
0