Skip to content

Commit cefe9b2

Browse files
authored
Merge branch 'master' into JDK-8351566
2 parents 5e55757 + c6ab63d commit cefe9b2

File tree

242 files changed

+5358
-5397
lines changed

Some content is hidden

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

242 files changed

+5358
-5397
lines changed

doc/hotspot-style.html

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ <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"
@@ -791,6 +794,33 @@ <h3 id="atomic">&lt;atomic&gt;</h3>
791794
"conservative" memory ordering, which may differ from (may be stronger
792795
than) sequentially consistent. There are algorithms in HotSpot that are
793796
believed to rely on that ordering.</p>
797+
<h3
798+
id="initializing-variables-with-static-storage-duration">Initializing
799+
variables with static storage duration</h3>
800+
<p>Variables with static storage duration and <em>dynamic
801+
initialization</em> <a
802+
href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf">C++14
803+
3.6.2</a>). should be avoided, unless an implementation is permitted to
804+
perform the initialization as a static initialization. The order in
805+
which dynamic initializations occur is incompletely specified.
806+
Initialization order problems can be difficult to deal with and lead to
807+
surprises.</p>
808+
<p>Variables with static storage duration and non-trivial destructors
809+
should be avoided. HotSpot doesn't generally try to cleanup on exit, and
810+
running destructors at exit can lead to problems.</p>
811+
<p>Some of the approaches used in HotSpot to avoid dynamic
812+
initialization include:</p>
813+
<ul>
814+
<li><p>Use the <code>Deferred&lt;T&gt;</code> class template. Add a call
815+
to its initialization function at an appropriate place during VM
816+
initialization. The underlying object is never destroyed.</p></li>
817+
<li><p>For objects of class type, use a variable whose value is a
818+
pointer to the class, initialized to <code>nullptr</code>. Provide an
819+
initialization function that sets the variable to a dynamically
820+
allocated object. Add a call to that function at an appropriate place
821+
during VM initialization. Such objects are usually never
822+
destroyed.</p></li>
823+
</ul>
794824
<h3 id="uniform-initialization">Uniform Initialization</h3>
795825
<p>The use of <em>uniform initialization</em> (<a
796826
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm">n2672</a>),
@@ -1198,12 +1228,6 @@ <h3 id="excluded-features">Excluded Features</h3>
11981228
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2179.html">n2179</a>)
11991229
— HotSpot does not permit the use of exceptions, so this feature isn't
12001230
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>
12071231
<li><p>Avoid most operator overloading, preferring named functions. When
12081232
operator overloading is used, ensure the semantics conform to the normal
12091233
expected behavior of the operation.</p></li>

doc/hotspot-style.md

Lines changed: 26 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_
@@ -1199,13 +1225,6 @@ namespace std;` to avoid needing to qualify Standard Library names.
11991225
([n2179](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2179.html)) &mdash;
12001226
HotSpot does not permit the use of exceptions, so this feature isn't useful.
12011227
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-
12091228
* Avoid most operator overloading, preferring named functions. When
12101229
operator overloading is used, ensure the semantics conform to the
12111230
normal expected behavior of the operation.

make/test/JtregNativeJdk.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ BUILD_JDK_JTREG_LIBRARIES_JDK_LIBS_libGetXSpace := java.base:libjava
6262
ifeq ($(call isTargetOs, windows), true)
6363
BUILD_JDK_JTREG_EXCLUDE += libDirectIO.c libInheritedChannel.c \
6464
libExplicitAttach.c libImplicitAttach.c \
65-
exelauncher.c
65+
exelauncher.c libFDLeaker.c exeFDLeakTester.c
6666

6767
BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeNullCallerTest := $(LIBCXX)
6868
BUILD_JDK_JTREG_EXECUTABLES_LIBS_exerevokeall := advapi32.lib

src/hotspot/cpu/aarch64/aarch64.ad

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1888,7 +1888,7 @@ void MachEpilogNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
18881888
code_stub = &stub->entry();
18891889
}
18901890
__ relocate(relocInfo::poll_return_type);
1891-
__ safepoint_poll(*code_stub, true /* at_return */, false /* acquire */, true /* in_nmethod */);
1891+
__ safepoint_poll(*code_stub, true /* at_return */, true /* in_nmethod */);
18921892
}
18931893
}
18941894

src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ void LIR_Assembler::return_op(LIR_Opr result, C1SafepointPollStub* code_stub) {
483483

484484
code_stub->set_safepoint_offset(__ offset());
485485
__ relocate(relocInfo::poll_return_type);
486-
__ safepoint_poll(*code_stub->entry(), true /* at_return */, false /* acquire */, true /* in_nmethod */);
486+
__ safepoint_poll(*code_stub->entry(), true /* at_return */, true /* in_nmethod */);
487487
__ ret(lr);
488488
}
489489

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/downcallLinker_aarch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ void DowncallLinker::StubGenerator::generate() {
289289

290290
__ verify_sve_vector_length(tmp1);
291291

292-
__ safepoint_poll(L_safepoint_poll_slow_path, true /* at_return */, true /* acquire */, false /* in_nmethod */, tmp1);
292+
__ safepoint_poll(L_safepoint_poll_slow_path, true /* at_return */, false /* in_nmethod */, tmp1);
293293

294294
__ ldrw(tmp1, Address(rthread, JavaThread::suspend_flags_offset()));
295295
__ cbnzw(tmp1, L_safepoint_poll_slow_path);

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

0 commit comments

Comments
 (0)