# HG changeset patch # User Roland Schatz # Date 1364222372 -3600 # Node ID 5d029634736792e398449d617f68e47b6ec869e2 # Parent b27261747964b0794dba24516801be4416278239 Use ServiceLoader to make installation of MethodSubstitutions extensible. diff -r b27261747964 -r 5d0296347367 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Mar 25 15:39:31 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Mar 25 15:39:32 2013 +0100 @@ -152,7 +152,9 @@ // to be valid for the entire run of the VM. Assumptions assumptions = new Assumptions(false); ReplacementsInstaller installer = new HotSpotReplacementsInstaller(runtime, assumptions, runtime.getGraalRuntime().getTarget()); - GraalMethodSubstitutions.installIntrinsics(installer); + for (ReplacementsProvider provider : ServiceLoader.loadInstalled(ReplacementsProvider.class)) { + provider.installReplacements(installer); + } runtime.installReplacements(graalRuntime.getBackend(), installer, assumptions); } }); diff -r b27261747964 -r 5d0296347367 graal/com.oracle.graal.replacements/src/META-INF/services/com.oracle.graal.replacements.ReplacementsProvider --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.replacements/src/META-INF/services/com.oracle.graal.replacements.ReplacementsProvider Mon Mar 25 15:39:32 2013 +0100 @@ -0,0 +1,1 @@ +com.oracle.graal.replacements.GraalMethodSubstitutions diff -r b27261747964 -r 5d0296347367 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java Mon Mar 25 15:39:31 2013 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java Mon Mar 25 15:39:32 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -27,9 +27,9 @@ /** * Method substitutions that are VM-independent. */ -public class GraalMethodSubstitutions { +public class GraalMethodSubstitutions implements ReplacementsProvider { - public static void installIntrinsics(ReplacementsInstaller installer) { + public void installReplacements(ReplacementsInstaller installer) { if (GraalOptions.Intrinsify) { installer.installSubstitutions(MathSubstitutionsX86.class); installer.installSubstitutions(DoubleSubstitutions.class); diff -r b27261747964 -r 5d0296347367 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsProvider.java Mon Mar 25 15:39:32 2013 +0100 @@ -0,0 +1,31 @@ +/* + * 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.replacements; + +/** + * Interface for service providers that install replacements into the compiler. + */ +public interface ReplacementsProvider { + + void installReplacements(ReplacementsInstaller installer); +}