3 ms·
But Go used to implement some things with self modifying code. iOS (and OpenBSD) with their W^X restrictions are largely why Go changed.
by bradfitz 4y ago
But Go used to implement some things with self modifying code. iOS (and OpenBSD) with their W^X restrictions are largely why Go changed.
- amelius 4y agoI wonder what kind of performance setback this resulted in. Didn't JavaScript runtimes get close to C/C++ performance exactly because they started using JIT compilation?
- xavxav 4y agoI doubt it hurt performance, self-modifying code must play havoc on all the modern CPU caches, branch prediction, instruction decoding etc… A jit makes it worthwhile by doing it for hot paths for which the payoff outweighs this cost (or attempts to).
- amelius 4y agoIt will definitely hurt performance (to remove JIT functionality), otherwise why would JIT compilation be even used?
- simjnd 4y agoI may be wrong, but I think it goes something like this: Languages that benefit from JIT compilation are languages with a dynamic type system: the JIT profiles the hot paths to optimize (e.g. this function is called a lot with integer parameters but only once with string parameters, so I'm going to compile the version with ints to optimal code and compile the string version to a suboptimal but inexpensive code) Go on the other hand has a static type system, so when you AOT compile it can already produce all the optimal code needed thanks to static types.
- amelius 4y agoYes, this was already noted a few comments above: https://news.ycombinator.com/item?id=33394615 https://news.ycombinator.com/item?id=33394615 Type information is not the only thing that helps though. Partial specialization can be applied to other things.
- pjmlp 4y agoWell for dynamic languages like JavaScript, JIT is the only reasonable option. You can AOT compile them, but the code cannot ever be optiomal without any kind of PGO feedback loop, thus a JIT ends up being a much better option. Unless they support optional types, like in the Lisp based languages. So something like Typescript could eventually have a good AOT story, and this is what Microsoft does on their MakeCode project, compiling a Typescript subset via C++ code generation.
- amelius 4y agoGood point. I guess another reasonable strategy would be to instrumentalize the code, run it once, and feed the results back to another AOT compiler pass which then optimizes the code based on usage statistics. But that would not apply to Go really, because it has strong typing already.
- Lvl999Noob 4y agoisnt this what PGO is?