[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] smash types in implicit global type declar

From: Felix
Subject: Re: [Chicken-hackers] [PATCH] smash types in implicit global type declarations
Date: Sat, 23 Jun 2012 14:21:54 +0200 (CEST)

> Thanks, looks good.  Pushed.

Thank you.

> There's one thing I don't completely understand: When I change this test
> so the variable is local (in a LET) instead of global (as a DEFINE), it
> fails when I remove the vector-set! (as the scrutinizer correctly infers
> it's a vector of booleans), but when it's defined global without the
> vector-set! it still succeeds.
> Example:
> (define vec (make-vector 10 #f))
> ;; With this commented out, it still succeeds since the vector is smashed
> ;;(vector-set! vec 0 99)   
> (assert  
>  (compiler-typecase vec  
>     ((vector-of boolean) #f)  
>      (vector #t)))
> ;;;; Versus:
> (let ((vec (make-vector 10 #f)))
>   ;; With this commented out, the test fails: the scrutinizer knows it's
>   ;; not modified so it can keep the (vector-of boolean) type.
>   ;;(vector-set! vec 0 99)
>   (assert
>     (compiler-typecase vec
>       ((vector-of boolean) #f)
>        (vector #t))))
> How do globals in block mode differ from locals?

Any call to a procedure not globally declared "pure" between the
creation and the use of nested mutable data structures assigned to
locals will "smash" the registered types. If the type of a global
variable can be inferred (which requires block or local mode to
declare that we know nobody will mutate the variable from some other
compilation unit) it is globally registered but it is not
flow-sensitive: the scrutinizer only does intraprocedural
flow-analysis. Therefore we conservatively smash component types for
globally registered, inferred and implicit type declarations.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]