From: Alex Ionescu
Well, I'm kind of confused. I always thought a code generator
that removes code duplication would *slow down* the code
(Because it uses a general approach) and *reduce size*
(because it doesn't duplicate code anymore). I am at a loss
on why autogenerating code would make win32k faster and 3
times larger? Isn't removing duplicate code going to make it smaller?
Depends on what you call "duplicated code". I meant hand-written code. The
code generator will in itself create a lot of
almost-identical-but-slightly-different code. Basically what I'm trying to
do is move "if" statements from the innermost loop to the outside. That
results in a speed increase (less code in the inner loops) at the expense of
bigger code (almost-identical-but-slightly-different code in the if and else
parts).
I've been thinking a bit more about it. There are 256 raster operations,
some of which are used more often than others. For example, the PATCOPY
("Copies the brush currently selected in hdcDest, into the destination
bitmap.") rop is used far more often than the NOTSRCCPY ("Copies the
inverted source rectangle to the destination.") rop. It doesn't make sense
to use a lot of memory for code which is seldom executed.
So, I'm going to limit myself to the 15 named (see BitBlt documentation) rop
codes. For the other 241 codes the current (generic) code can be used. At 6
depths, this still means 90 primitive routines so I'll think I'll continue
work on the code generator.
Ofcourse, before actually committing anything I'll do some timing tests to
see if there is actually a significant performance improvement.
Gé van Geldorp.