Re: new gc interface

Date view Thread view Subject view Author view

From: Godmar Back (gback@cs.utah.edu)
Date: Wed Jan 27 1999 - 12:22:19 EST


>
> On Jan 27, 1999, Godmar Back <gback@cs.utah.edu> wrote:
>
> >>
> >> > Implementations of the interface will look like this:
> >>
> >> > struct _CollectorImpl {
> >> > Collector collector; // pointer to shared vtable
> >> > gcList gclists[5];
> >>
> >> I still don't see the point of adding an extra level of indirection
> >> (although only at source code level). It seems a mere inconvenience
> >> to me.
> >>
>
> > Look at this picture to better understand what's going on:
>
> Ok, I understand what's going on, but I still don't buy the need for
> the additional struction. We'd be able to accomplish exactly the same
> with an explicit pointer to the vtable within _CollectorImpl, wouldn't
> we?
>

Think about it some more. collector.ops is nothing but an explicit
pointer to the vtable.

typedef struct _Collector {
        struct GarbageCollectorInterface_Ops *ops;
} Collector;

and

struct _CollectorImpl {
        Collector collector;
}

note that it's not:

struct _CollectorImpl {
        Collector *collector;
}

So if you inline it, it's

struct _CollectorImpl {
        struct _Collector {
                struct GarbageCollectorInterface_Ops *ops;
        } collector;
}

JNI writes (*env)->blabla instead; same difference.
I like the macros better because the have the nice feature that they warn
you of certain mistakes when subclassing interfaces.

        - Godmar


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:50 EDT