Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3112)

Unified Diff: base/android/linker/linker_jni.cc

Issue 958473003: Asynchronously pre-fault the native library pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Whitespace. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/android/linker/linker_jni.cc
diff --git a/base/android/linker/linker_jni.cc b/base/android/linker/linker_jni.cc
index 1a11639dd5364d3039591bd66da7201126d6d9bf..6e8369292bf17e475014a3269b2d6a32253ff71a 100644
--- a/base/android/linker/linker_jni.cc
+++ b/base/android/linker/linker_jni.cc
@@ -609,6 +609,44 @@ jstring GetLibraryFilePathInZipFile(JNIEnv* env,
return env->NewStringUTF(buffer);
}
+// Prefault the pages of a native library stored in a zip file.
+//
+// |env| is the current JNI environment handle.
+// |clazz| is the static class handle which is not used here.
+// |lib_name| is the library base name.
+// Returns true for success.
+jboolean PrefaultLibraryInZipFile(JNIEnv* env, jclass clazz,
+ jstring zip_filename, jstring lib_name) {
+ char path_in_zip[kMaxFilePathLengthInZip + 1];
+ crazy_status_t status;
+ String lib_name_str(env, lib_name);
+ String zip_filename_str(env, zip_filename);
+ int offset, size;
+
+ status = crazy_library_file_path_in_zip_file(lib_name_str.c_str(),
+ path_in_zip, 256);
+ if (status == CRAZY_STATUS_FAILURE) return false;
+ status = crazy_library_offset_size_in_zip_file(zip_filename_str.c_str(),
+ path_in_zip, &offset, &size);
+ if (status == CRAZY_STATUS_FAILURE) return false;
+ status = crazy_prefault_library(zip_filename_str.c_str(), offset, size);
+ return true;
+}
+
+// Prefault the pages of a native library.
+//
+// |env| is the current JNI environment handle.
+// |clazz| is the static class handle which is not used here.
+// |lib_filename| is the library file name.
+// Returns true for success.
+jboolean PrefaultLibraryInFile(JNIEnv* env, jclass clazz,
+ jstring lib_filename) {
+ String lib_filename_str(env, lib_filename);
+
+ return (crazy_prefault_library(lib_filename_str.c_str(), 0, -1)
+ == CRAZY_STATUS_SUCCESS);
+}
+
// Check whether the device supports mapping the APK file with executable
// permission.
//
@@ -730,6 +768,21 @@ const JNINativeMethod kNativeMethods[] = {
")"
"Ljava/lang/String;",
reinterpret_cast<void*>(&GetLibraryFilePathInZipFile)},
+ {"nativePrefaultLibraryInFile",
+ "("
+ "Ljava/lang/String;"
+ ")"
+ "Z",
+ reinterpret_cast<void*>(&PrefaultLibraryInFile)
+ },
+ {"nativePrefaultLibraryInZipFile",
+ "("
+ "Ljava/lang/String;"
+ "Ljava/lang/String;"
+ ")"
+ "Z",
+ reinterpret_cast<void*>(&PrefaultLibraryInZipFile)
+ },
{"nativeCheckMapExecSupport",
"("
"Ljava/lang/String;"

Powered by Google App Engine
This is Rietveld 408576698