ProgramSpecialization is used where a variable is known to often hold one particular value. In this case, it is possible to generate code taking advantage of this constant value, e.g. not passing a parameter, using immediate addressing modes, eliminating the evaulation of an if-then-else statement and one of the clauses, (either the _then_ or _else_ clauses) etc. For example, if you have code like if (extendedBehavior) doExtended(); else x = 11; and extendedBehavior is often false, then you can _specialize_ the above code to just "x=11;". Usually, the assumption can't be proved (e.g. that extendedBehavior is false), so the specialized code has to be protected by a guard, which essentially says "if extendedBehavior is true, branch to the non specialized code; else branch to the specialized code". Under appropriate circumstances, the performance gain from specialization can be quite considerable. See also PartialEvaluation, ProgramSpecialization (a synonym for PartialEvaluation). -- Main.MikeVanEmmerik - 03 Dec 2001
(Specialization is not a TWiki.WikiName; renamed the topic to ProgramSpecialization -- Main.EelcoVisser - 04 Dec 2001) ------ CategoryOptimization