Faster Virtual Method Dispatch

James Dunne james.jdunne at gmail.com
Wed Apr 26 14:27:08 PDT 2006


Walter Bright wrote:
> James Dunne wrote:
> 
>> Can you provide me a few legitimate examples of when you won't know 
>> what to free and when to free it?  I'm having a tough time coming up 
>> with examples on my own...
> 
> 
> One example that has plagued me in the past is having two distinct tree 
> data structures, and it becomes necessary for a node in one tree to 
> refer to data in the other.
> 
> Or when you have a third data structure, and you need to point to data 
> in one or the other or both of the first two trees.
> 
> A typical example of that is symbol tables inside the compiler. In the 
> DMD front end (which is garbage collected) the data has all kinds of 
> cross-connections in it.
> 
> I.e. the problem crops up when the data in memory just doesn't fit into 
> a strictly heirarcical format.

Your example is having two trees _point_ to data within each other.  The 
original data is still _owned_ by the original tree which the data 
resides in.  You wouldn't be swapping ownership of the data like you're 
talking about.  In this system, when memory is allocated it is assigned 
an owner and that ownership does not ever change.  So the system 
resembles a tree (one parent only), not a directed graph.

Funny you mention compiler, because that is the example application I 
was referring to. :)

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O 
M--@ V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e 
h>--->++ r+++ y+++
------END GEEK CODE BLOCK------

James Dunne



More information about the Digitalmars-d mailing list