4 ms·
> What happens when the pointers are in registers? What happens when the loop is occurring in a thread running on another core? These are all ancient-solved pr
by white-flame 12y ago
> What happens when the pointers are in registers? What happens when the loop is occurring in a thread running on another core?
These are all ancient-solved problems. When any interruption occurs, CPU state is spilled onto the stack. Depending on the architecture, the current register usage is either part of the language ABI or determined by the code location indicated by the PC.
> Yes, you can make GC work in these situations, but you are going to pay for it. In perf.
I'm not a big fan of Java the language, but the JVM gets incredible performance doing stuff exactly like this. That and optimization features like inlining virtual function calls (a distinctly faster-than-C++ feature) should be a huge inspiration and impetus towards higher level machine optimization, rather than the human hand-holding the machine through its execution details.