8369186: HotSpot Style Guide should permit some uses of the C++ Standard Library

Reviewed-by: jrose, lkorinth, iwalulya, kvn, stefank
This commit is contained in:
Kim Barrett 2025-11-02 07:02:06 +00:00
parent 7c900da198
commit e8a1a8707e
68 changed files with 531 additions and 235 deletions

View File

@ -114,7 +114,7 @@ id="toc-compatibility-with-c11">Compatibility with C11</a></li>
id="toc-additional-permitted-features">Additional Permitted
Features</a></li>
</ul></li>
<li><a href="#excluded-features" id="toc-excluded-features">Excluded
<li><a href="#forbidden-features" id="toc-forbidden-features">Forbidden
Features</a>
<ul>
<li><a href="#structured-bindings"
@ -123,8 +123,8 @@ id="toc-structured-bindings">Structured Bindings</a></li>
System Library</a></li>
<li><a href="#aggregate-extensions"
id="toc-aggregate-extensions">Aggregate Extensions</a></li>
<li><a href="#additional-excluded-features"
id="toc-additional-excluded-features">Additional Excluded
<li><a href="#additional-forbidden-features"
id="toc-additional-forbidden-features">Additional Forbidden
Features</a></li>
</ul></li>
<li><a href="#undecided-features" id="toc-undecided-features">Undecided
@ -506,19 +506,19 @@ uses a subset. (Backports to JDK versions lacking support for more
recent Standards must of course stick with the original C++98/03
subset.)</p>
<p>This section describes that subset. Features from the C++98/03
language may be used unless explicitly excluded here. Features from
language may be used unless explicitly forbidden here. Features from
C++11, C++14, and C++17 may be explicitly permitted or explicitly
excluded, and discussed accordingly here. There is a third category,
forbidden, and discussed accordingly here. There is a third category,
undecided features, about which HotSpot developers have not yet reached
a consensus, or perhaps have not discussed at all. Use of these features
is also excluded.</p>
is also forbidden.</p>
<p>(The use of some features may not be immediately obvious and may slip
in anyway, since the compiler will accept them. The code review process
is the main defense against this.)</p>
<p>Some features are discussed in their own subsection, typically to
provide more extensive discussion or rationale for limitations. Features
that don't have their own subsection are listed in omnibus feature
sections for permitted, excluded, and undecided features.</p>
sections for permitted, forbidden, and undecided features.</p>
<p>Lists of new features for C++11, C++14, and C++17, along with links
to their descriptions, can be found in the online documentation for some
of the compilers and libraries. The C++17 Standard is the definitive
@ -594,14 +594,15 @@ title="Runtime Type Information">RTTI</a> are deemed not worthwhile,
given the alternatives.</p>
<h3 id="memory-allocation">Memory Allocation</h3>
<p>Do not use the standard global allocation and deallocation functions
(operator new and related functions). Use of these functions by HotSpot
code is disabled for some platforms.</p>
(global <code>operator new</code> and related functions), other than the
non-allocating forms of those functions. Use of these functions by
HotSpot code is disabled for some platforms.</p>
<p>Rationale: HotSpot often uses "resource" or "arena" allocation. Even
where heap allocation is used, the standard global functions are avoided
in favor of wrappers around malloc and free that support the VM's Native
Memory Tracking (NMT) feature. Typically, uses of the global operator
new are inadvertent and therefore often associated with memory
leaks.</p>
in favor of wrappers around <code>malloc</code> and <code>free</code>
that support the JVM's Native Memory Tracking (NMT) feature. Typically,
uses of the global <code>operator new</code> are inadvertent and
therefore often associated with memory leaks.</p>
<p>Native memory allocation failures are often treated as
non-recoverable. The place where "out of memory" is (first) detected may
be an innocent bystander, unrelated to the actual culprit.</p>
@ -648,7 +649,39 @@ for anonymous namespaces.</p>
class="uri">https://sourceware.org/bugzilla/show_bug.cgi?id=16874</a><br>
Bug for similar gdb problems.</p>
<h3 id="c-standard-library">C++ Standard Library</h3>
<p>Avoid using the C++ Standard Library.</p>
<p>Only curated parts of the C++ Standard Library may be used by HotSpot
code.</p>
<p>Functions that may throw exceptions must not be used. This is in
accordance with the HotSpot policy of <a href="#error-handling">not
using exceptions</a>.</p>
<p>Also in accordance with HotSpot policy, the <a
href="#memory-allocation">standard global allocator must not be
used</a>. This means that uses of standard container classes cannot
presently be used, as doing so requires specialization on some allocator
type that is integrated with the existing HotSpot allocation mechanisms.
(Such allocators may be provided in the future.)</p>
<p>Standard Library identifiers should usually be fully qualified;
<code>using</code> directives must not be used to bring Standard Library
identifiers into scope just to remove the need for namespace
qualification. Requiring qualification makes it easy to distinguish
between references to external libraries and code that is part of
HotSpot.</p>
<p>As with language features, Standard Library facilities are either
permitted, explicitly forbidden, or undecided (and so implicitly
forbidden).</p>
<p>Most HotSpot code should not directly <code>#include</code> C++
Standard Library headers. HotSpot provides a set of wrapper headers for
the Standard Library headers containing permitted definitions. These
wrappers are in the <code>cppstdlib</code> directory, with the same name
as the corresponding Standard Library header and a <code>.hpp</code>
extension. These wrappers provide a place for any additional code (some
of which may be platform-specific) needed to support HotSpot usage.</p>
<p>These wrappers also provide a place to document HotSpot usage,
including any restrictions. The set of wrappers and the usage
documentation should be considered part of HotSpot style. Any changes
are subject to the same process as applies to this document. (For
historical reasons, there may be many direct inclusions of some C++
Standard Library headers.)</p>
<p>Historically, HotSpot has mostly avoided use of the Standard
Library.</p>
<p>(It used to be impossible to use most of it in shared code, because
@ -661,46 +694,60 @@ in mid-2017. Support for Solaris was removed in 2020.)</p>
of Standard Library facilities is exceptions. HotSpot does not use
exceptions and, for platforms which allow doing so, builds with them
turned off. Many Standard Library facilities implicitly or explicitly
use exceptions.</p></li>
use exceptions. On the other hand, many don't, and can be used without
concern for this issue. Others may have a useful subset that doesn't use
exceptions.</p></li>
<li><p><code>assert</code>. An issue that is quickly encountered is the
<code>assert</code> macro name collision (<a
href="https://bugs.openjdk.org/browse/JDK-8007770">JDK-8007770</a>).
Some mechanism for addressing this would be needed before much of the
Standard Library could be used. (Not all Standard Library
implementations use assert in header files, but some do.)</p></li>
(Not all Standard Library implementations use <code>assert</code> in
header files, but some do.) HotSpot provides a mechanism for addressing
this, by establishing a scope around the include of a library header
where the HotSpot <code>assert</code> macro is suppressed. One of the
reasons for using wrapper headers rather than directly including
standard headers is to provide a central place to deal with this issue
for each header.</p></li>
<li><p>Memory allocation. HotSpot requires explicit control over where
allocations occur. The C++98/03 <code>std::allocator</code> class is too
limited to support our usage. (Changes in more recent Standards may
remove this limitation.)</p></li>
limited to support our usage. But changes to the allocator concept in
more recent Standards removed some of the limitations, supporting
stateful allocators. HotSpot may, in the future, provide
standard-conforming allocators that are integrated with HotSpot's
existing allocation mechanisms.</p></li>
<li><p>Implementation vagaries. Bugs, or simply different implementation
choices, can lead to different behaviors among the various Standard
Libraries we need to deal with.</p></li>
Libraries we need to deal with. But only selected parts of the Standard
Library are being permitted, and one of the selection criteria is
maturity. Some of these facilities are among the most heavily tested and
used C++ codes that exist.</p></li>
<li><p>Inconsistent naming conventions. HotSpot and the C++ Standard use
different naming conventions. The coexistence of those different
conventions might appear jarring and reduce readability.</p></li>
</ul>
<p>There are a few exceptions to this rule.</p>
conventions might appear jarring and reduce readability. However,
experience in some other code bases suggests this isn't a significant
problem, so long as Standard Library names are namespace-qualified. It
is tempting to bring the Standard Library names into scope via a
<code>using std;</code> directive. Doing so makes writing code using
those names easier, since the qualifiers don't need to be included. But
there are several reasons not to do that.</p>
<ul>
<li><code>#include &lt;new&gt;</code> to use placement <code>new</code>,
<code>std::nothrow</code>, and <code>std::nothrow_t</code>.</li>
<li><code>#include &lt;limits&gt;</code> to use
<code>std::numeric_limits</code>.</li>
<li><code>#include &lt;type_traits&gt;</code> with some restrictions,
listed below.</li>
<li><code>#include &lt;cstddef&gt;</code> to use
<code>std::nullptr_t</code> and <code>std::max_align_t</code>.</li>
<li><p>There is a risk of future name collisions. Additional Standard
Library headers may be included, adding to the list of names being used.
Also, future versions of the Standard Library may add currently unknown
names to the headers already being included.</p></li>
<li><p>It may harm readability. Code where this is relevant is a mixture
of the local HotSpot naming conventions and the Standard Library's (or
other 3rd-party library's) naming conventions. With only unqualified
names, any distinctions from the naming conventions for the different
code sources are lost. Instead one may end up with an undifferentiated
mess, where it's not obvious whether an identifier is from local code
that is inconsistent with HotSpot style (and there's a regretable amount
of that for historical reasons), or is following some other convention.
Having the qualifiers disambiguates that.</p></li>
<li><p>It can be helpful to know, at a glance, whether the definition is
in HotSpot or elsewhere, for purposes of looking up the definition or
documentation.</p></li>
</ul></li>
</ul>
<p>Certain restrictions apply to the declarations provided by
<code>&lt;type_traits&gt;</code>.</p>
<ul>
<li>The <code>alignof</code> operator should be used rather than
<code>std::alignment_of&lt;&gt;</code>.</li>
</ul>
<p>TODO: Rather than directly #including (permitted) Standard Library
headers, use a convention of #including wrapper headers (in some
location like hotspot/shared/stdcpp). This provides a single place for
dealing with issues we might have for any given header, esp.
platform-specific issues.</p>
<h3 id="type-deduction">Type Deduction</h3>
<p>Use type deduction only if it makes the code clearer or safer. Do not
use it merely to avoid the inconvenience of writing an explicit type,
@ -1577,10 +1624,10 @@ href="http://wg21.link/p0138r2">p0138r2</a>)</p></li>
<li><p>Allow <code>typename</code> in template template parameter (<a
href="http://wg21.link/n4051">n4051</a>) — template template parameters
are barely used (if at all) in HotSpot, but there's no reason to
artificially disallow this syntactic regularization in any such
artificially forbid this syntactic regularization in any such
uses.</p></li>
</ul>
<h2 id="excluded-features">Excluded Features</h2>
<h2 id="forbidden-features">Forbidden Features</h2>
<h3 id="structured-bindings">Structured Bindings</h3>
<p>The use of structured bindings <a
href="http://wg21.link/p0217r3">p0217r3</a> is forbidden. Preferred
@ -1622,8 +1669,33 @@ initialization for classes with base classes (<a
href="https://wg21.link/p0017r1">p0017r1</a>). HotSpot makes very little
use of aggregate classes, preferring explicit constructors even for very
simple classes.</p>
<h3 id="additional-excluded-features">Additional Excluded Features</h3>
<h3 id="additional-forbidden-features">Additional Forbidden
Features</h3>
<ul>
<li><p><code>&lt;algorithm&gt;</code>, <code>&lt;iterator&gt;</code>,
<code>&lt;numeric&gt;</code><br> Not useful without standard containers
or similar classes in HotSpot.</p></li>
<li><p><code>&lt;bitset&gt;</code> - Overlap with HotSpot
<code>BitMap</code>.</p></li>
<li><p><code>&lt;cassert&gt;</code>, <code>assert.h</code> - HotSpot has
its own <code>assert</code> macro.</p></li>
<li><p><code>&lt;exception&gt;</code>, <code>&lt;stdexcept&gt;</code> -
Use of <a href="#error-handling">exceptions</a> is not
permitted.</p></li>
<li><p>Thread support - <code>&lt;thread&gt;</code>,
<code>&lt;mutex&gt;</code>, <code>&lt;shared_mutex&gt;</code>,
<code>&lt;condition_varible&gt;</code>, <code>&lt;future&gt;</code><br>
HotSpot has its own threading support.</p></li>
<li><p>Streams - HotSpot doesn't use the C++ I/O library.</p></li>
<li><p><code>&lt;scoped_allocator&gt;</code> - Not useful without
specialized allocators.</p></li>
<li><p><code>&lt;string&gt;</code> - Requires allocator support, similar
to standard containers.</p></li>
<li><p><code>&lt;typeinfo&gt;</code>, <code>&lt;typeindex&gt;</code><br>
Use of <a href="#runtime-type-information">runtime type information</a>
is not permitted.</p></li>
<li><p><code>&lt;valarray&gt;</code> - May allocate, but is not
allocator-aware.</p></li>
<li><p>New string and character literals</p>
<ul>
<li>New character types (<a
@ -1881,8 +1953,43 @@ that developers should need to know about this feature. But if someone
does come up with a good use-case, it's likely that the alternatives are
significantly worse, because pack manipulation without this can be
complicated.</p></li>
<li><p><a
href="https://en.cppreference.com/w/cpp/header/tuple.html"><code>&lt;tuple&gt;</code></a>
— Prefer named access to class objects, rather than indexed access to
anonymous heterogeneous sequences. In particular, a standard-layout
class is preferred to a tuple.</p></li>
<li><p><code>std::invoke&lt;&gt;()</code> (<a
href="http://wg21.link/n4169">n4169</a>)</p></li>
<li><p><a
href="https://en.cppreference.com/w/cpp/header/chrono.html"><code>&lt;chrono&gt;</code></a>
— The argument for chrono is that our existing APIs aren't serving us
well. chrono provides strong type safety. We've had multiple cases of
mistakes like a double seconds being treated as double milliseconds or
vice versa, and other similar errors. But it would be a large effort to
adopt chrono. We'd also need to decide whether to use the predefined
clocks or hook up chrono to our clocks. It may be that using the
predefined clocks is fine, but it's a question that needs careful
study.</p></li>
<li><p><a
href="https://en.cppreference.com/w/cpp/header/initializer_list.html"><code>&lt;initializer_list&gt;</code></a>
— The potential ambiguity between some forms of direct initialization
and initializer list initialization, and the resolution of that
ambiguity, is unfortunate.</p></li>
<li><p><a
href="https://en.cppreference.com/w/cpp/header/ratio.html"><code>&lt;ratio&gt;</code></a>
<code>&lt;ratio&gt;</code> is a <em>compile-time</em> rational
arithmetic package. It's also fixed (though parameterized) precision.
It's not a general purpose rational arithmetic facility. It appears to
have started out as an implementation detail of chrono, and was
extracted and promoted to a public facility in the belief that it has
broader utility.</p></li>
<li><p><a
href="https://en.cppreference.com/w/cpp/header/system_error.html"><code>&lt;system_error&gt;</code></a>
— We don't really have a generally agreed upon mechanism for managing
errors. Instead, we have a plethora of bespoke ad hoc mechanisms.
Managing errors is a topic of substantial discussion.
<code>&lt;system_error&gt;</code> might end up being a part of a result
from that discussion.</p></li>
</ul>
</body>
</html>

View File

@ -413,12 +413,12 @@ support for more recent Standards must of course stick with the
original C++98/03 subset.)
This section describes that subset. Features from the C++98/03
language may be used unless explicitly excluded here. Features from
C++11, C++14, and C++17 may be explicitly permitted or explicitly excluded,
language may be used unless explicitly forbidden here. Features from
C++11, C++14, and C++17 may be explicitly permitted or explicitly forbidden,
and discussed accordingly here. There is a third category, undecided
features, about which HotSpot developers have not yet reached a
consensus, or perhaps have not discussed at all. Use of these
features is also excluded.
features is also forbidden.
(The use of some features may not be immediately obvious and may slip
in anyway, since the compiler will accept them. The code review
@ -427,7 +427,7 @@ process is the main defense against this.)
Some features are discussed in their own subsection, typically to provide
more extensive discussion or rationale for limitations. Features that
don't have their own subsection are listed in omnibus feature sections
for permitted, excluded, and undecided features.
for permitted, forbidden, and undecided features.
Lists of new features for C++11, C++14, and C++17, along with links to their
descriptions, can be found in the online documentation for some of the
@ -494,15 +494,16 @@ worthwhile, given the alternatives.
### Memory Allocation
Do not use the standard global allocation and deallocation functions
(operator new and related functions). Use of these functions by HotSpot
code is disabled for some platforms.
Do not use the standard global allocation and deallocation functions (global
`operator new` and related functions), other than the non-allocating forms of
those functions. Use of these functions by HotSpot code is disabled for some
platforms.
Rationale: HotSpot often uses "resource" or "arena" allocation. Even
where heap allocation is used, the standard global functions are
avoided in favor of wrappers around malloc and free that support the
VM's Native Memory Tracking (NMT) feature. Typically, uses of the global
operator new are inadvertent and therefore often associated with memory
avoided in favor of wrappers around `malloc` and `free` that support the
JVM's Native Memory Tracking (NMT) feature. Typically, uses of the global
`operator new` are inadvertent and therefore often associated with memory
leaks.
Native memory allocation failures are often treated as non-recoverable.
@ -560,7 +561,39 @@ Bug for similar gdb problems.
### C++ Standard Library
Avoid using the C++ Standard Library.
Only curated parts of the C++ Standard Library may be used by HotSpot code.
Functions that may throw exceptions must not be used. This is in accordance
with the HotSpot policy of [not using exceptions](#error-handling).
Also in accordance with HotSpot policy, the
[standard global allocator must not be used](#memory-allocation). This means
that uses of standard container classes cannot presently be used, as doing so
requires specialization on some allocator type that is integrated with the
existing HotSpot allocation mechanisms. (Such allocators may be provided in
the future.)
Standard Library identifiers should usually be fully qualified; `using`
directives must not be used to bring Standard Library identifiers into scope
just to remove the need for namespace qualification. Requiring qualification
makes it easy to distinguish between references to external libraries and code
that is part of HotSpot.
As with language features, Standard Library facilities are either permitted,
explicitly forbidden, or undecided (and so implicitly forbidden).
Most HotSpot code should not directly `#include` C++ Standard Library headers.
HotSpot provides a set of wrapper headers for the Standard Library headers
containing permitted definitions. These wrappers are in the `cppstdlib`
directory, with the same name as the corresponding Standard Library header and
a `.hpp` extension. These wrappers provide a place for any additional code
(some of which may be platform-specific) needed to support HotSpot usage.
These wrappers also provide a place to document HotSpot usage, including any
restrictions. The set of wrappers and the usage documentation should be
considered part of HotSpot style. Any changes are subject to the same process
as applies to this document. (For historical reasons, there may be many direct
inclusions of some C++ Standard Library headers.)
Historically, HotSpot has mostly avoided use of the Standard
Library.
@ -577,43 +610,59 @@ Some reasons for this include
Standard Library facilities is exceptions. HotSpot does not use
exceptions and, for platforms which allow doing so, builds with them
turned off. Many Standard Library facilities implicitly or explicitly
use exceptions. On the other hand, many don't, and can be used without
concern for this issue. Others may have a useful subset that doesn't
use exceptions.
* `assert`. An issue that is quickly encountered is the `assert` macro name
collision ([JDK-8007770](https://bugs.openjdk.org/browse/JDK-8007770)).
Some mechanism for addressing this would be needed before much of the
Standard Library could be used. (Not all Standard Library implementations
use assert in header files, but some do.)
(Not all Standard Library implementations use `assert` in header files, but
some do.) HotSpot provides a mechanism for addressing this, by establishing a
scope around the include of a library header where the HotSpot `assert` macro
is suppressed. One of the reasons for using wrapper headers rather than
directly including standard headers is to provide a central place to deal with
this issue for each header.
* Memory allocation. HotSpot requires explicit control over where
allocations occur. The C++98/03 `std::allocator` class is too limited
to support our usage. (Changes in more recent Standards may remove
this limitation.)
* Memory allocation. HotSpot requires explicit control over where allocations
occur. The C++98/03 `std::allocator` class is too limited to support our
usage. But changes to the allocator concept in more recent Standards removed
some of the limitations, supporting stateful allocators. HotSpot may, in the
future, provide standard-conforming allocators that are integrated with
HotSpot's existing allocation mechanisms.
* Implementation vagaries. Bugs, or simply different implementation choices,
can lead to different behaviors among the various Standard Libraries we need
to deal with.
to deal with. But only selected parts of the Standard Library are being
permitted, and one of the selection criteria is maturity. Some of these
facilities are among the most heavily tested and used C++ codes that exist.
* Inconsistent naming conventions. HotSpot and the C++ Standard use
different naming conventions. The coexistence of those different conventions
might appear jarring and reduce readability.
* Inconsistent naming conventions. HotSpot and the C++ Standard use different
naming conventions. The coexistence of those different conventions might
appear jarring and reduce readability. However, experience in some other code
bases suggests this isn't a significant problem, so long as Standard Library
names are namespace-qualified. It is tempting to bring the Standard Library
names into scope via a `using std;` directive. Doing so makes writing code
using those names easier, since the qualifiers don't need to be included. But
there are several reasons not to do that.
There are a few exceptions to this rule.
* There is a risk of future name collisions. Additional Standard Library
headers may be included, adding to the list of names being used. Also,
future versions of the Standard Library may add currently unknown names to
the headers already being included.
* `#include <new>` to use placement `new`, `std::nothrow`, and `std::nothrow_t`.
* `#include <limits>` to use `std::numeric_limits`.
* `#include <type_traits>` with some restrictions, listed below.
* `#include <cstddef>` to use `std::nullptr_t` and `std::max_align_t`.
* It may harm readability. Code where this is relevant is a mixture of the
local HotSpot naming conventions and the Standard Library's (or other
3rd-party library's) naming conventions. With only unqualified names, any
distinctions from the naming conventions for the different code sources
are lost. Instead one may end up with an undifferentiated mess, where it's
not obvious whether an identifier is from local code that is inconsistent
with HotSpot style (and there's a regretable amount of that for historical
reasons), or is following some other convention. Having the qualifiers
disambiguates that.
Certain restrictions apply to the declarations provided by `<type_traits>`.
* The `alignof` operator should be used rather than `std::alignment_of<>`.
TODO: Rather than directly \#including (permitted) Standard Library
headers, use a convention of \#including wrapper headers (in some
location like hotspot/shared/stdcpp). This provides a single place
for dealing with issues we might have for any given header, esp.
platform-specific issues.
* It can be helpful to know, at a glance, whether the definition is in
HotSpot or elsewhere, for purposes of looking up the definition or
documentation.
### Type Deduction
@ -1529,9 +1578,9 @@ single-argument form are permitted.
* Allow `typename` in template template parameter
([n4051](http://wg21.link/n4051)) &mdash; template template parameters are
barely used (if at all) in HotSpot, but there's no reason to artificially
disallow this syntactic regularization in any such uses.
forbid this syntactic regularization in any such uses.
## Excluded Features
## Forbidden Features
### Structured Bindings
@ -1581,7 +1630,32 @@ initialization for classes with base classes
aggregate classes, preferring explicit constructors even for very simple
classes.
### Additional Excluded Features
### Additional Forbidden Features
* `<algorithm>`, `<iterator>`, `<numeric>`<br>
Not useful without standard containers or similar classes in HotSpot.
* `<bitset>` - Overlap with HotSpot `BitMap`.
* `<cassert>`, `assert.h` - HotSpot has its own `assert` macro.
* `<exception>`, `<stdexcept>` - Use of [exceptions](#error-handling) is not
permitted.
* Thread support - `<thread>`, `<mutex>`, `<shared_mutex>`,
`<condition_varible>`, `<future>`<br>
HotSpot has its own threading support.
* Streams - HotSpot doesn't use the C++ I/O library.
* `<scoped_allocator>` - Not useful without specialized allocators.
* `<string>` - Requires allocator support, similar to standard containers.
* `<typeinfo>`, `<typeindex>`<br>
Use of [runtime type information](#runtime-type-information) is not permitted.
* `<valarray>` - May allocate, but is not allocator-aware.
* New string and character literals
* New character types
@ -1880,9 +1954,40 @@ should need to know about this feature. But if someone does come up with a
good use-case, it's likely that the alternatives are significantly worse,
because pack manipulation without this can be complicated.
* [`<tuple>`](https://en.cppreference.com/w/cpp/header/tuple.html) &mdash;
Prefer named access to class objects, rather than indexed access
to anonymous heterogeneous sequences. In particular, a standard-layout
class is preferred to a tuple.
* `std::invoke<>()`
([n4169](http://wg21.link/n4169))
* [`<chrono>`](https://en.cppreference.com/w/cpp/header/chrono.html) &mdash;
The argument for chrono is that our existing APIs aren't serving us well.
chrono provides strong type safety. We've had multiple cases of mistakes like
a double seconds being treated as double milliseconds or vice versa, and other
similar errors. But it would be a large effort to adopt chrono. We'd also need
to decide whether to use the predefined clocks or hook up chrono to our
clocks. It may be that using the predefined clocks is fine, but it's a
question that needs careful study.
* [`<initializer_list>`](https://en.cppreference.com/w/cpp/header/initializer_list.html) &mdash;
The potential ambiguity between some forms of direct initialization and
initializer list initialization, and the resolution of that ambiguity, is
unfortunate.
* [`<ratio>`](https://en.cppreference.com/w/cpp/header/ratio.html) &mdash;
`<ratio>` is a *compile-time* rational arithmetic package. It's also fixed
(though parameterized) precision. It's not a general purpose rational
arithmetic facility. It appears to have started out as an implementation
detail of chrono, and was extracted and promoted to a public facility in the
belief that it has broader utility.
* [`<system_error>`](https://en.cppreference.com/w/cpp/header/system_error.html) &mdash;
We don't really have a generally agreed upon mechanism for managing
errors. Instead, we have a plethora of bespoke ad hoc mechanisms. Managing
errors is a topic of substantial discussion. `<system_error>` might end up
being a part of a result from that discussion.
[ADL]: https://en.cppreference.com/w/cpp/language/adl

View File

@ -27,12 +27,12 @@
#define CPU_AARCH64_ASSEMBLER_AARCH64_HPP
#include "asm/register.hpp"
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/enableIf.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include <type_traits>
#ifdef __GNUC__

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@ -30,11 +30,11 @@
#include "asm/assembler.hpp"
#include "asm/register.hpp"
#include "code/codeCache.hpp"
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/enableIf.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include <type_traits>
#define XLEN 64

View File

@ -28,6 +28,7 @@
#include "code/vtableStubs.hpp"
#include "compiler/disassembler.hpp"
#include "compiler/oopMap.hpp"
#include "cppstdlib/type_traits.hpp"
#include "interpreter/bytecode.hpp"
#include "interpreter/interpreter.hpp"
#include "jvm.h"
@ -53,8 +54,6 @@
#include "c1/c1_Runtime1.hpp"
#endif
#include <type_traits>
// Virtual methods are not allowed in code blobs to simplify caching compiled code.
// Check all "leaf" subclasses of CodeBlob class.

View File

@ -26,6 +26,7 @@
#include "code/compiledIC.hpp"
#include "code/nmethod.hpp"
#include "code/relocInfo.hpp"
#include "cppstdlib/type_traits.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
#include "oops/compressedOops.inline.hpp"
@ -37,7 +38,6 @@
#include "utilities/copy.hpp"
#include <new>
#include <type_traits>
const RelocationHolder RelocationHolder::none; // its type is relocInfo::none

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_CPPSTDLIB_CSTDDEF_HPP
#define SHARE_CPPSTDLIB_CSTDDEF_HPP
#include "utilities/compilerWarnings.hpp"
// HotSpot usage for <cstddef>:
// permitted:
// * std::max_align_t, std::nullptr_t
// * size_t (preferred) and std::size_t
// * ptrdiff_t (preferred) and std::ptrdiff_t
// * offsetof
//
// forbidden:
// * <upcase>null</> macro - use nullptr instead.
// * std::byte
BEGIN_ALLOW_FORBIDDEN_FUNCTIONS
#include "utilities/vmassert_uninstall.hpp"
#include <cstddef>
#include "utilities/vmassert_reinstall.hpp" // don't reorder
END_ALLOW_FORBIDDEN_FUNCTIONS
#endif // SHARE_CPPSTDLIB_CSTDDEF_HPP

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_CPPSTDLIB_LIMITS_HPP
#define SHARE_CPPSTDLIB_LIMITS_HPP
#include "utilities/compilerWarnings.hpp"
// HotSpot usage for <limits>:
// No restrictions on the facilities in this header.
BEGIN_ALLOW_FORBIDDEN_FUNCTIONS
#include "utilities/vmassert_uninstall.hpp"
#include <limits>
#include "utilities/vmassert_reinstall.hpp" // don't reorder
END_ALLOW_FORBIDDEN_FUNCTIONS
#endif // SHARE_CPPSTDLIB_LIMITS_HPP

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_CPPSTDLIB_TYPE_TRAITS_HPP
#define SHARE_CPPSTDLIB_TYPE_TRAITS_HPP
#include "utilities/compilerWarnings.hpp"
// HotSpot usage for <type_traits>:
// * Use the `alignof` operator instead of `std::alignment_of<>`.
// * Do not use `std::aligned_storage<>` or `std::aligned_union<>`. These are
// deprecated in C++23, with the rationale that the `alignas` operator
// provides a better mechanism for accomplishing the same task.
//
// Other than the above, no restrictions on the facilities in this header.
BEGIN_ALLOW_FORBIDDEN_FUNCTIONS
#include "utilities/vmassert_uninstall.hpp"
#include <type_traits>
#include "utilities/vmassert_reinstall.hpp" // don't reorder
END_ALLOW_FORBIDDEN_FUNCTIONS
#endif // SHARE_CPPSTDLIB_TYPE_TRAITS_HPP

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,14 +25,13 @@
#ifndef SHARE_GC_SHARED_BUFFERNODE_HPP
#define SHARE_GC_SHARED_BUFFERNODE_HPP
#include "cppstdlib/limits.hpp"
#include "gc/shared/freeListAllocator.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/lockFreeStack.hpp"
#include "utilities/macros.hpp"
#include <limits>
class BufferNode {
using InternalSizeType = LP64_ONLY(uint32_t) NOT_LP64(uint16_t);
static_assert(sizeof(InternalSizeType) <= sizeof(size_t), "assumption");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,7 @@
#include "gc/shared/oopStorage.hpp"
#include "cppstdlib/type_traits.hpp"
#include "memory/allocation.hpp"
#include "oops/oop.hpp"
#include "runtime/safepoint.hpp"
@ -35,8 +36,6 @@
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
// Array of all active blocks. Refcounted for lock-free reclaim of
// old array when a new array is allocated for expansion.
class OopStorage::ActiveArray {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,11 +25,10 @@
#ifndef SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP
#define SHARE_GC_SHARED_OOPSTORAGEPARSTATE_HPP
#include "cppstdlib/type_traits.hpp"
#include "gc/shared/oopStorage.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
//////////////////////////////////////////////////////////////////////////////
// Support for parallel and optionally concurrent state iteration.
//

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,11 +27,10 @@
#include "gc/shared/oopStorageParState.hpp"
#include "cppstdlib/type_traits.hpp"
#include "gc/shared/oopStorage.inline.hpp"
#include "utilities/macros.hpp"
#include <type_traits>
template<typename F>
class OopStorage::BasicParState::AlwaysTrueFn {
F _f;

View File

@ -25,14 +25,13 @@
#ifndef SHARE_GC_SHARED_WORKERUTILS_HPP
#define SHARE_GC_SHARED_WORKERUTILS_HPP
#include "cppstdlib/type_traits.hpp"
#include "memory/allocation.hpp"
#include "metaprogramming/enableIf.hpp"
#include "runtime/mutex.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
// A class that acts as a synchronisation barrier. Workers enter
// the barrier and must wait until all other workers have entered
// before any of them may leave.

View File

@ -25,10 +25,9 @@
#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHSIMPLEBITMAP_HPP
#define SHARE_GC_SHENANDOAH_SHENANDOAHSIMPLEBITMAP_HPP
#include "cppstdlib/cstddef.hpp"
#include "gc/shenandoah/shenandoahAsserts.hpp"
#include <cstddef>
// TODO: Merge the enhanced capabilities of ShenandoahSimpleBitMap into src/hotspot/share/utilities/bitMap.hpp
// and deprecate ShenandoahSimpleBitMap. The key enhanced capabilities to be integrated include:
//

View File

@ -26,6 +26,7 @@
#include "gc/z/zAddress.hpp"
#include "cppstdlib/type_traits.hpp"
#include "gc/shared/gc_globals.hpp"
#include "gc/z/zGlobals.hpp"
#include "oops/oop.hpp"
@ -38,8 +39,6 @@
#include "utilities/powerOfTwo.hpp"
#include CPU_HEADER_INLINE(gc/z/zAddress)
#include <type_traits>
// Offset Operator Macro
// Creates operators for the offset, offset_end style types

View File

@ -24,14 +24,13 @@
#ifndef SHARE_GC_Z_ZARRAY_HPP
#define SHARE_GC_Z_ZARRAY_HPP
#include "cppstdlib/type_traits.hpp"
#include "memory/allocation.hpp"
#include "runtime/atomicAccess.hpp"
#include "runtime/os.hpp"
#include "runtime/thread.hpp"
#include "utilities/growableArray.hpp"
#include <type_traits>
template<typename T> class ZArray;
class ZLock;

View File

@ -27,8 +27,9 @@
#include "gc/z/zDeferredConstructed.hpp"
#include "cppstdlib/type_traits.hpp"
#include <new>
#include <type_traits>
template <typename T>
inline ZDeferredConstructed<T>::ZDeferredConstructed()

View File

@ -21,6 +21,7 @@
* questions.
*/
#include "cppstdlib/limits.hpp"
#include "gc/shared/gc_globals.hpp"
#include "gc/z/zCollectedHeap.hpp"
#include "gc/z/zDirector.hpp"
@ -32,8 +33,6 @@
#include "gc/z/zStat.hpp"
#include "logging/log.hpp"
#include <limits>
ZDirector* ZDirector::_director;
constexpr double one_in_1000 = 3.290527;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,12 +24,11 @@
#ifndef SHARE_GC_Z_ZFORWARDINGENTRY_HPP
#define SHARE_GC_Z_ZFORWARDINGENTRY_HPP
#include "cppstdlib/type_traits.hpp"
#include "gc/z/zBitField.hpp"
#include "memory/allocation.hpp"
#include "metaprogramming/primitiveConversions.hpp"
#include <type_traits>
//
// Forwarding entry layout
// -----------------------

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,11 +24,10 @@
#ifndef SHARE_GC_Z_ZINITIALIZE_HPP
#define SHARE_GC_Z_ZINITIALIZE_HPP
#include "cppstdlib/cstddef.hpp"
#include "memory/allStatic.hpp"
#include "utilities/compilerWarnings.hpp"
#include <cstddef>
class ZBarrierSet;
class ZInitializer {

View File

@ -26,10 +26,9 @@
#include "gc/z/zPageAge.hpp"
#include "cppstdlib/type_traits.hpp"
#include "utilities/checkedCast.hpp"
#include <type_traits>
inline uint untype(ZPageAge age) {
return static_cast<uint>(age);
}

View File

@ -26,14 +26,13 @@
#include "gc/z/zPageTable.hpp"
#include "cppstdlib/limits.hpp"
#include "gc/z/zAddress.inline.hpp"
#include "gc/z/zGranuleMap.inline.hpp"
#include "gc/z/zIndexDistributor.inline.hpp"
#include "gc/z/zPage.inline.hpp"
#include "gc/z/zPageAllocator.inline.hpp"
#include <limits>
inline int ZPageTable::count() const {
const size_t size = _map._size;
assert(size <= std::numeric_limits<int>::max(), "Invalid page table size");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,10 +24,9 @@
#ifndef SHARE_GC_Z_ZSAFEDELETE_HPP
#define SHARE_GC_Z_ZSAFEDELETE_HPP
#include "cppstdlib/type_traits.hpp"
#include "gc/z/zArray.hpp"
#include <type_traits>
template <typename T>
class ZSafeDelete {
private:

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,10 +26,9 @@
#include "gc/z/zSafeDelete.hpp"
#include "cppstdlib/type_traits.hpp"
#include "gc/z/zArray.inline.hpp"
#include <type_traits>
template <typename T>
ZSafeDelete<T>::ZSafeDelete(bool locked)
: _deferred(locked) {}

View File

@ -21,6 +21,7 @@
* questions.
*/
#include "cppstdlib/limits.hpp"
#include "gc/shared/gc_globals.hpp"
#include "gc/z/zAbort.inline.hpp"
#include "gc/z/zCollectedHeap.hpp"
@ -46,8 +47,6 @@
#include "utilities/debug.hpp"
#include "utilities/ticks.hpp"
#include <limits>
#define ZSIZE_FMT "%zuM(%.0f%%)"
#define ZSIZE_ARGS_WITH_MAX(size, max) ((size) / M), (percent_of(size, max))
#define ZSIZE_ARGS(size) ZSIZE_ARGS_WITH_MAX(size, ZStatHeap::max_capacity())

View File

@ -26,13 +26,12 @@
#define SHARE_MEMORY_METADATAFACTORY_HPP
#include "classfile/classLoaderData.hpp"
#include "cppstdlib/type_traits.hpp"
#include "memory/classLoaderMetaspace.hpp"
#include "oops/array.inline.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
class MetadataFactory : AllStatic {
public:
template <typename T>

View File

@ -26,12 +26,11 @@
#ifndef SHARE_MEMORY_METASPACE_COUNTERS_HPP
#define SHARE_MEMORY_METASPACE_COUNTERS_HPP
#include "cppstdlib/type_traits.hpp"
#include "runtime/atomicAccess.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
namespace metaspace {
// We seem to be counting a lot of things which makes it worthwhile to

View File

@ -25,6 +25,7 @@
#ifndef SHARE_MEMORY_METASPACECLOSURE_HPP
#define SHARE_MEMORY_METASPACECLOSURE_HPP
#include "cppstdlib/type_traits.hpp"
#include "logging/log.hpp"
#include "memory/allocation.hpp"
#include "metaprogramming/enableIf.hpp"
@ -35,8 +36,6 @@
#include "utilities/macros.hpp"
#include "utilities/resizableHashTable.hpp"
#include <type_traits>
// The metadata hierarchy is separate from the oop hierarchy
class MetaspaceObj; // no C++ vtable
//class Array; // no C++ vtable

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,7 +25,7 @@
#ifndef SHARE_METAPROGRAMMING_ENABLEIF_HPP
#define SHARE_METAPROGRAMMING_ENABLEIF_HPP
#include <type_traits>
#include "cppstdlib/type_traits.hpp"
// Retained temporarily for backward compatibility.
// For function template SFINAE, use the ENABLE_IF macro below.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,12 +25,11 @@
#ifndef SHARE_METAPROGRAMMING_PRIMITIVECONVERSIONS_HPP
#define SHARE_METAPROGRAMMING_PRIMITIVECONVERSIONS_HPP
#include "cppstdlib/type_traits.hpp"
#include "memory/allStatic.hpp"
#include "metaprogramming/enableIf.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
class PrimitiveConversions : public AllStatic {
// True if types are the same size and either is integral.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,10 +25,9 @@
#ifndef SHARE_NMT_ARRAYWITHFREELIST_HPP
#define SHARE_NMT_ARRAYWITHFREELIST_HPP
#include "cppstdlib/type_traits.hpp"
#include "utilities/growableArray.hpp"
#include <type_traits>
// A flat array of elements E, backed by C-heap, growing on-demand. It allows for
// returning arbitrary elements and keeps them in a freelist. Elements can be uniquely
// identified via array index.

View File

@ -25,12 +25,11 @@
#ifndef SHARE_NMT_NMTNATIVECALLSTACKSTORAGE_HPP
#define SHARE_NMT_NMTNATIVECALLSTACKSTORAGE_HPP
#include "cppstdlib/limits.hpp"
#include "nmt/arrayWithFreeList.hpp"
#include "utilities/growableArray.hpp"
#include "utilities/nativeCallStack.hpp"
#include <limits>
// Virtual memory regions that are tracked by NMT also have their NativeCallStack (NCS) tracked.
// NCS:s are:
// - Fairly large

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
#ifndef SHARE_OOPS_ACCESSBACKEND_HPP
#define SHARE_OOPS_ACCESSBACKEND_HPP
#include "cppstdlib/type_traits.hpp"
#include "gc/shared/barrierSetConfig.hpp"
#include "memory/allocation.hpp"
#include "metaprogramming/enableIf.hpp"
@ -34,8 +35,6 @@
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
// This metafunction returns either oop or narrowOop depending on whether
// an access needs to use compressed oops or not.
template <DecoratorSet decorators>

View File

@ -27,6 +27,7 @@
#include "oops/accessBackend.hpp"
#include "cppstdlib/type_traits.hpp"
#include "oops/access.hpp"
#include "oops/arrayOop.hpp"
#include "oops/compressedOops.inline.hpp"
@ -34,8 +35,6 @@
#include "runtime/atomicAccess.hpp"
#include "runtime/orderAccess.hpp"
#include <type_traits>
template <DecoratorSet decorators>
template <DecoratorSet idecorators, typename T>
inline typename EnableIf<

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,12 +25,11 @@
#ifndef SHARE_OOPS_ACCESSDECORATORS_HPP
#define SHARE_OOPS_ACCESSDECORATORS_HPP
#include "cppstdlib/type_traits.hpp"
#include "gc/shared/barrierSetConfig.hpp"
#include "memory/allStatic.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
// A decorator is an attribute or property that affects the way a memory access is performed in some way.
// There are different groups of decorators. Some have to do with memory ordering, others to do with,
// e.g. strength of references, strength of GC barriers, or whether compression should be applied or not.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,13 +25,12 @@
#ifndef SHARE_OOPS_COMPRESSEDOOPS_HPP
#define SHARE_OOPS_COMPRESSEDOOPS_HPP
#include "cppstdlib/type_traits.hpp"
#include "memory/allStatic.hpp"
#include "memory/memRegion.hpp"
#include "oops/oopsHierarchy.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
class outputStream;
class ReservedHeapSpace;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,10 +25,9 @@
#ifndef SHARE_OOPS_INSTANCEOOP_HPP
#define SHARE_OOPS_INSTANCEOOP_HPP
#include "cppstdlib/type_traits.hpp"
#include "oops/oop.hpp"
#include <type_traits>
// An instanceOop is an instance of a Java Class
// Evaluating "new HashTable()" will create an instanceOop.

View File

@ -25,13 +25,12 @@
#ifndef SHARE_OOPS_MARKWORD_HPP
#define SHARE_OOPS_MARKWORD_HPP
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/primitiveConversions.hpp"
#include "oops/compressedKlass.hpp"
#include "oops/oopsHierarchy.hpp"
#include "runtime/globals.hpp"
#include <type_traits>
// The markWord describes the header of an object.
//
// Bit-format of an object header (most significant first, big endian layout below):

View File

@ -25,11 +25,10 @@
#ifndef SHARE_OOPS_OBJARRAYOOP_HPP
#define SHARE_OOPS_OBJARRAYOOP_HPP
#include "cppstdlib/type_traits.hpp"
#include "oops/arrayOop.hpp"
#include "utilities/align.hpp"
#include <type_traits>
class Klass;
// An objArrayOop is an array containing oops.

View File

@ -25,6 +25,7 @@
#ifndef SHARE_OOPS_OOP_HPP
#define SHARE_OOPS_OOP_HPP
#include "cppstdlib/type_traits.hpp"
#include "memory/iterator.hpp"
#include "memory/memRegion.hpp"
#include "oops/accessDecorators.hpp"
@ -36,8 +37,6 @@
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include <type_traits>
// oopDesc is the top baseclass for objects classes. The {name}Desc classes describe
// the format of Java objects so the fields can be accessed from C++.
// oopDesc is abstract.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,11 +25,10 @@
#ifndef SHARE_OOPS_OOPHANDLE_HPP
#define SHARE_OOPS_OOPHANDLE_HPP
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/primitiveConversions.hpp"
#include "oops/oopsHierarchy.hpp"
#include <type_traits>
class OopStorage;
// Simple classes for wrapping oop and atomically accessed oop pointers

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,11 +25,10 @@
#ifndef SHARE_OOPS_OOPSHIERARCHY_HPP
#define SHARE_OOPS_OOPSHIERARCHY_HPP
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/primitiveConversions.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
// OBJECT hierarchy
// This hierarchy is a representation hierarchy, i.e. if A is a superclass
// of B, A's representation is a prefix of B's representation.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,11 +25,10 @@
#ifndef SHARE_OOPS_TYPEARRAYOOP_HPP
#define SHARE_OOPS_TYPEARRAYOOP_HPP
#include "cppstdlib/type_traits.hpp"
#include "oops/arrayOop.hpp"
#include "oops/typeArrayKlass.hpp"
#include <type_traits>
// A typeArrayOop is an array containing basic types (non oop elements).
// It is used for arrays of {characters, singles, doubles, bytes, shorts, integers, longs}
#include <limits.h>

View File

@ -25,10 +25,9 @@
#ifndef SHARE_OPTO_RANGEINFERENCE_HPP
#define SHARE_OPTO_RANGEINFERENCE_HPP
#include "cppstdlib/type_traits.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
class outputStream;
class Type;
class TypeInt;

View File

@ -31,6 +31,7 @@
#include "classfile/stringTable.hpp"
#include "classfile/symbolTable.hpp"
#include "compiler/compilerDefinitions.hpp"
#include "cppstdlib/limits.hpp"
#include "gc/shared/gc_globals.hpp"
#include "gc/shared/gcArguments.hpp"
#include "gc/shared/gcConfig.hpp"
@ -75,8 +76,6 @@
#include "jfr/jfr.hpp"
#endif
#include <limits>
static const char _default_java_launcher[] = "generic";
#define DEFAULT_JAVA_LAUNCHER _default_java_launcher

View File

@ -25,6 +25,7 @@
#ifndef SHARE_RUNTIME_ATOMICACCESS_HPP
#define SHARE_RUNTIME_ATOMICACCESS_HPP
#include "cppstdlib/type_traits.hpp"
#include "memory/allocation.hpp"
#include "metaprogramming/enableIf.hpp"
#include "metaprogramming/primitiveConversions.hpp"
@ -34,8 +35,6 @@
#include "utilities/checkedCast.hpp"
#include "utilities/macros.hpp"
#include <type_traits>
enum atomic_memory_order {
// The modes that align with C++11 are intended to
// follow the same semantics.

View File

@ -28,6 +28,7 @@
#include "code/nmethod.inline.hpp"
#include "code/vmreg.inline.hpp"
#include "compiler/oopMap.inline.hpp"
#include "cppstdlib/type_traits.hpp"
#include "gc/shared/barrierSet.hpp"
#include "gc/shared/continuationGCSupport.inline.hpp"
#include "gc/shared/gc_globals.hpp"
@ -74,8 +75,6 @@
#include "jfr/jfr.inline.hpp"
#endif
#include <type_traits>
/*
* This file contains the implementation of continuation freezing (yield) and thawing (run).
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,13 +25,12 @@
#ifndef SHARE_RUNTIME_FLAGS_JVMFLAG_HPP
#define SHARE_RUNTIME_FLAGS_JVMFLAG_HPP
#include "cppstdlib/type_traits.hpp"
#include "utilities/enumIterator.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include "utilities/vmEnums.hpp"
#include <type_traits>
class outputStream;
enum class JVMFlagOrigin : int {

View File

@ -24,6 +24,7 @@
*
*/
#include "cppstdlib/type_traits.hpp"
#include "memory/allocation.hpp"
#include "oops/markWord.hpp"
#include "oops/oop.inline.hpp"
@ -43,8 +44,6 @@
#include "utilities/ostream.hpp"
#include "utilities/sizes.hpp"
#include <type_traits>
const int LockStack::lock_stack_offset = in_bytes(JavaThread::lock_stack_offset());
const int LockStack::lock_stack_top_offset = in_bytes(JavaThread::lock_stack_top_offset());
const int LockStack::lock_stack_base_offset = in_bytes(JavaThread::lock_stack_base_offset());

View File

@ -22,13 +22,12 @@
*
*/
#include "cppstdlib/limits.hpp"
#include "jni.h"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/sharedRuntime.hpp"
#include "sanitizers/ub.hpp"
#include <limits>
// This file contains copies of the fdlibm routines used by
// StrictMath. It turns out that it is almost always required to use
// these runtime routines; the Intel CPU doesn't meet the Java

View File

@ -26,15 +26,13 @@
#define SHARE_SERVICES_DIAGNOSTICFRAMEWORK_HPP
#include "classfile/vmSymbols.hpp"
#include "cppstdlib/type_traits.hpp"
#include "memory/allocation.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/os.hpp"
#include "runtime/vmThread.hpp"
#include "utilities/ostream.hpp"
#include <type_traits>
enum DCmdSource {
DCmd_Source_Internal = 0x01U, // invocation from the JVM
DCmd_Source_AttachAPI = 0x02U, // invocation via the attachAPI

View File

@ -25,14 +25,13 @@
#ifndef SHARE_UTILITIES_ALIGN_HPP
#define SHARE_UTILITIES_ALIGN_HPP
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/enableIf.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/powerOfTwo.hpp"
#include <type_traits>
// Compute mask to use for aligning to or testing alignment.
// The alignment must be a power of 2. Returns alignment - 1, which is
// a mask with all bits set below alignment's single bit.

View File

@ -25,13 +25,13 @@
#ifndef SHARE_UTILITIES_BYTESWAP_HPP
#define SHARE_UTILITIES_BYTESWAP_HPP
#include "cppstdlib/cstddef.hpp"
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/enableIf.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/globalDefinitions.hpp"
#include <cstddef>
#include <cstdint>
#include <type_traits>
template <typename T, size_t N = sizeof(T)>
struct ByteswapImpl;

View File

@ -27,6 +27,7 @@
#include "utilities/concurrentHashTable.hpp"
#include "cppstdlib/type_traits.hpp"
#include "memory/allocation.inline.hpp"
#include "runtime/atomicAccess.hpp"
#include "runtime/orderAccess.hpp"
@ -37,8 +38,6 @@
#include "utilities/numberSeq.hpp"
#include "utilities/spinYield.hpp"
#include <type_traits>
// 2^30 = 1G buckets
#define SIZE_BIG_LOG2 30
// 2^2 = 4 buckets

View File

@ -25,10 +25,10 @@
#ifndef SHARE_UTILITIES_DEFERREDSTATIC_HPP
#define SHARE_UTILITIES_DEFERREDSTATIC_HPP
#include "cppstdlib/type_traits.hpp"
#include "utilities/globalDefinitions.hpp"
#include <new>
#include <type_traits>
// The purpose of this class is to provide control over the initialization
// time for an object of type T with static storage duration. An instance of

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,11 +28,10 @@
#include "utilities/devirtualizer.hpp"
#include "classfile/classLoaderData.hpp"
#include "cppstdlib/type_traits.hpp"
#include "oops/access.inline.hpp"
#include "utilities/debug.hpp"
#include <type_traits>
// Implementation of the non-virtual do_oop dispatch.
//
// The same implementation is used for do_metadata, do_klass, and do_cld.

View File

@ -25,14 +25,13 @@
#ifndef SHARE_UTILITIES_ENUMITERATOR_HPP
#define SHARE_UTILITIES_ENUMITERATOR_HPP
#include "cppstdlib/limits.hpp"
#include "cppstdlib/type_traits.hpp"
#include "memory/allStatic.hpp"
#include "metaprogramming/enableIf.hpp"
#include "metaprogramming/primitiveConversions.hpp"
#include "utilities/debug.hpp"
#include <limits>
#include <type_traits>
// Iteration support for enums.
//
// E is enum type, U is underlying type of E.

View File

@ -26,6 +26,9 @@
#define SHARE_UTILITIES_GLOBALDEFINITIONS_HPP
#include "classfile_constants.h"
#include "cppstdlib/cstddef.hpp"
#include "cppstdlib/limits.hpp"
#include "cppstdlib/type_traits.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/compilerWarnings.hpp"
#include "utilities/debug.hpp"
@ -34,10 +37,7 @@
#include COMPILER_HEADER(utilities/globalDefinitions)
#include <cstddef>
#include <cstdint>
#include <limits>
#include <type_traits>
class oopDesc;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,13 +25,12 @@
#ifndef SHARE_UTILITIES_HASHTABLE_HPP
#define SHARE_UTILITIES_HASHTABLE_HPP
#include "cppstdlib/type_traits.hpp"
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/numberSeq.hpp"
#include "utilities/tableStatistics.hpp"
#include <type_traits>
template<typename K, typename V>
class HashTableNode : public AnyObj {
public:

View File

@ -25,10 +25,9 @@
#ifndef SHARE_UTILITIES_INTN_T_HPP
#define SHARE_UTILITIES_INTN_T_HPP
#include "cppstdlib/limits.hpp"
#include "utilities/count_leading_zeros.hpp"
#include <limits>
template <unsigned int nbits>
class uintn_t;

View File

@ -25,11 +25,10 @@
#ifndef SHARE_UTILITIES_INTPOW_HPP
#define SHARE_UTILITIES_INTPOW_HPP
#include "cppstdlib/limits.hpp"
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/enableIf.hpp"
#include <limits>
#include <type_traits>
// Raise v to the power p mod 2**N, where N is the width of the type T.
template <typename T, ENABLE_IF(std::is_integral<T>::value && std::is_unsigned<T>::value)>
static constexpr T intpow(T v, unsigned p) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -26,13 +26,13 @@
#ifndef SHARE_UTILITIES_PARSE_INTEGER_HPP
#define SHARE_UTILITIES_PARSE_INTEGER_HPP
#include "cppstdlib/limits.hpp"
#include "metaprogramming/enableIf.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include <errno.h>
#include <limits>
#include <stdlib.h>
// *************************************************************************

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,13 +25,12 @@
#ifndef SHARE_UTILITIES_POPULATION_COUNT_HPP
#define SHARE_UTILITIES_POPULATION_COUNT_HPP
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/enableIf.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
// Returns the population count of x, i.e., the number of bits set in x.
//
// Adapted from Hacker's Delight, 2nd Edition, Figure 5-2 and the text that

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,15 +25,14 @@
#ifndef SHARE_UTILITIES_POWEROFTWO_HPP
#define SHARE_UTILITIES_POWEROFTWO_HPP
#include "cppstdlib/limits.hpp"
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/enableIf.hpp"
#include "utilities/count_leading_zeros.hpp"
#include "utilities/count_trailing_zeros.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include <limits>
#include <type_traits>
// Power of two convenience library.
template <typename T, ENABLE_IF(std::is_integral<T>::value)>

View File

@ -25,13 +25,12 @@
#ifndef SHARE_UTILITIES_RBTREE_HPP
#define SHARE_UTILITIES_RBTREE_HPP
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/enableIf.hpp"
#include "nmt/memTag.hpp"
#include "runtime/os.hpp"
#include "utilities/globalDefinitions.hpp"
#include <type_traits>
// An intrusive red-black tree is constructed with two template parameters:
// K is the key type used.
// COMPARATOR must have a static function `cmp(K a, const IntrusiveRBNode* b)` which returns:

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, Google and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -26,13 +26,13 @@
#ifndef SHARE_UTILITIES_REVERSE_BITS_HPP
#define SHARE_UTILITIES_REVERSE_BITS_HPP
#include "cppstdlib/cstddef.hpp"
#include "cppstdlib/type_traits.hpp"
#include "metaprogramming/enableIf.hpp"
#include "utilities/byteswap.hpp"
#include "utilities/globalDefinitions.hpp"
#include <cstddef>
#include <cstdint>
#include <type_traits>
template <typename T, size_t N = sizeof(T)>
struct ReverseBitsImpl;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,7 +25,7 @@
#ifndef SHARE_UTILITIES_TUPLE_HPP
#define SHARE_UTILITIES_TUPLE_HPP
#include <type_traits>
#include "cppstdlib/type_traits.hpp"
template <class... Ts>
class Tuple;