Usage of C++ features
john.r.rose at oracle.com
Thu Feb 6 17:40:35 PST 2014
On Feb 6, 2014, at 3:27 AM, David Holmes <david.holmes at oracle.com> wrote:
> That said the compiler folk have expressed interest in using C++ exceptions within the compiler.
On Feb 6, 2014, at 5:07 PM, Christian Thalinger <christian.thalinger at oracle.com> wrote:
The HotSpot project as a whole is not likely to be an early adopter of new C++ mechanisms, especially those which require specialized run-time or link-time support.
For example, it took us many years to embrace templates, because anything other than the most straightforward uses (compile-time, macro-like) risked bugs or poor performance (speed or code-size) on one or more of our many platforms. Now that STL is widely used, it appears that all C++ compilers handle templates well.
For reasons like this HotSpot must be a follower of C++ uptake, so the technology can lead in other dimensions such as portability. It's not good enough for us that one or two reference implementations of C++ (out of windows, gcc, clang, Solaris, etc.) are solid and performant on some C++ feature in order for HotSpot to use it.
C++ exceptions probably have special expenses in addition to stability and portability risks. I would not be surprised if the low-level details of C++ non-local exits and unwind handlers will interfere with some other aspect of HotSpot, such as the JVM's own stack walking requirements. Or, the fine-grained nature of C++ destructor ordering might (on some platforms, until implementations mature) inflate some combination of exception table metadata and/or exit path code and/or object size.
You can think of it this way also: Platform-specific problems and their workarounds are a significant project cost even now, so branching out into new parts of the C++ language needs to be done with an eye towards managing that cost.
On the other hand, managing the cost also includes testing proposals for new C++ code patterns from time to time. It is possible (though I am skeptical) that C++ exceptions could simplify some parts of our source code, such as the compiler, with reasonable costs on all platforms.
More information about the hotspot-dev