diff options
author | Ian Pedowitz <ijpedowitz@google.com> | 2015-10-22 22:08:07 +0000 |
---|---|---|
committer | Ian Pedowitz <ijpedowitz@google.com> | 2015-10-22 22:09:04 +0000 |
commit | e2adb2cf0f2c90c77fab3f09285a92e05e70b567 (patch) | |
tree | d4ec080654207956b09cd45ccdfc6d8ba7eeba4e /core | |
parent | ab3f9724035046d65124a72db2a09c824b3d5c67 (diff) | |
download | frameworks_base-e2adb2cf0f2c90c77fab3f09285a92e05e70b567.zip frameworks_base-e2adb2cf0f2c90c77fab3f09285a92e05e70b567.tar.gz frameworks_base-e2adb2cf0f2c90c77fab3f09285a92e05e70b567.tar.bz2 |
Revert "Track ashmem memory usage in Parcel"
This reverts commit ab3f9724035046d65124a72db2a09c824b3d5c67.
Bug: 25169267
Bug: 25191602
Bug: 25004154
Change-Id: Ic51e62515273e4687359dfd9ff770a4d06c0c667
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/os/Parcel.java | 42 | ||||
-rw-r--r-- | core/jni/android_os_Parcel.cpp | 38 |
2 files changed, 25 insertions, 55 deletions
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java index 5852f5f..1273772 100644 --- a/core/java/android/os/Parcel.java +++ b/core/java/android/os/Parcel.java @@ -16,7 +16,6 @@ package android.os; -import android.annotation.IntegerRes; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; @@ -43,8 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import dalvik.system.VMRuntime; - /** * Container for a message (data and object references) that can * be sent through an IBinder. A Parcel can contain both flattened data @@ -196,7 +193,6 @@ public final class Parcel { * indicating that we're responsible for its lifecycle. */ private boolean mOwnsNativeParcelObject; - private long mNativeSize; private RuntimeException mStack; @@ -248,7 +244,7 @@ public final class Parcel { private static native int nativeDataAvail(long nativePtr); private static native int nativeDataPosition(long nativePtr); private static native int nativeDataCapacity(long nativePtr); - private static native long nativeSetDataSize(long nativePtr, int size); + private static native void nativeSetDataSize(long nativePtr, int size); private static native void nativeSetDataPosition(long nativePtr, int pos); private static native void nativeSetDataCapacity(long nativePtr, int size); @@ -263,7 +259,7 @@ public final class Parcel { private static native void nativeWriteDouble(long nativePtr, double val); private static native void nativeWriteString(long nativePtr, String val); private static native void nativeWriteStrongBinder(long nativePtr, IBinder val); - private static native long nativeWriteFileDescriptor(long nativePtr, FileDescriptor val); + private static native void nativeWriteFileDescriptor(long nativePtr, FileDescriptor val); private static native byte[] nativeCreateByteArray(long nativePtr); private static native byte[] nativeReadBlob(long nativePtr); @@ -276,13 +272,13 @@ public final class Parcel { private static native FileDescriptor nativeReadFileDescriptor(long nativePtr); private static native long nativeCreate(); - private static native long nativeFreeBuffer(long nativePtr); + private static native void nativeFreeBuffer(long nativePtr); private static native void nativeDestroy(long nativePtr); private static native byte[] nativeMarshall(long nativePtr); - private static native long nativeUnmarshall( + private static native void nativeUnmarshall( long nativePtr, byte[] data, int offset, int length); - private static native long nativeAppendFrom( + private static native void nativeAppendFrom( long thisNativePtr, long otherNativePtr, int offset, int length); private static native boolean nativeHasFileDescriptors(long nativePtr); private static native void nativeWriteInterfaceToken(long nativePtr, String interfaceName); @@ -394,7 +390,7 @@ public final class Parcel { * @param size The new number of bytes in the Parcel. */ public final void setDataSize(int size) { - updateNativeSize(nativeSetDataSize(mNativePtr, size)); + nativeSetDataSize(mNativePtr, size); } /** @@ -446,11 +442,11 @@ public final class Parcel { * Set the bytes in data to be the raw bytes of this Parcel. */ public final void unmarshall(byte[] data, int offset, int length) { - updateNativeSize(nativeUnmarshall(mNativePtr, data, offset, length)); + nativeUnmarshall(mNativePtr, data, offset, length); } public final void appendFrom(Parcel parcel, int offset, int length) { - updateNativeSize(nativeAppendFrom(mNativePtr, parcel.mNativePtr, offset, length)); + nativeAppendFrom(mNativePtr, parcel.mNativePtr, offset, length); } /** @@ -603,24 +599,7 @@ public final class Parcel { * if {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE} is set.</p> */ public final void writeFileDescriptor(FileDescriptor val) { - updateNativeSize(nativeWriteFileDescriptor(mNativePtr, val)); - } - - private void updateNativeSize(long newNativeSize) { - if (mOwnsNativeParcelObject) { - if (newNativeSize > Integer.MAX_VALUE) { - newNativeSize = Integer.MAX_VALUE; - } - if (newNativeSize != mNativeSize) { - int delta = (int) (newNativeSize - mNativeSize); - if (delta > 0) { - VMRuntime.getRuntime().registerNativeAllocation(delta); - } else { - VMRuntime.getRuntime().registerNativeFree(-delta); - } - mNativeSize = newNativeSize; - } - } + nativeWriteFileDescriptor(mNativePtr, val); } /** @@ -2566,7 +2545,7 @@ public final class Parcel { private void freeBuffer() { if (mOwnsNativeParcelObject) { - updateNativeSize(nativeFreeBuffer(mNativePtr)); + nativeFreeBuffer(mNativePtr); } } @@ -2574,7 +2553,6 @@ public final class Parcel { if (mNativePtr != 0) { if (mOwnsNativeParcelObject) { nativeDestroy(mNativePtr); - updateNativeSize(0); } mNativePtr = 0; } diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp index 07b7e60..0f5ba83 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 jlong android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jlong nativePtr, jint size) +static void android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jlong nativePtr, jint size) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -122,9 +122,7 @@ static jlong android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jlong nati 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) @@ -306,7 +304,7 @@ static void android_os_Parcel_writeStrongBinder(JNIEnv* env, jclass clazz, jlong } } -static jlong android_os_Parcel_writeFileDescriptor(JNIEnv* env, jclass clazz, jlong nativePtr, jobject object) +static void android_os_Parcel_writeFileDescriptor(JNIEnv* env, jclass clazz, jlong nativePtr, jobject object) { Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { @@ -315,9 +313,7 @@ static jlong android_os_Parcel_writeFileDescriptor(JNIEnv* env, jclass clazz, jl 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) @@ -554,14 +550,12 @@ static jlong android_os_Parcel_create(JNIEnv* env, jclass clazz) return reinterpret_cast<jlong>(parcel); } -static jlong android_os_Parcel_freeBuffer(JNIEnv* env, jclass clazz, jlong nativePtr) +static void 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) @@ -599,12 +593,12 @@ static jbyteArray android_os_Parcel_marshall(JNIEnv* env, jclass clazz, jlong na return ret; } -static jlong android_os_Parcel_unmarshall(JNIEnv* env, jclass clazz, jlong nativePtr, - jbyteArray data, jint offset, jint length) +static void 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 0; + return; } jbyte* array = (jbyte*)env->GetPrimitiveArrayCritical(data, 0); @@ -618,26 +612,24 @@ static jlong android_os_Parcel_unmarshall(JNIEnv* env, jclass clazz, jlong nativ env->ReleasePrimitiveArrayCritical(data, array, 0); } - return parcel->getOpenAshmemSize(); } -static jlong android_os_Parcel_appendFrom(JNIEnv* env, jclass clazz, jlong thisNativePtr, - jlong otherNativePtr, jint offset, jint length) +static void 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 0; + return; } Parcel* otherParcel = reinterpret_cast<Parcel*>(otherNativePtr); if (otherParcel == NULL) { - return thisParcel->getOpenAshmemSize(); + return; } 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) @@ -730,7 +722,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)J", (void*)android_os_Parcel_setDataSize}, + {"nativeSetDataSize", "(JI)V", (void*)android_os_Parcel_setDataSize}, {"nativeSetDataPosition", "(JI)V", (void*)android_os_Parcel_setDataPosition}, {"nativeSetDataCapacity", "(JI)V", (void*)android_os_Parcel_setDataCapacity}, @@ -745,7 +737,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;)J", (void*)android_os_Parcel_writeFileDescriptor}, + {"nativeWriteFileDescriptor", "(JLjava/io/FileDescriptor;)V", (void*)android_os_Parcel_writeFileDescriptor}, {"nativeCreateByteArray", "(J)[B", (void*)android_os_Parcel_createByteArray}, {"nativeReadBlob", "(J)[B", (void*)android_os_Parcel_readBlob}, @@ -763,12 +755,12 @@ static const JNINativeMethod gParcelMethods[] = { {"clearFileDescriptor", "(Ljava/io/FileDescriptor;)V", (void*)android_os_Parcel_clearFileDescriptor}, {"nativeCreate", "()J", (void*)android_os_Parcel_create}, - {"nativeFreeBuffer", "(J)J", (void*)android_os_Parcel_freeBuffer}, + {"nativeFreeBuffer", "(J)V", (void*)android_os_Parcel_freeBuffer}, {"nativeDestroy", "(J)V", (void*)android_os_Parcel_destroy}, {"nativeMarshall", "(J)[B", (void*)android_os_Parcel_marshall}, - {"nativeUnmarshall", "(J[BII)J", (void*)android_os_Parcel_unmarshall}, - {"nativeAppendFrom", "(JJII)J", (void*)android_os_Parcel_appendFrom}, + {"nativeUnmarshall", "(J[BII)V", (void*)android_os_Parcel_unmarshall}, + {"nativeAppendFrom", "(JJII)V", (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}, |