Self-Modifying code for user settings optimization
Jason Jeffory via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jan 9 02:31:03 PST 2016
Instead of something like
DoSomething(UserSettings["width"]);
Which requires an access to UserSettings, which may be slow in
time critical code(but you want to provide some way to configure
various behaviors), why not use self-modifying code?
DoSomething(3); // 3 maybe the default, but a hack is somehow
introduced, such as modifying the "push 3" instruction to "push
width" (but width is constant for all runs, the instruction
itself changes values only when the default value is
changed(could be done at setup). (push could be mov or whatever)
This would avoid pipelining issue and provide the absolute fasted
way to have settings?
(Of course, we'd have to know where all the "push" instructions
are located and all that since the modification could not occur
serially(would be somewhat pointless then))
Not even sure if CPU's allow SMC anymore?
More information about the Digitalmars-d
mailing list