8270461: ZGC: Invalid oop passed to ZBarrierSetRuntime::load_barrier_on_oop_array

Reviewed-by: chagedorn, kvn
This commit is contained in:
Tobias Hartmann
2021-07-22 05:59:12 +00:00
parent 89f7998aa7
commit 4119a52c4b
3 changed files with 19 additions and 6 deletions

View File

@@ -296,6 +296,18 @@ void ZBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* a
Node* dest_offset = ac->in(ArrayCopyNode::DestPos);
Node* length = ac->in(ArrayCopyNode::Length);
if (bt == T_OBJECT) {
// BarrierSetC2::clone sets the offsets via BarrierSetC2::arraycopy_payload_base_offset
// which 8-byte aligns them to allow for word size copies. Make sure the offsets point
// to the first element in the array when cloning object arrays. Otherwise, load
// barriers are applied to parts of the header.
assert(src_offset == dest_offset, "should be equal");
assert((src_offset->get_long() == arrayOopDesc::base_offset_in_bytes(T_OBJECT) && UseCompressedClassPointers) ||
(src_offset->get_long() == arrayOopDesc::length_offset_in_bytes() && !UseCompressedClassPointers),
"unexpected offset for object array clone");
src_offset = phase->longcon(arrayOopDesc::base_offset_in_bytes(T_OBJECT));
dest_offset = src_offset;
}
Node* payload_src = phase->basic_plus_adr(src, src_offset);
Node* payload_dst = phase->basic_plus_adr(dest, dest_offset);

View File

@@ -307,8 +307,8 @@ address PhaseMacroExpand::basictype2arraycopy(BasicType t,
bool disjoint_bases,
const char* &name,
bool dest_uninitialized) {
const TypeInt* src_offset_inttype = _igvn.find_int_type(src_offset);;
const TypeInt* dest_offset_inttype = _igvn.find_int_type(dest_offset);;
const TypeInt* src_offset_inttype = _igvn.find_int_type(src_offset);
const TypeInt* dest_offset_inttype = _igvn.find_int_type(dest_offset);
bool aligned = false;
bool disjoint = disjoint_bases;

View File

@@ -23,14 +23,15 @@
/*
* @test
* @bug 8155643
* @summary Test Object.clone() intrinsic if ReduceInitialCardMarks is disabled.
* @bug 8155643 8268125 8270461
* @summary Test Object.clone() intrinsic.
*
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-ReduceInitialCardMarks
* -XX:CompileCommand=compileonly,compiler.arraycopy.TestObjectArrayClone::testClone*
* compiler.arraycopy.TestObjectArrayClone
*
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions
* @run main/othervm -XX:CompileCommand=compileonly,compiler.arraycopy.TestObjectArrayClone::testClone*
* compiler.arraycopy.TestObjectArrayClone
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedClassPointers -Xmx128m
* -XX:CompileCommand=compileonly,compiler.arraycopy.TestObjectArrayClone::testClone*
* compiler.arraycopy.TestObjectArrayClone
*/