I seem to recall some emulators do a bit of this with JIT techniques. ![]() ![]() I wrote a number of decompilers and cross-compilers many years ago and I envisaged that instead of emulation that conversion would be the way to go, decompile, convert and compile (in simplistic terms). I guess though things might get hairy when writing an emulator/translator that is translating code optimised by some compiler for some architecture to run on a different architecture with a different memory model. But then we have higher level abstractions to handle that in our languages, like "volatile" in C and atomics in C++. Unless they are talking to hardware or writing multithreaded code. Typically developers never need to worry about all this and compilers are not putting in barriers willy nilly. Other threads for example, or hardware devices mapped to those addresses. The only time this matters is when something else is watching that same RAM other than your piece of code. Similarly processors can rearrange things, as long as the outcome is the same. ![]() ![]() Or it may be keeping intermediate values in registers and never write them to memory. Of course if that x is not used it can elide that as well. In C then the optimiser can reduce that to an instruction sequence that only writes 3 to x.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |