# HG changeset patch # User Andreas Woess # Date 1439898140 -7200 # Node ID 360295240c97d5386b284a8b1954ff75e6e94945 # Parent cef905a78886f91ea27856c4b5096699ef6eb2a5 Truffle: allow registration of additional invocation plugins via jvmci service diff -r cef905a78886 -r 360295240c97 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Tue Aug 18 12:37:18 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Tue Aug 18 13:42:20 2015 +0200 @@ -35,6 +35,7 @@ import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.options.*; +import jdk.internal.jvmci.service.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.compiler.common.type.*; @@ -375,6 +376,10 @@ protected void registerTruffleInvocationPlugins(InvocationPlugins invocationPlugins, boolean canDelayIntrinsification) { TruffleGraphBuilderPlugins.registerInvocationPlugins(providers.getMetaAccess(), invocationPlugins, canDelayIntrinsification, snippetReflection); + + for (TruffleInvocationPluginProvider p : Services.load(TruffleInvocationPluginProvider.class)) { + p.registerInvocationPlugins(providers.getMetaAccess(), invocationPlugins, canDelayIntrinsification, snippetReflection); + } } protected InvocationPlugins createDecodingInvocationPlugins() { diff -r cef905a78886 -r 360295240c97 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java Tue Aug 18 12:37:18 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java Tue Aug 18 13:42:20 2015 +0200 @@ -332,7 +332,7 @@ }); } - private static void registerUnsafeCast(Registration r, boolean canDelayIntrinsification) { + public static void registerUnsafeCast(Registration r, boolean canDelayIntrinsification) { r.register4("unsafeCast", Object.class, Class.class, boolean.class, boolean.class, new InvocationPlugin() { public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object, ValueNode clazz, ValueNode condition, ValueNode nonNull) { if (clazz.isConstant() && nonNull.isConstant()) { @@ -375,7 +375,7 @@ }); } - protected static void registerUnsafeLoadStorePlugins(Registration r, Kind... kinds) { + public static void registerUnsafeLoadStorePlugins(Registration r, Kind... kinds) { for (Kind kind : kinds) { String kindName = kind.getJavaName(); kindName = toUpperCase(kindName.charAt(0)) + kindName.substring(1); diff -r cef905a78886 -r 360295240c97 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleInvocationPluginProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleInvocationPluginProvider.java Tue Aug 18 13:42:20 2015 +0200 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015, 2015, 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.truffle.substitutions; + +import jdk.internal.jvmci.meta.*; + +import com.oracle.graal.api.replacements.*; +import com.oracle.graal.graphbuilderconf.*; + +public interface TruffleInvocationPluginProvider { + void registerInvocationPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins, boolean canDelayIntrinsification, SnippetReflectionProvider snippetReflection); +}