I often think this could maybe allow fantastic runtime optimisations. I realise this would be hardly debuggable but still..
It already does, in the form of JIT compilation.
Writing a Self-Mutating x86_64 C Program (2013)
11–20 of 42 posts
Re: Writing a Self-Mutating x86_64 C Program (2013)
#12I often think this could maybe allow fantastic runtime optimisations. I realise this would be hardly debuggable but still..
Re: Writing a Self-Mutating x86_64 C Program (2013)
#13Re: Writing a Self-Mutating x86_64 C Program (2013)
#14Re: Writing a Self-Mutating x86_64 C Program (2013)
#15Re: Writing a Self-Mutating x86_64 C Program (2013)
#16I often think this could maybe allow fantastic runtime optimisations. I realise this would be hardly debuggable but still..
Programs from the 80s-90s are likely to have such tricks. I have done something similar to "hardcode" semi-constants like frame sizes and quantisers in critical loops related to audio and video decompression, and the performance gain is indeed measurable.
You mean you somehow avoided a load. But what if the constant was already placed in a register ? Also how could you pinpoint the reference to your constant in the machine code ? I'm quite profane about all this.
Re: Writing a Self-Mutating x86_64 C Program (2013)
#17Earlier quoted context omitted.
Programs from the 80s-90s are likely to have such tricks. I have done something similar to "hardcode" semi-constants like frame sizes and quantisers in critical loops related to audio and video decompression, and the performance gain is indeed measurable.
> "hardcode" semi-constants You mean you somehow avoided a load . But what if the constant was already placed in a register ? Also how could you pinpoint the reference to your constant in the machine code ? I'm quite profane about all this.
Not OP, but often one uses an easily identifiable dummy pattern like 0xC0DECA57 or 0xDEADBEEF which can be substituted without also messing up the machine code.
Re: Writing a Self-Mutating x86_64 C Program (2013)
#18Earlier quoted context omitted.
> "hardcode" semi-constants You mean you somehow avoided a load . But what if the constant was already placed in a register ? Also how could you pinpoint the reference to your constant in the machine code ? I'm quite profane about all this.
> Also how could you pinpoint the reference to your constant in the machine code? Not OP, but often one uses an easily identifiable dummy pattern like 0xC0DECA57 or 0xDEADBEEF which can be substituted without also messing up the machine code.
Re: Writing a Self-Mutating x86_64 C Program (2013)
#19Earlier quoted context omitted.
Programs from the 80s-90s are likely to have such tricks. I have done something similar to "hardcode" semi-constants like frame sizes and quantisers in critical loops related to audio and video decompression, and the performance gain is indeed measurable.
> "hardcode" semi-constants You mean you somehow avoided a load . But what if the constant was already placed in a register ? Also how could you pinpoint the reference to your constant in the machine code ? I'm quite profane about all this.
You use a label.
Re: Writing a Self-Mutating x86_64 C Program (2013)
#20Earlier quoted context omitted.
It already does, in the form of JIT compilation.
OK but I meant in already native code, like in a C program - no bytecode.