cpu.x86: fix crashes when using certain features (threads, errors, etc) with profiling enabled on x86-64. The profiling stub was clobbering an argument for the unwind_native_frames() entry point

db4
Slava Pestov 2010-02-05 14:29:45 +13:00
parent 5fb4c30eb3
commit aa3d65272a
2 changed files with 12 additions and 7 deletions

View File

@ -56,15 +56,15 @@ big-endian off
[
! Load word
temp0 0 MOV rc-absolute-cell rt-literal jit-rel
safe-reg 0 MOV rc-absolute-cell rt-literal jit-rel
! Bump profiling counter
temp0 profile-count-offset [+] 1 tag-fixnum ADD
safe-reg profile-count-offset [+] 1 tag-fixnum ADD
! Load word->code
temp0 temp0 word-code-offset [+] MOV
safe-reg safe-reg word-code-offset [+] MOV
! Compute word entry point
temp0 compiled-header-size ADD
safe-reg compiled-header-size ADD
! Jump to entry point
temp0 JMP
safe-reg JMP
] jit-profiling jit-define
[

View File

@ -1,6 +1,6 @@
USING: accessors tools.profiler tools.test kernel memory math
threads alien alien.c-types tools.profiler.private sequences
compiler.test compiler.units words ;
compiler.test compiler.units words arrays ;
IN: tools.profiler.tests
[ t ] [
@ -9,7 +9,7 @@ IN: tools.profiler.tests
\ length counter>> =
] unit-test
[ ] [ [ 10 [ gc ] times ] profile ] unit-test
[ ] [ [ 3 [ gc ] times ] profile ] unit-test
[ ] [ [ 1000000 sleep ] profile ] unit-test
@ -72,3 +72,8 @@ IN: tools.profiler.tests
] profile
counter>>
] unit-test
! unwind_native_frames() would fail if profiling was enabled
! because the jit-profiling stub would clobber a parameter register
! on x86-64
[ [ -10 f <array> ] profile ] must-fail