< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/HotSpotInvokeDynamicPluginTest.java

Print this page
rev 56282 : [mq]: graal
   1 /*
   2  * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.hotspot.test;
  26 
  27 import java.lang.invoke.MethodHandle;
  28 import java.lang.invoke.MethodHandles;
  29 import java.lang.invoke.MethodType;
  30 import java.security.PrivilegedAction;
  31 import java.util.function.IntPredicate;
  32 
  33 import org.graalvm.compiler.core.common.GraalOptions;
  34 import org.graalvm.compiler.hotspot.meta.HotSpotClassInitializationPlugin;
  35 import org.graalvm.compiler.hotspot.meta.HotSpotInvokeDynamicPlugin;
  36 import org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode;
  37 import org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicStubCall;
  38 import org.graalvm.compiler.nodes.StructuredGraph;
  39 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
  40 import org.graalvm.compiler.nodes.ValueNode;
  41 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
  42 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
  43 import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo;
  44 import org.graalvm.compiler.nodes.spi.CoreProviders;
  45 import org.graalvm.compiler.nodes.spi.LoweringTool;
  46 import org.graalvm.compiler.options.OptionValues;
  47 import org.graalvm.compiler.phases.OptimisticOptimizations;
  48 import org.graalvm.compiler.phases.common.CanonicalizerPhase;
  49 import org.graalvm.compiler.phases.common.FrameStateAssignmentPhase;
  50 import org.graalvm.compiler.phases.common.GuardLoweringPhase;
  51 import org.graalvm.compiler.phases.common.LoweringPhase;
  52 import org.graalvm.compiler.phases.tiers.MidTierContext;
  53 import org.junit.Assert;
  54 import org.junit.Test;
  55 
  56 import jdk.vm.ci.meta.ResolvedJavaMethod;
  57 
  58 public class HotSpotInvokeDynamicPluginTest extends HotSpotGraalCompilerTest {
  59     @Override
  60     protected Plugins getDefaultGraphBuilderPlugins() {
  61         Plugins plugins = super.getDefaultGraphBuilderPlugins();
  62         plugins.setClassInitializationPlugin(new HotSpotClassInitializationPlugin());
  63         plugins.setInvokeDynamicPlugin(new HotSpotInvokeDynamicPlugin() {
  64             @Override
  65             public boolean isResolvedDynamicInvoke(GraphBuilderContext builder, int index, int opcode) {
  66                 // Allow invokedynamic testing with older JVMCI
  67                 ResolvedJavaMethod m = builder.getMethod();
  68                 if (m.getName().startsWith("invokeDynamic") && m.getDeclaringClass().getName().equals("Lorg/graalvm/compiler/hotspot/test/HotSpotInvokeDynamicPluginTest;")) {
  69                     return false;
  70                 }
  71                 return super.isResolvedDynamicInvoke(builder, index, opcode);
  72             }
  73 
  74             @Override
  75             public boolean supportsDynamicInvoke(GraphBuilderContext builder, int index, int opcode) {
  76                 // Allow invokehandle testing with older JVMCI
  77                 ResolvedJavaMethod m = builder.getMethod();
  78                 if (m.getName().startsWith("invokeHandle") && m.getDeclaringClass().getName().equals("Lorg/graalvm/compiler/hotspot/test/HotSpotInvokeDynamicPluginTest;")) {
  79                     return true;
  80                 }
  81                 return super.supportsDynamicInvoke(builder, index, opcode);
  82             }


   1 /*
   2  * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.hotspot.test;
  26 
  27 import java.lang.invoke.MethodHandle;
  28 import java.lang.invoke.MethodHandles;
  29 import java.lang.invoke.MethodType;
  30 import java.security.PrivilegedAction;
  31 import java.util.function.IntPredicate;
  32 
  33 import org.graalvm.compiler.core.common.GraalOptions;
  34 import org.graalvm.compiler.hotspot.meta.HotSpotAOTClassInitializationPlugin;
  35 import org.graalvm.compiler.hotspot.meta.HotSpotInvokeDynamicPlugin;
  36 import org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode;
  37 import org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicStubCall;
  38 import org.graalvm.compiler.nodes.StructuredGraph;
  39 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
  40 import org.graalvm.compiler.nodes.ValueNode;
  41 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
  42 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
  43 import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo;
  44 import org.graalvm.compiler.nodes.spi.CoreProviders;
  45 import org.graalvm.compiler.nodes.spi.LoweringTool;
  46 import org.graalvm.compiler.options.OptionValues;
  47 import org.graalvm.compiler.phases.OptimisticOptimizations;
  48 import org.graalvm.compiler.phases.common.CanonicalizerPhase;
  49 import org.graalvm.compiler.phases.common.FrameStateAssignmentPhase;
  50 import org.graalvm.compiler.phases.common.GuardLoweringPhase;
  51 import org.graalvm.compiler.phases.common.LoweringPhase;
  52 import org.graalvm.compiler.phases.tiers.MidTierContext;
  53 import org.junit.Assert;
  54 import org.junit.Test;
  55 
  56 import jdk.vm.ci.meta.ResolvedJavaMethod;
  57 
  58 public class HotSpotInvokeDynamicPluginTest extends HotSpotGraalCompilerTest {
  59     @Override
  60     protected Plugins getDefaultGraphBuilderPlugins() {
  61         Plugins plugins = super.getDefaultGraphBuilderPlugins();
  62         plugins.setClassInitializationPlugin(new HotSpotAOTClassInitializationPlugin());
  63         plugins.setInvokeDynamicPlugin(new HotSpotInvokeDynamicPlugin() {
  64             @Override
  65             public boolean isResolvedDynamicInvoke(GraphBuilderContext builder, int index, int opcode) {
  66                 // Allow invokedynamic testing with older JVMCI
  67                 ResolvedJavaMethod m = builder.getMethod();
  68                 if (m.getName().startsWith("invokeDynamic") && m.getDeclaringClass().getName().equals("Lorg/graalvm/compiler/hotspot/test/HotSpotInvokeDynamicPluginTest;")) {
  69                     return false;
  70                 }
  71                 return super.isResolvedDynamicInvoke(builder, index, opcode);
  72             }
  73 
  74             @Override
  75             public boolean supportsDynamicInvoke(GraphBuilderContext builder, int index, int opcode) {
  76                 // Allow invokehandle testing with older JVMCI
  77                 ResolvedJavaMethod m = builder.getMethod();
  78                 if (m.getName().startsWith("invokeHandle") && m.getDeclaringClass().getName().equals("Lorg/graalvm/compiler/hotspot/test/HotSpotInvokeDynamicPluginTest;")) {
  79                     return true;
  80                 }
  81                 return super.supportsDynamicInvoke(builder, index, opcode);
  82             }


< prev index next >