tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] enforced immutability - proposed research project


From: Michael Matz
Subject: Re: [Tinycc-devel] enforced immutability - proposed research project
Date: Mon, 18 Jan 2021 16:45:05 +0100 (CET)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)

Hello,

On Mon, 18 Jan 2021, Barath Aron via Tinycc-devel wrote:

Yes, this is how you would do it without proper type system (like C
has). I mean, if you want to add runtime stuff here, it is fine for me
(until it is optional :P -- I use tcc on an exotic hosted system, so it
is crucial for me [hmm, did I mentioned that tcc works only partially,
due to lack of PIE support?]

[The x86-64 code was mostly PIE already, and Herman fixed more things regarding that recently, so if it still doesn't work 100% it should be relatively easy to fix. For the other targets Herman also fixed a couple things towards position independence, but for some architectures a performance price needs to be paid, so it should only be optional.]

). But in the example above, it is clearly,
you need to do something in your code to get this working. Another
aspect would be an extension to the C type system, which makes such
escapes impossible (like 'const'):

   immutable struct S *globalp;
   void init(immutable struct S *x) { x->foo = 1; globalp = x; }

*x can't be immutable within init(), otherwise it couldn't initialize x->foo. Except if you say that 'init' is somehow special, like constructors in C++, and allow it to write through immutable references.

And make this property permanent, so no one can cast it away.

Forbidding to cast away immutability is easy. The problem is at the side of creating immutability retroactively, and what to do with the mutable references that already exist.

I mean, I see two ways to do it. One will work only in certain hosted system, while the other will work with any hosted and freestanding environment. And it would be useful to examine both directions, especially for a research project. :)

True that. For a real research project the type system route should definitely be included :)


Ciao,
Michael.



reply via email to

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