Realised how long it has been since I posted a diary entry.
Been revising and doing exams. Not fun.
Learning Bonobo, which is cool.
Thought of a good binary rewriting thing I might try to write, from reading abou JVMs. Hope there are no bastard patents about this. Temporary name: charm. Basically,
mmaps the executable bit of your binary. copies it, inserting a call to a recording function, say record() anytime it comes across any interesting jump ( branch on condition or a function call). map the modified memory executable. jmp to the beginning of copied code (dunno whether to do dynamic linking before this or not. Probably yes, or it will get confused. ) This will run the program as usual, if a bit slower. This ends up calling record() every time a jump happens. So you can tell how every branch resulted. This then gets recorded in some file. This file can be used to optimise the compilation next time round.
So if you know that an if statement nearly always jumps , you change around the branch instructions to make it the cheap case. Or a small function gets called a lot in the same place, so you make it inline.
You could also do this on the binary, and just dump an optimised version of it out at the end. This is pretty annoying for open source projects though, as particular binarys are just transient pieces of fluff that never last long ;-)
I want to call it charm cause it will be cool to type: