Ignore:
Timestamp:
Jul 22, 2009, 3:17:10 PM (16 years ago)
Author:
[email protected]
Message:

2009-07-22 Gavin Barraclough <[email protected]>

Reviewed by Sam Weinig.

With ENABLE(ASSEMBLER_WX_EXCLUSIVE), only change permissions once per repatch event.
( https://bugs.webkit.org/show_bug.cgi?id=27564 )

Currently we change permissions forwards and backwards for each instruction modified,
instead we should only change permissions once per complete repatching event.

2.5% progression running with ENABLE(ASSEMBLER_WX_EXCLUSIVE) enabled,
which recoups 1/3 of the penalty of running with this mode enabled.

  • assembler/ARMAssembler.cpp: (JSC::ARMAssembler::linkBranch):
    • Replace usage of MakeWritable with cacheFlush.


  • assembler/ARMAssembler.h: (JSC::ARMAssembler::patchPointerInternal): (JSC::ARMAssembler::repatchLoadPtrToLEA):
    • Replace usage of MakeWritable with cacheFlush.
  • assembler/ARMv7Assembler.h: (JSC::ARMv7Assembler::relinkJump): (JSC::ARMv7Assembler::relinkCall): (JSC::ARMv7Assembler::repatchInt32): (JSC::ARMv7Assembler::repatchPointer): (JSC::ARMv7Assembler::repatchLoadPtrToLEA): (JSC::ARMv7Assembler::setInt32):
    • Replace usage of MakeWritable with cacheFlush.
  • assembler/LinkBuffer.h: (JSC::LinkBuffer::performFinalization):
    • Make explicit call to cacheFlush.
  • assembler/MacroAssemblerCodeRef.h: (JSC::MacroAssemblerCodeRef::MacroAssemblerCodeRef):
    • Make size always available.
  • assembler/RepatchBuffer.h: (JSC::RepatchBuffer::RepatchBuffer): (JSC::RepatchBuffer::~RepatchBuffer):
    • Add calls to MakeWritable & makeExecutable.
  • assembler/X86Assembler.h: (JSC::X86Assembler::relinkJump): (JSC::X86Assembler::relinkCall): (JSC::X86Assembler::repatchInt32): (JSC::X86Assembler::repatchPointer): (JSC::X86Assembler::repatchLoadPtrToLEA):
    • Remove usage of MakeWritable.
  • bytecode/CodeBlock.h: (JSC::CodeBlock::getJITCode):
    • Provide access to CodeBlock's JITCode.
  • jit/ExecutableAllocator.h: (JSC::ExecutableAllocator::makeExecutable): (JSC::ExecutableAllocator::cacheFlush):
    • Remove MakeWritable, make cacheFlush public.
  • jit/JIT.cpp: (JSC::ctiPatchNearCallByReturnAddress): (JSC::ctiPatchCallByReturnAddress): (JSC::JIT::privateCompile): (JSC::JIT::unlinkCall): (JSC::JIT::linkCall):
    • Add CodeBlock argument to RepatchBuffer.
  • jit/JIT.h:
    • Pass CodeBlock argument for use by RepatchBuffer.
  • jit/JITCode.h: (JSC::JITCode::start): (JSC::JITCode::size):
    • Provide access to code start & size.
  • jit/JITPropertyAccess.cpp: (JSC::JIT::privateCompilePutByIdTransition): (JSC::JIT::patchGetByIdSelf): (JSC::JIT::patchMethodCallProto): (JSC::JIT::patchPutByIdReplace): (JSC::JIT::privateCompilePatchGetArrayLength): (JSC::JIT::privateCompileGetByIdProto): (JSC::JIT::privateCompileGetByIdSelfList): (JSC::JIT::privateCompileGetByIdProtoList): (JSC::JIT::privateCompileGetByIdChainList): (JSC::JIT::privateCompileGetByIdChain):
    • Add CodeBlock argument to RepatchBuffer.
  • jit/JITStubs.cpp: (JSC::JITThunks::tryCachePutByID): (JSC::JITThunks::tryCacheGetByID): (JSC::JITStubs::DEFINE_STUB_FUNCTION):
    • Pass CodeBlock argument for use by RepatchBuffer.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/ExecutableAllocator.h

    r46059 r46247  
    157157    }
    158158
    159 #if ENABLE(ASSEMBLER_WX_EXCLUSIVE) || !(PLATFORM(X86) || PLATFORM(X86_64))
     159#if ENABLE(ASSEMBLER_WX_EXCLUSIVE)
    160160    static void makeWritable(void* start, size_t size)
    161161    {
     
    166166    {
    167167        reprotectRegion(start, size, Executable);
    168         cacheFlush(start, size);
    169     }
    170 
    171     // If ASSEMBLER_WX_EXCLUSIVE protection is turned on, or on non-x86 platforms,
    172     // we need to track start & size so we can makeExecutable/cacheFlush at the end.
    173     class MakeWritable {
    174     public:
    175         MakeWritable(void* start, size_t size)
    176             : m_start(start)
    177             , m_size(size)
    178         {
    179             makeWritable(start, size);
    180         }
    181 
    182         ~MakeWritable()
    183         {
    184             makeExecutable(m_start, m_size);
    185         }
    186 
    187     private:
    188         void* m_start;
    189         size_t m_size;
    190     };
     168    }
    191169#else
    192170    static void makeWritable(void*, size_t) {}
    193171    static void makeExecutable(void*, size_t) {}
    194 
    195     // On x86, without ASSEMBLER_WX_EXCLUSIVE, there is nothing to do here.
    196     class MakeWritable { public: MakeWritable(void*, size_t) {} };
    197 #endif
    198 
    199 private:
    200 
    201 #if ENABLE(ASSEMBLER_WX_EXCLUSIVE) || !(PLATFORM(X86) || PLATFORM(X86_64))
    202 #if ENABLE(ASSEMBLER_WX_EXCLUSIVE)
    203     static void reprotectRegion(void*, size_t, ProtectionSeting);
    204 #else
    205     static void reprotectRegion(void*, size_t, ProtectionSeting) {}
    206 #endif
    207 
    208    static void cacheFlush(void* code, size_t size)
    209     {
     172#endif
     173
     174
    210175#if PLATFORM(X86) || PLATFORM(X86_64)
    211         UNUSED_PARAM(code);
    212         UNUSED_PARAM(size);
     176    static void cacheFlush(void*, size_t)
     177    {
     178    }
    213179#elif PLATFORM_ARM_ARCH(7) && PLATFORM(IPHONE)
     180    static void cacheFlush(void* code, size_t size)
     181    {
    214182        sys_dcache_flush(code, size);
    215183        sys_icache_invalidate(code, size);
     184    }
    216185#elif PLATFORM(ARM)
     186    static void cacheFlush(void* code, size_t size)
     187    {
    217188    #if COMPILER(GCC) && (GCC_VERSION >= 30406)
    218189        __clear_cache(reinterpret_cast<char*>(code), reinterpret_cast<char*>(code) + size);
     
    229200           :   "r0", "r1", "r7");
    230201    #endif // COMPILER(GCC) && (GCC_VERSION >= 30406)
    231 #else
    232 #error "ExecutableAllocator::cacheFlush not implemented on this platform."
    233 #endif
    234     }
     202    }
     203#endif
     204
     205private:
     206
     207#if ENABLE(ASSEMBLER_WX_EXCLUSIVE)
     208    static void reprotectRegion(void*, size_t, ProtectionSeting);
    235209#endif
    236210
Note: See TracChangeset for help on using the changeset viewer.