Skip to content

Commit

Permalink
8296243: [IR Framework] Fix issues with IRNode.ALLOC* regexes
Browse files Browse the repository at this point in the history
Reviewed-by: mdoerr, thartmann
  • Loading branch information
chhagedorn committed Nov 14, 2022
1 parent 8eb90e2 commit 34d10f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
19 changes: 9 additions & 10 deletions test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java
Expand Up @@ -167,27 +167,25 @@ public class IRNode {

public static final String ALLOC = PREFIX + "ALLOC" + POSTFIX;
static {
String idealIndependentRegex = START + "Allocate" + MID + END;
String optoRegex = "(.*precise .*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END;
allocNodes(ALLOC, idealIndependentRegex, optoRegex);
String optoRegex = "(.*precise .*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END;
allocNodes(ALLOC, "Allocate", optoRegex);
}

public static final String ALLOC_OF = COMPOSITE_PREFIX + "ALLOC_OF" + POSTFIX;
static {
String regex = "(.*precise .*" + IS_REPLACED + ":.*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END;
String regex = "(.*precise .*" + IS_REPLACED + ":.*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END;
optoOnly(ALLOC_OF, regex);
}

public static final String ALLOC_ARRAY = PREFIX + "ALLOC_ARRAY" + POSTFIX;
static {
String idealIndependentRegex = START + "AllocateArray" + MID + END;
String optoRegex = "(.*precise \\[.*\\R((.*(?i:mov|xor|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END;
allocNodes(ALLOC_ARRAY, idealIndependentRegex, optoRegex);
String optoRegex = "(.*precise \\[.*\\R((.*(?i:mov|xor|nop|spill).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END;
allocNodes(ALLOC_ARRAY, "AllocateArray", optoRegex);
}

public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "ALLOC_ARRAY_OF" + POSTFIX;
static {
String regex = "(.*precise \\[.*" + IS_REPLACED + ":.*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END;
String regex = "(.*precise \\[.*" + IS_REPLACED + ":.*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*(LGHI|LI).*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END;
optoOnly(ALLOC_ARRAY_OF, regex);
}

Expand Down Expand Up @@ -1182,10 +1180,11 @@ private static void beforeMatchingNameRegex(String irNodePlaceholder, String irN
IR_NODE_MAPPINGS.put(irNodePlaceholder, new RegexTypeEntry(RegexType.IDEAL_INDEPENDENT, regex));
}

private static void allocNodes(String irNode, String idealRegex, String optoRegex) {
private static void allocNodes(String irNode, String irNodeName, String optoRegex) {
String idealIndependentRegex = START + irNodeName + "\\b" + MID + END;
Map<PhaseInterval, String> intervalToRegexMap = new HashMap<>();
intervalToRegexMap.put(new PhaseInterval(CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.PHASEIDEALLOOP_ITERATIONS),
idealRegex);
idealIndependentRegex);
intervalToRegexMap.put(new PhaseInterval(CompilePhase.PRINT_OPTO_ASSEMBLY), optoRegex);
MultiPhaseRangeEntry entry = new MultiPhaseRangeEntry(CompilePhase.PRINT_OPTO_ASSEMBLY, intervalToRegexMap);
IR_NODE_MAPPINGS.put(irNode, entry);
Expand Down
Expand Up @@ -104,6 +104,8 @@ class Basics {
long l;
Object obj;
Object obj2;
Object obj3;
Object obj4;

@Test
@IR(failOn = IRNode.STORE, phase = {CompilePhase.DEFAULT, CompilePhase.PRINT_IDEAL})
Expand Down Expand Up @@ -243,6 +245,16 @@ public void alloc() {
obj = new Object();
obj2 = new Object[1];
}

@Test
@IR(counts = {IRNode.ALLOC, "2", IRNode.ALLOC_ARRAY, "2"}, // works for all phases
phase = {CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.CCP1, CompilePhase.PRINT_OPTO_ASSEMBLY, CompilePhase.DEFAULT})
public void alloc2() {
obj = new Object();
obj2 = new Object[1];
obj3 = new Object();
obj4 = new Object[2];
}
}

class NoCompilationOutput {
Expand Down

1 comment on commit 34d10f1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.