Skip to content

Commit 1c3177e

Browse files
committed
8315029: [BACKOUT] Generational ZGC: Tests crash with assert(index == 0 || is_power_of_2(index))
Reviewed-by: chagedorn, mdoerr
1 parent dd23f7d commit 1c3177e

File tree

5 files changed

+26
-107
lines changed

5 files changed

+26
-107
lines changed

src/hotspot/share/gc/shared/c2/barrierSetC2.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -675,15 +675,8 @@ void BarrierSetC2::clone(GraphKit* kit, Node* src_base, Node* dst_base, Node* si
675675
Node* payload_size = size;
676676
Node* offset = kit->MakeConX(base_off);
677677
payload_size = kit->gvn().transform(new SubXNode(payload_size, offset));
678-
if (is_array) {
679-
// Ensure the array payload size is rounded up to the next BytesPerLong
680-
// multiple when converting to double-words. This is necessary because array
681-
// size does not include object alignment padding, so it might not be a
682-
// multiple of BytesPerLong for sub-long element types.
683-
payload_size = kit->gvn().transform(new AddXNode(payload_size, kit->MakeConX(BytesPerLong - 1)));
684-
}
685678
payload_size = kit->gvn().transform(new URShiftXNode(payload_size, kit->intcon(LogBytesPerLong)));
686-
ArrayCopyNode* ac = ArrayCopyNode::make(kit, false, src_base, offset, dst_base, offset, payload_size, true, false);
679+
ArrayCopyNode* ac = ArrayCopyNode::make(kit, false, src_base, offset, dst_base, offset, payload_size, true, false);
687680
if (is_array) {
688681
ac->set_clone_array();
689682
} else {

src/hotspot/share/opto/graphKit.cpp

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,10 +3728,7 @@ Node* GraphKit::new_instance(Node* klass_node,
37283728
//-------------------------------new_array-------------------------------------
37293729
// helper for both newarray and anewarray
37303730
// The 'length' parameter is (obviously) the length of the array.
3731-
// The optional arguments are for specialized use by intrinsics:
3732-
// - If 'return_size_val', report the non-padded array size (sum of header size
3733-
// and array body) to the caller.
3734-
// - deoptimize_on_exception controls how Java exceptions are handled (rethrow vs deoptimize)
3731+
// See comments on new_instance for the meaning of the other arguments.
37353732
Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable)
37363733
Node* length, // number of array elements
37373734
int nargs, // number of arguments to push back for uncommon trap
@@ -3782,21 +3779,25 @@ Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable)
37823779
// The rounding mask is strength-reduced, if possible.
37833780
int round_mask = MinObjAlignmentInBytes - 1;
37843781
Node* header_size = nullptr;
3782+
int header_size_min = arrayOopDesc::base_offset_in_bytes(T_BYTE);
37853783
// (T_BYTE has the weakest alignment and size restrictions...)
37863784
if (layout_is_con) {
37873785
int hsize = Klass::layout_helper_header_size(layout_con);
37883786
int eshift = Klass::layout_helper_log2_element_size(layout_con);
3787+
BasicType etype = Klass::layout_helper_element_type(layout_con);
37893788
if ((round_mask & ~right_n_bits(eshift)) == 0)
37903789
round_mask = 0; // strength-reduce it if it goes away completely
37913790
assert((hsize & right_n_bits(eshift)) == 0, "hsize is pre-rounded");
3792-
int header_size_min = arrayOopDesc::base_offset_in_bytes(T_BYTE);
37933791
assert(header_size_min <= hsize, "generic minimum is smallest");
3794-
header_size = intcon(hsize);
3792+
header_size_min = hsize;
3793+
header_size = intcon(hsize + round_mask);
37953794
} else {
37963795
Node* hss = intcon(Klass::_lh_header_size_shift);
37973796
Node* hsm = intcon(Klass::_lh_header_size_mask);
3798-
header_size = _gvn.transform(new URShiftINode(layout_val, hss));
3799-
header_size = _gvn.transform(new AndINode(header_size, hsm));
3797+
Node* hsize = _gvn.transform( new URShiftINode(layout_val, hss) );
3798+
hsize = _gvn.transform( new AndINode(hsize, hsm) );
3799+
Node* mask = intcon(round_mask);
3800+
header_size = _gvn.transform( new AddINode(hsize, mask) );
38003801
}
38013802

38023803
Node* elem_shift = nullptr;
@@ -3848,29 +3849,24 @@ Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable)
38483849
}
38493850
#endif
38503851

