diff --git a/basis/compiler/tests/codegen.factor b/basis/compiler/tests/codegen.factor index 288940e660..2edb016734 100644 --- a/basis/compiler/tests/codegen.factor +++ b/basis/compiler/tests/codegen.factor @@ -462,3 +462,13 @@ TUPLE: myseq { underlying1 byte-array read-only } { underlying2 byte-array read- 1 1 [ [ HEX: f bitand ] bi@ [ shift ] [ drop -3 shift ] 2bi ] compile-call ] unit-test + +! GC root offsets were computed wrong on x86 +: gc-root-messup ( a -- b ) + dup [ + 1024 (byte-array) 2array + 10 void* "libc" "malloc" { ulong } alien-invoke + void "libc" "free" { void* } alien-invoke + ] when ; + +[ ] [ 2000 [ "hello" clone dup gc-root-messup first eq? t assert= ] times ] unit-test diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index 6019a5af8b..d4a3be49b6 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -45,7 +45,7 @@ HOOK: extra-stack-space cpu ( stack-frame -- n ) : param@ ( n -- op ) reserved-stack-space + stack@ ; : gc-root-offsets ( seq -- seq' ) - [ n>> special-offset ] map f like ; + [ n>> spill-offset special-offset ] map f like ; : decr-stack-reg ( n -- ) dup 0 = [ drop ] [ stack-reg swap SUB ] if ;