mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-10 21:50:07 +00:00
8235762: JVM crash in SWPointer during C2 compilation
Reviewed-by: thartmann, chagedorn, neliasso
This commit is contained in:
parent
b95d34698e
commit
e3eb6dbd1f
@ -576,12 +576,13 @@ void SuperWord::find_adjacent_refs() {
|
||||
}
|
||||
|
||||
Node_List align_to_refs;
|
||||
int max_idx;
|
||||
int best_iv_adjustment = 0;
|
||||
MemNode* best_align_to_mem_ref = NULL;
|
||||
|
||||
while (memops.size() != 0) {
|
||||
// Find a memory reference to align to.
|
||||
MemNode* mem_ref = find_align_to_ref(memops);
|
||||
MemNode* mem_ref = find_align_to_ref(memops, max_idx);
|
||||
if (mem_ref == NULL) break;
|
||||
align_to_refs.push(mem_ref);
|
||||
int iv_adjustment = get_iv_adjustment(mem_ref);
|
||||
@ -699,34 +700,40 @@ void SuperWord::find_adjacent_refs() {
|
||||
// Put memory ops from remaining packs back on memops list for
|
||||
// the best alignment search.
|
||||
uint orig_msize = memops.size();
|
||||
if (_packset.length() == 1 && orig_msize == 0) {
|
||||
// If there are no remaining memory ops and only 1 pack we have only one choice
|
||||
// for the alignment
|
||||
Node_List* p = _packset.at(0);
|
||||
assert(p->size() > 0, "sanity");
|
||||
for (int i = 0; i < _packset.length(); i++) {
|
||||
Node_List* p = _packset.at(i);
|
||||
MemNode* s = p->at(0)->as_Mem();
|
||||
assert(!same_velt_type(s, mem_ref), "sanity");
|
||||
best_align_to_mem_ref = s;
|
||||
} else {
|
||||
for (int i = 0; i < _packset.length(); i++) {
|
||||
Node_List* p = _packset.at(i);
|
||||
MemNode* s = p->at(0)->as_Mem();
|
||||
assert(!same_velt_type(s, mem_ref), "sanity");
|
||||
memops.push(s);
|
||||
}
|
||||
best_align_to_mem_ref = find_align_to_ref(memops);
|
||||
if (best_align_to_mem_ref == NULL) {
|
||||
if (TraceSuperWord) {
|
||||
tty->print_cr("SuperWord::find_adjacent_refs(): best_align_to_mem_ref == NULL");
|
||||
}
|
||||
break;
|
||||
}
|
||||
best_iv_adjustment = get_iv_adjustment(best_align_to_mem_ref);
|
||||
NOT_PRODUCT(find_adjacent_refs_trace_1(best_align_to_mem_ref, best_iv_adjustment);)
|
||||
// Restore list.
|
||||
while (memops.size() > orig_msize)
|
||||
(void)memops.pop();
|
||||
memops.push(s);
|
||||
}
|
||||
best_align_to_mem_ref = find_align_to_ref(memops, max_idx);
|
||||
if (best_align_to_mem_ref == NULL) {
|
||||
if (TraceSuperWord) {
|
||||
tty->print_cr("SuperWord::find_adjacent_refs(): best_align_to_mem_ref == NULL");
|
||||
}
|
||||
// best_align_to_mem_ref will be used for adjusting the pre-loop limit in
|
||||
// SuperWord::align_initial_loop_index. Find one with the biggest vector size,
|
||||
// smallest data size and smallest iv offset from memory ops from remaining packs.
|
||||
if (_packset.length() > 0) {
|
||||
if (orig_msize == 0) {
|
||||
best_align_to_mem_ref = memops.at(max_idx)->as_Mem();
|
||||
} else {
|
||||
for (uint i = 0; i < orig_msize; i++) {
|
||||
memops.remove(0);
|
||||
}
|
||||
best_align_to_mem_ref = find_align_to_ref(memops, max_idx);
|
||||
assert(best_align_to_mem_ref == NULL, "sanity");
|
||||
best_align_to_mem_ref = memops.at(max_idx)->as_Mem();
|
||||
}
|
||||
assert(best_align_to_mem_ref != NULL, "sanity");
|
||||
}
|
||||
break;
|
||||
}
|
||||
best_iv_adjustment = get_iv_adjustment(best_align_to_mem_ref);
|
||||
NOT_PRODUCT(find_adjacent_refs_trace_1(best_align_to_mem_ref, best_iv_adjustment);)
|
||||
// Restore list.
|
||||
while (memops.size() > orig_msize)
|
||||
(void)memops.pop();
|
||||
}
|
||||
} // unaligned memory accesses
|
||||
|
||||
@ -761,7 +768,7 @@ void SuperWord::find_adjacent_refs_trace_1(Node* best_align_to_mem_ref, int best
|
||||
// Find a memory reference to align the loop induction variable to.
|
||||
// Looks first at stores then at loads, looking for a memory reference
|
||||
// with the largest number of references similar to it.
|
||||
MemNode* SuperWord::find_align_to_ref(Node_List &memops) {
|
||||
MemNode* SuperWord::find_align_to_ref(Node_List &memops, int &idx) {
|
||||
GrowableArray<int> cmp_ct(arena(), memops.size(), memops.size(), 0);
|
||||
|
||||
// Count number of comparable memory ops
|
||||
@ -848,6 +855,7 @@ MemNode* SuperWord::find_align_to_ref(Node_List &memops) {
|
||||
}
|
||||
#endif
|
||||
|
||||
idx = max_idx;
|
||||
if (max_ct > 0) {
|
||||
#ifdef ASSERT
|
||||
if (TraceSuperWord) {
|
||||
|
||||
@ -408,7 +408,7 @@ class SuperWord : public ResourceObj {
|
||||
void print_loop(bool whole);
|
||||
#endif
|
||||
// Find a memory reference to align the loop induction variable to.
|
||||
MemNode* find_align_to_ref(Node_List &memops);
|
||||
MemNode* find_align_to_ref(Node_List &memops, int &idx);
|
||||
// Calculate loop's iv adjustment for this memory ops.
|
||||
int get_iv_adjustment(MemNode* mem);
|
||||
// Can the preloop align the reference to position zero in the vector?
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Huawei Technologies Co. Ltd. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8235762
|
||||
* @summary JVM crash in SWPointer during C2 compilation
|
||||
*
|
||||
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement
|
||||
-XX:CompileCommand=compileonly,compiler.loopopts.superword.TestSearchAlignment::vMeth
|
||||
* compiler.loopopts.superword.TestSearchAlignment
|
||||
*/
|
||||
|
||||
package compiler.loopopts.superword;
|
||||
|
||||
public class TestSearchAlignment {
|
||||
|
||||
public static final int N = 400;
|
||||
public static byte bArr[] = new byte[N];
|
||||
public static int iArr[] = new int[N];
|
||||
public static long lArr[] = new long[N];
|
||||
|
||||
public static void vMeth(byte bArg, int iArg, long lArg) {
|
||||
int i = N - 1;
|
||||
do {
|
||||
iArr[i - 1] += iArg;
|
||||
iArr[i] += iArg;
|
||||
lArr[i - 1] = lArg;
|
||||
bArr[i - 1] = bArg;
|
||||
} while (--i > 0);
|
||||
}
|
||||
|
||||
public void mainTest() {
|
||||
byte b = 0;
|
||||
int i = 0;
|
||||
long l = 0;
|
||||
for (int j = 0; j < N; ++j) {
|
||||
vMeth(b, i, l);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestSearchAlignment _instance = new TestSearchAlignment();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
_instance.mainTest();
|
||||
}
|
||||
System.out.println("Test passed.");
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user