From dd2a4c2c7783cb08605c117436f5ec5b6236eb18 Mon Sep 17 00:00:00 2001 From: Slava Pestov <slava@slava-pestovs-macbook-pro.local> Date: Tue, 4 May 2010 02:50:25 -0400 Subject: [PATCH] cpu.x86: GC root offsets were computed wrong in words containing alien calls --- basis/compiler/tests/codegen.factor | 10 ++++++++++ basis/cpu/x86/x86.factor | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) 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 ;