Mercurial > hg > graal-compiler
changeset 5492:35f9b57d70cb
Merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 07 Jun 2012 13:01:45 +0200 |
parents | f0130457c50c (current diff) f70b1547c7bf (diff) |
children | a4dfee0b8fbd e09a1efdeafd |
files | graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java |
diffstat | 4 files changed, 55 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/CheckCastSnippets.java Thu Jun 07 12:14:39 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/CheckCastSnippets.java Thu Jun 07 13:01:45 2012 +0200 @@ -23,8 +23,8 @@ package com.oracle.graal.hotspot.snippets; import static com.oracle.graal.hotspot.snippets.ArrayCopySnippets.*; import static com.oracle.graal.hotspot.snippets.CheckCastSnippets.Counter.*; -import static com.oracle.graal.snippets.Snippet.Arguments.*; import static com.oracle.graal.snippets.Snippet.Multiple.*; +import static com.oracle.graal.snippets.SnippetTemplate.Arguments.*; import java.io.*; import java.util.*; @@ -43,10 +43,11 @@ import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.snippets.*; -import com.oracle.graal.snippets.Snippet.Arguments; import com.oracle.graal.snippets.Snippet.Constant; import com.oracle.graal.snippets.Snippet.Parameter; +import com.oracle.graal.snippets.SnippetTemplate.Arguments; import com.oracle.graal.snippets.SnippetTemplate.Cache; +import com.oracle.graal.snippets.SnippetTemplate.Key; import com.oracle.graal.snippets.nodes.*; import com.oracle.max.cri.ci.*; import com.oracle.max.cri.ri.*; @@ -361,23 +362,23 @@ final HotSpotTypeResolvedImpl target = (HotSpotTypeResolvedImpl) checkcast.targetClass(); boolean checkNull = !object.stamp().nonNull(); Arguments arguments; - SnippetTemplate.Key key; + Key key; if (target == null) { HotSpotKlassOop[] hints = createHints(hintInfo); - key = new SnippetTemplate.Key(unknown).add("hints", multiple(Object.class, hints.length)).add("checkNull", checkNull); + key = new Key(unknown).add("hints", multiple(Object.class, hints.length)).add("checkNull", checkNull); arguments = arguments("hub", hub).add("object", object).add("hints", hints); } else if (hintInfo.exact) { HotSpotKlassOop[] hints = createHints(hintInfo); assert hints.length == 1; - key = new SnippetTemplate.Key(exact).add("checkNull", checkNull); + key = new Key(exact).add("checkNull", checkNull); arguments = arguments("object", object).add("exactHub", hints[0]); } else if (target.isPrimaryType()) { - key = new SnippetTemplate.Key(primary).add("checkNull", checkNull).add("superCheckOffset", target.superCheckOffset()); + key = new Key(primary).add("checkNull", checkNull).add("superCheckOffset", target.superCheckOffset()); arguments = arguments("hub", hub).add("object", object); } else { HotSpotKlassOop[] hints = createHints(hintInfo); - key = new SnippetTemplate.Key(secondary).add("hints", multiple(Object.class, hints.length)).add("checkNull", checkNull); + key = new Key(secondary).add("hints", multiple(Object.class, hints.length)).add("checkNull", checkNull); arguments = arguments("hub", hub).add("object", object).add("hints", hints); }
--- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/Snippet.java Thu Jun 07 12:14:39 2012 +0200 +++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/Snippet.java Thu Jun 07 13:01:45 2012 +0200 @@ -24,8 +24,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; -import java.util.*; -import java.util.Map.Entry; import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.snippets.nodes.*; @@ -80,37 +78,6 @@ } /** - * Arguments used to instantiate a template. - */ - public static class Arguments implements Iterable<Map.Entry<String, Object>> { - private final HashMap<String, Object> map = new HashMap<>(); - - public static Arguments arguments(String name, Object value) { - return new Arguments().add(name, value); - } - - public Arguments add(String name, Object value) { - assert !map.containsKey(name); - map.put(name, value); - return this; - } - - public int length() { - return map.size(); - } - - @Override - public Iterator<Entry<String, Object>> iterator() { - return map.entrySet().iterator(); - } - - @Override - public String toString() { - return map.toString(); - } - } - - /** * Wrapper for the prototype value of a {@linkplain Parameter#multiple() multiple} parameter. */ public static class Multiple {
--- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java Thu Jun 07 12:14:39 2012 +0200 +++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetTemplate.java Thu Jun 07 13:01:45 2012 +0200 @@ -37,7 +37,6 @@ import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.util.*; -import com.oracle.graal.snippets.Snippet.Arguments; import com.oracle.graal.snippets.Snippet.Constant; import com.oracle.graal.snippets.Snippet.Multiple; import com.oracle.graal.snippets.Snippet.Parameter; @@ -111,6 +110,37 @@ } /** + * Arguments used to instantiate a template. + */ + public static class Arguments implements Iterable<Map.Entry<String, Object>> { + private final HashMap<String, Object> map = new HashMap<>(); + + public static Arguments arguments(String name, Object value) { + return new Arguments().add(name, value); + } + + public Arguments add(String name, Object value) { + assert !map.containsKey(name); + map.put(name, value); + return this; + } + + public int length() { + return map.size(); + } + + @Override + public Iterator<Entry<String, Object>> iterator() { + return map.entrySet().iterator(); + } + + @Override + public String toString() { + return map.toString(); + } + } + + /** * A collection of snippet templates accessed by a {@link Key} instance. */ public static class Cache { @@ -343,7 +373,7 @@ * * @return the map that will be used to bind arguments to parameters when inlining this template */ - private IdentityHashMap<Node, Node> bind(StructuredGraph replaceeGraph, RiRuntime runtime, Snippet.Arguments args) { + private IdentityHashMap<Node, Node> bind(StructuredGraph replaceeGraph, RiRuntime runtime, SnippetTemplate.Arguments args) { IdentityHashMap<Node, Node> replacements = new IdentityHashMap<>(); for (Map.Entry<String, Object> e : args) { @@ -388,7 +418,7 @@ */ public void instantiate(RiRuntime runtime, Node replacee, - FixedWithNextNode anchor, Arguments args) { + FixedWithNextNode anchor, SnippetTemplate.Arguments args) { // Inline the snippet nodes, replacing parameters with the given args in the process String name = graph.name == null ? "{copy}" : graph.name + "{copy}";
--- a/mx/commands.py Thu Jun 07 12:14:39 2012 +0200 +++ b/mx/commands.py Thu Jun 07 13:01:45 2012 +0200 @@ -565,8 +565,7 @@ # Exclude all compiler tests and snippets excludes = ['com.oracle.graal.compiler.tests.*'] for p in mx.projects(): - _add_classes_with_annotation(excludes, p, None, '@Snippet', includeInnerClasses=True) - _add_classes_with_annotation(excludes, p, None, '@ClassSubstitution', includeInnerClasses=True) + _find_classes_with_annotations(excludes, p, None, ['@Snippet', '@ClassSubstitution'], includeInnerClasses=True) agentOptions = { 'append' : 'true' if _jacoco == 'append' else 'false', 'bootclasspath' : 'true', @@ -577,19 +576,21 @@ exe = join(_jdk(build), 'bin', mx.exe_suffix('java')) return mx.run([exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) -def _add_classes_with_annotation(classes, p, pkgRoot, annotation, includeInnerClasses=False): +def _find_classes_with_annotations(classes, p, pkgRoot, annotations, includeInnerClasses=False): """ Scan the sources of project 'p' for Java source files containing a line starting with 'annotation' (ignoring preceding whitespace) and add the fully qualified class name to 'classes' for each Java source file matched. """ + for a in annotations: + assert a.startswith('@') pkgDecl = re.compile(r"^package\s+([a-zA-Z_][\w\.]*)\s*;$") for srcDir in p.source_dirs(): outputDir = p.output_dir() for root, _, files in os.walk(srcDir): for name in files: if name.endswith('.java') and name != 'package-info.java': - hasTest = False + annotationFound = False with open(join(root, name)) as f: pkg = None for line in f: @@ -598,10 +599,14 @@ if match: pkg = match.group(1) else: - if line.strip().startswith(annotation): - hasTest = True + stripped = line.strip() + for a in annotations: + if stripped == a or stripped.startswith(a + '('): + annotationFound = True + break + if annotationFound: break - if hasTest: + if annotationFound: basename = name[:-len('.java')] assert pkg is not None if pkgRoot is None or pkg.startswith(pkgRoot): @@ -647,7 +652,7 @@ p = mx.project(proj) classes = [] for pkg in _unittests[proj]: - _add_classes_with_annotation(classes, p, pkg, '@Test') + _find_classes_with_annotations(classes, p, pkg, ['@Test']) if len(pos) != 0: classes = [c for c in classes if containsAny(c, pos)] @@ -677,7 +682,7 @@ p = mx.project(proj) classes = [] for pkg in _jtttests[proj]: - _add_classes_with_annotation(classes, p, pkg, '@Test') + _find_classes_with_annotations(classes, p, pkg, ['@Test']) if len(pos) != 0: classes = [c for c in classes if containsAny(c, pos)]