Skip to content

Commit 3aa3724

Browse files
author
Datadog Syncup Service
committed
Merge branch 'upstream-master'
2 parents d656a48 + 6cff49c commit 3aa3724

File tree

24 files changed

+971
-115
lines changed

24 files changed

+971
-115
lines changed

src/hotspot/cpu/arm/stubDeclarations_arm.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
do_arch_blob, \
3131
do_arch_entry, \
3232
do_arch_entry_init) \
33-
do_arch_blob(preuniverse, 0) \
33+
do_arch_blob(preuniverse, 500) \
34+
do_stub(preuniverse, atomic_load_long) \
35+
do_arch_entry(Arm, preuniverse, atomic_load_long, \
36+
atomic_load_long_entry, atomic_load_long_entry) \
37+
do_stub(preuniverse, atomic_store_long) \
38+
do_arch_entry(Arm, preuniverse, atomic_store_long, \
39+
atomic_store_long_entry, atomic_store_long_entry) \
3440

3541

3642
#define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \
@@ -41,12 +47,6 @@
4147
do_stub(initial, idiv_irem) \
4248
do_arch_entry(Arm, initial, idiv_irem, \
4349
idiv_irem_entry, idiv_irem_entry) \
44-
do_stub(initial, atomic_load_long) \
45-
do_arch_entry(Arm, initial, atomic_load_long, \
46-
atomic_load_long_entry, atomic_load_long_entry) \
47-
do_stub(initial, atomic_store_long) \
48-
do_arch_entry(Arm, initial, atomic_store_long, \
49-
atomic_store_long_entry, atomic_store_long_entry) \
5050

5151
#define STUBGEN_CONTINUATION_BLOBS_ARCH_DO(do_stub, \
5252
do_arch_blob, \

