Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.
/ jdk20 Public archive

Commit 48f6127

Browse files
committed
8298376: ZGC: thaws stackChunk with stale oops
Backport-of: ed8a212
1 parent 22a6b59 commit 48f6127

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

src/hotspot/share/oops/stackChunkOop.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class stackChunkOopDesc : public instanceOopDesc {
9191
inline int max_thawing_size() const;
9292
inline void set_max_thawing_size(int value);
9393

94+
inline oop cont() const;
95+
template<typename P>
9496
inline oop cont() const;
9597
inline void set_cont(oop value);
9698
template<typename P>

src/hotspot/share/oops/stackChunkOop.inline.hpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,18 @@ inline void stackChunkOopDesc::set_max_thawing_size(int value) {
8686
jdk_internal_vm_StackChunk::set_maxThawingSize(this, (jint)value);
8787
}
8888

89-
inline oop stackChunkOopDesc::cont() const { return jdk_internal_vm_StackChunk::cont(as_oop()); }
89+
inline oop stackChunkOopDesc::cont() const { return UseCompressedOops ? cont<narrowOop>() : cont<oop>(); /* jdk_internal_vm_StackChunk::cont(as_oop()); */ }
90+
template<typename P>
91+
inline oop stackChunkOopDesc::cont() const {
92+
// The state of the cont oop is used by ZCollectedHeap::requires_barriers,
93+
// to determine the age of the stackChunkOopDesc. For that to work, it is
94+
// only the GC that is allowed to perform a load barrier on the oop.
95+
// This function is used by non-GC code and therfore create a stack-local
96+
// copy on the oop and perform the load barrier on that copy instead.
97+
oop obj = jdk_internal_vm_StackChunk::cont_raw<P>(as_oop());
98+
obj = (oop)NativeAccess<>::oop_load(&obj);
99+
return obj;
100+
}
90101
inline void stackChunkOopDesc::set_cont(oop value) { jdk_internal_vm_StackChunk::set_cont(this, value); }
91102
template<typename P>
92103
inline void stackChunkOopDesc::set_cont_raw(oop value) { jdk_internal_vm_StackChunk::set_cont_raw<P>(this, value); }

src/hotspot/share/runtime/continuationJavaClasses.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ class jdk_internal_vm_StackChunk: AllStatic {
124124
static inline void set_maxThawingSize(oop chunk, int value);
125125

126126
// cont oop's processing is essential for the chunk's GC protocol
127-
static inline oop cont(oop chunk);
127+
template<typename P>
128+
static inline oop cont_raw(oop chunk);
128129
static inline void set_cont(oop chunk, oop value);
129130
template<typename P>
130131
static inline void set_cont_raw(oop chunk, oop value);

src/hotspot/share/runtime/continuationJavaClasses.inline.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ inline void jdk_internal_vm_StackChunk::set_parent_access(oop chunk, oop value)
8181
chunk->obj_field_put_access<decorators>(_parent_offset, value);
8282
}
8383

84-
inline oop jdk_internal_vm_StackChunk::cont(oop chunk) {
85-
return chunk->obj_field(_cont_offset);
84+
template<typename P>
85+
inline oop jdk_internal_vm_StackChunk::cont_raw(oop chunk) {
86+
return (oop)RawAccess<>::oop_load(chunk->field_addr<P>(_cont_offset));
8687
}
8788

8889
inline void jdk_internal_vm_StackChunk::set_cont(oop chunk, oop value) {

0 commit comments

Comments
 (0)