[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Garbage collection durint pcall.
- From: Andrew Gierth <andrew@...>
- Date: Sun, 02 Jun 2019 16:15:20 +0100
>>>>> "Roberto" == Roberto Ierusalimschy <roberto@inf.puc-rio.br> writes:
>> This may be totally kosher given the right definition. An object is
>> dead whenever nobody uses it again, and can be collected at any time
>> after that.
>>
>> But this definition opens a can of worms for the optimizer. If I do
>> a=collectable;.......lot of things....;a=a; the optimizer cannot
>> optimize away the a=a stuff, because that object liveness definition
>> changes the semantics of a=a, and of all reads of vars in general.
Roberto> I see the problem the other way around. It is not optimization
Roberto> that should be restricted; what should be restricted are the
Roberto> assumptions around finalizers. Of course any optimizer should
Roberto> be able to erase 'a=a' (as long as the assignment itself has
Roberto> no side effects, as it can have in C++), as it should be able
Roberto> to erase any code that does not produce side effects.
But even in the absence of finalizers, holding a (strong) reference to
an object has a visible effect: it prevents the object from vanishing
from a weak table due to collection. So the actual lifetime of a local
variable matters, even if its value is never fetched.
--
Andrew.