[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-hackers] Only specialize string-length if type is definitel
From: |
Felix |
Subject: |
Re: [Chicken-hackers] Only specialize string-length if type is definitely known |
Date: |
Mon, 28 May 2012 14:45:17 +0200 (CEST) |
From: Christian Kellermann <address@hidden>
Subject: [Chicken-hackers] Only specialize string-length if type is definitely
known
Date: Sun, 27 May 2012 20:29:47 +0200
> Hi Hackers,
>
> as Mario pointed out the previously commited fix for #855 was only the
> sympthom not the cause of the troubles. The real cause has been the
> unconditionally specialization of string-length to ##sys#size which
> will segfault if given immediate types (since it is only a wrapper for
> C_block_size).
>
> So the attached patch removes #:enforce from its types.db entry.
>
> You can test it for yourself with the following example code:
>
> (define (t l)
> (let ((s1 (car l)))
> (zero? (string-length s1))))
>
> (t '(1))
>
> I am not fully sure whether I have understood the purpose of #:enforce
> correctly. As I understood it signals the compiler to carry on even if
> it does not know for sure which type it is, as the specialization code
> will handle type errors by itself. Is that correct? Who can enlighten
> me?
>
Enforce merely specifies that the argument is of the declared type
_in_case_the_procedure_call_returns_without_error_. Apparantly here is
a bug in the flow-analysis that causes the enforcement property of
"string-length" to be applied to early: it assumes "s1" is a string
because it is passed to "string-length", but it does so too early.
Removing the "#:enforce" declaration is not a solution to this. Please
hold, this needs scrutinizer hacking and needs to be addressed
cheers,
felix