4 ms·
Of course you can, you just add a record whenever you do the jump, exactly like what you’re describing with inlined calls. It’s not hard to implement, it’s just
by OskarS 6y ago
Of course you can, you just add a record whenever you do the jump, exactly like what you’re describing with inlined calls. It’s not hard to implement, it’s just that nobody does it, because it’s dumb.
You seem to have a very Java-centered view of the universe, because it is absolutely not true in most languages that inlined calls preserve call stacks. Call stacks are debug information, and there’s absolutely no requirement for compilers to preserve debug information while doing optimization. Requiring that would be lunacy, and it would prohibit a huge number of optimizations (or require costly bookkeeping).
I don’t know what the situation is in Java-land, but if Java preserves inlining information in call stacks using bookkeeping, then good for it, I guess. It can’t come for free, so you’re taking a performance hit for that pleasure. It’s certainly not something that is common, or commonly understood as a requirement for optimization.
- chrisseaton 6y ago> you just add a record whenever you do the jump, exactly like what you’re describing with inlined calls Add another record where? On some kind of stack of records from calls? That will grow linearly with the number of calls? So that's a call-stack is it? The whole point of TCO was to eliminate the stack and you've re-invented it there! If you have an infinite tail-call (like a web server accepting requests in a loop) you'll have an infinitely long list of records with your idea. > It’s certainly not something that is common, or commonly understood as a requirement for optimization. In many languages (Python, Ruby, Java, etc) they are not debug information - they're part of the program semantics and (from experience!) if you change them you'll break programs.