[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Clearing stale references from the stack
From: |
Andy Wingo |
Subject: |
Re: Clearing stale references from the stack |
Date: |
Tue, 31 Jan 2012 21:46:02 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
Hello :-)
On Tue 31 Jan 2012 19:02, address@hidden (Ludovic Courtès) writes:
> "Andy Wingo" <address@hidden> skribis:
>
>> +;; Recurse through a C function that should clear any values that might
>> +;; have spilled on the stack temporarily. (The salient feature of
>> +;; with-continuation-barrier is that currently it is implemented as a C
>> +;; function that recursively calls the VM.)
>> +;;
>> +(define* (clear-stale-stack-references #:optional (n 10))
>> + (if (positive? n)
>> + (with-continuation-barrier
>> + (lambda ()
>> + (clear-stale-stack-references (1- n))))))
>> +
>> ;;; Call THUNK with a given locale
>> (define (with-locale* nloc thunk)
>> (let ((loc #f))
>> diff --git a/test-suite/tests/gc.test b/test-suite/tests/gc.test
>> index 97eeb19..1afcea3 100644
>> --- a/test-suite/tests/gc.test
>> +++ b/test-suite/tests/gc.test
>> @@ -49,13 +49,6 @@
>> ;;;
>> ;;;
>>
>> -(define (stack-cleanup depth)
>> - ;; Clean up stack space for DEPTH words. This is defined here so that
>> - ;; `peval' doesn't inline it.
>> - (let cleanup ((i depth))
>> - (and (> i 0)
>> - (begin (cleanup (1- i)) i))))
>> -
>
> Note that ‘1-’ here is a subr call (because ‘stack-cleanup’ is
> interpreted), so both procedures may have a similar effect, no?
I don't think so. The question for me is, how far up the C stack does
this get? For `stack-cleanup' (I have to learn how to type those nice
quotes some day), there will never be more than one `1-' frame active on
the C stack. With clear-stale-stack-references, there will be `depth'
many.
I think!
Andy
--
http://wingolog.org/