| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 17 | #include "dalvik_system_VMRuntime.h" |
| 18 | |
| Bilyan Borisov | bb661c0 | 2016-04-04 16:27:32 +0100 | [diff] [blame] | 19 | #ifdef ART_TARGET_ANDROID |
| Hiroshi Yamauchi | d7f0339 | 2017-03-29 14:47:49 -0700 | [diff] [blame] | 20 | #include <sys/resource.h> |
| Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 21 | #include <sys/time.h> |
| Dmitriy Ivanov | 15efde2 | 2015-05-22 18:03:34 -0700 | [diff] [blame] | 22 | extern "C" void android_set_application_target_sdk_version(uint32_t version); |
| 23 | #endif |
| Hans Boehm | f57f7d4 | 2019-03-14 17:49:26 -0700 | [diff] [blame] | 24 | #include <inttypes.h> |
| 25 | #include <limits> |
| Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 26 | #include <limits.h> |
| Andreas Gampe | 373a9b5 | 2017-10-18 09:01:57 -0700 | [diff] [blame] | 27 | #include "nativehelper/scoped_utf_chars.h" |
| Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 28 | |
| Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 29 | #include <android-base/stringprintf.h> |
| 30 | #include <android-base/strings.h> |
| Andreas Gampe | 46ee31b | 2016-12-14 10:11:49 -0800 | [diff] [blame] | 31 | |
| Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 32 | #include "arch/instruction_set.h" |
| Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 33 | #include "art_method-inl.h" |
| Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 34 | #include "base/enums.h" |
| David Brazdil | 2bb2fbd | 2018-11-13 18:24:26 +0000 | [diff] [blame] | 35 | #include "base/sdk_version.h" |
| Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 36 | #include "class_linker-inl.h" |
| Dan Zimmerman | c9fa770 | 2020-01-31 13:35:12 -0800 | [diff] [blame] | 37 | #include "class_loader_context.h" |
| Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 38 | #include "common_throws.h" |
| Elliott Hughes | f6a1e1e | 2011-10-25 16:28:04 -0700 | [diff] [blame] | 39 | #include "debugger.h" |
| Mathieu Chartier | 1f1cb9f | 2018-06-04 09:22:46 -0700 | [diff] [blame] | 40 | #include "dex/class_accessor-inl.h" |
| David Sehr | 9e734c7 | 2018-01-04 17:56:19 -0800 | [diff] [blame] | 41 | #include "dex/dex_file-inl.h" |
| 42 | #include "dex/dex_file_types.h" |
| Brian Carlstrom | e810452 | 2013-10-15 21:56:36 -0700 | [diff] [blame] | 43 | #include "gc/accounting/card_table-inl.h" |
| Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 44 | #include "gc/allocator/dlmalloc.h" |
| Mathieu Chartier | 8235331 | 2013-07-18 10:47:51 -0700 | [diff] [blame] | 45 | #include "gc/heap.h" |
| Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 46 | #include "gc/space/dlmalloc_space.h" |
| Brian Carlstrom | 31d8f52 | 2014-09-29 11:22:54 -0700 | [diff] [blame] | 47 | #include "gc/space/image_space.h" |
| Mathieu Chartier | a5eae69 | 2014-12-17 17:56:03 -0800 | [diff] [blame] | 48 | #include "gc/task_processor.h" |
| Brian Carlstrom | e810452 | 2013-10-15 21:56:36 -0700 | [diff] [blame] | 49 | #include "intern_table.h" |
| David Srbecky | bfcea3d | 2019-08-05 15:44:00 +0100 | [diff] [blame] | 50 | #include "jit/jit.h" |
| Vladimir Marko | a3ad0cd | 2018-05-04 10:06:38 +0100 | [diff] [blame] | 51 | #include "jni/java_vm_ext.h" |
| 52 | #include "jni/jni_internal.h" |
| Andreas Gampe | 8e0f043 | 2018-10-24 13:38:03 -0700 | [diff] [blame] | 53 | #include "mirror/array-alloc-inl.h" |
| Ian Rogers | 4f6ad8a | 2013-03-18 15:27:28 -0700 | [diff] [blame] | 54 | #include "mirror/class-inl.h" |
| Brian Carlstrom | e810452 | 2013-10-15 21:56:36 -0700 | [diff] [blame] | 55 | #include "mirror/dex_cache-inl.h" |
| Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 56 | #include "mirror/object-inl.h" |
| Andreas Gampe | 87583b3 | 2017-05-25 11:22:18 -0700 | [diff] [blame] | 57 | #include "native_util.h" |
| Steven Moreland | e431e27 | 2017-07-18 16:53:49 -0700 | [diff] [blame] | 58 | #include "nativehelper/jni_macros.h" |
| Andreas Gampe | 373a9b5 | 2017-10-18 09:01:57 -0700 | [diff] [blame] | 59 | #include "nativehelper/scoped_local_ref.h" |
| Mathieu Chartier | 893263b | 2014-03-04 11:07:42 -0800 | [diff] [blame] | 60 | #include "runtime.h" |
| Mathieu Chartier | 0795f23 | 2016-09-27 18:43:30 -0700 | [diff] [blame] | 61 | #include "scoped_fast_native_object_access-inl.h" |
| 62 | #include "scoped_thread_state_change-inl.h" |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 63 | #include "thread.h" |
| Elliott Hughes | 88c5c35 | 2012-03-15 18:49:48 -0700 | [diff] [blame] | 64 | #include "thread_list.h" |
| Andreas Gampe | d0332e0 | 2017-09-22 19:23:38 -0700 | [diff] [blame] | 65 | #include "well_known_classes.h" |
| Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 66 | |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 67 | namespace art { |
| 68 | |
| Andreas Gampe | 46ee31b | 2016-12-14 10:11:49 -0800 | [diff] [blame] | 69 | using android::base::StringPrintf; |
| 70 | |
| Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 71 | static jfloat VMRuntime_getTargetHeapUtilization(JNIEnv*, jobject) { |
| Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 72 | return Runtime::Current()->GetHeap()->GetTargetHeapUtilization(); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 75 | static void VMRuntime_nativeSetTargetHeapUtilization(JNIEnv*, jobject, jfloat target) { |
| Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 76 | Runtime::Current()->GetHeap()->SetTargetHeapUtilization(target); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| Mathew Inwood | 3383aa5 | 2018-03-16 14:18:33 +0000 | [diff] [blame] | 79 | static void VMRuntime_setHiddenApiExemptions(JNIEnv* env, |
| 80 | jclass, |
| 81 | jobjectArray exemptions) { |
| 82 | std::vector<std::string> exemptions_vec; |
| 83 | int exemptions_length = env->GetArrayLength(exemptions); |
| 84 | for (int i = 0; i < exemptions_length; i++) { |
| 85 | jstring exemption = reinterpret_cast<jstring>(env->GetObjectArrayElement(exemptions, i)); |
| 86 | const char* raw_exemption = env->GetStringUTFChars(exemption, nullptr); |
| 87 | exemptions_vec.push_back(raw_exemption); |
| 88 | env->ReleaseStringUTFChars(exemption, raw_exemption); |
| 89 | } |
| 90 | |
| 91 | Runtime::Current()->SetHiddenApiExemptions(exemptions_vec); |
| 92 | } |
| 93 | |
| Mathew Inwood | 73ddda4 | 2018-04-03 15:32:32 +0100 | [diff] [blame] | 94 | static void VMRuntime_setHiddenApiAccessLogSamplingRate(JNIEnv*, jclass, jint rate) { |
| 95 | Runtime::Current()->SetHiddenApiEventLogSampleRate(rate); |
| 96 | } |
| 97 | |
| Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 98 | static jobject VMRuntime_newNonMovableArray(JNIEnv* env, jobject, jclass javaElementClass, |
| Brian Carlstrom | e810452 | 2013-10-15 21:56:36 -0700 | [diff] [blame] | 99 | jint length) { |
| Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 100 | ScopedFastNativeObjectAccess soa(env); |
| Ian Rogers | f9c612f | 2014-02-27 10:58:17 -0800 | [diff] [blame] | 101 | if (UNLIKELY(length < 0)) { |
| 102 | ThrowNegativeArraySizeException(length); |
| 103 | return nullptr; |
| 104 | } |
| Mathieu Chartier | bc5a795 | 2016-10-17 15:46:31 -0700 | [diff] [blame] | 105 | ObjPtr<mirror::Class> element_class = soa.Decode<mirror::Class>(javaElementClass); |
| Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 106 | if (UNLIKELY(element_class == nullptr)) { |
| Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 107 | ThrowNullPointerException("element class == null"); |
| Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 108 | return nullptr; |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 109 | } |
| Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 110 | Runtime* runtime = Runtime::Current(); |
| Mathieu Chartier | bc5a795 | 2016-10-17 15:46:31 -0700 | [diff] [blame] | 111 | ObjPtr<mirror::Class> array_class = |
| Vladimir Marko | bcf1752 | 2018-06-01 13:14:32 +0100 | [diff] [blame] | 112 | runtime->GetClassLinker()->FindArrayClass(soa.Self(), element_class); |
| Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 113 | if (UNLIKELY(array_class == nullptr)) { |
| 114 | return nullptr; |
| 115 | } |
| 116 | gc::AllocatorType allocator = runtime->GetHeap()->GetCurrentNonMovingAllocator(); |
| Vladimir Marko | 9b81ac3 | 2019-05-16 16:47:08 +0100 | [diff] [blame] | 117 | ObjPtr<mirror::Array> result = mirror::Array::Alloc(soa.Self(), |
| 118 | array_class, |
| 119 | length, |
| 120 | array_class->GetComponentSizeShift(), |
| 121 | allocator); |
| Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 122 | return soa.AddLocalReference<jobject>(result); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| Ian Rogers | f9c612f | 2014-02-27 10:58:17 -0800 | [diff] [blame] | 125 | static jobject VMRuntime_newUnpaddedArray(JNIEnv* env, jobject, jclass javaElementClass, |
| 126 | jint length) { |
| 127 | ScopedFastNativeObjectAccess soa(env); |
| 128 | if (UNLIKELY(length < 0)) { |
| 129 | ThrowNegativeArraySizeException(length); |
| 130 | return nullptr; |
| 131 | } |
| Mathieu Chartier | bc5a795 | 2016-10-17 15:46:31 -0700 | [diff] [blame] | 132 | ObjPtr<mirror::Class> element_class = soa.Decode<mirror::Class>(javaElementClass); |
| Ian Rogers | f9c612f | 2014-02-27 10:58:17 -0800 | [diff] [blame] | 133 | if (UNLIKELY(element_class == nullptr)) { |
| Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 134 | ThrowNullPointerException("element class == null"); |
| Ian Rogers | f9c612f | 2014-02-27 10:58:17 -0800 | [diff] [blame] | 135 | return nullptr; |
| 136 | } |
| Ian Rogers | f9c612f | 2014-02-27 10:58:17 -0800 | [diff] [blame] | 137 | Runtime* runtime = Runtime::Current(); |
| Mathieu Chartier | bc5a795 | 2016-10-17 15:46:31 -0700 | [diff] [blame] | 138 | ObjPtr<mirror::Class> array_class = runtime->GetClassLinker()->FindArrayClass(soa.Self(), |
| Vladimir Marko | bcf1752 | 2018-06-01 13:14:32 +0100 | [diff] [blame] | 139 | element_class); |
| Ian Rogers | f9c612f | 2014-02-27 10:58:17 -0800 | [diff] [blame] | 140 | if (UNLIKELY(array_class == nullptr)) { |
| 141 | return nullptr; |
| 142 | } |
| 143 | gc::AllocatorType allocator = runtime->GetHeap()->GetCurrentAllocator(); |
| Vladimir Marko | 9b81ac3 | 2019-05-16 16:47:08 +0100 | [diff] [blame] | 144 | ObjPtr<mirror::Array> result = |
| 145 | mirror::Array::Alloc</*kIsInstrumented=*/ true, /*kFillUsable=*/ true>( |
| 146 | soa.Self(), |
| 147 | array_class, |
| 148 | length, |
| 149 | array_class->GetComponentSizeShift(), |
| 150 | allocator); |
| Ian Rogers | f9c612f | 2014-02-27 10:58:17 -0800 | [diff] [blame] | 151 | return soa.AddLocalReference<jobject>(result); |
| 152 | } |
| 153 | |
| Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 154 | static jlong VMRuntime_addressOf(JNIEnv* env, jobject, jobject javaArray) { |
| Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 155 | if (javaArray == nullptr) { // Most likely allocation failed |
| Ian Rogers | a15e67d | 2012-02-28 13:51:55 -0800 | [diff] [blame] | 156 | return 0; |
| 157 | } |
| Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 158 | ScopedFastNativeObjectAccess soa(env); |
| Mathieu Chartier | 0795f23 | 2016-09-27 18:43:30 -0700 | [diff] [blame] | 159 | ObjPtr<mirror::Array> array = soa.Decode<mirror::Array>(javaArray); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 160 | if (!array->IsArrayInstance()) { |
| Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 161 | ThrowIllegalArgumentException("not an array"); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 162 | return 0; |
| 163 | } |
| Mathieu Chartier | bc5a795 | 2016-10-17 15:46:31 -0700 | [diff] [blame] | 164 | if (Runtime::Current()->GetHeap()->IsMovableObject(array)) { |
| Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 165 | ThrowRuntimeException("Trying to get address of movable array object"); |
| 166 | return 0; |
| 167 | } |
| Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 168 | return reinterpret_cast<uintptr_t>(array->GetRawData(array->GetClass()->GetComponentSize(), 0)); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 171 | static void VMRuntime_clearGrowthLimit(JNIEnv*, jobject) { |
| Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 172 | Runtime::Current()->GetHeap()->ClearGrowthLimit(); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 173 | } |
| 174 | |
| Mathieu Chartier | 379d09f | 2015-01-08 11:28:13 -0800 | [diff] [blame] | 175 | static void VMRuntime_clampGrowthLimit(JNIEnv*, jobject) { |
| 176 | Runtime::Current()->GetHeap()->ClampGrowthLimit(); |
| 177 | } |
| 178 | |
| Oleksiy Vyalov | 278a80b | 2016-03-30 20:27:00 -0700 | [diff] [blame] | 179 | static jboolean VMRuntime_isNativeDebuggable(JNIEnv*, jobject) { |
| 180 | return Runtime::Current()->IsNativeDebuggable(); |
| 181 | } |
| 182 | |
| Mathew Inwood | eef7757 | 2018-05-18 13:32:09 +0100 | [diff] [blame] | 183 | static jboolean VMRuntime_isJavaDebuggable(JNIEnv*, jobject) { |
| 184 | return Runtime::Current()->IsJavaDebuggable(); |
| 185 | } |
| 186 | |
| Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 187 | static jobjectArray VMRuntime_properties(JNIEnv* env, jobject) { |
| Andreas Gampe | d0332e0 | 2017-09-22 19:23:38 -0700 | [diff] [blame] | 188 | DCHECK(WellKnownClasses::java_lang_String != nullptr); |
| 189 | |
| 190 | const std::vector<std::string>& properties = Runtime::Current()->GetProperties(); |
| 191 | ScopedLocalRef<jobjectArray> ret(env, |
| 192 | env->NewObjectArray(static_cast<jsize>(properties.size()), |
| 193 | WellKnownClasses::java_lang_String, |
| 194 | nullptr /* initial element */)); |
| 195 | if (ret == nullptr) { |
| 196 | DCHECK(env->ExceptionCheck()); |
| 197 | return nullptr; |
| 198 | } |
| 199 | for (size_t i = 0; i != properties.size(); ++i) { |
| 200 | ScopedLocalRef<jstring> str(env, env->NewStringUTF(properties[i].c_str())); |
| 201 | if (str == nullptr) { |
| 202 | DCHECK(env->ExceptionCheck()); |
| 203 | return nullptr; |
| 204 | } |
| 205 | env->SetObjectArrayElement(ret.get(), static_cast<jsize>(i), str.get()); |
| 206 | DCHECK(!env->ExceptionCheck()); |
| 207 | } |
| 208 | return ret.release(); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| Brian Carlstrom | 7d5ffb5 | 2012-02-01 14:27:54 -0800 | [diff] [blame] | 211 | // This is for backward compatibility with dalvik which returned the |
| 212 | // meaningless "." when no boot classpath or classpath was |
| 213 | // specified. Unfortunately, some tests were using java.class.path to |
| 214 | // lookup relative file locations, so they are counting on this to be |
| 215 | // ".", presumably some applications or libraries could have as well. |
| Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 216 | static const char* DefaultToDot(const std::string& class_path) { |
| Brian Carlstrom | 7d5ffb5 | 2012-02-01 14:27:54 -0800 | [diff] [blame] | 217 | return class_path.empty() ? "." : class_path.c_str(); |
| 218 | } |
| 219 | |
| Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 220 | static jstring VMRuntime_bootClassPath(JNIEnv* env, jobject) { |
| Vladimir Marko | 91f1032 | 2018-12-07 18:04:10 +0000 | [diff] [blame] | 221 | std::string boot_class_path = android::base::Join(Runtime::Current()->GetBootClassPath(), ':'); |
| 222 | return env->NewStringUTF(DefaultToDot(boot_class_path)); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 225 | static jstring VMRuntime_classPath(JNIEnv* env, jobject) { |
| Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 226 | return env->NewStringUTF(DefaultToDot(Runtime::Current()->GetClassPathString())); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 227 | } |
| 228 | |
| Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 229 | static jstring VMRuntime_vmVersion(JNIEnv* env, jobject) { |
| Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 230 | return env->NewStringUTF(Runtime::GetVersion()); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 231 | } |
| 232 | |
| Brian Carlstrom | cef450c | 2013-06-28 14:38:26 -0700 | [diff] [blame] | 233 | static jstring VMRuntime_vmLibrary(JNIEnv* env, jobject) { |
| 234 | return env->NewStringUTF(kIsDebugBuild ? "libartd.so" : "libart.so"); |
| 235 | } |
| 236 | |
| Sebastien Hertz | a705376 | 2014-05-16 16:56:45 +0200 | [diff] [blame] | 237 | static jstring VMRuntime_vmInstructionSet(JNIEnv* env, jobject) { |
| 238 | InstructionSet isa = Runtime::Current()->GetInstructionSet(); |
| 239 | const char* isa_string = GetInstructionSetString(isa); |
| 240 | return env->NewStringUTF(isa_string); |
| 241 | } |
| 242 | |
| Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 243 | static jboolean VMRuntime_is64Bit(JNIEnv*, jobject) { |
| Sebastien Hertz | a705376 | 2014-05-16 16:56:45 +0200 | [diff] [blame] | 244 | bool is64BitMode = (sizeof(void*) == sizeof(uint64_t)); |
| 245 | return is64BitMode ? JNI_TRUE : JNI_FALSE; |
| 246 | } |
| 247 | |
| 248 | static jboolean VMRuntime_isCheckJniEnabled(JNIEnv* env, jobject) { |
| Ian Rogers | 55256cb | 2017-12-21 17:07:11 -0800 | [diff] [blame] | 249 | return down_cast<JNIEnvExt*>(env)->GetVm()->IsCheckJniEnabled() ? JNI_TRUE : JNI_FALSE; |
| Sebastien Hertz | a705376 | 2014-05-16 16:56:45 +0200 | [diff] [blame] | 250 | } |
| 251 | |
| Jeff Hao | f00571c | 2014-05-29 17:29:47 -0700 | [diff] [blame] | 252 | static void VMRuntime_setTargetSdkVersionNative(JNIEnv*, jobject, jint target_sdk_version) { |
| Ian Rogers | 987560f | 2014-04-22 11:42:59 -0700 | [diff] [blame] | 253 | // This is the target SDK version of the app we're about to run. It is intended that this a place |
| 254 | // where workarounds can be enabled. |
| Elliott Hughes | c2dc62d | 2012-01-17 20:06:12 -0800 | [diff] [blame] | 255 | // Note that targetSdkVersion may be CUR_DEVELOPMENT (10000). |
| 256 | // Note that targetSdkVersion may be 0, meaning "current". |
| David Brazdil | 2bb2fbd | 2018-11-13 18:24:26 +0000 | [diff] [blame] | 257 | uint32_t uint_target_sdk_version = |
| 258 | target_sdk_version <= 0 ? static_cast<uint32_t>(SdkVersion::kUnset) |
| 259 | : static_cast<uint32_t>(target_sdk_version); |
| 260 | Runtime::Current()->SetTargetSdkVersion(uint_target_sdk_version); |
| Dmitriy Ivanov | 15efde2 | 2015-05-22 18:03:34 -0700 | [diff] [blame] | 261 | |
| Bilyan Borisov | bb661c0 | 2016-04-04 16:27:32 +0100 | [diff] [blame] | 262 | #ifdef ART_TARGET_ANDROID |
| Dmitriy Ivanov | 15efde2 | 2015-05-22 18:03:34 -0700 | [diff] [blame] | 263 | // This part is letting libc/dynamic linker know about current app's |
| 264 | // target sdk version to enable compatibility workarounds. |
| David Brazdil | 2bb2fbd | 2018-11-13 18:24:26 +0000 | [diff] [blame] | 265 | android_set_application_target_sdk_version(uint_target_sdk_version); |
| Dmitriy Ivanov | 15efde2 | 2015-05-22 18:03:34 -0700 | [diff] [blame] | 266 | #endif |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 267 | } |
| 268 | |
| atrost | fab7208 | 2019-12-06 13:37:36 +0000 | [diff] [blame] | 269 | static void VMRuntime_setDisabledCompatChangesNative(JNIEnv* env, jobject, |
| 270 | jlongArray disabled_compat_changes) { |
| 271 | if (disabled_compat_changes == nullptr) { |
| 272 | return; |
| 273 | } |
| atrost | a9ff45b | 2020-01-14 15:59:02 +0000 | [diff] [blame] | 274 | std::set<uint64_t> disabled_compat_changes_set; |
| atrost | fab7208 | 2019-12-06 13:37:36 +0000 | [diff] [blame] | 275 | int length = env->GetArrayLength(disabled_compat_changes); |
| 276 | jlong* elements = env->GetLongArrayElements(disabled_compat_changes, /*isCopy*/nullptr); |
| 277 | for (int i = 0; i < length; i++) { |
| atrost | a9ff45b | 2020-01-14 15:59:02 +0000 | [diff] [blame] | 278 | disabled_compat_changes_set.insert(static_cast<uint64_t>(elements[i])); |
| atrost | fab7208 | 2019-12-06 13:37:36 +0000 | [diff] [blame] | 279 | } |
| Andrei Onea | 037d282 | 2020-11-19 00:20:04 +0000 | [diff] [blame] | 280 | Runtime::Current()->GetCompatFramework().SetDisabledCompatChanges(disabled_compat_changes_set); |
| atrost | fab7208 | 2019-12-06 13:37:36 +0000 | [diff] [blame] | 281 | } |
| 282 | |
| Hans Boehm | f57f7d4 | 2019-03-14 17:49:26 -0700 | [diff] [blame] | 283 | static inline size_t clamp_to_size_t(jlong n) { |
| 284 | if (sizeof(jlong) > sizeof(size_t) |
| 285 | && UNLIKELY(n > static_cast<jlong>(std::numeric_limits<size_t>::max()))) { |
| 286 | return std::numeric_limits<size_t>::max(); |
| 287 | } else { |
| 288 | return n; |
| Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 289 | } |
| Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 290 | } |
| 291 | |
| Hans Boehm | f57f7d4 | 2019-03-14 17:49:26 -0700 | [diff] [blame] | 292 | static void VMRuntime_registerNativeAllocation(JNIEnv* env, jobject, jlong bytes) { |
| Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 293 | if (UNLIKELY(bytes < 0)) { |
| 294 | ScopedObjectAccess soa(env); |
| Hans Boehm | f57f7d4 | 2019-03-14 17:49:26 -0700 | [diff] [blame] | 295 | ThrowRuntimeException("allocation size negative %" PRId64, bytes); |
| Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 296 | return; |
| 297 | } |
| Hans Boehm | f57f7d4 | 2019-03-14 17:49:26 -0700 | [diff] [blame] | 298 | Runtime::Current()->GetHeap()->RegisterNativeAllocation(env, clamp_to_size_t(bytes)); |
| 299 | } |
| 300 | |
| 301 | static void VMRuntime_registerNativeFree(JNIEnv* env, jobject, jlong bytes) { |
| 302 | if (UNLIKELY(bytes < 0)) { |
| 303 | ScopedObjectAccess soa(env); |
| 304 | ThrowRuntimeException("allocation size negative %" PRId64, bytes); |
| 305 | return; |
| 306 | } |
| 307 | Runtime::Current()->GetHeap()->RegisterNativeFree(env, clamp_to_size_t(bytes)); |
| Mathieu Chartier | 987ccff | 2013-07-08 11:05:21 -0700 | [diff] [blame] | 308 | } |
| 309 | |
| Hans Boehm | c220f98 | 2018-10-12 16:15:45 -0700 | [diff] [blame] | 310 | static jint VMRuntime_getNotifyNativeInterval(JNIEnv*, jclass) { |
| 311 | return Runtime::Current()->GetHeap()->GetNotifyNativeInterval(); |
| 312 | } |
| 313 | |
| 314 | static void VMRuntime_notifyNativeAllocationsInternal(JNIEnv* env, jobject) { |
| 315 | Runtime::Current()->GetHeap()->NotifyNativeAllocations(env); |
| 316 | } |
| 317 | |
| Hans Boehm | b215557 | 2019-03-27 14:25:53 -0700 | [diff] [blame] | 318 | static jlong VMRuntime_getFinalizerTimeoutMs(JNIEnv*, jobject) { |
| 319 | return Runtime::Current()->GetFinalizerTimeoutMs(); |
| 320 | } |
| 321 | |
| Hans Boehm | c220f98 | 2018-10-12 16:15:45 -0700 | [diff] [blame] | 322 | static void VMRuntime_registerSensitiveThread(JNIEnv*, jobject) { |
| 323 | Runtime::Current()->RegisterSensitiveThread(); |
| 324 | } |
| 325 | |
| Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 326 | static void VMRuntime_updateProcessState(JNIEnv*, jobject, jint process_state) { |
| 327 | Runtime* runtime = Runtime::Current(); |
| Mathieu Chartier | f8cb178 | 2016-03-18 18:45:41 -0700 | [diff] [blame] | 328 | runtime->UpdateProcessState(static_cast<ProcessState>(process_state)); |
| Mathieu Chartier | ca2a24d | 2013-11-25 15:12:12 -0800 | [diff] [blame] | 329 | } |
| 330 | |
| Mathieu Chartier | 175ce3d | 2019-03-06 16:54:24 -0800 | [diff] [blame] | 331 | static void VMRuntime_notifyStartupCompleted(JNIEnv*, jobject) { |
| 332 | Runtime::Current()->NotifyStartupCompleted(); |
| 333 | } |
| 334 | |
| Mathieu Chartier | a5eae69 | 2014-12-17 17:56:03 -0800 | [diff] [blame] | 335 | static void VMRuntime_trimHeap(JNIEnv* env, jobject) { |
| 336 | Runtime::Current()->GetHeap()->Trim(ThreadForEnv(env)); |
| Elliott Hughes | 8cf5bc0 | 2012-02-02 16:32:16 -0800 | [diff] [blame] | 337 | } |
| 338 | |
| Mathieu Chartier | a5eae69 | 2014-12-17 17:56:03 -0800 | [diff] [blame] | 339 | static void VMRuntime_requestHeapTrim(JNIEnv* env, jobject) { |
| 340 | Runtime::Current()->GetHeap()->RequestTrim(ThreadForEnv(env)); |
| Mathieu Chartier | 079101a | 2014-12-15 14:23:10 -0800 | [diff] [blame] | 341 | } |
| Mathieu Chartier | a5eae69 | 2014-12-17 17:56:03 -0800 | [diff] [blame] | 342 | |
| 343 | static void VMRuntime_requestConcurrentGC(JNIEnv* env, jobject) { |
| Hans Boehm | 5c4d0df | 2021-04-29 16:16:39 +0000 | [diff] [blame] | 344 | gc::Heap *heap = Runtime::Current()->GetHeap(); |
| 345 | heap->RequestConcurrentGC(ThreadForEnv(env), |
| 346 | gc::kGcCauseBackground, |
| 347 | true, |
| 348 | heap->GetCurrentGcNum()); |
| Mathieu Chartier | a5eae69 | 2014-12-17 17:56:03 -0800 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | static void VMRuntime_startHeapTaskProcessor(JNIEnv* env, jobject) { |
| 352 | Runtime::Current()->GetHeap()->GetTaskProcessor()->Start(ThreadForEnv(env)); |
| 353 | } |
| 354 | |
| 355 | static void VMRuntime_stopHeapTaskProcessor(JNIEnv* env, jobject) { |
| 356 | Runtime::Current()->GetHeap()->GetTaskProcessor()->Stop(ThreadForEnv(env)); |
| 357 | } |
| 358 | |
| 359 | static void VMRuntime_runHeapTasks(JNIEnv* env, jobject) { |
| 360 | Runtime::Current()->GetHeap()->GetTaskProcessor()->RunAllTasks(ThreadForEnv(env)); |
| Mathieu Chartier | 079101a | 2014-12-15 14:23:10 -0800 | [diff] [blame] | 361 | } |
| 362 | |
| David Srbecky | d259ffb | 2020-12-08 16:59:18 +0000 | [diff] [blame] | 363 | static void VMRuntime_preloadDexCaches(JNIEnv* env ATTRIBUTE_UNUSED, jobject) { |
| Brian Carlstrom | e810452 | 2013-10-15 21:56:36 -0700 | [diff] [blame] | 364 | } |
| 365 | |
| Dave Allison | 0aded08 | 2013-11-07 13:15:11 -0800 | [diff] [blame] | 366 | /* |
| Calin Juravle | 3ddf4d4 | 2021-05-11 10:19:28 -0700 | [diff] [blame] | 367 | * This is called by the framework after it loads a code path on behalf of the app. |
| 368 | * The code_path_type indicates the type of the apk being loaded and can be used |
| 369 | * for more precise telemetry (e.g. is the split apk odex up to date?) and debugging. |
| Dave Allison | 0aded08 | 2013-11-07 13:15:11 -0800 | [diff] [blame] | 370 | */ |
| Calin Juravle | 31f2c15 | 2015-10-23 17:56:15 +0100 | [diff] [blame] | 371 | static void VMRuntime_registerAppInfo(JNIEnv* env, |
| 372 | jclass clazz ATTRIBUTE_UNUSED, |
| Calin Juravle | c2753e6 | 2021-06-25 15:34:09 -0700 | [diff] [blame] | 373 | jstring package_name, |
| Calin Juravle | 3ddf4d4 | 2021-05-11 10:19:28 -0700 | [diff] [blame] | 374 | jstring cur_profile_file, |
| Calin Juravle | beb9f20 | 2021-06-02 14:42:03 -0700 | [diff] [blame] | 375 | jstring ref_profile_file, |
| Calin Juravle | 3ddf4d4 | 2021-05-11 10:19:28 -0700 | [diff] [blame] | 376 | jobjectArray code_paths, |
| Calin Juravle | c2753e6 | 2021-06-25 15:34:09 -0700 | [diff] [blame] | 377 | jint code_path_type) { |
| Calin Juravle | 66f5523 | 2015-12-08 15:09:10 +0000 | [diff] [blame] | 378 | std::vector<std::string> code_paths_vec; |
| 379 | int code_paths_length = env->GetArrayLength(code_paths); |
| 380 | for (int i = 0; i < code_paths_length; i++) { |
| 381 | jstring code_path = reinterpret_cast<jstring>(env->GetObjectArrayElement(code_paths, i)); |
| 382 | const char* raw_code_path = env->GetStringUTFChars(code_path, nullptr); |
| 383 | code_paths_vec.push_back(raw_code_path); |
| 384 | env->ReleaseStringUTFChars(code_path, raw_code_path); |
| 385 | } |
| Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 386 | |
| Calin Juravle | 3ddf4d4 | 2021-05-11 10:19:28 -0700 | [diff] [blame] | 387 | const char* raw_cur_profile_file = env->GetStringUTFChars(cur_profile_file, nullptr); |
| 388 | std::string cur_profile_file_str(raw_cur_profile_file); |
| 389 | env->ReleaseStringUTFChars(cur_profile_file, raw_cur_profile_file); |
| Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 390 | |
| Calin Juravle | beb9f20 | 2021-06-02 14:42:03 -0700 | [diff] [blame] | 391 | const char* raw_ref_profile_file = env->GetStringUTFChars(ref_profile_file, nullptr); |
| 392 | std::string ref_profile_file_str(raw_ref_profile_file); |
| 393 | env->ReleaseStringUTFChars(ref_profile_file, raw_ref_profile_file); |
| 394 | |
| Calin Juravle | c2753e6 | 2021-06-25 15:34:09 -0700 | [diff] [blame] | 395 | const char* raw_package_name = env->GetStringUTFChars(package_name, nullptr); |
| 396 | std::string package_name_str(raw_package_name); |
| 397 | env->ReleaseStringUTFChars(package_name, raw_package_name); |
| 398 | |
| 399 | Runtime::Current()->RegisterAppInfo( |
| 400 | package_name_str, |
| 401 | code_paths_vec, |
| 402 | cur_profile_file_str, |
| 403 | ref_profile_file_str, |
| 404 | static_cast<int32_t>(code_path_type)); |
| Dave Allison | 0aded08 | 2013-11-07 13:15:11 -0800 | [diff] [blame] | 405 | } |
| 406 | |
| Brian Carlstrom | 31d8f52 | 2014-09-29 11:22:54 -0700 | [diff] [blame] | 407 | static jboolean VMRuntime_isBootClassPathOnDisk(JNIEnv* env, jclass, jstring java_instruction_set) { |
| 408 | ScopedUtfChars instruction_set(env, java_instruction_set); |
| 409 | if (instruction_set.c_str() == nullptr) { |
| 410 | return JNI_FALSE; |
| 411 | } |
| 412 | InstructionSet isa = GetInstructionSetFromString(instruction_set.c_str()); |
| Vladimir Marko | 33bff25 | 2017-11-01 14:35:42 +0000 | [diff] [blame] | 413 | if (isa == InstructionSet::kNone) { |
| Brian Carlstrom | 31d8f52 | 2014-09-29 11:22:54 -0700 | [diff] [blame] | 414 | ScopedLocalRef<jclass> iae(env, env->FindClass("java/lang/IllegalArgumentException")); |
| 415 | std::string message(StringPrintf("Instruction set %s is invalid.", instruction_set.c_str())); |
| 416 | env->ThrowNew(iae.get(), message.c_str()); |
| 417 | return JNI_FALSE; |
| 418 | } |
| Vladimir Marko | f9dfd77 | 2020-01-30 13:56:13 +0000 | [diff] [blame] | 419 | return gc::space::ImageSpace::IsBootClassPathOnDisk(isa); |
| Brian Carlstrom | 31d8f52 | 2014-09-29 11:22:54 -0700 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | static jstring VMRuntime_getCurrentInstructionSet(JNIEnv* env, jclass) { |
| 423 | return env->NewStringUTF(GetInstructionSetString(kRuntimeISA)); |
| 424 | } |
| 425 | |
| Hiroshi Yamauchi | d7f0339 | 2017-03-29 14:47:49 -0700 | [diff] [blame] | 426 | static void VMRuntime_setSystemDaemonThreadPriority(JNIEnv* env ATTRIBUTE_UNUSED, |
| 427 | jclass klass ATTRIBUTE_UNUSED) { |
| 428 | #ifdef ART_TARGET_ANDROID |
| 429 | Thread* self = Thread::Current(); |
| 430 | DCHECK(self != nullptr); |
| 431 | pid_t tid = self->GetTid(); |
| 432 | // We use a priority lower than the default for the system daemon threads (eg HeapTaskDaemon) to |
| 433 | // avoid jank due to CPU contentions between GC and other UI-related threads. b/36631902. |
| 434 | // We may use a native priority that doesn't have a corresponding java.lang.Thread-level priority. |
| 435 | static constexpr int kSystemDaemonNiceValue = 4; // priority 124 |
| 436 | if (setpriority(PRIO_PROCESS, tid, kSystemDaemonNiceValue) != 0) { |
| 437 | PLOG(INFO) << *self << " setpriority(PRIO_PROCESS, " << tid << ", " |
| 438 | << kSystemDaemonNiceValue << ") failed"; |
| 439 | } |
| 440 | #endif |
| 441 | } |
| 442 | |
| Mathew Inwood | 80900a3 | 2018-04-19 14:40:40 +0100 | [diff] [blame] | 443 | static void VMRuntime_setDedupeHiddenApiWarnings(JNIEnv* env ATTRIBUTE_UNUSED, |
| 444 | jclass klass ATTRIBUTE_UNUSED, |
| 445 | jboolean dedupe) { |
| 446 | Runtime::Current()->SetDedupeHiddenApiWarnings(dedupe); |
| 447 | } |
| 448 | |
| Mathew Inwood | 5bcef17 | 2018-05-01 14:40:12 +0100 | [diff] [blame] | 449 | static void VMRuntime_setProcessPackageName(JNIEnv* env, |
| 450 | jclass klass ATTRIBUTE_UNUSED, |
| 451 | jstring java_package_name) { |
| 452 | ScopedUtfChars package_name(env, java_package_name); |
| 453 | Runtime::Current()->SetProcessPackageName(package_name.c_str()); |
| 454 | } |
| 455 | |
| David Brazdil | c2f4357 | 2019-04-03 12:56:14 +0100 | [diff] [blame] | 456 | static void VMRuntime_setProcessDataDirectory(JNIEnv* env, jclass, jstring java_data_dir) { |
| 457 | ScopedUtfChars data_dir(env, java_data_dir); |
| 458 | Runtime::Current()->SetProcessDataDirectory(data_dir.c_str()); |
| 459 | } |
| 460 | |
| David Srbecky | bfcea3d | 2019-08-05 15:44:00 +0100 | [diff] [blame] | 461 | static void VMRuntime_bootCompleted(JNIEnv* env ATTRIBUTE_UNUSED, |
| 462 | jclass klass ATTRIBUTE_UNUSED) { |
| 463 | jit::Jit* jit = Runtime::Current()->GetJit(); |
| 464 | if (jit != nullptr) { |
| 465 | jit->BootCompleted(); |
| 466 | } |
| 467 | } |
| 468 | |
| Mathieu Chartier | 0aa0206 | 2019-11-21 16:24:09 -0800 | [diff] [blame] | 469 | class ClearJitCountersVisitor : public ClassVisitor { |
| 470 | public: |
| 471 | bool operator()(ObjPtr<mirror::Class> klass) override REQUIRES_SHARED(Locks::mutator_lock_) { |
| 472 | // Avoid some types of classes that don't need their methods visited. |
| 473 | if (klass->IsProxyClass() || |
| 474 | klass->IsArrayClass() || |
| 475 | klass->IsPrimitive() || |
| 476 | !klass->IsResolved() || |
| 477 | klass->IsErroneousResolved()) { |
| 478 | return true; |
| 479 | } |
| 480 | for (ArtMethod& m : klass->GetMethods(kRuntimePointerSize)) { |
| 481 | if (!m.IsAbstract()) { |
| 482 | if (m.GetCounter() != 0) { |
| 483 | m.SetCounter(0); |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | return true; |
| 488 | } |
| 489 | }; |
| 490 | |
| 491 | static void VMRuntime_resetJitCounters(JNIEnv* env, jclass klass ATTRIBUTE_UNUSED) { |
| 492 | ScopedObjectAccess soa(env); |
| 493 | ClearJitCountersVisitor visitor; |
| 494 | Runtime::Current()->GetClassLinker()->VisitClasses(&visitor); |
| 495 | } |
| 496 | |
| Dan Zimmerman | c9fa770 | 2020-01-31 13:35:12 -0800 | [diff] [blame] | 497 | static jboolean VMRuntime_isValidClassLoaderContext(JNIEnv* env, |
| 498 | jclass klass ATTRIBUTE_UNUSED, |
| 499 | jstring jencoded_class_loader_context) { |
| 500 | if (UNLIKELY(jencoded_class_loader_context == nullptr)) { |
| 501 | ScopedFastNativeObjectAccess soa(env); |
| 502 | ThrowNullPointerException("encoded_class_loader_context == null"); |
| 503 | return false; |
| 504 | } |
| 505 | ScopedUtfChars encoded_class_loader_context(env, jencoded_class_loader_context); |
| 506 | return ClassLoaderContext::IsValidEncoding(encoded_class_loader_context.c_str()); |
| 507 | } |
| 508 | |
| Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 509 | static JNINativeMethod gMethods[] = { |
| Igor Murashkin | 3b6f440 | 2017-02-16 16:13:17 -0800 | [diff] [blame] | 510 | FAST_NATIVE_METHOD(VMRuntime, addressOf, "(Ljava/lang/Object;)J"), |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 511 | NATIVE_METHOD(VMRuntime, bootClassPath, "()Ljava/lang/String;"), |
| Mathieu Chartier | 379d09f | 2015-01-08 11:28:13 -0800 | [diff] [blame] | 512 | NATIVE_METHOD(VMRuntime, clampGrowthLimit, "()V"), |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 513 | NATIVE_METHOD(VMRuntime, classPath, "()Ljava/lang/String;"), |
| 514 | NATIVE_METHOD(VMRuntime, clearGrowthLimit, "()V"), |
| Mathew Inwood | 3383aa5 | 2018-03-16 14:18:33 +0000 | [diff] [blame] | 515 | NATIVE_METHOD(VMRuntime, setHiddenApiExemptions, "([Ljava/lang/String;)V"), |
| Mathew Inwood | 73ddda4 | 2018-04-03 15:32:32 +0100 | [diff] [blame] | 516 | NATIVE_METHOD(VMRuntime, setHiddenApiAccessLogSamplingRate, "(I)V"), |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 517 | NATIVE_METHOD(VMRuntime, getTargetHeapUtilization, "()F"), |
| Igor Murashkin | 3b6f440 | 2017-02-16 16:13:17 -0800 | [diff] [blame] | 518 | FAST_NATIVE_METHOD(VMRuntime, isNativeDebuggable, "()Z"), |
| Mathew Inwood | eef7757 | 2018-05-18 13:32:09 +0100 | [diff] [blame] | 519 | NATIVE_METHOD(VMRuntime, isJavaDebuggable, "()Z"), |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 520 | NATIVE_METHOD(VMRuntime, nativeSetTargetHeapUtilization, "(F)V"), |
| Igor Murashkin | 3b6f440 | 2017-02-16 16:13:17 -0800 | [diff] [blame] | 521 | FAST_NATIVE_METHOD(VMRuntime, newNonMovableArray, "(Ljava/lang/Class;I)Ljava/lang/Object;"), |
| 522 | FAST_NATIVE_METHOD(VMRuntime, newUnpaddedArray, "(Ljava/lang/Class;I)Ljava/lang/Object;"), |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 523 | NATIVE_METHOD(VMRuntime, properties, "()[Ljava/lang/String;"), |
| Alex Klyubin | 881392f | 2013-10-24 16:31:56 -0700 | [diff] [blame] | 524 | NATIVE_METHOD(VMRuntime, setTargetSdkVersionNative, "(I)V"), |
| atrost | fab7208 | 2019-12-06 13:37:36 +0000 | [diff] [blame] | 525 | NATIVE_METHOD(VMRuntime, setDisabledCompatChangesNative, "([J)V"), |
| Hans Boehm | f57f7d4 | 2019-03-14 17:49:26 -0700 | [diff] [blame] | 526 | NATIVE_METHOD(VMRuntime, registerNativeAllocation, "(J)V"), |
| 527 | NATIVE_METHOD(VMRuntime, registerNativeFree, "(J)V"), |
| Hans Boehm | c220f98 | 2018-10-12 16:15:45 -0700 | [diff] [blame] | 528 | NATIVE_METHOD(VMRuntime, getNotifyNativeInterval, "()I"), |
| Hans Boehm | b215557 | 2019-03-27 14:25:53 -0700 | [diff] [blame] | 529 | NATIVE_METHOD(VMRuntime, getFinalizerTimeoutMs, "()J"), |
| Hans Boehm | c220f98 | 2018-10-12 16:15:45 -0700 | [diff] [blame] | 530 | NATIVE_METHOD(VMRuntime, notifyNativeAllocationsInternal, "()V"), |
| Mathieu Chartier | 175ce3d | 2019-03-06 16:54:24 -0800 | [diff] [blame] | 531 | NATIVE_METHOD(VMRuntime, notifyStartupCompleted, "()V"), |
| Calin Juravle | 97cbc92 | 2016-04-15 16:16:35 +0100 | [diff] [blame] | 532 | NATIVE_METHOD(VMRuntime, registerSensitiveThread, "()V"), |
| Mathieu Chartier | a5eae69 | 2014-12-17 17:56:03 -0800 | [diff] [blame] | 533 | NATIVE_METHOD(VMRuntime, requestConcurrentGC, "()V"), |
| 534 | NATIVE_METHOD(VMRuntime, requestHeapTrim, "()V"), |
| 535 | NATIVE_METHOD(VMRuntime, runHeapTasks, "()V"), |
| Mathieu Chartier | ca2a24d | 2013-11-25 15:12:12 -0800 | [diff] [blame] | 536 | NATIVE_METHOD(VMRuntime, updateProcessState, "(I)V"), |
| Mathieu Chartier | a5eae69 | 2014-12-17 17:56:03 -0800 | [diff] [blame] | 537 | NATIVE_METHOD(VMRuntime, startHeapTaskProcessor, "()V"), |
| Mathieu Chartier | a5eae69 | 2014-12-17 17:56:03 -0800 | [diff] [blame] | 538 | NATIVE_METHOD(VMRuntime, stopHeapTaskProcessor, "()V"), |
| Elliott Hughes | 8cf5bc0 | 2012-02-02 16:32:16 -0800 | [diff] [blame] | 539 | NATIVE_METHOD(VMRuntime, trimHeap, "()V"), |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 540 | NATIVE_METHOD(VMRuntime, vmVersion, "()Ljava/lang/String;"), |
| Brian Carlstrom | cef450c | 2013-06-28 14:38:26 -0700 | [diff] [blame] | 541 | NATIVE_METHOD(VMRuntime, vmLibrary, "()Ljava/lang/String;"), |
| Sebastien Hertz | a705376 | 2014-05-16 16:56:45 +0200 | [diff] [blame] | 542 | NATIVE_METHOD(VMRuntime, vmInstructionSet, "()Ljava/lang/String;"), |
| Igor Murashkin | 3b6f440 | 2017-02-16 16:13:17 -0800 | [diff] [blame] | 543 | FAST_NATIVE_METHOD(VMRuntime, is64Bit, "()Z"), |
| 544 | FAST_NATIVE_METHOD(VMRuntime, isCheckJniEnabled, "()Z"), |
| Brian Carlstrom | e810452 | 2013-10-15 21:56:36 -0700 | [diff] [blame] | 545 | NATIVE_METHOD(VMRuntime, preloadDexCaches, "()V"), |
| Calin Juravle | 3ddf4d4 | 2021-05-11 10:19:28 -0700 | [diff] [blame] | 546 | NATIVE_METHOD(VMRuntime, registerAppInfo, |
| 547 | "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;I)V"), |
| Brian Carlstrom | 31d8f52 | 2014-09-29 11:22:54 -0700 | [diff] [blame] | 548 | NATIVE_METHOD(VMRuntime, isBootClassPathOnDisk, "(Ljava/lang/String;)Z"), |
| 549 | NATIVE_METHOD(VMRuntime, getCurrentInstructionSet, "()Ljava/lang/String;"), |
| Hiroshi Yamauchi | d7f0339 | 2017-03-29 14:47:49 -0700 | [diff] [blame] | 550 | NATIVE_METHOD(VMRuntime, setSystemDaemonThreadPriority, "()V"), |
| Mathew Inwood | 80900a3 | 2018-04-19 14:40:40 +0100 | [diff] [blame] | 551 | NATIVE_METHOD(VMRuntime, setDedupeHiddenApiWarnings, "(Z)V"), |
| Mathew Inwood | 5bcef17 | 2018-05-01 14:40:12 +0100 | [diff] [blame] | 552 | NATIVE_METHOD(VMRuntime, setProcessPackageName, "(Ljava/lang/String;)V"), |
| David Brazdil | c2f4357 | 2019-04-03 12:56:14 +0100 | [diff] [blame] | 553 | NATIVE_METHOD(VMRuntime, setProcessDataDirectory, "(Ljava/lang/String;)V"), |
| David Srbecky | bfcea3d | 2019-08-05 15:44:00 +0100 | [diff] [blame] | 554 | NATIVE_METHOD(VMRuntime, bootCompleted, "()V"), |
| Mathieu Chartier | 0aa0206 | 2019-11-21 16:24:09 -0800 | [diff] [blame] | 555 | NATIVE_METHOD(VMRuntime, resetJitCounters, "()V"), |
| Dan Zimmerman | c9fa770 | 2020-01-31 13:35:12 -0800 | [diff] [blame] | 556 | NATIVE_METHOD(VMRuntime, isValidClassLoaderContext, "(Ljava/lang/String;)Z"), |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 557 | }; |
| 558 | |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 559 | void register_dalvik_system_VMRuntime(JNIEnv* env) { |
| Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 560 | REGISTER_NATIVE_METHODS("dalvik/system/VMRuntime"); |
| Elliott Hughes | 7ede61e | 2011-09-14 18:18:06 -0700 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | } // namespace art |