summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/674-hotness-compiled/expected.txt1
-rw-r--r--test/674-hotness-compiled/info.txt1
-rwxr-xr-xtest/674-hotness-compiled/run17
-rw-r--r--test/674-hotness-compiled/src/Main.java46
-rw-r--r--test/common/runtime_state.cc7
5 files changed, 65 insertions, 7 deletions
diff --git a/test/674-hotness-compiled/expected.txt b/test/674-hotness-compiled/expected.txt
new file mode 100644
index 0000000000..6a5618ebc6
--- /dev/null
+++ b/test/674-hotness-compiled/expected.txt
@@ -0,0 +1 @@
+JNI_OnLoad called
diff --git a/test/674-hotness-compiled/info.txt b/test/674-hotness-compiled/info.txt
new file mode 100644
index 0000000000..e2cf59a093
--- /dev/null
+++ b/test/674-hotness-compiled/info.txt
@@ -0,0 +1 @@
+Test for the --count-hotness-in-compiled-code compiler option.
diff --git a/test/674-hotness-compiled/run b/test/674-hotness-compiled/run
new file mode 100755
index 0000000000..85e8e3b13f
--- /dev/null
+++ b/test/674-hotness-compiled/run
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# Copyright (C) 2018 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.
+
+${RUN} "$@" -Xcompiler-option --count-hotness-in-compiled-code
diff --git a/test/674-hotness-compiled/src/Main.java b/test/674-hotness-compiled/src/Main.java
new file mode 100644
index 0000000000..76ec92777f
--- /dev/null
+++ b/test/674-hotness-compiled/src/Main.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 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 {
+ public static void $noinline$hotnessCount() {
+ }
+
+ public static void $noinline$hotnessCountWithLoop() {
+ for (int i = 0; i < 100; i++) {
+ $noinline$hotnessCount();
+ }
+ }
+
+ public static void main(String[] args) {
+ System.loadLibrary(args[0]);
+ if (!isAotCompiled(Main.class, "main")) {
+ return;
+ }
+ $noinline$hotnessCount();
+ int counter = getHotnessCounter(Main.class, "$noinline$hotnessCount");
+ if (counter == 0) {
+ throw new Error("Expected hotness counter to be updated");
+ }
+
+ $noinline$hotnessCountWithLoop();
+ if (getHotnessCounter(Main.class, "$noinline$hotnessCountWithLoop") <= counter) {
+ throw new Error("Expected hotness counter of a loop to be greater than without loop");
+ }
+ }
+
+ public static native int getHotnessCounter(Class<?> cls, String methodName);
+ public static native boolean isAotCompiled(Class<?> cls, String methodName);
+}
diff --git a/test/common/runtime_state.cc b/test/common/runtime_state.cc
index 84993483f2..298a2f0033 100644
--- a/test/common/runtime_state.cc
+++ b/test/common/runtime_state.cc
@@ -251,13 +251,6 @@ extern "C" JNIEXPORT int JNICALL Java_Main_getHotnessCounter(JNIEnv* env,
jclass,
jclass cls,
jstring method_name) {
- jit::Jit* jit = Runtime::Current()->GetJit();
- if (jit == nullptr) {
- // The hotness counter is valid only under JIT.
- // If we don't JIT return 0 to match test expectations.
- return 0;
- }
-
ArtMethod* method = nullptr;
{
ScopedObjectAccess soa(Thread::Current());