mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
YJIT: Fix leak in compilation loop
Previously, when there are too many blocks in a batch, the last block in the batch is not tracked in the array of batches and not freed.
This commit is contained in:
parent
c47e821b89
commit
82bb9cedd3
Notes:
git
2021-12-09 07:00:17 +09:00
2 changed files with 20 additions and 5 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
assert_normal_exit %q{
|
||||||
|
# regression test for a leak caught by an asert on --yjit-call-threshold=2
|
||||||
|
Foo = 1
|
||||||
|
|
||||||
|
eval("def foo = [#{(['Foo,']*256).join}]")
|
||||||
|
|
||||||
|
foo
|
||||||
|
foo
|
||||||
|
|
||||||
|
Object.send(:remove_const, :Foo)
|
||||||
|
}
|
||||||
|
|
||||||
assert_equal '[nil, nil, nil, nil, nil, nil]', %q{
|
assert_equal '[nil, nil, nil, nil, nil, nil]', %q{
|
||||||
[NilClass, TrueClass, FalseClass, Integer, Float, Symbol].each do |klass|
|
[NilClass, TrueClass, FalseClass, Integer, Float, Symbol].each do |klass|
|
||||||
klass.class_eval("def foo = @foo")
|
klass.class_eval("def foo = @foo")
|
||||||
|
|
13
yjit_core.c
13
yjit_core.c
|
@ -747,15 +747,14 @@ gen_block_version(blockid_t blockid, const ctx_t *start_ctx, rb_execution_contex
|
||||||
|
|
||||||
// Generate code for the first block
|
// Generate code for the first block
|
||||||
block = gen_single_block(blockid, start_ctx, ec);
|
block = gen_single_block(blockid, start_ctx, ec);
|
||||||
batch_success = block && compiled_count < MAX_PER_BATCH;
|
if (block) {
|
||||||
|
|
||||||
if (batch_success) {
|
|
||||||
// Track the block
|
// Track the block
|
||||||
add_block_version(block);
|
add_block_version(block);
|
||||||
|
|
||||||
batch[compiled_count] = block;
|
batch[compiled_count] = block;
|
||||||
compiled_count++;
|
compiled_count++;
|
||||||
}
|
}
|
||||||
|
batch_success = block;
|
||||||
|
|
||||||
// For each successor block to compile
|
// For each successor block to compile
|
||||||
while (batch_success) {
|
while (batch_success) {
|
||||||
|
@ -780,8 +779,12 @@ gen_block_version(blockid_t blockid, const ctx_t *start_ctx, rb_execution_contex
|
||||||
// Generate code for the current block using context from the last branch.
|
// Generate code for the current block using context from the last branch.
|
||||||
blockid_t requested_id = last_branch->targets[0];
|
blockid_t requested_id = last_branch->targets[0];
|
||||||
const ctx_t *requested_ctx = &last_branch->target_ctxs[0];
|
const ctx_t *requested_ctx = &last_branch->target_ctxs[0];
|
||||||
block = gen_single_block(requested_id, requested_ctx, ec);
|
|
||||||
batch_success = block && compiled_count < MAX_PER_BATCH;
|
batch_success = compiled_count < MAX_PER_BATCH;
|
||||||
|
if (batch_success) {
|
||||||
|
block = gen_single_block(requested_id, requested_ctx, ec);
|
||||||
|
batch_success = block;
|
||||||
|
}
|
||||||
|
|
||||||
// If the batch failed, stop
|
// If the batch failed, stop
|
||||||
if (!batch_success) {
|
if (!batch_success) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue