Mark common android.os.Parcel methods as FastNative
Mark the marshaling functions for non-primitive parameters as being
@FastNative: they're all expected to complete quickly.
According to the table in CriticalNative.java, the difference between
a regular JNI call and a FastNative call is about 80ns, so this change
should shave about 160ns per non-primitive parameter off the latency
of a binder transaction. The actual savings will be greater as we also
use these Parcel methods to marshal and unmarshal complex objects like
PackageInfo sent as objects over Binder.
Bug: 142271139
Test: boots
Change-Id: I85c3ee8498640193b9c0777c8c5e7eb349c7b23c
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 50487e9..783ab44 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -305,8 +305,11 @@
private static native void nativeWriteFloat(long nativePtr, float val);
@FastNative
private static native void nativeWriteDouble(long nativePtr, double val);
+ @FastNative
static native void nativeWriteString(long nativePtr, String val);
+ @FastNative
private static native void nativeWriteStrongBinder(long nativePtr, IBinder val);
+ @FastNative
private static native long nativeWriteFileDescriptor(long nativePtr, FileDescriptor val);
private static native byte[] nativeCreateByteArray(long nativePtr);
@@ -320,8 +323,11 @@
private static native float nativeReadFloat(long nativePtr);
@CriticalNative
private static native double nativeReadDouble(long nativePtr);
+ @FastNative
static native String nativeReadString(long nativePtr);
+ @FastNative
private static native IBinder nativeReadStrongBinder(long nativePtr);
+ @FastNative
private static native FileDescriptor nativeReadFileDescriptor(long nativePtr);
private static native long nativeCreate();