Ignore:
Timestamp:
Oct 14, 2010, 12:19:17 PM (15 years ago)
Author:
[email protected]
Message:

need way to measure size of JITed ARM code
https://bugs.webkit.org/show_bug.cgi?id=47121

Patch by David Goodwin <[email protected]> on 2010-10-14
Reviewed by Darin Adler.

  • assembler/LinkBuffer.h:

(JSC::LinkBuffer::linkCode):
(JSC::LinkBuffer::dumpLinkStats):
(JSC::LinkBuffer::dumpCode):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/assembler/LinkBuffer.h

    r69743 r69787  
    2828
    2929#if ENABLE(ASSEMBLER)
     30
     31#define DUMP_LINK_STATISTICS 0
     32#define DUMP_CODE 0
    3033
    3134#include <MacroAssembler.h>
     
    264267        m_size = writePtr + m_assembler->size() - readPtr;
    265268        m_executablePool->returnLastBytes(initialSize - m_size);
     269
     270#if DUMP_LINK_STATISTICS
     271        dumpLinkStatistics(m_code, initialSize, m_size);
     272#endif
     273#if DUMP_CODE
     274        dumpCode(m_code, m_size);
     275#endif
    266276#endif
    267277    }
     
    278288    }
    279289
     290#if DUMP_LINK_STATISTICS
     291    static void dumpLinkStatistics(void* code, size_t initialSize, size_t finalSize)
     292    {
     293        static unsigned linkCount = 0;
     294        static unsigned totalInitialSize = 0;
     295        static unsigned totalFinalSize = 0;
     296        linkCount++;
     297        totalInitialSize += initialSize;
     298        totalFinalSize += finalSize;
     299        printf("link %p: orig %u, compact %u (delta %u, %.2f%%)\n",
     300               code, static_cast<unsigned>(initialSize), static_cast<unsigned>(finalSize),
     301               static_cast<unsigned>(initialSize - finalSize),
     302               100.0 * (initialSize - finalSize) / initialSize);
     303        printf("\ttotal %u: orig %u, compact %u (delta %u, %.2f%%)\n",
     304               linkCount, totalInitialSize, totalFinalSize, totalInitialSize - totalFinalSize,
     305               100.0 * (totalInitialSize - totalFinalSize) / totalInitialSize);
     306    }
     307#endif
     308   
     309#if DUMP_CODE
     310    static void dumpCode(void* code, size_t size)
     311    {
     312#if CPU(ARM_THUMB2)
     313        // Dump the generated code in an asm file format that can be assembled and then disassembled
     314        // for debugging purposes. For example, save this output as jit.s:
     315        //   gcc -arch armv7 -c jit.s
     316        //   otool -tv jit.o
     317        static unsigned codeCount = 0;
     318        unsigned short* tcode = static_cast<unsigned short*>(code);
     319        size_t tsize = size / sizeof(short);
     320        char nameBuf[128];
     321        snprintf(nameBuf, sizeof(nameBuf), "_jsc_jit%u", codeCount++);
     322        printf("\t.syntax unified\n"
     323               "\t.section\t__TEXT,__text,regular,pure_instructions\n"
     324               "\t.globl\t%s\n"
     325               "\t.align 2\n"
     326               "\t.code 16\n"
     327               "\t.thumb_func\t%s\n"
     328               "# %p\n"
     329               "%s:\n", nameBuf, nameBuf, code, nameBuf);
     330       
     331        for (unsigned i = 0; i < tsize; i++)
     332            printf("\t.short\t0x%x\n", tcode[i]);
     333#endif
     334    }
     335#endif
     336   
    280337    RefPtr<ExecutablePool> m_executablePool;
    281338    size_t m_size;
Note: See TracChangeset for help on using the changeset viewer.