Skip to content

Commit 29cd004

Browse files
committed
Merge remote-tracking branch 'origin/master' into JDK-8358655-profile_taken_branch
2 parents c2d5ef3 + 9c3eaa4 commit 29cd004

File tree

302 files changed

+4814
-4813
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+4814
-4813
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ jobs:
310310
uses: ./.github/workflows/build-windows.yml
311311
with:
312312
platform: windows-x64
313-
msvc-toolset-version: '14.43'
313+
msvc-toolset-version: '14.44'
314314
msvc-toolset-architecture: 'x86.x64'
315315
configure-arguments: ${{ github.event.inputs.configure-arguments }}
316316
make-arguments: ${{ github.event.inputs.make-arguments }}
@@ -322,7 +322,7 @@ jobs:
322322
uses: ./.github/workflows/build-windows.yml
323323
with:
324324
platform: windows-aarch64
325-
msvc-toolset-version: '14.43'
325+
msvc-toolset-version: '14.44'
326326
msvc-toolset-architecture: 'arm64'
327327
make-target: 'hotspot'
328328
extra-conf-options: '--openjdk-target=aarch64-unknown-cygwin'

doc/hotspot-style.html

Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,17 @@ <h1 class="title">HotSpot Coding Style</h1>
7777
<li><a href="#thread_local" id="toc-thread_local">thread_local</a></li>
7878
<li><a href="#nullptr" id="toc-nullptr">nullptr</a></li>
7979
<li><a href="#atomic" id="toc-atomic">&lt;atomic&gt;</a></li>
80+
<li><a href="#initializing-variables-with-static-storage-duration"
81+
id="toc-initializing-variables-with-static-storage-duration">Initializing
82+
variables with static storage duration</a></li>
8083
<li><a href="#uniform-initialization"
8184
id="toc-uniform-initialization">Uniform Initialization</a></li>
8285
<li><a href="#local-function-objects"
8386
id="toc-local-function-objects">Local Function Objects</a></li>
8487
<li><a href="#inheriting-constructors"
8588
id="toc-inheriting-constructors">Inheriting constructors</a></li>
8689
<li><a href="#attributes" id="toc-attributes">Attributes</a></li>
90+
<li><a href="#noexcept" id="toc-noexcept">noexcept</a></li>
8791
<li><a href="#additional-permitted-features"
8892
id="toc-additional-permitted-features">Additional Permitted
8993
Features</a></li>
@@ -791,6 +795,33 @@ <h3 id="atomic">&lt;atomic&gt;</h3>
791795
"conservative" memory ordering, which may differ from (may be stronger
792796
than) sequentially consistent. There are algorithms in HotSpot that are
793797
believed to rely on that ordering.</p>
798+
<h3
799+
id="initializing-variables-with-static-storage-duration">Initializing
800+
variables with static storage duration</h3>
801+
<p>Variables with static storage duration and <em>dynamic
802+
initialization</em> <a
803+
href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf">C++14
804+
3.6.2</a>). should be avoided, unless an implementation is permitted to
805+
perform the initialization as a static initialization. The order in
806+
which dynamic initializations occur is incompletely specified.
807+
Initialization order problems can be difficult to deal with and lead to
808+
surprises.</p>
809+
<p>Variables with static storage duration and non-trivial destructors
810+
should be avoided. HotSpot doesn't generally try to cleanup on exit, and
811+
running destructors at exit can lead to problems.</p>
812+
<p>Some of the approaches used in HotSpot to avoid dynamic
813+
initialization include:</p>
814+
<ul>
815+
<li><p>Use the <code>Deferred&lt;T&gt;</code> class template. Add a call
816+
to its initialization function at an appropriate place during VM
817+
initialization. The underlying object is never destroyed.</p></li>
818+
<li><p>For objects of class type, use a variable whose value is a
819+
pointer to the class, initialized to <code>nullptr</code>. Provide an
820+
initialization function that sets the variable to a dynamically
821+
allocated object. Add a call to that function at an appropriate place
822+
during VM initialization. Such objects are usually never
823+
destroyed.</p></li>
824+
</ul>
794825
<h3 id="uniform-initialization">Uniform Initialization</h3>
795826
<p>The use of <em>uniform initialization</em> (<a
796827
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm">n2672</a>),
@@ -1110,6 +1141,58 @@ <h3 id="attributes">Attributes</h3>
11101141
<code>memory_order_consume</code>.</li>
11111142
<li><code>[[deprecated]]</code> - Not relevant in HotSpot code.</li>
11121143
</ul>
1144+
<h3 id="noexcept">noexcept</h3>
1145+
<p>Use of <code>noexcept</code> exception specifications (<a
1146+
href="http://wg21.link/n3050">n3050</a>) are permitted with restrictions
1147+
described below.</p>
1148+
<ul>
1149+
<li>Only the argument-less form of <code>noexcept</code> exception
1150+
specifications are permitted.</li>
1151+
<li>Allocation functions that may return <code>nullptr</code> to
1152+
indicate allocation failure must be declared <code>noexcept</code>.</li>
1153+
<li>All other uses of <code>noexcept</code> exception specifications are
1154+
forbidden.</li>
1155+
<li><code>noexcept</code> expressions are forbidden.</li>
1156+
<li>Dynamic exception specifications are forbidden.</li>
1157+
</ul>
1158+
<p>HotSpot is built with exceptions disabled, e.g. compile with
1159+
<code>-fno-exceptions</code> (gcc, clang) or no <code>/EH</code> option
1160+
(MSVC++). So why do we need to consider <code>noexcept</code> at all?
1161+
It's because <code>noexcept</code> exception specifications serve two
1162+
distinct purposes.</p>
1163+
<p>The first is to allow the compiler to avoid generating code or data
1164+
in support of exceptions being thrown by a function. But this is
1165+
unnecessary, because exceptions are disabled.</p>
1166+
<p>The second is to allow the compiler and library code to choose
1167+
different algorithms, depending on whether some function may throw
1168+
exceptions. This is only relevant to a certain set of functions.</p>
1169+
<ul>
1170+
<li><p>Some allocation functions (<code>operator new</code> and
1171+
<code>operator new[]</code>) return <code>nullptr</code> to indicate
1172+
allocation failure. If a <code>new</code> expression calls such an
1173+
allocation function, it must check for and handle that possibility.
1174+
Declaring such a function <code>noexcept</code> informs the compiler
1175+
that <code>nullptr</code> is a possible result. If an allocation
1176+
function is not declared <code>noexcept</code> then the compiler may
1177+
elide that checking and handling for a <code>new</code> expression
1178+
calling that function.</p></li>
1179+
<li><p>Certain Standard Library facilities (notably containers) provide
1180+
different guarantees for some operations (and may choose different
1181+
algorithms to implement those operations), depending on whether certain
1182+
functions (constructors, copy/move operations, swap) are nothrow or not.
1183+
They detect this using type traits that test whether a function is
1184+
declared <code>noexcept</code>. This can have a significant performance
1185+
impact if, for example, copying is chosen over a potentially throwing
1186+
move. But this isn't relevant, since HotSpot forbids the use of most
1187+
Standard Library facilities.</p></li>
1188+
</ul>
1189+
<p>HotSpot code can assume no exceptions will ever be thrown, even from
1190+
functions not declared <code>noexcept</code>. So HotSpot code doesn't
1191+
ever need to check, either with conditional exception specifications or
1192+
with <code>noexcept</code> expressions.</p>
1193+
<p>Dynamic exception specifications were deprecated in C++11. C++17
1194+
removed all but <code>throw()</code>, with that remaining a deprecated
1195+
equivalent to <code>noexcept</code>.</p>
11131196
<h3 id="additional-permitted-features">Additional Permitted
11141197
Features</h3>
11151198
<ul>
@@ -1198,12 +1281,6 @@ <h3 id="excluded-features">Excluded Features</h3>
11981281
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2179.html">n2179</a>)
11991282
— HotSpot does not permit the use of exceptions, so this feature isn't
12001283
useful.</p></li>
1201-
<li><p>Avoid non-local variables with non-constexpr initialization. In
1202-
particular, avoid variables with types requiring non-trivial
1203-
initialization or destruction. Initialization order problems can be
1204-
difficult to deal with and lead to surprises, as can destruction
1205-
ordering. HotSpot doesn't generally try to cleanup on exit, and running
1206-
destructors at exit can also lead to problems.</p></li>
12071284
<li><p>Avoid most operator overloading, preferring named functions. When
12081285
operator overloading is used, ensure the semantics conform to the normal
12091286
expected behavior of the operation.</p></li>

doc/hotspot-style.md

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,32 @@ ordering, which may differ from (may be stronger than) sequentially
770770
consistent. There are algorithms in HotSpot that are believed to rely
771771
on that ordering.
772772

773+
### Initializing variables with static storage duration
774+
775+
Variables with static storage duration and _dynamic initialization_
776+
[C++14 3.6.2](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf)).
777+
should be avoided, unless an implementation is permitted to perform the
778+
initialization as a static initialization. The order in which dynamic
779+
initializations occur is incompletely specified. Initialization order
780+
problems can be difficult to deal with and lead to surprises.
781+
782+
Variables with static storage duration and non-trivial destructors should be
783+
avoided. HotSpot doesn't generally try to cleanup on exit, and running
784+
destructors at exit can lead to problems.
785+
786+
Some of the approaches used in HotSpot to avoid dynamic initialization
787+
include:
788+
789+
* Use the `Deferred<T>` class template. Add a call to its initialization
790+
function at an appropriate place during VM initialization. The underlying
791+
object is never destroyed.
792+
793+
* For objects of class type, use a variable whose value is a pointer to the
794+
class, initialized to `nullptr`. Provide an initialization function that sets
795+
the variable to a dynamically allocated object. Add a call to that function at
796+
an appropriate place during VM initialization. Such objects are usually never
797+
destroyed.
798+
773799
### Uniform Initialization
774800

