diff options
author | Adrian Roos <roosa@google.com> | 2015-10-21 14:50:38 -0700 |
---|---|---|
committer | Adrian Roos <roosa@google.com> | 2015-10-22 00:31:47 +0000 |
commit | ab3f9724035046d65124a72db2a09c824b3d5c67 (patch) | |
tree | 40fc9c9bc7927018aedc91a0c2b3cc69ff3205a7 /core/jni | |
parent | cb10c09f0a6c0750d79bf4f681a623fa35f4cef7 (diff) | |
download | frameworks_base-ab3f9724035046d65124a72db2a09c824b3d5c67.zip frameworks_base-ab3f9724035046d65124a72db2a09c824b3d5c67.tar.gz frameworks_base-ab3f9724035046d65124a72db2a09c824b3d5c67.tar.bz2 |
Track ashmem memory usage in Parcel
Bug: 25004154
Change-Id: Id9d5656dd0605f1b50525596b75601309f67ebdc
(cherry picked from commit 4701a496a5477a7de01fbc9eaf4af9812f83770c)
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android_os_Parcel.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp index 0f5ba83..07b7e60 100644 --- a/core/jni/android_os_Parcel.cpp +++ b/core/jni/android_os_Parcel.cpp @@ -114,7 +114,7 @@ static jint android_os_Parcel_dataCapacity(JNIEnv* env, jclass clazz, jlong nati return parcel ? parcel->dataCapacity() : 0; } -static void android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jlong nativePtr, jint size) +static jlong android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jlong nativePtr, jint size) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -122,7 +122,9 @@ static void android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jlong nativ if (err != NO_ERROR) { signalExceptionForError(env, clazz, err); } + return parcel->getOpenAshmemSize(); } + return 0; } static void android_os_Parcel_setDataPosition(JNIEnv* env, jclass clazz, jlong nativePtr, jint pos) @@ -304,7 +306,7 @@ static void android_os_Parcel_writeStrongBinder(JNIEnv* env, jclass clazz, jlong } } -static void android_os_Parcel_writeFileDescriptor(JNIEnv* env, jclass clazz, jlong nativePtr, jobject object) +static jlong android_os_Parcel_writeFileDescriptor(JNIEnv* env, jclass clazz, jlong nativePtr, jobject object) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -313,7 +315,9 @@ static void android_os_Parcel_writeFileDescriptor(JNIEnv* env, jclass clazz, jlo if (err != NO_ERROR) { signalExceptionForError(env, clazz, err); } + return parcel->getOpenAshmemSize(); } + return 0; } static jbyteArray android_os_Parcel_createByteArray(JNIEnv* env, jclass clazz, jlong nativePtr) @@ -550,12 +554,14 @@ static jlong android_os_Parcel_create(JNIEnv* env, jclass clazz) return reinterpret_cast<jlong>(parcel); } -static void android_os_Parcel_freeBuffer(JNIEnv* env, jclass clazz, jlong nativePtr) +static jlong android_os_Parcel_freeBuffer(JNIEnv* env, jclass clazz, jlong nativePtr) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { parcel->freeData(); + return parcel->getOpenAshmemSize(); } + return 0; } static void android_os_Parcel_destroy(JNIEnv* env, jclass clazz, jlong nativePtr) @@ -593,12 +599,12 @@ static jbyteArray android_os_Parcel_marshall(JNIEnv* env, jclass clazz, jlong na return ret; } -static void android_os_Parcel_unmarshall(JNIEnv* env, jclass clazz, jlong nativePtr, - jbyteArray data, jint offset, jint length) +static jlong android_os_Parcel_unmarshall(JNIEnv* env, jclass clazz, jlong nativePtr, + jbyteArray data, jint offset, jint length) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel == NULL || length < 0) { - return; + return 0; } jbyte* array = (jbyte*)env->GetPrimitiveArrayCritical(data, 0); @@ -612,24 +618,26 @@ static void android_os_Parcel_unmarshall(JNIEnv* env, jclass clazz, jlong native env->ReleasePrimitiveArrayCritical(data, array, 0); } + return parcel->getOpenAshmemSize(); } -static void android_os_Parcel_appendFrom(JNIEnv* env, jclass clazz, jlong thisNativePtr, - jlong otherNativePtr, jint offset, jint length) +static jlong android_os_Parcel_appendFrom(JNIEnv* env, jclass clazz, jlong thisNativePtr, + jlong otherNativePtr, jint offset, jint length) { Parcel* thisParcel = reinterpret_cast<Parcel*>(thisNativePtr); if (thisParcel == NULL) { - return; + return 0; } Parcel* otherParcel = reinterpret_cast<Parcel*>(otherNativePtr); if (otherParcel == NULL) { - return; + return thisParcel->getOpenAshmemSize(); } status_t err = thisParcel->appendFrom(otherParcel, offset, length); if (err != NO_ERROR) { signalExceptionForError(env, clazz, err); } + return thisParcel->getOpenAshmemSize(); } static jboolean android_os_Parcel_hasFileDescriptors(JNIEnv* env, jclass clazz, jlong nativePtr) @@ -722,7 +730,7 @@ static const JNINativeMethod gParcelMethods[] = { {"nativeDataAvail", "(J)I", (void*)android_os_Parcel_dataAvail}, {"nativeDataPosition", "(J)I", (void*)android_os_Parcel_dataPosition}, {"nativeDataCapacity", "(J)I", (void*)android_os_Parcel_dataCapacity}, - {"nativeSetDataSize", "(JI)V", (void*)android_os_Parcel_setDataSize}, + {"nativeSetDataSize", "(JI)J", (void*)android_os_Parcel_setDataSize}, {"nativeSetDataPosition", "(JI)V", (void*)android_os_Parcel_setDataPosition}, {"nativeSetDataCapacity", "(JI)V", (void*)android_os_Parcel_setDataCapacity}, @@ -737,7 +745,7 @@ static const JNINativeMethod gParcelMethods[] = { {"nativeWriteDouble", "(JD)V", (void*)android_os_Parcel_writeDouble}, {"nativeWriteString", "(JLjava/lang/String;)V", (void*)android_os_Parcel_writeString}, {"nativeWriteStrongBinder", "(JLandroid/os/IBinder;)V", (void*)android_os_Parcel_writeStrongBinder}, - {"nativeWriteFileDescriptor", "(JLjava/io/FileDescriptor;)V", (void*)android_os_Parcel_writeFileDescriptor}, + {"nativeWriteFileDescriptor", "(JLjava/io/FileDescriptor;)J", (void*)android_os_Parcel_writeFileDescriptor}, {"nativeCreateByteArray", "(J)[B", (void*)android_os_Parcel_createByteArray}, {"nativeReadBlob", "(J)[B", (void*)android_os_Parcel_readBlob}, @@ -755,12 +763,12 @@ static const JNINativeMethod gParcelMethods[] = { {"clearFileDescriptor", "(Ljava/io/FileDescriptor;)V", (void*)android_os_Parcel_clearFileDescriptor}, {"nativeCreate", "()J", (void*)android_os_Parcel_create}, - {"nativeFreeBuffer", "(J)V", (void*)android_os_Parcel_freeBuffer}, + {"nativeFreeBuffer", "(J)J", (void*)android_os_Parcel_freeBuffer}, {"nativeDestroy", "(J)V", (void*)android_os_Parcel_destroy}, {"nativeMarshall", "(J)[B", (void*)android_os_Parcel_marshall}, - {"nativeUnmarshall", "(J[BII)V", (void*)android_os_Parcel_unmarshall}, - {"nativeAppendFrom", "(JJII)V", (void*)android_os_Parcel_appendFrom}, + {"nativeUnmarshall", "(J[BII)J", (void*)android_os_Parcel_unmarshall}, + {"nativeAppendFrom", "(JJII)J", (void*)android_os_Parcel_appendFrom}, {"nativeHasFileDescriptors", "(J)Z", (void*)android_os_Parcel_hasFileDescriptors}, {"nativeWriteInterfaceToken", "(JLjava/lang/String;)V", (void*)android_os_Parcel_writeInterfaceToken}, {"nativeEnforceInterface", "(JLjava/lang/String;)V", (void*)android_os_Parcel_enforceInterface}, |