• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/base_jni_headers/LibraryPrefetcher_jni.h"
14 #include "base/logging.h"
15 
16 namespace base {
17 namespace android {
18 
JNI_LibraryPrefetcher_ForkAndPrefetchNativeLibrary(JNIEnv * env)19 static void JNI_LibraryPrefetcher_ForkAndPrefetchNativeLibrary(JNIEnv* env) {
20 #if BUILDFLAG(SUPPORTS_CODE_ORDERING)
21   return NativeLibraryPrefetcher::ForkAndPrefetchNativeLibrary(
22       IsUsingOrderfileOptimization());
23 #endif
24 }
25 
JNI_LibraryPrefetcher_PercentageOfResidentNativeLibraryCode(JNIEnv * env)26 static jint JNI_LibraryPrefetcher_PercentageOfResidentNativeLibraryCode(
27     JNIEnv* env) {
28 #if BUILDFLAG(SUPPORTS_CODE_ORDERING)
29   return NativeLibraryPrefetcher::PercentageOfResidentNativeLibraryCode();
30 #else
31   return -1;
32 #endif
33 }
34 
JNI_LibraryPrefetcher_PeriodicallyCollectResidency(JNIEnv * env)35 static void JNI_LibraryPrefetcher_PeriodicallyCollectResidency(JNIEnv* env) {
36 #if BUILDFLAG(SUPPORTS_CODE_ORDERING)
37   NativeLibraryPrefetcher::PeriodicallyCollectResidency();
38 #else
39   LOG(WARNING) << "Collecting residency is not supported.";
40 #endif
41 }
42 
43 }  // namespace android
44 }  // namespace base
45