Re: Compiler writers will love this language

mwotton@cse.unsw.edu.au (Mark Alexander Wotton)
22 Jun 2003 23:20:37 -0400

          From comp.compilers

Related articles
[8 earlier articles]
Re: Compiler writers will love this language marcov@toad.stack.nl (Marco van de Voort) (2003-06-20)
Re: Compiler writers will love this language ericmuttta@email.com (2003-06-20)
Re: Compiler writers will love this language ericmuttta@email.com (2003-06-20)
Re: Compiler writers will love this language ericmuttta@email.com (2003-06-20)
Re: Compiler writers will love this language torbenm@diku.dk (2003-06-20)
Re: Compiler writers will love this language d00-mla@nada.kth.se (Mikael 'Zayenz' Lagerkvist) (2003-06-22)
Re: Compiler writers will love this language mwotton@cse.unsw.edu.au (2003-06-22)
Re: Compiler writers will love this language dot@dotat.at (Tony Finch) (2003-06-25)
Re: Compiler writers will love this language lex@cc.gatech.edu (Lex Spoon) (2003-06-25)
Re: Compiler writers will love this language firefly@diku.dk (Peter \Firefly\Lund) (2003-06-25)
Re: Compiler writers will love this language joachim.durchholz@web.de (Joachim Durchholz) (2003-07-02)
Re: Compiler writers will love this language strohm@airmail.net (John R. Strohm) (2003-07-02)
Re: Compiler writers will love this language genew@mail.ocis.net (2003-07-02)
[27 later articles]
| List of all articles for this month |
From: mwotton@cse.unsw.edu.au (Mark Alexander Wotton)
Newsgroups: comp.compilers
Date: 22 Jun 2003 23:20:37 -0400
Organization: Mare's Nest Collective
References: 03-05-211 03-06-015 03-06-054 03-06-057 03-06-078
Keywords: storage
Posted-Date: 22 Jun 2003 23:20:37 EDT

On 20 Jun 2003 00:02:55 -0400, Eric posted:
> mwotton@cse.unsw.edu.au (Mark Alexander Wotton) wrote
>>
>> Either that, or only released when all references to it have passed
>> out of scope. This is how many modern garbage-collected language
>> implementations work.
>
> This scheme (reference-counting) is used in VB6 for instance.


Reference counting and mark-and-sweep are just ways of implementing the basic
idea of deallocating when references are out of scope.


> VB7 (and every other .NET language?) uses generational,
> mark-and-sweep GC (hope that's the right term for it). When I read
> its description, it sounded like a rather elaborate scheme and one
> that would need a good deal of implementation effort. I prefer plain
> vanilla automatic reference-counting. Its deterministic (hence
> useful in real-time systems), simple to explain and understand, and
> a lot easier to implement and get right.


You do have the problem with reference-counting that it doesn't cope
very well with two-way links. Generational collection is nice partly
because it's complete (all unused allocations are reclaimed), and also
because it takes advantage of common memory use patterns: it's
optimised for the case of new objects pointing to old objects, which
is the usual case.


> I admit, reference-counting has its problems and I have been toying
> around with an idea for what I call "compile-time
> reference-counting". Basically, I am looking for a set of rules,
> that will allow the compiler to figure out when to release memory
> for an object, *without* having to allocate memory space for a
> reference counter value. Instead, using these rules, the compiler
> can analyse code at compile time and statically work out the
> life-time of an object. Its a bit wishy washy at the moment but if
> its at all possible, I will write a paper on it :)


It smells a bit undecidable to me. At least for the complete case, I think
this reduces to the halting problem.


    Object foo(Object x, Object y) {
if (halts(x)) {
return y;
} else {
return x;
}
    }


When do you release x's memory?


You may be able to find some decent heuristics, but I suspect it's a lot
harder than it looks.


mrak


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.