Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b627a225 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Optimize Process thread priority method calls" into main

parents 2ad4a772 ce97e4ad
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -87,3 +87,10 @@ HSPLandroid/os/Message;->compareMessages(Landroid/os/Message;Landroid/os/Message
# and is captured with the boot image profiling pipeline.
HSPLcom/android/internal/pm/SystemFeaturesMetadata;->*
Lcom/android/internal/pm/SystemFeaturesMetadata;

# These methods were previously direct `native` JNI calls, but were made into
# Java wrappers with a recent change. Ensure they're compiled to avoid
# regressions on any hot paths.
# TOOD(b/417492941): Remove after inclusion in generated boot-image-profile.txt.
HSPLandroid/os/Process;->setThreadPriority(II)V
HSPLandroid/os/Process;->setThreadPriority(I)V
+5 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.webkit.WebViewZygote;
import com.android.sdksandbox.flags.Flags;

import dalvik.annotation.optimization.CriticalNative;
import dalvik.annotation.optimization.FastNative;
import dalvik.system.VMDebug;
import dalvik.system.VMRuntime;

@@ -1127,6 +1128,7 @@ public class Process {
        }
    }

    @FastNative
    private static native void setThreadPriorityNative(int tid,
            @IntRange(from = -20, to = THREAD_PRIORITY_LOWEST) int priority)
            throws IllegalArgumentException, SecurityException;
@@ -1141,9 +1143,11 @@ public class Process {
     * @hide
     */
    @RavenwoodRedirect
    @FastNative
    public static final native void setCanSelfBackground(boolean backgroundOk);

    @RavenwoodRedirect
    @CriticalNative
    private static native boolean getCanSelfBackground();

    /**
@@ -1339,6 +1343,7 @@ public class Process {
     */
    @RavenwoodRedirect
    @IntRange(from = -20, to = THREAD_PRIORITY_LOWEST)
    @FastNative
    public static final native int getThreadPriority(int tid)
            throws IllegalArgumentException;

+7 −3
Original line number Diff line number Diff line
@@ -551,7 +551,7 @@ static void android_os_Process_setCanSelfBackground(JNIEnv* env, jobject clazz,
#endif
}

static jboolean android_os_Process_getCanSelfBackground(JNIEnv* env, jclass clazz) {
static jboolean android_os_Process_getCanSelfBackground(CRITICAL_JNI_PARAMS) {
#if GUARD_THREAD_PRIORITY
    void* bgOk = pthread_getspecific(gBgKey);
    if (bgOk == ((void*)0xbaad)) {
@@ -1408,11 +1408,15 @@ void android_os_Process_freezeCgroupUID(JNIEnv* env, jobject clazz, jint uid, jb
static const JNINativeMethod methods[] = {
        {"getUidForName", "(Ljava/lang/String;)I", (void*)android_os_Process_getUidForName},
        {"getGidForName", "(Ljava/lang/String;)I", (void*)android_os_Process_getGidForName},
        {"setThreadPriorityNative", "(II)V", (void*)android_os_Process_setThreadPriorityNative},
        {"setThreadScheduler", "(III)V", (void*)android_os_Process_setThreadScheduler},
        // @FastNative
        {"setThreadPriorityNative", "(II)V", (void*)android_os_Process_setThreadPriorityNative},
        // @FastNative
        {"getThreadPriority", "(I)I", (void*)android_os_Process_getThreadPriority},
        // @FastNative
        {"setCanSelfBackground", "(Z)V", (void*)android_os_Process_setCanSelfBackground},
        // @CriticalNative
        {"getCanSelfBackground", "()Z", (void*)android_os_Process_getCanSelfBackground},
        {"getThreadPriority", "(I)I", (void*)android_os_Process_getThreadPriority},
        {"getThreadScheduler", "(I)I", (void*)android_os_Process_getThreadScheduler},
        {"setThreadGroup", "(II)V", (void*)android_os_Process_setThreadGroup},
        {"setThreadGroupAndCpuset", "(II)V", (void*)android_os_Process_setThreadGroupAndCpuset},