This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, libfortran] RFC: Shared vtables, constification


PING! (At this point, obviously for trunk only)

On Mon, Feb 13, 2012 at 20:20, Janne Blomqvist
<blomqvist.janne@gmail.com> wrote:
> Hi,
>
> the attached patch changes the low-level libgfortran IO dispatching
> mechanism to use shared vtables for each stream type, instead of all
> the function pointers being replicated for each unit. This is similar
> to e.g. how the C++ frontend implements vtables. The benefits are:
>
> - Slightly smaller heap memory overhead for each unit as only the
> vtable pointer needs to be stored, and slightly faster unit
> initialization as only the vtable pointer needs to be setup instead of
> all the function pointers in the stream struct.
>
> - Looking at unix.o with readelf, one sees
>
> Relocation section '.rela.data.rel.ro.local.mem_vtable' at offset
> 0x15550 contains 8 entries:
>
> and similarly for the other vtables; according to
> http://www.airs.com/blog/archives/189 this means that after relocation
> the page where this data resides may be marked read-only.
>
> The downside is that the sizes of the .text and .data sections are
> increased. Before:
>
>  text  Âdata   bss   dec   hex filename
> 1116991 Â Â6664 Â Â 592 1124247 Â112797
> ./x86_64-unknown-linux-gnu/libgfortran/.libs/libgfortran.so
>
> After:
>
>  text  Âdata   bss   dec   hex filename
> 1117487 Â Â6936 Â Â 592 1125015 Â112a97
> ./x86_64-unknown-linux-gnu/libgfortran/.libs/libgfortran.so
>
>
> The data section increase is due to the vtables, the text increase is,
> I guess, due to the extra pointer dereference when calling the IO
> functions.
>
> Regtested on x86_64-unknown-linux-gnu, Ok for trunk, or 4.8?
>
> 2012-02-13 ÂJanne Blomqvist Â<jb@gcc.gnu.org>
>
> Â Â Â Â* io/unix.h (struct stream): Rename to stream_vtable.
> Â Â Â Â(struct stream): New struct definition.
> Â Â Â Â(sread): Dereference vtable pointer.
> Â Â Â Â(swrite): Likewise.
> Â Â Â Â(sseek): Likewise.
> Â Â Â Â(struncate): Likewise.
> Â Â Â Â(sflush): Likewise.
> Â Â Â Â(sclose): Likewise.
> Â Â Â Â* io/unix.c (raw_vtable): New variable.
> Â Â Â Â(buf_vtable): Likewise.
> Â Â Â Â(mem_vtable): Likewise.
> Â Â Â Â(mem4_vtable): Likewise.
> Â Â Â Â(raw_init): Assign vtable pointer.
> Â Â Â Â(buf_init): Likewise.
> Â Â Â Â(open_internal): Likewise.
> Â Â Â Â(open_internal4): Likewise.
>
>
>
> --
> Janne Blomqvist



-- 
Janne Blomqvist


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]