Skip to content

Commit 75d4844

Browse files
author
duke
committed
Backport cd61f97c2de94d19c0101c51bde143001078c89f
1 parent ec24039 commit 75d4844

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

src/hotspot/share/opto/gcm.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,20 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) {
648648
// The anti-dependence constraints apply only to the fringe of this tree.
649649

650650
Node* initial_mem = load->in(MemNode::Memory);
651+
// We don't optimize the memory graph for pinned loads, so we may need to raise the
652+
// root of our search tree through the corresponding slices of MergeMem nodes to
653+
// get to the node that really creates the memory state for this slice.
654+
if (load_alias_idx >= Compile::AliasIdxRaw) {
655+
while (initial_mem->is_MergeMem()) {
656+
MergeMemNode* mm = initial_mem->as_MergeMem();
657+
Node* p = mm->memory_at(load_alias_idx);
658+
if (p != mm->base_memory()) {
659+
initial_mem = p;
660+
} else {
661+
break;
662+
}
663+
}
664+
}
651665
worklist_store.push(initial_mem);
652666
worklist_visited.push(initial_mem);
653667
worklist_mem.push(nullptr);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/**
25+
* @test
26+
* @bug 8337066
27+
* @summary Test that MergeMem is skipped when looking for stores
28+
* @run main/othervm -Xbatch -XX:-TieredCompilation
29+
* -XX:CompileCommand=compileonly,java.lang.StringUTF16::reverse
30+
* compiler.controldependency.TestAntiDependencyForPinnedLoads
31+
*/
32+
33+
package compiler.controldependency;
34+
35+
public class TestAntiDependencyForPinnedLoads {
36+
public static void main(String[] args) {
37+
for(int i = 0; i < 50_000; i++) {
38+
String str = "YYYY年MM月DD日";
39+
StringBuffer strBuffer = new StringBuffer(str);
40+
String revStr = strBuffer.reverse().toString();
41+
if (!revStr.equals("日DD月MM年YYYY")) throw new InternalError("FAIL");
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)