VM: make visit_instruction_operands() skip over uninitialized blocks
It will crash otherwise when compacting the code heap.char-rename
parent
9e4a520862
commit
9eab4b5652
|
@ -0,0 +1,40 @@
|
||||||
|
USING: accessors combinators.short-circuit compiler.units kernel
|
||||||
|
locals math random sequences tools.memory tools.test vocabs words ;
|
||||||
|
IN: compiler.tests.code-heap
|
||||||
|
|
||||||
|
! This is a test for filling up the code heap.
|
||||||
|
!
|
||||||
|
! We take 100 random words and continuously run modify-code-heap with
|
||||||
|
! them until the code heap fills up, prompting a compaction of it from
|
||||||
|
! allot_code_block() in code_blocks.cpp. Then compaction must work
|
||||||
|
! despite there being a number of uninitialized code blocks in the
|
||||||
|
! heap. See #1715.
|
||||||
|
: special-word? ( word -- ? )
|
||||||
|
{
|
||||||
|
[ "macro" word-prop ]
|
||||||
|
[ "no-compile" word-prop ]
|
||||||
|
[ "special" word-prop ]
|
||||||
|
[ "custom-inlining" word-prop ]
|
||||||
|
} 1|| ;
|
||||||
|
|
||||||
|
: normal-words ( -- words )
|
||||||
|
all-words [ special-word? ] reject ;
|
||||||
|
|
||||||
|
: random-compilation-data ( -- compiled-data )
|
||||||
|
[
|
||||||
|
normal-words 50 sample recompile
|
||||||
|
] with-compilation-unit ;
|
||||||
|
|
||||||
|
: heap-free ( -- n )
|
||||||
|
code-room total-free>> ;
|
||||||
|
|
||||||
|
:: (trash-code-heap) ( data last-free -- )
|
||||||
|
data f f modify-code-heap heap-free :> new-free
|
||||||
|
last-free new-free > [ data new-free (trash-code-heap) ] when ;
|
||||||
|
|
||||||
|
: trash-code-heap ( -- )
|
||||||
|
random-compilation-data heap-free (trash-code-heap) ;
|
||||||
|
|
||||||
|
{ } [
|
||||||
|
trash-code-heap
|
||||||
|
] unit-test
|
|
@ -485,6 +485,8 @@ void slot_visitor<Fixup>::visit_instruction_operands(code_block* block,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (parent->code->uninitialized_p(block))
|
||||||
|
return;
|
||||||
block->each_instruction_operand(visit_func);
|
block->each_instruction_operand(visit_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue