Mercurial > hg > graal-jvmci-8
changeset 16981:54a21a1bec26
matcher needs to indirect through NodeClass to work properly in the presence of generated Node classes
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 27 Aug 2014 18:59:09 +0200 |
parents | 5762848171e7 |
children | a65b459ab270 |
files | graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchPattern.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchRuleRegistry.java |
diffstat | 3 files changed, 11 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Wed Aug 27 18:58:15 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Wed Aug 27 18:59:09 2014 +0200 @@ -94,7 +94,7 @@ private ValueNode currentInstruction; private ValueNode lastInstructionPrinted; // Debugging only - private Map<Class<? extends ValueNode>, List<MatchStatement>> matchRules; + private Map<NodeClass, List<MatchStatement>> matchRules; public NodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool gen) { this.gen = gen; @@ -277,7 +277,7 @@ continue; } // See if this node is the root of any MatchStatements - List<MatchStatement> statements = matchRules.get(node.getClass()); + List<MatchStatement> statements = matchRules.get(node.getNodeClass()); if (statements != null) { for (MatchStatement statement : statements) { if (statement.generate(this, index, node, nodes)) {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchPattern.java Wed Aug 27 18:58:15 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchPattern.java Wed Aug 27 18:59:09 2014 +0200 @@ -185,7 +185,7 @@ } private Result matchType(ValueNode node) { - if (nodeClass != null && node.getClass() != nodeClass) { + if (nodeClass != null && node.getNodeClass() != NodeClass.get(nodeClass)) { return Result.WRONG_CLASS(node, this); } return Result.OK;
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchRuleRegistry.java Wed Aug 27 18:58:15 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchRuleRegistry.java Wed Aug 27 18:59:09 2014 +0200 @@ -79,7 +79,7 @@ return result; } - private static final HashMap<Class<? extends NodeLIRBuilder>, Map<Class<? extends ValueNode>, List<MatchStatement>>> registry = new HashMap<>(); + private static final HashMap<Class<? extends NodeLIRBuilder>, Map<NodeClass, List<MatchStatement>>> registry = new HashMap<>(); /** * Collect all the {@link MatchStatement}s defined by the superclass chain of theClass. @@ -87,12 +87,12 @@ * @param theClass * @return the set of {@link MatchStatement}s applicable to theClass. */ - public synchronized static Map<Class<? extends ValueNode>, List<MatchStatement>> lookup(Class<? extends NodeLIRBuilder> theClass) { - Map<Class<? extends ValueNode>, List<MatchStatement>> result = registry.get(theClass); + public synchronized static Map<NodeClass, List<MatchStatement>> lookup(Class<? extends NodeLIRBuilder> theClass) { + Map<NodeClass, List<MatchStatement>> result = registry.get(theClass); if (result == null) { NodeClassLookup lookup = new DefaultNodeClassLookup(); - Map<Class<? extends ValueNode>, List<MatchStatement>> rules = createRules(theClass, lookup); + Map<NodeClass, List<MatchStatement>> rules = createRules(theClass, lookup); registry.put(theClass, rules); assert registry.get(theClass) == rules; result = rules; @@ -100,7 +100,7 @@ if (LogVerbose.getValue()) { try (Scope s = Debug.scope("MatchComplexExpressions")) { Debug.log("Match rules for %s", theClass.getSimpleName()); - for (Entry<Class<? extends ValueNode>, List<MatchStatement>> entry : result.entrySet()) { + for (Entry<NodeClass, List<MatchStatement>> entry : result.entrySet()) { Debug.log(" For node class: %s", entry.getKey()); for (MatchStatement statement : entry.getValue()) { Debug.log(" %s", statement.getPattern()); @@ -120,7 +120,7 @@ * This is a separate, public method so that external clients can create rules with a custom * lookup and without the default caching behavior. */ - public static Map<Class<? extends ValueNode>, List<MatchStatement>> createRules(Class<? extends NodeLIRBuilder> theClass, NodeClassLookup lookup) { + public static Map<NodeClass, List<MatchStatement>> createRules(Class<? extends NodeLIRBuilder> theClass, NodeClassLookup lookup) { HashMap<Class<? extends NodeLIRBuilder>, MatchStatementSet> matchSets = new HashMap<>(); Iterable<MatchStatementSet> sl = Services.load(MatchStatementSet.class); for (MatchStatementSet rules : sl) { @@ -129,14 +129,14 @@ // Walk the class hierarchy collecting lists and merge them together. The subclass // rules are first which gives them preference over earlier rules. - Map<Class<? extends ValueNode>, List<MatchStatement>> rules = new HashMap<>(); + Map<NodeClass, List<MatchStatement>> rules = new HashMap<>(); Class<?> currentClass = theClass; do { MatchStatementSet matchSet = matchSets.get(currentClass); if (matchSet != null) { List<MatchStatement> statements = matchSet.statements(lookup); for (MatchStatement statement : statements) { - Class<? extends ValueNode> nodeClass = statement.getPattern().nodeClass(); + NodeClass nodeClass = NodeClass.get(statement.getPattern().nodeClass()); List<MatchStatement> current = rules.get(nodeClass); if (current == null) { current = new ArrayList<>();