8298376: ZGC: thaws stackChunk with stale oops

Backport-of: ed8a2120ca1e9756c6ab5eeebfe24c15d549f04e
This commit is contained in:
Stefan Karlsson 2022-12-15 11:44:21 +00:00
parent 22a6b59102
commit 48f6127325
4 changed files with 19 additions and 4 deletions

@ -91,6 +91,8 @@ public:
inline int max_thawing_size() const;
inline void set_max_thawing_size(int value);
inline oop cont() const;
template<typename P>
inline oop cont() const;
inline void set_cont(oop value);
template<typename P>

@ -86,7 +86,18 @@ inline void stackChunkOopDesc::set_max_thawing_size(int value) {
jdk_internal_vm_StackChunk::set_maxThawingSize(this, (jint)value);
}
inline oop stackChunkOopDesc::cont() const { return jdk_internal_vm_StackChunk::cont(as_oop()); }
inline oop stackChunkOopDesc::cont() const { return UseCompressedOops ? cont<narrowOop>() : cont<oop>(); /* jdk_internal_vm_StackChunk::cont(as_oop()); */ }
template<typename P>
inline oop stackChunkOopDesc::cont() const {
// The state of the cont oop is used by ZCollectedHeap::requires_barriers,
// to determine the age of the stackChunkOopDesc. For that to work, it is
// only the GC that is allowed to perform a load barrier on the oop.
// This function is used by non-GC code and therfore create a stack-local
// copy on the oop and perform the load barrier on that copy instead.
oop obj = jdk_internal_vm_StackChunk::cont_raw<P>(as_oop());
obj = (oop)NativeAccess<>::oop_load(&obj);
return obj;
}
inline void stackChunkOopDesc::set_cont(oop value) { jdk_internal_vm_StackChunk::set_cont(this, value); }
template<typename P>
inline void stackChunkOopDesc::set_cont_raw(oop value) { jdk_internal_vm_StackChunk::set_cont_raw<P>(this, value); }

@ -124,7 +124,8 @@ class jdk_internal_vm_StackChunk: AllStatic {
static inline void set_maxThawingSize(oop chunk, int value);
// cont oop's processing is essential for the chunk's GC protocol
static inline oop cont(oop chunk);
template<typename P>
static inline oop cont_raw(oop chunk);
static inline void set_cont(oop chunk, oop value);
template<typename P>
static inline void set_cont_raw(oop chunk, oop value);

@ -81,8 +81,9 @@ inline void jdk_internal_vm_StackChunk::set_parent_access(oop chunk, oop value)
chunk->obj_field_put_access<decorators>(_parent_offset, value);
}
inline oop jdk_internal_vm_StackChunk::cont(oop chunk) {
return chunk->obj_field(_cont_offset);
template<typename P>
inline oop jdk_internal_vm_StackChunk::cont_raw(oop chunk) {
return (oop)RawAccess<>::oop_load(chunk->field_addr<P>(_cont_offset));
}
inline void jdk_internal_vm_StackChunk::set_cont(oop chunk, oop value) {