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

Commit 3ebd97e3 authored by Shai Barack's avatar Shai Barack
Browse files

Annotate android.os.Debug native heap accessors with @CriticalNative

These methods do not require an Env and don't make any high/variable latency
operations, so should be safe to annotate as such.

Bug: 374158990
Flag: EXEMPT annotation change can't be flagged
Test: presubmit
Change-Id: If62c2ace15d2c60ec518c172990a9c2294eb7395
parent 2018da88
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.Preconditions;
import com.android.internal.util.TypedProperties;

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

import org.apache.harmony.dalvik.ddmc.Chunk;
@@ -1936,18 +1937,21 @@ public final class Debug
     * Returns the size of the native heap.
     * @return The size of the native heap in bytes.
     */
    @CriticalNative
    public static native long getNativeHeapSize();

    /**
     * Returns the amount of allocated memory in the native heap.
     * @return The allocated size in bytes.
     */
    @CriticalNative
    public static native long getNativeHeapAllocatedSize();

    /**
     * Returns the amount of free memory in the native heap.
     * @return The freed size in bytes.
     */
    @CriticalNative
    public static native long getNativeHeapFreeSize();

    /**
+5 −3
Original line number Diff line number Diff line
@@ -51,10 +51,12 @@
#include <utils/misc.h>
#include <vintf/KernelConfigs.h>


#include <iomanip>
#include <string>
#include <vector>

#include "core_jni_helpers.h"
#include "jni.h"

namespace android
@@ -102,19 +104,19 @@ static jfieldID hasSwappedOutPss_field;

#define BINDER_STATS "/proc/binder/stats"

static jlong android_os_Debug_getNativeHeapSize(JNIEnv *env, jobject clazz)
static jlong android_os_Debug_getNativeHeapSize(CRITICAL_JNI_PARAMS)
{
    struct mallinfo info = mallinfo();
    return (jlong) info.usmblks;
}

static jlong android_os_Debug_getNativeHeapAllocatedSize(JNIEnv *env, jobject clazz)
static jlong android_os_Debug_getNativeHeapAllocatedSize(CRITICAL_JNI_PARAMS)
{
    struct mallinfo info = mallinfo();
    return (jlong) info.uordblks;
}

static jlong android_os_Debug_getNativeHeapFreeSize(JNIEnv *env, jobject clazz)
static jlong android_os_Debug_getNativeHeapFreeSize(CRITICAL_JNI_PARAMS)
{
    struct mallinfo info = mallinfo();
    return (jlong) info.fordblks;