775801
The use of _uniform initialization_
@@ -1104,6 +1130,57 @@ The following attributes are expressly forbidden:
11041130
* `[[carries_dependency]]` - Related to `memory_order_consume`.
11051131
* `[[deprecated]]` - Not relevant in HotSpot code.
11061132
1133+
### noexcept
1134+
1135+
Use of `noexcept` exception specifications
1136+
([n3050](http://wg21.link/n3050))
1137+
are permitted with restrictions described below.
1138+
1139+
* Only the argument-less form of `noexcept` exception specifications are
1140+
permitted.
1141+
* Allocation functions that may return `nullptr` to indicate allocation
1142+
failure must be declared `noexcept`.
1143+
* All other uses of `noexcept` exception specifications are forbidden.
1144+
* `noexcept` expressions are forbidden.
1145+
* Dynamic exception specifications are forbidden.
1146+
1147+
HotSpot is built with exceptions disabled, e.g. compile with `-fno-exceptions`
1148+
(gcc, clang) or no `/EH` option (MSVC++). So why do we need to consider
1149+
`noexcept` at all? It's because `noexcept` exception specifications serve two
1150+
distinct purposes.
1151+
1152+
The first is to allow the compiler to avoid generating code or data in support
1153+
of exceptions being thrown by a function. But this is unnecessary, because
1154+
exceptions are disabled.
1155+
1156+
The second is to allow the compiler and library code to choose different
1157+
algorithms, depending on whether some function may throw exceptions. This is
1158+
only relevant to a certain set of functions.
1159+
1160+
* Some allocation functions (`operator new` and `operator new[]`) return
1161+
`nullptr` to indicate allocation failure. If a `new` expression calls such an
1162+
allocation function, it must check for and handle that possibility. Declaring
1163+
such a function `noexcept` informs the compiler that `nullptr` is a possible
1164+
result. If an allocation function is not declared `noexcept` then the compiler
1165+
may elide that checking and handling for a `new` expression calling that
1166+
function.
1167+
1168+
* Certain Standard Library facilities (notably containers) provide different
1169+
guarantees for some operations (and may choose different algorithms to
1170+
implement those operations), depending on whether certain functions
1171+
(constructors, copy/move operations, swap) are nothrow or not. They detect
1172+
this using type traits that test whether a function is declared `noexcept`.
1173+
This can have a significant performance impact if, for example, copying is
1174+
chosen over a potentially throwing move. But this isn't relevant, since
1175+
HotSpot forbids the use of most Standard Library facilities.
1176+
1177+
HotSpot code can assume no exceptions will ever be thrown, even from functions
1178+
not declared `noexcept`. So HotSpot code doesn't ever need to check, either
1179+
with conditional exception specifications or with `noexcept` expressions.
1180+
1181+
Dynamic exception specifications were deprecated in C++11. C++17 removed all
1182+
but `throw()`, with that remaining a deprecated equivalent to `noexcept`.
1183+
11071184
### Additional Permitted Features
11081185
11091186
* `alignof`
@@ -1199,13 +1276,6 @@ namespace std;` to avoid needing to qualify Standard Library names.
11991276
([n2179](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2179.html)) &mdash;
12001277
HotSpot does not permit the use of exceptions, so this feature isn't useful.
12011278
1202-
* Avoid non-local variables with non-constexpr initialization.
1203-
In particular, avoid variables with types requiring non-trivial
1204-
initialization or destruction. Initialization order problems can be
1205-
difficult to deal with and lead to surprises, as can destruction
1206-
ordering. HotSpot doesn't generally try to cleanup on exit, and
1207-
running destructors at exit can also lead to problems.
1208-
12091279
* Avoid most operator overloading, preferring named functions. When
12101280
operator overloading is used, ensure the semantics conform to the
12111281
normal expected behavior of the operation.

src/hotspot/cpu/aarch64/c1_globals_aarch64.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -43,15 +43,15 @@ define_pd_global(intx, CompileThreshold, 1500 );
4343

4444
define_pd_global(intx, OnStackReplacePercentage, 933 );
4545
define_pd_global(intx, NewSizeThreadIncrease, 4*K );
46-
define_pd_global(intx, InitialCodeCacheSize, 160*K);
47-
define_pd_global(intx, ReservedCodeCacheSize, 32*M );
48-
define_pd_global(intx, NonProfiledCodeHeapSize, 13*M );
49-
define_pd_global(intx, ProfiledCodeHeapSize, 14*M );
50-
define_pd_global(intx, NonNMethodCodeHeapSize, 5*M );
46+
define_pd_global(size_t, InitialCodeCacheSize, 160*K);
47+
define_pd_global(size_t, ReservedCodeCacheSize, 32*M );
48+
define_pd_global(size_t, NonProfiledCodeHeapSize, 13*M );
49+
define_pd_global(size_t, ProfiledCodeHeapSize, 14*M );
50+
define_pd_global(size_t, NonNMethodCodeHeapSize, 5*M );
5151
define_pd_global(bool, ProfileInterpreter, false);
52-
define_pd_global(intx, CodeCacheExpansionSize, 32*K );
53-
define_pd_global(uintx, CodeCacheMinBlockLength, 1);
54-
define_pd_global(uintx, CodeCacheMinimumUseSpace, 400*K);
52+
define_pd_global(size_t, CodeCacheExpansionSize, 32*K );
53+
define_pd_global(size_t, CodeCacheMinBlockLength, 1);
54+
define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K);
5555
define_pd_global(bool, NeverActAsServerClassMachine, true );
5656
define_pd_global(uint64_t,MaxRAM, 1ULL*G);
5757
define_pd_global(bool, CICompileOSR, true );

src/hotspot/cpu/aarch64/c2_globals_aarch64.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -51,8 +51,8 @@ define_pd_global(intx, NewSizeThreadIncrease, ScaleForWordSize(4*K));
5151
define_pd_global(intx, LoopUnrollLimit, 60);
5252
define_pd_global(intx, LoopPercentProfileLimit, 10);
5353
// InitialCodeCacheSize derived from specjbb2000 run.
54-
define_pd_global(intx, InitialCodeCacheSize, 2496*K); // Integral multiple of CodeCacheExpansionSize
55-
define_pd_global(intx, CodeCacheExpansionSize, 64*K);
54+
define_pd_global(size_t, InitialCodeCacheSize, 2496*K); // Integral multiple of CodeCacheExpansionSize
55+
define_pd_global(size_t, CodeCacheExpansionSize, 64*K);
5656

5757
// Ergonomics related flags
5858
define_pd_global(uint64_t,MaxRAM, 128ULL*G);
@@ -69,12 +69,12 @@ define_pd_global(bool, SuperWordLoopUnrollAnalysis, true);
6969
define_pd_global(uint, SuperWordStoreToLoadForwardingFailureDetection, 8);
7070
define_pd_global(bool, IdealizeClearArrayNode, true);
7171

72-
define_pd_global(intx, ReservedCodeCacheSize, 48*M);
73-
define_pd_global(intx, NonProfiledCodeHeapSize, 21*M);
74-
define_pd_global(intx, ProfiledCodeHeapSize, 22*M);
75-
define_pd_global(intx, NonNMethodCodeHeapSize, 5*M );
76-
define_pd_global(uintx, CodeCacheMinBlockLength, 6);
77-
define_pd_global(uintx, CodeCacheMinimumUseSpace, 400*K);
72+
define_pd_global(size_t, ReservedCodeCacheSize, 48*M);
73+
define_pd_global(size_t, NonProfiledCodeHeapSize, 21*M);
74+
define_pd_global(size_t, ProfiledCodeHeapSize, 22*M);
75+
define_pd_global(size_t, NonNMethodCodeHeapSize, 5*M );
76+
define_pd_global(size_t, CodeCacheMinBlockLength, 6);
77+
define_pd_global(size_t, CodeCacheMinimumUseSpace, 400*K);
7878

7979
// Ergonomics related flags
8080
define_pd_global(bool, NeverActAsServerClassMachine, false);

src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ void CompiledDirectCall::set_to_interpreted(const methodHandle& callee, address
9090
= nativeMovConstReg_at(stub + NativeInstruction::instruction_size);
9191

9292
#ifdef ASSERT
93-
NativeGeneralJump* jump = nativeGeneralJump_at(method_holder->next_instruction_address());
93+
NativeJump* jump = MacroAssembler::codestub_branch_needs_far_jump()
94+
? nativeGeneralJump_at(method_holder->next_instruction_address())
95+
: nativeJump_at(method_holder->next_instruction_address());
9496
verify_mt_safe(callee, entry, method_holder, jump);
9597
#endif
9698

9799
// Update stub.
98100
method_holder->set_data((intptr_t)callee());
99-
NativeGeneralJump::insert_unconditional(method_holder->next_instruction_address(), entry);
101+
MacroAssembler::pd_patch_instruction(method_holder->next_instruction_address(), entry);
100102
ICache::invalidate_range(stub, to_interp_stub_size());
101103
// Update jump to call.
102104
set_destination_mt_safe(stub);

src/hotspot/cpu/aarch64/globals_aarch64.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ define_pd_global(bool, UncommonNullCast, true); // Uncommon-trap nulls
3838

3939
define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_OR_JVMCI);
4040

41-
define_pd_global(uintx, CodeCacheSegmentSize, 64);
41+
define_pd_global(size_t, CodeCacheSegmentSize, 64);
4242
define_pd_global(intx, CodeEntryAlignment, 64);
4343
define_pd_global(intx, OptoLoopAlignment, 16);
4444

src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,11 +984,19 @@ void MacroAssembler::emit_static_call_stub() {
984984
mov_metadata(rmethod, nullptr);
985985

986986
// Jump to the entry point of the c2i stub.
987-
movptr(rscratch1, 0);
988-
br(rscratch1);
987+
if (codestub_branch_needs_far_jump()) {
988+
movptr(rscratch1, 0);
989+
br(rscratch1);
990+
} else {
991+
b(pc());
992+
}
989993
}
990994

991995
int MacroAssembler::static_call_stub_size() {
996+
if (!codestub_branch_needs_far_jump()) {
997+
// isb; movk; movz; movz; b
998+
return 5 * NativeInstruction::instruction_size;
999+
}
9921000
// isb; movk; movz; movz; movk; movz; movz; br
9931001
return 8 * NativeInstruction::instruction_size;
9941002
}

src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -386,18 +386,6 @@ void NativeJump::patch_verified_entry(address entry, address verified_entry, add
386386

387387
void NativeGeneralJump::verify() { }
388388

389-
void NativeGeneralJump::insert_unconditional(address code_pos, address entry) {
390-
NativeGeneralJump* n_jump = (NativeGeneralJump*)code_pos;
391-
392-
CodeBuffer cb(code_pos, instruction_size);
393-
MacroAssembler a(&cb);
394-
395-
a.movptr(rscratch1, (uintptr_t)entry);
396-
a.br(rscratch1);
397-
398-
ICache::invalidate_range(code_pos, instruction_size);
399-
}
400-
401389
// MT-safe patching of a long jump instruction.
402390
void NativeGeneralJump::replace_mt_safe(address instr_addr, address code_buffer) {
403391
ShouldNotCallThis();

src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2014, 2108, Red Hat Inc. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2014, 2025, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -383,7 +383,6 @@ class NativeGeneralJump: public NativeJump {
383383
address jump_destination() const;
384384
void set_jump_destination(address dest);
385385

386-
static void insert_unconditional(address code_pos, address entry);
387386
static void replace_mt_safe(address instr_addr, address code_buffer);
388387
static void verify();
389388
};

0 commit comments

Comments
 (0)