library_prefetcher_hooks.cc 1.3 KB

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