On Tue, Aug 17, 2010 at 10:23 AM, Jeffrey Yasskin <[email protected]> wrote:
> On Mon, Aug 16, 2010 at 6:13 AM, Graydon Hoare <[email protected]> wrote:

>>  - Things that *could* be compile-time constants can't be calculated
>>    "once". We wind up putting code in the executable rather than
>>    read-only data, and re-calculating repeatedly at runtime.
>
> 'Course, there's no reason you couldn't optimize the function to
> "return global_constant", but that still involves the call and
> refcounting overhead. If you figure out how to solve the rodata vs
> refcounting problem, you could skip the refcounting here too.

I believe that CoreFoundation has 'magic refcounts' for read-only data
(for example literal strings declared with CFSTR) These objects  have
a certain (large) value for their refcount which retain/release check
- if it equals the magic number they don't do anything. Would that be
useful?


>>  - Value-level equality needs to be preserved and/or checked somehow
>>    between compile-time and load-time, rather than just type
>>    compatibility. Compiling a crate with math.pi = 3.14, then finding
>>    you linked against a recompiled crate with math.pi = 3.15, is an
>>    unwelcome situation. We'd need some kind of scheme to guard against
>>    this, or make users somehow aware of the risks. Possibly just
>>    require compilation-unit UUID-identity or CHF-identity if there's
>>    been any constant folding? Or track the constants that were folded
>>    and check equality at runtime link time? Awkward options, all...
>
> This bit is separable. I think it'd make sense to say that constants
> in one crate are runtime values from another crate. If you start
> inlining functions across crate boundaries, you can re-use the same
> checking mechanism to inline constants. You'd want a way to let the
> user control this in case they actually want the crate to be
> upgradeable without relinking.

Is it possible to create a hash (SHA1 or whatever) from just the
'interface' bit of a crate? All the constant values could be laid out
in a contiguous block and hashed. Then a rust program could check that
the crate's hash was still equal to what it had at link time. This
could include the function signatures too if needed.

Pete

(sorry for the repeat JY; I forgot to reply-to-all)
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to