src/hotspot/cpu/arm/stubGenerator_arm.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3127,7 +3127,14 @@ class StubGenerator: public StubCodeGenerator {
31273127
// Initialization
31283128

31293129
void generate_preuniverse_stubs() {
3130-
// preuniverse stubs are not needed for arm
3130+
// Atomics are used in universe initialization code (e.g. CDS relocation),
3131+
// therefore we need to generate real stubs very early on.
3132+
StubRoutines::_atomic_add_entry = generate_atomic_add();
3133+
StubRoutines::_atomic_xchg_entry = generate_atomic_xchg();
3134+
StubRoutines::_atomic_cmpxchg_entry = generate_atomic_cmpxchg();
3135+
StubRoutines::_atomic_cmpxchg_long_entry = generate_atomic_cmpxchg_long();
3136+
StubRoutines::Arm::_atomic_load_long_entry = generate_atomic_load_long();
3137+
StubRoutines::Arm::_atomic_store_long_entry = generate_atomic_store_long();
31313138
}
31323139

31333140
void generate_initial_stubs() {
@@ -3151,14 +3158,6 @@ class StubGenerator: public StubCodeGenerator {
31513158

31523159
// integer division used both by interpreter and compiler
31533160
StubRoutines::Arm::_idiv_irem_entry = generate_idiv_irem();
3154-
3155-
StubRoutines::_atomic_add_entry = generate_atomic_add();
3156-
StubRoutines::_atomic_xchg_entry = generate_atomic_xchg();
3157-
StubRoutines::_atomic_cmpxchg_entry = generate_atomic_cmpxchg();
3158-
StubRoutines::_atomic_cmpxchg_long_entry = generate_atomic_cmpxchg_long();
3159-
StubRoutines::Arm::_atomic_load_long_entry = generate_atomic_load_long();
3160-
StubRoutines::Arm::_atomic_store_long_entry = generate_atomic_store_long();
3161-
31623161
}
31633162

31643163
void generate_continuation_stubs() {

src/hotspot/cpu/riscv/nativeInst_riscv.cpp

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ class NativeFarCall: public NativeInstruction {
6060
address next_instruction_address() const { return addr_at(return_address_offset); }
6161
address return_address() const { return addr_at(return_address_offset); }
6262
address destination() const;
63-
address reloc_destination(address orig_address);
63+
address reloc_destination();
6464

6565
void set_destination(address dest);
6666
void verify();
6767
void print();
6868

69-
bool set_destination_mt_safe(address dest, bool assert_lock = true);
69+
bool set_destination_mt_safe(address dest);
7070
bool reloc_set_destination(address dest);
7171

7272
private:
@@ -88,28 +88,30 @@ address NativeFarCall::destination() const {
8888
address destination = MacroAssembler::target_addr_for_insn(addr);
8989

9090
CodeBlob* cb = CodeCache::find_blob(addr);
91-
assert(cb && cb->is_nmethod(), "sanity");
91+
assert(cb != nullptr && cb->is_nmethod(), "nmethod expected");
9292
nmethod *nm = (nmethod *)cb;
9393
assert(nm != nullptr, "Sanity");
9494
assert(nm->stub_contains(destination), "Sanity");
9595
assert(destination != nullptr, "Sanity");
9696
return stub_address_destination_at(destination);
9797
}
9898

99-
address NativeFarCall::reloc_destination(address orig_address) {
99+
address NativeFarCall::reloc_destination() {
100100
address call_addr = instruction_address();
101+
assert(NativeFarCall::is_at(call_addr), "unexpected code at call site");
101102

102103
CodeBlob *code = CodeCache::find_blob(call_addr);
103104
assert(code != nullptr, "Could not find the containing code blob");
104105

105106
address stub_addr = nullptr;
106-
if (code != nullptr && code->is_nmethod()) {
107-
stub_addr = trampoline_stub_Relocation::get_trampoline_for(call_addr, (nmethod*)code);
107+
if (code->is_nmethod()) {
108+
stub_addr = trampoline_stub_Relocation::get_trampoline_for(call_addr, code->as_nmethod());
108109
}
109110

110111
if (stub_addr != nullptr) {
111112
stub_addr = MacroAssembler::target_addr_for_insn(call_addr);
112113
}
114+
113115
return stub_addr;
114116
}
115117

@@ -128,18 +130,13 @@ void NativeFarCall::print() {
128130
tty->print_cr(PTR_FORMAT ": auipc,ld,jalr x1, offset/reg, ", p2i(addr_at(0)));
129131
}
130132

131-
bool NativeFarCall::set_destination_mt_safe(address dest, bool assert_lock) {
133+
bool NativeFarCall::set_destination_mt_safe(address dest) {
132134
assert(NativeFarCall::is_at(addr_at(0)), "unexpected code at call site");
133-
assert(!assert_lock ||
134-
(CodeCache_lock->is_locked() || SafepointSynchronize::is_at_safepoint()) ||
135+
assert((CodeCache_lock->is_locked() || SafepointSynchronize::is_at_safepoint()) ||
135136
CompiledICLocker::is_safe(addr_at(0)),
136137
"concurrent code patching");
137138

138-
address call_addr = addr_at(0);
139-
assert(NativeFarCall::is_at(call_addr), "unexpected code at call site");
140-
141139
address stub_addr = stub_address();
142-
143140
if (stub_addr != nullptr) {
144141
set_stub_address_destination_at(stub_addr, dest);
145142
return true;
@@ -156,10 +153,9 @@ bool NativeFarCall::reloc_set_destination(address dest) {
156153
assert(code != nullptr, "Could not find the containing code blob");
157154

158155
address stub_addr = nullptr;
159-
if (code != nullptr && code->is_nmethod()) {
160-
stub_addr = trampoline_stub_Relocation::get_trampoline_for(call_addr, (nmethod*)code);
156+
if (code->is_nmethod()) {
157+
stub_addr = trampoline_stub_Relocation::get_trampoline_for(call_addr, code->as_nmethod());
161158
}
162-
163159
if (stub_addr != nullptr) {
164160
MacroAssembler::pd_patch_instruction_size(call_addr, stub_addr);
165161
}
@@ -209,7 +205,7 @@ bool NativeFarCall::is_at(address addr) {
209205
(MacroAssembler::extract_rd(addr + instr_size) == x6) &&
210206
(MacroAssembler::extract_rs1(addr + instr_size) == x6) &&
211207
(MacroAssembler::extract_rs1(addr + 2 * instr_size) == x6) &&
212-
(MacroAssembler::extract_rd(addr + 2 * instr_size) == x1)) {
208+
(MacroAssembler::extract_rd(addr + 2 * instr_size) == x1)) {
213209
return true;
214210
}
215211
return false;
@@ -238,8 +234,8 @@ address NativeCall::destination() const {
238234
return NativeFarCall::at(addr_at(0))->destination();
239235
}
240236

241-
address NativeCall::reloc_destination(address orig_address) {
242-
return NativeFarCall::at(addr_at(0))->reloc_destination(orig_address);
237+
address NativeCall::reloc_destination() {
238+
return NativeFarCall::at(addr_at(0))->reloc_destination();
243239
}
244240

245241
void NativeCall::set_destination(address dest) {
@@ -254,8 +250,8 @@ void NativeCall::print() {
254250
NativeFarCall::at(addr_at(0))->print();;
255251
}
256252

257-
bool NativeCall::set_destination_mt_safe(address dest, bool assert_lock) {
258-
return NativeFarCall::at(addr_at(0))->set_destination_mt_safe(dest, assert_lock);
253+
bool NativeCall::set_destination_mt_safe(address dest) {
254+
return NativeFarCall::at(addr_at(0))->set_destination_mt_safe(dest);
259255
}
260256

261257
bool NativeCall::reloc_set_destination(address dest) {

src/hotspot/cpu/riscv/nativeInst_riscv.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ class NativeCall: private NativeInstruction {
134134
address next_instruction_address() const;
135135
address return_address() const;
136136
address destination() const;
137-
address reloc_destination(address orig_address);
137+
address reloc_destination();
138138

139139
void verify_alignment() {} // do nothing on riscv
140140
void verify();
141141
void print();
142142

143143
void set_destination(address dest);
144-
bool set_destination_mt_safe(address dest, bool assert_lock = true);
144+
bool set_destination_mt_safe(address dest);
145145
bool reloc_set_destination(address dest);
146146

147147
static bool is_at(address addr);

src/hotspot/cpu/riscv/relocInfo_riscv.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,12 @@ void Relocation::pd_set_data_value(address x, bool verify_only) {
7272
}
7373

7474
address Relocation::pd_call_destination(address orig_addr) {
75-
assert(is_call(), "should be an address instruction here");
75+
assert(is_call(), "should be a call here");
7676
if (NativeCall::is_at(addr())) {
77-
return nativeCall_at(addr())->reloc_destination(orig_addr);
77+
return nativeCall_at(addr())->reloc_destination();
7878
}
79-
// Non call reloc
79+
8080
if (orig_addr != nullptr) {
81-
// the extracted address from the instructions in address orig_addr
8281
address new_addr = MacroAssembler::pd_call_destination(orig_addr);
8382
// If call is branch to self, don't try to relocate it, just leave it
8483
// as branch to self. This happens during code generation if the code
@@ -87,20 +86,19 @@ address Relocation::pd_call_destination(address orig_addr) {
8786
new_addr = (new_addr == orig_addr) ? addr() : new_addr;
8887
return new_addr;
8988
}
89+
9090
return MacroAssembler::pd_call_destination(addr());
9191
}
9292

9393
void Relocation::pd_set_call_destination(address x) {
94-
assert(is_call(), "should be an address instruction here");
94+
assert(is_call(), "should be a call here");
9595
if (NativeCall::is_at(addr())) {
96-
NativeCall* nc = nativeCall_at(addr());
97-
if (nc->reloc_set_destination(x)) {
98-
return;
99-
}
96+
NativeCall* call = nativeCall_at(addr());
97+
call->reloc_set_destination(x);
98+
} else {
99+
MacroAssembler::pd_patch_instruction_size(addr(), x);
100+
assert(pd_call_destination(addr()) == x, "fail in reloc");
100101
}
101-
MacroAssembler::pd_patch_instruction_size(addr(), x);
102-
address pd_call = pd_call_destination(addr());
103-
assert(pd_call == x, "fail in reloc");
104102
}
105103

106104
address* Relocation::pd_address_in_code() {

src/hotspot/cpu/zero/stubGenerator_zero.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ class StubGenerator: public StubCodeGenerator {
180180

181181
void generate_preuniverse_stubs() {
182182
StubRoutines::_fence_entry = ShouldNotCallThisStub();
183+
StubRoutines::_atomic_xchg_entry = ShouldNotCallThisStub();
184+
StubRoutines::_atomic_cmpxchg_entry = ShouldNotCallThisStub();
185+
StubRoutines::_atomic_cmpxchg_long_entry = ShouldNotCallThisStub();
186+
StubRoutines::_atomic_add_entry = ShouldNotCallThisStub();
183187
}
184188

185189
void generate_initial_stubs() {
@@ -192,12 +196,6 @@ class StubGenerator: public StubCodeGenerator {
192196
StubRoutines::_forward_exception_entry = ShouldNotCallThisStub();
193197
StubRoutines::_call_stub_entry = (address) call_stub;
194198
StubRoutines::_catch_exception_entry = ShouldNotCallThisStub();
195-
196-
// atomic calls
197-
StubRoutines::_atomic_xchg_entry = ShouldNotCallThisStub();
198-
StubRoutines::_atomic_cmpxchg_entry = ShouldNotCallThisStub();
199-
StubRoutines::_atomic_cmpxchg_long_entry = ShouldNotCallThisStub();
200-
StubRoutines::_atomic_add_entry = ShouldNotCallThisStub();
201199
}
202200

203201
void generate_continuation_stubs() {

src/hotspot/share/gc/shared/parallelCleaning.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,6 @@ void KlassCleaningTask::work() {
128128
// All workers will help cleaning the classes,
129129
InstanceKlass* klass;
130130
while ((klass = claim_next_klass()) != nullptr) {
131-
clean_klass(klass);
131+
Klass::clean_weak_instanceklass_links(klass);
132132
}
133133
}

src/hotspot/share/gc/shared/parallelCleaning.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ class KlassCleaningTask : public StackObj {
6666

6767
public:
6868

69-
void clean_klass(InstanceKlass* ik) {
70-
ik->clean_weak_instanceklass_links();
71-
}
72-
7369
void work();
7470
};
7571

src/hotspot/share/oops/klass.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -749,17 +749,20 @@ void Klass::clean_weak_klass_links(bool unloading_occurred, bool clean_alive_kla
749749
// Clean the implementors list and method data.
750750
if (clean_alive_klasses && current->is_instance_klass()) {
751751
InstanceKlass* ik = InstanceKlass::cast(current);
752-
ik->clean_weak_instanceklass_links();
753-
754-
// JVMTI RedefineClasses creates previous versions that are not in
755-
// the class hierarchy, so process them here.
756-
while ((ik = ik->previous_versions()) != nullptr) {
757-
ik->clean_weak_instanceklass_links();
758-
}
752+
clean_weak_instanceklass_links(ik);
759753
}
760754
}
761755
}
762756

757+
void Klass::clean_weak_instanceklass_links(InstanceKlass* ik) {
758+
ik->clean_weak_instanceklass_links();
759+
// JVMTI RedefineClasses creates previous versions that are not in
760+
// the class hierarchy, so process them here.
761+
while ((ik = ik->previous_versions()) != nullptr) {
762+
ik->clean_weak_instanceklass_links();
763+
}
764+
}
765+
763766
void Klass::metaspace_pointers_do(MetaspaceClosure* it) {
764767
if (log_is_enabled(Trace, aot)) {
765768
ResourceMark rm;

src/hotspot/share/oops/klass.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,10 @@ class Klass : public Metadata {
734734

735735
void clean_subklass();
736736

737+
// Clean out unnecessary weak klass links from the whole klass hierarchy.
737738
static void clean_weak_klass_links(bool unloading_occurred, bool clean_alive_klasses = true);
739+
// Clean out unnecessary weak klass links from the given InstanceKlass.
740+
static void clean_weak_instanceklass_links(InstanceKlass* ik);
738741

739742
// Return self, except for abstract classes with exactly 1
740743
// implementor. Then return the 1 concrete implementation.

0 commit comments

Comments
 (0)