[poppler] Why does Gfx::opTab need to be built at runtime?
Jeff Muizelaar
jeff at infidigm.net
Wed Sep 26 20:03:17 PDT 2007
On Wed, Sep 26, 2007 at 11:43:35AM -0700, Krzysztof Kowalczyk wrote:
> On 9/26/07, Albert Astals Cid <aacid at kde.org> wrote:
> > A Dimarts 25 Setembre 2007, Krzysztof Kowalczyk va escriure:
> > > I'm looking at optimizing poppler in various ways and just noticed
> > > something I don't understand. I hope someone will be able to enlighten
> > > me.
> > >
> > > In Gfx.h there is:
> > >
> > > struct Operator {
> > > char name[4];
> > > int numArgs;
> > > TchkType tchk[maxArgs];
> > > void (Gfx::*func)(Object args[], int numArgs);
> > > };
> > >
> > > and in Gfx.cc a table is filled out like this:
> > >
> > > Operator Gfx::opTab[] = {
> > > {"\"", 3, {tchkNum, tchkNum, tchkString},
> > > &Gfx::opMoveSetShowText},
> > >
> > > According to a profiler, at least on Windows, the single biggest
> > > function in poppler (~9k) is anonymous function constructed by the
> > > compiler to fill out Gfx::opTab.
> >
> > What do you exactly mean with ~9k ?
>
> It means that behind the scenes a compiler generates a function that
> is 9k of assembly code (that is in optimized msvc build) and all it
> does is constructing this table at runtime, even though I would hope
> all this data is known statically and could be simply stored in data
> section.
>
> Changing char name[4] to char* name saves 1k of code.
>
> Adding const doesn't change anything.
>
> Ultimately I would like to find a way to force compiler to fully build
> it at compile time.
>
> I haven't looked at what gcc produces but it should be apparent after
> looking at map file of inspecting symbol table.
gcc does not produce any code for this afaict. I can't understand why
visualc would be, unless you are just disassembling the .data section.
-Jeff
More information about the poppler
mailing list