JDK-6804517 : Some languages need to be able to perform tail calls
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 7,9,10
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2009-02-12
  • Updated: 2017-04-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 13
13Unresolved
Related Reports
Duplicate :  
Description
https://blogs.oracle.com/jrose/entry/tail_calls_in_the_vm

A major pain point in some language implementations is chaining method calls from callee to callee to callee, never returning to any previous callee, without blowing the stack.  Tail calls provide the standard remedy.

This requires support from several system components besides the JVM compiler:

- verifiable bytecode syntax for specifying hard tail calls (see blog for proposal)
- runtime support for tail calls through various calling sequences & combinations
- compile-time optimizations

Workarounds include requiring language implementors to inline across all tail calls, and to replace native JVM calling sequences with resettable calling sequences which use exceptions to transfer control down to trampolines frames instead of growing the stack.  These workarounds harm language functionality and inter-language interoperability.

Apart from language features visible to end userse, tail calls are also a powerful way to compose behavioral units inside of language runtimes.  In particular, the ability to tail-call from one handler at a dynamic call site to another handler provides flexible separation of concerns within the metaobject protocol which handles the dispatching of the call site.  This separation of concerns is traditionally managed with procedural abstraction, but without tail calls it can leave many undesirable frames on the stack between the original caller and its ultimate callee; these frames obscure debugger displays and sometimes cause bugs (such as stack overflow).