Skip to content

Commit 9b3b41f

Browse files
authored
Merge pull request #2005 from SAP/pr-jdk-26+4
Merge to tag jdk-26+4
2 parents 70d20e7 + 1ca008f commit 9b3b41f

File tree

358 files changed

+5033
-3080
lines changed

Some content is hidden

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

358 files changed

+5033
-3080
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ jobs:
317317
uses: ./.github/workflows/build-windows.yml
318318
with:
319319
platform: windows-x64
320-
msvc-toolset-version: '14.43'
320+
msvc-toolset-version: '14.44'
321321
msvc-toolset-architecture: 'x86.x64'
322322
configure-arguments: ${{ github.event.inputs.configure-arguments }}
323323
make-arguments: ${{ github.event.inputs.make-arguments }}
@@ -329,7 +329,7 @@ jobs:
329329
uses: ./.github/workflows/build-windows.yml
330330
with:
331331
platform: windows-aarch64
332-
msvc-toolset-version: '14.43'
332+
msvc-toolset-version: '14.44'
333333
msvc-toolset-architecture: 'arm64'
334334
make-target: 'hotspot'
335335
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/aarch64.ad

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,10 +1765,6 @@ void MachPrologNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
17651765
// n.b. frame size includes space for return pc and rfp
17661766
const int framesize = C->output()->frame_size_in_bytes();
17671767

1768-
// insert a nop at the start of the prolog so we can patch in a
1769-
// branch if we need to invalidate the method later
1770-
__ nop();
1771-
17721768
if (C->clinit_barrier_on_entry()) {
17731769
assert(!C->method()->holder()->is_not_initialized(), "initialization should have been started");
17741770

src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,31 +1016,16 @@ void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) {
10161016
}
10171017

10181018

1019-
void InterpreterMacroAssembler::profile_taken_branch(Register mdp,
1020-
Register bumped_count) {
1019+
void InterpreterMacroAssembler::profile_taken_branch(Register mdp) {
10211020
if (ProfileInterpreter) {
10221021
Label profile_continue;
10231022

10241023
// If no method data exists, go to profile_continue.
1025-
// Otherwise, assign to mdp
10261024
test_method_data_pointer(mdp, profile_continue);
10271025

10281026
// We are taking a branch. Increment the taken count.
1029-
// We inline increment_mdp_data_at to return bumped_count in a register
1030-
//increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
1031-
Address data(mdp, in_bytes(JumpData::taken_offset()));
1032-
ldr(bumped_count, data);
1033-
assert(DataLayout::counter_increment == 1,
1034-
"flow-free idiom only works with 1");
1035-
// Intel does this to catch overflow
1036-
// addptr(bumped_count, DataLayout::counter_increment);
1037-
// sbbptr(bumped_count, 0);
1038-
// so we do this
1039-
adds(bumped_count, bumped_count, DataLayout::counter_increment);
1040-
Label L;
1041-
br(Assembler::CS, L); // skip store if counter overflow
1042-
str(bumped_count, data);
1043-
bind(L);
1027+
increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset()));
1028+
10441029
// The method data pointer needs to be updated to reflect the new target.
10451030
update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset()));
10461031
bind(profile_continue);
@@ -1055,7 +1040,7 @@ void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) {
10551040
// If no method data exists, go to profile_continue.
10561041
test_method_data_pointer(mdp, profile_continue);
10571042

1058-
// We are taking a branch. Increment the not taken count.
1043+
// We are not taking a branch. Increment the not taken count.
10591044
increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset()));
10601045

10611046
// The method data pointer needs to be updated to correspond to

src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class InterpreterMacroAssembler: public MacroAssembler {
276276
// narrow int return value
277277
void narrow(Register result);
278278

279-
void profile_taken_branch(Register mdp, Register bumped_count);
279+
void profile_taken_branch(Register mdp);
280280
void profile_not_taken_branch(Register mdp);
281281
void profile_call(Register mdp);
282282
void profile_final_call(Register mdp);

src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,6 @@ void NativeMovRegMem::verify() {
212212

213213
void NativeJump::verify() { ; }
214214

215-
216-
void NativeJump::check_verified_entry_alignment(address entry, address verified_entry) {
217-
}
218-
219-
220215
address NativeJump::jump_destination() const {
221216
address dest = MacroAssembler::target_addr_for_insn_or_null(instruction_address());
222217

@@ -345,10 +340,6 @@ bool NativeInstruction::is_movk() {
345340
return Instruction_aarch64::extract(int_at(0), 30, 23) == 0b11100101;
346341
}
347342

348-
bool NativeInstruction::is_sigill_not_entrant() {
349-
return uint_at(0) == 0xd4bbd5a1; // dcps1 #0xdead
350-
}
351-
352343
void NativeIllegalInstruction::insert(address code_pos) {
353344
*(juint*)code_pos = 0xd4bbd5a1; // dcps1 #0xdead
354345
}
@@ -359,31 +350,6 @@ bool NativeInstruction::is_stop() {
359350

360351
//-------------------------------------------------------------------
361352

362-
// MT-safe inserting of a jump over a jump or a nop (used by
363-
// nmethod::make_not_entrant)
364-
365-
void NativeJump::patch_verified_entry(address entry, address verified_entry, address dest) {
366-
367-
assert(dest == SharedRuntime::get_handle_wrong_method_stub(), "expected fixed destination of patch");
368-
assert(nativeInstruction_at(verified_entry)->is_jump_or_nop()
369-
|| nativeInstruction_at(verified_entry)->is_sigill_not_entrant(),
370-
"Aarch64 cannot replace non-jump with jump");
371-
372-
// Patch this nmethod atomically.
373-
if (Assembler::reachable_from_branch_at(verified_entry, dest)) {
374-
ptrdiff_t disp = dest - verified_entry;
375-
guarantee(disp < 1 << 27 && disp > - (1 << 27), "branch overflow");
376-
377-
unsigned int insn = (0b000101 << 26) | ((disp >> 2) & 0x3ffffff);
378-
*(unsigned int*)verified_entry = insn;
379-
} else {
380-
// We use an illegal instruction for marking a method as not_entrant.
381-
NativeIllegalInstruction::insert(verified_entry);
382-
}
383-
384-
ICache::invalidate_range(verified_entry, instruction_size);
385-
}
386-
387353
void NativeGeneralJump::verify() { }
388354

389355
// MT-safe patching of a long jump instruction.

src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ class NativeInstruction {
8383
bool is_safepoint_poll();
8484
bool is_movz();
8585
bool is_movk();
86-
bool is_sigill_not_entrant();
8786
bool is_stop();
8887

8988
protected:
@@ -360,9 +359,6 @@ class NativeJump: public NativeInstruction {
360359

361360
// Insertion of native jump instruction
362361
static void insert(address code_pos, address entry);
363-
// MT-safe insertion of native jump at verified method entry
364-
static void check_verified_entry_alignment(address entry, address verified_entry);
365-
static void patch_verified_entry(address entry, address verified_entry, address dest);
366362
};
367363

368364
inline NativeJump* nativeJump_at(address address) {

0 commit comments

Comments
 (0)