共舞台上页面JIT - 这是什么意思?这是、什么意思、共舞、台上

2023-09-05 05:25:38 作者:讨好

我收到的logcat输出如下:

I am getting logcat output as follows:

02-12 20:06:18.515  11470-11470/? D/dalvikvm﹕ GC_EXTERNAL_ALLOC freed 3K, 48% free 3188K/6023K, external 7949K/8580K, paused 29ms
02-12 20:06:18.804  11470-11470/? D/dalvikvm﹕ GC_EXTERNAL_ALLOC freed <1K, 48% free 3189K/6023K, external 13255K/13400K, paused 28ms
02-12 20:06:19.406  11470-11470/? D/dalvikvm﹕ GC_EXTERNAL_ALLOC freed <1K, 48% free 3189K/6023K, external 14706K/16754K, paused 56ms
02-12 20:06:19.914  11470-11475/? I/dalvikvm﹕ Total arena pages for JIT: 11

什么是共舞台上页面JIT究竟意味着什么?

What does "Total arena pages for JIT" really mean?

推荐答案

之谜... 这引起我的兴趣也一样,当我第一次看到它。所以我进行了一些研究。 =) 对于一开始,让我澄清什么是JIT。 JIT代表刚刚在实时编译器。它的Dalvik是翻译字节code,以优化本地code运行时的一部分。 我从 Dalvik的来源发现中的字符串共舞台上页面JIT能够满足只在一个类 - 工具从Dalvik的\虚拟机\编译器。下面是一段简短的其code:

Mystery... It interested me too, when I first saw it. So I've performed a little research. =) For the beginning, let me clarify what is 'JIT'. JIT stands for Just-In-Time compiler. It's a part of dalvik that translates byte code to optimized native code at run time. I found from dalvik sources that the string "Total arena pages for JIT" can be met only in one class - Utility from 'dalvik\vm\compiler'. Here is a short piece of its code:


    /* Arena-based malloc for compilation tasks */
    void * dvmCompilerNew(size_t size, bool zero)
    {
        /* edit: some code omitted. */
retry:
        /* Normal case - space is available in the current page */
        if (size + currentArena->bytesAllocated <= currentArena->blockSize) {
            void *ptr;
            ptr = &currentArena->ptr[currentArena->bytesAllocated];
            currentArena->bytesAllocated += size;
            /* edit: some code omitted. */
        } else {                                                      // <0>
            /*
             * See if there are previously allocated arena blocks before the last
             * reset
             */
            /* edit: some code omitted. */

            /* Time to allocate a new arena */
            ArenaMemBlock *newArena = (ArenaMemBlock *)
                malloc(sizeof(ArenaMemBlock) + blockSize);           // <1>
            if (newArena == NULL) {
                ALOGE("Arena allocation failure");
                dvmAbort();
            }
            newArena->blockSize = blockSize;
            newArena->bytesAllocated = 0;
            newArena->next = NULL;
            currentArena->next = newArena;                           // <2>
            currentArena = newArena;
            numArenaBlocks++;
            if (numArenaBlocks > 10)
                ALOGI("Total arena pages for JIT: %d", numArenaBlocks);
            goto retry;
        }
        /* edit: some code omitted. */
    }

正如你所看到的,只有当它被分配每一个编译器超过10页的舞台出现此消息。

As you can see, this message appears only if it was allocated more than 10 arena pages per a compiler.

究竟江湖是? 你可以读到它here或这里。在几句话,它是在多线程应用程序的内存管理的概念。内存分为赛区(区,区)。每个分配竞技场都有其自己的锁,所以多个线程不会相互干扰,当他们在同一时间分配内存。

What actually 'arena' is? You can read about it here or here. In a few words, it is a concept for the memory management in a multithreaded application. Memory is divided into arenas (regions, areas). Each allocation arena has its own lock, so multiple threads don't interfere with each other when they allocate memory at one time.

为什么我看到这则消息?我是真命天子? 不,我不这么认为。 =)我真的不知道,但它似乎就像从分配给它的大量的内存块的J​​IT内部警告。 国内这一领域为基础的malloc是建立在一个链表。即每个竞技场实现为的存储器大块链表。在当前模块( currentArena )保持一个指向下一个空闲位置,在块(及(currentArena-&GT; PTR [currentArena-&GT; bytesAllocated])),并且如果该块被填充(参见℃,>),一个新的分配(参见小于1>),并添加到列表中(见2>)

Why did I see this message? Am I the Chosen One? No, I don't think so. =) I'm not really sure, but it seems just like an internal warning from the JIT that it has allocated a large number of memory blocks. Internally this arena-based malloc is built upon a linked list. I.e. each arena is implemented as a linked list of large blocks of memory. The current block (currentArena) maintains a pointer to the next free position in the block (&(currentArena->ptr[currentArena->bytesAllocated])), and if the block is filled (see <0>), a new one is allocated (see <1>) and added to the list (see <2>).