src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/CompiledNullPointerExceptionTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/CompiledNullPointerExceptionTest.java

Print this page




   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 package org.graalvm.compiler.replacements.test;
  24 
  25 import static org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.BytecodeExceptionMode.CheckAll;
  26 
  27 import org.graalvm.compiler.core.common.CompilationIdentifier;
  28 import org.graalvm.compiler.core.phases.HighTier;
  29 import org.graalvm.compiler.core.test.GraalCompilerTest;
  30 import org.graalvm.compiler.nodes.StructuredGraph;
  31 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
  32 import org.graalvm.compiler.nodes.ValueNode;
  33 import org.graalvm.compiler.nodes.extended.BytecodeExceptionNode;
  34 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
  35 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
  36 import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo;
  37 import org.graalvm.compiler.options.OptionValues;


  38 import org.graalvm.compiler.phases.tiers.Suites;
  39 import org.junit.Assert;
  40 import org.junit.Test;
  41 
  42 import jdk.vm.ci.meta.ResolvedJavaMethod;
  43 
  44 /**
  45  * Tests compilation of a hot exception handler.
  46  */
  47 public class CompiledNullPointerExceptionTest extends GraalCompilerTest {
  48 
  49     @Override
  50     @SuppressWarnings("try")
  51     protected Suites createSuites(OptionValues options) {
  52         return super.createSuites(new OptionValues(options, HighTier.Options.Inline, false));
  53     }
  54 
  55     @Override
  56     protected InlineInfo bytecodeParserShouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) {
  57         return InlineInfo.DO_NOT_INLINE_NO_EXCEPTION;
  58     }
  59 
  60     @Override
  61     protected GraphBuilderConfiguration editGraphBuilderConfiguration(GraphBuilderConfiguration conf) {
  62         return super.editGraphBuilderConfiguration(conf).withBytecodeExceptionMode(CheckAll);
  63     }
  64 
  65     @Override
  66     protected StructuredGraph parseEager(ResolvedJavaMethod m, AllowAssumptions allowAssumptions, CompilationIdentifier compilationId, OptionValues options) {
  67         StructuredGraph graph = super.parseEager(m, allowAssumptions, compilationId, options);
  68         int handlers = graph.getNodes().filter(BytecodeExceptionNode.class).count();
  69         Assert.assertEquals(1, handlers);
  70         return graph;
  71     }
  72 
  73     private class TestClass {
  74 
  75         @Override
  76         public String toString() {
  77             return "TestClass";
  78         }
  79     }
  80 
  81     @Test
  82     public void test() {
  83         test("testSnippet", (TestClass) null, "object2");
  84         test("testSnippet", new TestClass(), "object2");
  85     }
  86 
  87     public static String testSnippet(TestClass o, Object o2) {


   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 package org.graalvm.compiler.replacements.test;
  24 
  25 import static org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.BytecodeExceptionMode.CheckAll;
  26 

  27 import org.graalvm.compiler.core.phases.HighTier;
  28 import org.graalvm.compiler.core.test.GraalCompilerTest;
  29 import org.graalvm.compiler.nodes.StructuredGraph;
  30 import org.graalvm.compiler.nodes.StructuredGraph.Builder;
  31 import org.graalvm.compiler.nodes.ValueNode;
  32 import org.graalvm.compiler.nodes.extended.BytecodeExceptionNode;
  33 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
  34 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
  35 import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo;
  36 import org.graalvm.compiler.options.OptionValues;
  37 import org.graalvm.compiler.phases.PhaseSuite;
  38 import org.graalvm.compiler.phases.tiers.HighTierContext;
  39 import org.graalvm.compiler.phases.tiers.Suites;
  40 import org.junit.Assert;
  41 import org.junit.Test;
  42 
  43 import jdk.vm.ci.meta.ResolvedJavaMethod;
  44 
  45 /**
  46  * Tests compilation of a hot exception handler.
  47  */
  48 public class CompiledNullPointerExceptionTest extends GraalCompilerTest {
  49 
  50     @Override
  51     @SuppressWarnings("try")
  52     protected Suites createSuites(OptionValues options) {
  53         return super.createSuites(new OptionValues(options, HighTier.Options.Inline, false));
  54     }
  55 
  56     @Override
  57     protected InlineInfo bytecodeParserShouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) {
  58         return InlineInfo.DO_NOT_INLINE_NO_EXCEPTION;
  59     }
  60 
  61     @Override
  62     protected GraphBuilderConfiguration editGraphBuilderConfiguration(GraphBuilderConfiguration conf) {
  63         return super.editGraphBuilderConfiguration(conf).withBytecodeExceptionMode(CheckAll);
  64     }
  65 
  66     @Override
  67     protected StructuredGraph parse(Builder builder, PhaseSuite<HighTierContext> graphBuilderSuite) {
  68         StructuredGraph graph = super.parse(builder, graphBuilderSuite);
  69         int handlers = graph.getNodes().filter(BytecodeExceptionNode.class).count();
  70         Assert.assertEquals(1, handlers);
  71         return graph;
  72     }
  73 
  74     private class TestClass {
  75 
  76         @Override
  77         public String toString() {
  78             return "TestClass";
  79         }
  80     }
  81 
  82     @Test
  83     public void test() {
  84         test("testSnippet", (TestClass) null, "object2");
  85         test("testSnippet", new TestClass(), "object2");
  86     }
  87 
  88     public static String testSnippet(TestClass o, Object o2) {
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/CompiledNullPointerExceptionTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File