# HG changeset patch # User Thomas Wuerthinger # Date 1366121247 -7200 # Node ID b67a0963fb007559c0f4d60bd57f5a47fae1dfb5 # Parent 07f05f2a8149ae98d27c07d2e7047cb61693a49f# Parent 57f85e39c75f1d0fab37023511614e9b91e610a3 Merge. diff -r 07f05f2a8149 -r b67a0963fb00 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Tue Apr 16 16:07:16 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Tue Apr 16 16:07:27 2013 +0200 @@ -139,12 +139,12 @@ plan.runPhases(PhasePosition.HIGH_LEVEL, graph); - Suites.DEFAULT.highTier.apply(graph, highTierContext); + Suites.DEFAULT.getHighTier().apply(graph, highTierContext); new LoweringPhase(target, runtime, replacements, assumptions).apply(graph); MidTierContext midTierContext = new MidTierContext(runtime, assumptions); - Suites.DEFAULT.midTier.apply(graph, midTierContext); + Suites.DEFAULT.getMidTier().apply(graph, midTierContext); plan.runPhases(PhasePosition.MID_LEVEL, graph); diff -r 07f05f2a8149 -r b67a0963fb00 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java Tue Apr 16 16:07:16 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java Tue Apr 16 16:07:27 2013 +0200 @@ -37,7 +37,7 @@ } if (GraalOptions.OptFloatingReads) { - PartialCanonicalizerPhase canonicalizer = new PartialCanonicalizerPhase<>(); + IncrementalCanonicalizerPhase canonicalizer = new IncrementalCanonicalizerPhase<>(); canonicalizer.addPhase(new FloatingReadPhase()); addPhase(canonicalizer); if (GraalOptions.OptReadElimination) { diff -r 07f05f2a8149 -r b67a0963fb00 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IncrementalCanonicalizerPhase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IncrementalCanonicalizerPhase.java Tue Apr 16 16:07:27 2013 +0200 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. 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. + */ +package com.oracle.graal.phases.common; + +import com.oracle.graal.nodes.*; +import com.oracle.graal.phases.*; +import com.oracle.graal.phases.common.CanonicalizerPhase.CustomCanonicalizer; +import com.oracle.graal.phases.tiers.*; + +public class IncrementalCanonicalizerPhase extends PhaseSuite { + + private final CustomCanonicalizer customCanonicalizer; + + public IncrementalCanonicalizerPhase() { + this(null); + } + + public IncrementalCanonicalizerPhase(CustomCanonicalizer customCanonicalizer) { + this.customCanonicalizer = customCanonicalizer; + } + + @Override + protected void run(StructuredGraph graph, C context) { + int mark = graph.getMark(); + super.run(graph, context); + new CanonicalizerPhase.Instance(context.getRuntime(), context.getAssumptions(), mark, customCanonicalizer).apply(graph); + } +} diff -r 07f05f2a8149 -r b67a0963fb00 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/PartialCanonicalizerPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/PartialCanonicalizerPhase.java Tue Apr 16 16:07:16 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. 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. - */ -package com.oracle.graal.phases.common; - -import com.oracle.graal.nodes.*; -import com.oracle.graal.phases.*; -import com.oracle.graal.phases.common.CanonicalizerPhase.CustomCanonicalizer; -import com.oracle.graal.phases.tiers.*; - -public class PartialCanonicalizerPhase extends PhaseSuite { - - private final CustomCanonicalizer customCanonicalizer; - - public PartialCanonicalizerPhase() { - this(null); - } - - public PartialCanonicalizerPhase(CustomCanonicalizer customCanonicalizer) { - this.customCanonicalizer = customCanonicalizer; - } - - @Override - protected void run(StructuredGraph graph, C context) { - int mark = graph.getMark(); - super.run(graph, context); - new CanonicalizerPhase.Instance(context.getRuntime(), context.getAssumptions(), mark, customCanonicalizer).apply(graph); - } -} diff -r 07f05f2a8149 -r b67a0963fb00 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java Tue Apr 16 16:07:16 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java Tue Apr 16 16:07:27 2013 +0200 @@ -29,13 +29,21 @@ public final class Suites { - public final PhaseSuite highTier; - public final PhaseSuite midTier; - public static final Suites DEFAULT; + private final PhaseSuite highTier; + private final PhaseSuite midTier; + private static final Map configurations; + public PhaseSuite getHighTier() { + return highTier; + } + + public PhaseSuite getMidTier() { + return midTier; + } + static { configurations = new HashMap<>(); for (CompilerConfiguration config : ServiceLoader.loadInstalled(CompilerConfiguration.class)) { diff -r 07f05f2a8149 -r b67a0963fb00 graal/com.oracle.graal.service.processor/src/com/oracle/graal/service/processor/ServiceProviderProcessor.java --- a/graal/com.oracle.graal.service.processor/src/com/oracle/graal/service/processor/ServiceProviderProcessor.java Tue Apr 16 16:07:16 2013 +0200 +++ b/graal/com.oracle.graal.service.processor/src/com/oracle/graal/service/processor/ServiceProviderProcessor.java Tue Apr 16 16:07:27 2013 +0200 @@ -29,7 +29,6 @@ import javax.lang.model.*; import javax.lang.model.element.*; import javax.lang.model.type.*; -import javax.lang.model.util.*; import javax.tools.Diagnostic.Kind; import javax.tools.*; @@ -39,38 +38,7 @@ @SupportedAnnotationTypes("com.oracle.graal.api.runtime.ServiceProvider") public class ServiceProviderProcessor extends AbstractProcessor { - private Map> serviceMap; - - public ServiceProviderProcessor() { - serviceMap = new HashMap<>(); - } - - private void addProvider(String serviceName, TypeElement serviceProvider) { - Set providers = serviceMap.get(serviceName); - if (providers == null) { - providers = new HashSet<>(); - serviceMap.put(serviceName, providers); - } - providers.add(serviceProvider); - } - - private void generateServicesFiles() { - Filer filer = processingEnv.getFiler(); - for (Map.Entry> entry : serviceMap.entrySet()) { - String filename = "META-INF/services/" + entry.getKey(); - TypeElement[] providers = entry.getValue().toArray(new TypeElement[0]); - try { - FileObject servicesFile = filer.createResource(StandardLocation.CLASS_OUTPUT, "", filename, providers); - PrintWriter writer = new PrintWriter(new OutputStreamWriter(servicesFile.openOutputStream(), "UTF-8")); - for (TypeElement provider : providers) { - writer.println(provider.getQualifiedName()); - } - writer.close(); - } catch (IOException e) { - processingEnv.getMessager().printMessage(Kind.ERROR, e.getMessage()); - } - } - } + private final Set processed = new HashSet<>(); private boolean verifyAnnotation(TypeMirror serviceInterface, TypeElement serviceProvider) { if (!processingEnv.getTypeUtils().isSubtype(serviceProvider.asType(), serviceInterface)) { @@ -83,6 +51,11 @@ } private void processElement(TypeElement serviceProvider) { + if (processed.contains(serviceProvider)) { + return; + } + + processed.add(serviceProvider); ServiceProvider annotation = serviceProvider.getAnnotation(ServiceProvider.class); if (annotation != null) { try { @@ -91,40 +64,27 @@ TypeMirror serviceInterface = ex.getTypeMirror(); if (verifyAnnotation(serviceInterface, serviceProvider)) { String interfaceName = ex.getTypeMirror().toString(); - addProvider(interfaceName, serviceProvider); + createProviderFile(serviceProvider, interfaceName); } } } } - private void processOldElements() { - Filer filer = processingEnv.getFiler(); - Elements elements = processingEnv.getElementUtils(); - for (String key : serviceMap.keySet()) { - String filename = "META-INF/services/" + key; - try { - FileObject servicesFile = filer.getResource(StandardLocation.CLASS_OUTPUT, "", filename); - BufferedReader reader = new BufferedReader(new InputStreamReader(servicesFile.openInputStream(), "UTF-8")); - String line; - while ((line = reader.readLine()) != null) { - TypeElement serviceProvider = elements.getTypeElement(line); - if (serviceProvider != null) { - processElement(serviceProvider); - } - } - reader.close(); - servicesFile.delete(); - } catch (IOException e) { - // old services file not found: do nothing - } + private void createProviderFile(TypeElement serviceProvider, String interfaceName) { + String filename = "META-INF/providers/" + serviceProvider.getQualifiedName(); + try { + FileObject file = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", filename, serviceProvider); + PrintWriter writer = new PrintWriter(new OutputStreamWriter(file.openOutputStream(), "UTF-8")); + writer.println(interfaceName); + writer.close(); + } catch (IOException e) { + processingEnv.getMessager().printMessage(Kind.ERROR, e.getMessage(), serviceProvider); } } @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { - processOldElements(); - generateServicesFiles(); return true; } diff -r 07f05f2a8149 -r b67a0963fb00 mxtool/mx.py --- a/mxtool/mx.py Tue Apr 16 16:07:16 2013 +0200 +++ b/mxtool/mx.py Tue Apr 16 16:07:27 2013 +0200 @@ -1684,6 +1684,12 @@ with open(join(root, f), 'r') as infile: for line in infile: outfile.write(line) + elif relpath == join('META-INF', 'providers'): + for f in files: + with open(join(root, f), 'r') as infile: + for line in infile: + with open(join(services, line.strip()), 'a') as outfile: + outfile.write(f + '\n') else: for f in files: arcname = join(relpath, f).replace(os.sep, '/')