summaryrefslogtreecommitdiff
path: root/test/638-checker-inline-cache-intrinsic
diff options
context:
space:
mode:
Diffstat (limited to 'test/638-checker-inline-cache-intrinsic')
-rw-r--r--test/638-checker-inline-cache-intrinsic/expected.txt1
-rw-r--r--test/638-checker-inline-cache-intrinsic/info.txt1
-rw-r--r--test/638-checker-inline-cache-intrinsic/run17
-rw-r--r--test/638-checker-inline-cache-intrinsic/src/Main.java95
4 files changed, 114 insertions, 0 deletions
diff --git a/test/638-checker-inline-cache-intrinsic/expected.txt b/test/638-checker-inline-cache-intrinsic/expected.txt
new file mode 100644
index 0000000000..6a5618ebc6
--- /dev/null
+++ b/test/638-checker-inline-cache-intrinsic/expected.txt
@@ -0,0 +1 @@
+JNI_OnLoad called
diff --git a/test/638-checker-inline-cache-intrinsic/info.txt b/test/638-checker-inline-cache-intrinsic/info.txt
new file mode 100644
index 0000000000..764577be54
--- /dev/null
+++ b/test/638-checker-inline-cache-intrinsic/info.txt
@@ -0,0 +1 @@
+Verify the devirtualization of a method that should be intrinsified.
diff --git a/test/638-checker-inline-cache-intrinsic/run b/test/638-checker-inline-cache-intrinsic/run
new file mode 100644
index 0000000000..f43681dd56
--- /dev/null
+++ b/test/638-checker-inline-cache-intrinsic/run
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+exec ${RUN} --jit --runtime-option -Xjitthreshold:100 -Xcompiler-option --verbose-methods=inlineMonomorphic,knownReceiverType,stringEquals $@
diff --git a/test/638-checker-inline-cache-intrinsic/src/Main.java b/test/638-checker-inline-cache-intrinsic/src/Main.java
new file mode 100644
index 0000000000..472cbf68bc
--- /dev/null
+++ b/test/638-checker-inline-cache-intrinsic/src/Main.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Main {
+
+ /// CHECK-START: char Main.$noinline$inlineMonomorphic(java.lang.CharSequence) inliner (before)
+ /// CHECK: InvokeInterface method_name:java.lang.CharSequence.charAt
+
+ /// CHECK-START: char Main.$noinline$inlineMonomorphic(java.lang.CharSequence) inliner (after)
+ /// CHECK: Deoptimize
+ /// CHECK: InvokeVirtual method_name:java.lang.String.charAt intrinsic:StringCharAt
+
+ /// CHECK-START: char Main.$noinline$inlineMonomorphic(java.lang.CharSequence) instruction_simplifier$after_inlining (after)
+ /// CHECK: Deoptimize
+ /// CHECK-NOT: InvokeInterface
+ /// CHECK-NOT: InvokeVirtual
+
+ public static char $noinline$inlineMonomorphic(CharSequence cs) {
+ return cs.charAt(0);
+ }
+
+ /// CHECK-START: char Main.$noinline$knownReceiverType() inliner (before)
+ /// CHECK: InvokeInterface method_name:java.lang.CharSequence.charAt
+
+ /// CHECK-START: char Main.$noinline$knownReceiverType() inliner (after)
+ /// CHECK: InvokeVirtual method_name:java.lang.String.charAt intrinsic:StringCharAt
+
+ /// CHECK-START: char Main.$noinline$knownReceiverType() instruction_simplifier$after_inlining (after)
+ /// CHECK-NOT: InvokeInterface
+ /// CHECK-NOT: InvokeVirtual
+
+ public static char $noinline$knownReceiverType() {
+ CharSequence cs = "abc";
+ return cs.charAt(1);
+ }
+
+ /// CHECK-START: boolean Main.$noinline$stringEquals(java.lang.Object) inliner (before)
+ /// CHECK: InvokeVirtual method_name:java.lang.Object.equals intrinsic:None
+
+ /// CHECK-START: boolean Main.$noinline$stringEquals(java.lang.Object) inliner (after)
+ /// CHECK: Deoptimize
+ /// CHECK: InvokeVirtual method_name:java.lang.Object.equals intrinsic:StringEquals
+
+ /// CHECK-START: boolean Main.$noinline$stringEquals(java.lang.Object) instruction_simplifier$after_inlining (after)
+ /// CHECK: Deoptimize
+ /// CHECK: InvokeVirtual method_name:java.lang.Object.equals intrinsic:StringEquals
+
+ public static boolean $noinline$stringEquals(Object obj) {
+ return obj.equals("def");
+ }
+
+ public static void test() {
+ // Warm up inline cache.
+ for (int i = 0; i < 45; i++) {
+ $noinline$inlineMonomorphic(str);
+ }
+ for (int i = 0; i < 60; i++) {
+ $noinline$stringEquals(str);
+ }
+ ensureJitCompiled(Main.class, "$noinline$stringEquals");
+ ensureJitCompiled(Main.class, "$noinline$inlineMonomorphic");
+ ensureJitCompiled(Main.class, "$noinline$knownReceiverType");
+ if ($noinline$inlineMonomorphic(str) != 'x') {
+ throw new Error("Expected x");
+ }
+ if ($noinline$knownReceiverType() != 'b') {
+ throw new Error("Expected b");
+ }
+ if ($noinline$stringEquals("abc")) {
+ throw new Error("Expected false");
+ }
+ }
+
+ public static void main(String[] args) {
+ System.loadLibrary(args[0]);
+ test();
+ }
+
+ static String str = "xyz";
+
+ private static native void ensureJitCompiled(Class<?> itf, String method_name);
+}