Mercurial > hg > truffle
changeset 8458:5d0296347367
Use ServiceLoader to make installation of MethodSubstitutions extensible.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Mon, 25 Mar 2013 15:39:32 +0100 |
parents | b27261747964 |
children | 3393f870e6a4 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java graal/com.oracle.graal.replacements/src/META-INF/services/com.oracle.graal.replacements.ReplacementsProvider graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsProvider.java |
diffstat | 4 files changed, 38 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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); } });
--- /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
--- 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);
--- /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); +}