1 // Copyright 2019 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include <string> 6 7 #include "base/android/jni_android.h" 8 #include "base/android/jni_string.h" 9 #include "base/android/library_loader/anchor_functions_buildflags.h" 10 #include "base/android/library_loader/library_loader_hooks.h" 11 #include "base/android/library_loader/library_prefetcher.h" 12 #include "base/android/scoped_java_ref.h" 13 #include "base/logging.h" 14 15 // Must come after all headers that specialize FromJniType() / ToJniType(). 16 #include "base/library_loader_jni/LibraryPrefetcher_jni.h" 17 18 namespace base { 19 namespace android { 20 JNI_LibraryPrefetcher_ForkAndPrefetchNativeLibrary(JNIEnv * env)21static void JNI_LibraryPrefetcher_ForkAndPrefetchNativeLibrary(JNIEnv* env) { 22 #if BUILDFLAG(SUPPORTS_CODE_ORDERING) 23 return NativeLibraryPrefetcher::ForkAndPrefetchNativeLibrary( 24 IsUsingOrderfileOptimization()); 25 #endif 26 } 27 JNI_LibraryPrefetcher_PercentageOfResidentNativeLibraryCode(JNIEnv * env)28static jint JNI_LibraryPrefetcher_PercentageOfResidentNativeLibraryCode( 29 JNIEnv* env) { 30 #if BUILDFLAG(SUPPORTS_CODE_ORDERING) 31 return NativeLibraryPrefetcher::PercentageOfResidentNativeLibraryCode(); 32 #else 33 return -1; 34 #endif 35 } 36 JNI_LibraryPrefetcher_PeriodicallyCollectResidency(JNIEnv * env)37static void JNI_LibraryPrefetcher_PeriodicallyCollectResidency(JNIEnv* env) { 38 #if BUILDFLAG(SUPPORTS_CODE_ORDERING) 39 NativeLibraryPrefetcher::PeriodicallyCollectResidency(); 40 #else 41 LOG(WARNING) << "Collecting residency is not supported."; 42 #endif 43 } 44 45 } // namespace android 46 } // namespace base 47