3851-
// Combine header size and body size for the array copy part, then align (if
3852-
// necessary) for the allocation part. This computation cannot overflow,
3853-
// because it is used only in two places, one where the length is sharply
3854-
// limited, and the other after a successful allocation.
3852+
// Combine header size (plus rounding) and body size. Then round down.
3853+
// This computation cannot overflow, because it is used only in two
3854+
// places, one where the length is sharply limited, and the other
3855+
// after a successful allocation.
38553856
Node* abody = lengthx;
3856-
if (elem_shift != nullptr) {
3857-
abody = _gvn.transform(new LShiftXNode(lengthx, elem_shift));
3857+
if (elem_shift != nullptr)
3858+
abody = _gvn.transform( new LShiftXNode(lengthx, elem_shift) );
3859+
Node* size = _gvn.transform( new AddXNode(headerx, abody) );
3860+
if (round_mask != 0) {
3861+
Node* mask = MakeConX(~round_mask);
3862+
size = _gvn.transform( new AndXNode(size, mask) );
38583863
}
3859-
Node* non_rounded_size = _gvn.transform(new AddXNode(headerx, abody));
3864+
// else if round_mask == 0, the size computation is self-rounding
38603865

38613866
if (return_size_val != nullptr) {
38623867
// This is the size
3863-
(*return_size_val) = non_rounded_size;
3864-
}
3865-
3866-
Node* size = non_rounded_size;
3867-
if (round_mask != 0) {
3868-
Node* mask1 = MakeConX(round_mask);
3869-
size = _gvn.transform(new AddXNode(size, mask1));
3870-
Node* mask2 = MakeConX(~round_mask);
3871-
size = _gvn.transform(new AndXNode(size, mask2));
3868+
(*return_size_val) = size;
38723869
}
3873-
// else if round_mask == 0, the size computation is self-rounding
38743870

38753871
// Now generate allocation code
38763872

src/hotspot/share/opto/library_call.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5021,8 +5021,8 @@ bool LibraryCallKit::inline_native_clone(bool is_virtual) {
50215021
PreserveJVMState pjvms(this);
50225022
set_control(array_ctl);
50235023
Node* obj_length = load_array_length(obj);
5024-
Node* array_size = nullptr; // Size of the array without object alignment padding.
5025-
Node* alloc_obj = new_array(obj_klass, obj_length, 0, &array_size, /*deoptimize_on_exception=*/true);
5024+
Node* obj_size = nullptr;
5025+
Node* alloc_obj = new_array(obj_klass, obj_length, 0, &obj_size, /*deoptimize_on_exception=*/true);
50265026

50275027
BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
50285028
if (bs->array_copy_requires_gc_barriers(true, T_OBJECT, true, false, BarrierSetC2::Parsing)) {
@@ -5055,7 +5055,7 @@ bool LibraryCallKit::inline_native_clone(bool is_virtual) {
50555055
// the object.)
50565056

50575057
if (!stopped()) {
5058-
copy_to_clone(obj, alloc_obj, array_size, true);
5058+
copy_to_clone(obj, alloc_obj, obj_size, true);
50595059

50605060
// Present the results of the copy.
50615061
result_reg->init_req(_array_path, control());
@@ -5095,7 +5095,7 @@ bool LibraryCallKit::inline_native_clone(bool is_virtual) {
50955095
if (!stopped()) {
50965096
// It's an instance, and it passed the slow-path tests.
50975097
PreserveJVMState pjvms(this);
5098-
Node* obj_size = nullptr; // Total object size, including object alignment padding.
5098+
Node* obj_size = nullptr;
50995099
// Need to deoptimize on exception from allocation since Object.clone intrinsic
51005100
// is reexecuted if deoptimization occurs and there could be problems when merging
51015101
// exception state between multiple Object.clone versions (reexecute=true vs reexecute=false).

test/hotspot/jtreg/compiler/gcbarriers/TestArrayCopyWithLargeObjectAlignment.java

Lines changed: 0 additions & 69 deletions
This file was deleted.

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java 8151492 generic-
478478
java/lang/invoke/LFCaching/LFGarbageCollectedTest.java 8078602 generic-all
479479
java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 8249079 linux-x64
480480
java/lang/invoke/RicochetTest.java 8251969 generic-all
481-
java/lang/template/StringTemplateTest.java 8315029 generic-all
482481

483482
############################################################################
484483

0 commit comments

Comments
 (0)