> This is called branch prediction, it has been the source of many fun security issues... No, that's speculative execution you just described. Branch prediction was implemented long before out-of-order CPUs were a thing, as you need branch prediction to make the most of pipelining (eg. fetching and decoding a new instruction while you're still executing the previous one--if you predict branches, you're more likely to…
Speculative execution does not require out-of-order execution. When you predict a branch, you're speculatively executing the predicted branch. Whether you're doing it in the same order as instruction order or out of order is independent of that.
JIT: So you want to be faster than an interpreter on modern CPUs
51–60 of 66 posts
Re: JIT: So you want to be faster than an interpreter on modern CPUs
#52Earlier quoted context omitted.
Speculative execution does not require out-of-order execution. When you predict a branch, you're speculatively executing the predicted branch. Whether you're doing it in the same order as instruction order or out of order is independent of that.
If you're executing instructions in order, wouldn't you already know the result of the branch by the time you reach its code?
Re: JIT: So you want to be faster than an interpreter on modern CPUs
#53Earlier quoted context omitted.
JIT compilation can be faster for compiled languages too, as it allows data driven inlining and devirtualization, as well as "effective constant" propogation and runtime architecture feature detection
Is there a production JIT for a compiled language that is actually faster? I understand the theory, I don't think the practice backs it up.
Re: JIT: So you want to be faster than an interpreter on modern CPUs
#54Earlier quoted context omitted.
Depends, what do you consider Java?
Java is certainly not the fastest language out there.
Re: JIT: So you want to be faster than an interpreter on modern CPUs
#55Earlier quoted context omitted.
Speculative execution does not require out-of-order execution. When you predict a branch, you're speculatively executing the predicted branch. Whether you're doing it in the same order as instruction order or out of order is independent of that.
The article is talking about OoO which is why I mentioned it. My point is that branch prediction and speculative execution are different things. You can do speculative execution without a branch predictor (run both branches and throw out the one that's wrong).
Re: JIT: So you want to be faster than an interpreter on modern CPUs
#56Good read. But a word of caution - the "JIT vs interpreter" comparisons often favor the interpreter when the JIT is inplemented as more-or-less simple inlining of the interpreter code. (Here called "copy-and-patch" but a decades-only approach). I've had fairly senior engineers try to convince me that this is true even for Java VMs. It's not in general, at least not with the right kind of JIT compiler design.
Re: JIT: So you want to be faster than an interpreter on modern CPUs
#57Earlier quoted context omitted.
Source? Is there any non-Apple app that has this entitlement?
I believe the Delta emulator has JIT support, but possibly only when installed as a developer.
Re: JIT: So you want to be faster than an interpreter on modern CPUs
#58Re: JIT: So you want to be faster than an interpreter on modern CPUs
#59That was a pretty interesting read. My take is that you can get pretty far these days with a simple bytecode interpreter. Food for thought if your side project could benefit from a DSL!
Re: JIT: So you want to be faster than an interpreter on modern CPUs
#60I'm not really interested in building an interpreter, but the part about scalar out of order execution got me thinking. The opcode sequencing logic of an interpreter is inherently serial and an obvious bottleneck (step++; goto step->label; requires an add, then a fetch and then a jump, pretty ugly). Why not do the same thing the CPU does and fetch N jump addresses at once? Now the overhead is gone and you just need t…