Changeset 64608 in webkit for trunk/JavaScriptCore/assembler


Ignore:
Timestamp:
Aug 3, 2010, 5:15:47 PM (15 years ago)
Author:
[email protected]
Message:

Bug 43390 - Do not CRASH if we run out of room for jit code.

Reviewed by Oliver Hunt.

Change the ExecutableAllocator implementations not to crash, and to return 0 if memory cannot be allocated.
The assemblers should pass this through without trying to use it in executableCopy.
Change the LinkBuffer to handle this, and to provide an allocationSuccessful() method to test for this.

Change the JIT to throw an exception if allocation fails.
Make JIT optimizations fail gracefully if memory cannot be allocated (use non-optimized path).
Change YARR JIT to fallback to PCRE

  • assembler/ARMAssembler.cpp:

(JSC::ARMAssembler::executableCopy):

  • assembler/ARMv7Assembler.h:

(JSC::ARMv7Assembler::executableCopy):

  • assembler/LinkBuffer.h:

(JSC::LinkBuffer::allocationSuccessful):

  • assembler/MIPSAssembler.h:

(JSC::MIPSAssembler::executableCopy):

  • assembler/X86Assembler.h:

(JSC::X86Assembler::executableCopy):

  • bytecode/StructureStubInfo.h:

(JSC::StructureStubInfo::initGetByIdProto):
(JSC::StructureStubInfo::initGetByIdChain):
(JSC::StructureStubInfo::initGetByIdSelfList):
(JSC::StructureStubInfo::initGetByIdProtoList):
(JSC::StructureStubInfo::initPutByIdTransition):

  • jit/ExecutableAllocator.cpp:

(JSC::ExecutablePool::systemAlloc):

  • jit/ExecutableAllocatorFixedVMPool.cpp:

(JSC::FixedVMPoolAllocator::allocInternal):

  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • jit/JIT.h:

(JSC::JIT::compileGetByIdProto):
(JSC::JIT::compileGetByIdSelfList):
(JSC::JIT::compileGetByIdProtoList):
(JSC::JIT::compileGetByIdChainList):
(JSC::JIT::compileGetByIdChain):
(JSC::JIT::compilePutByIdTransition):
(JSC::JIT::compilePatchGetArrayLength):

  • jit/JITOpcodes.cpp:

(JSC::JIT::privateCompileCTIMachineTrampolines):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::privateCompileCTIMachineTrampolines):
(JSC::JIT::privateCompileCTINativeCall):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::stringGetByValStubGenerator):
(JSC::JIT::privateCompilePutByIdTransition):
(JSC::JIT::privateCompilePatchGetArrayLength):
(JSC::JIT::privateCompileGetByIdProto):
(JSC::JIT::privateCompileGetByIdSelfList):
(JSC::JIT::privateCompileGetByIdProtoList):
(JSC::JIT::privateCompileGetByIdChainList):
(JSC::JIT::privateCompileGetByIdChain):

  • jit/JITPropertyAccess32_64.cpp:

(JSC::JIT::stringGetByValStubGenerator):
(JSC::JIT::privateCompilePutByIdTransition):
(JSC::JIT::privateCompilePatchGetArrayLength):
(JSC::JIT::privateCompileGetByIdProto):
(JSC::JIT::privateCompileGetByIdSelfList):
(JSC::JIT::privateCompileGetByIdProtoList):
(JSC::JIT::privateCompileGetByIdChainList):
(JSC::JIT::privateCompileGetByIdChain):

  • jit/JITStubs.cpp:

(JSC::JITThunks::tryCachePutByID):
(JSC::JITThunks::tryCacheGetByID):
(JSC::DEFINE_STUB_FUNCTION):
(JSC::setupPolymorphicProtoList):

  • jit/JITStubs.h:
  • jit/SpecializedThunkJIT.h:

(JSC::SpecializedThunkJIT::finalize):

  • runtime/ExceptionHelpers.cpp:

(JSC::createOutOfMemoryError):

  • runtime/ExceptionHelpers.h:
  • runtime/Executable.cpp:

(JSC::EvalExecutable::compileInternal):
(JSC::ProgramExecutable::compileInternal):
(JSC::FunctionExecutable::compileForCallInternal):
(JSC::FunctionExecutable::compileForConstructInternal):
(JSC::FunctionExecutable::reparseExceptionInfo):
(JSC::EvalExecutable::reparseExceptionInfo):

  • yarr/RegexJIT.cpp:

(JSC::Yarr::RegexGenerator::compile):

Location:
trunk/JavaScriptCore/assembler
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/assembler/ARMAssembler.cpp

    r64327 r64608  
    352352
    353353    char* data = reinterpret_cast<char*>(m_buffer.executableCopy(allocator));
     354    if (!data)
     355        return 0;
    354356
    355357    for (Jumps::Iterator iter = m_jumps.begin(); iter != m_jumps.end(); ++iter) {
  • trunk/JavaScriptCore/assembler/ARMv7Assembler.h

    r62437 r64608  
    16291629    {
    16301630        void* copy = m_formatter.executableCopy(allocator);
     1631        if (!copy)
     1632            return 0;
    16311633
    16321634        unsigned jumpCount = m_jumpsToLink.size();
     
    16381640        m_jumpsToLink.clear();
    16391641
    1640         ASSERT(copy);
    16411642        return copy;
    16421643    }
  • trunk/JavaScriptCore/assembler/LinkBuffer.h

    r55633 r64608  
    5757    typedef MacroAssembler::DataLabelPtr DataLabelPtr;
    5858
     59    enum LinkBufferState {
     60        StateInit,
     61        StateChecked,
     62        StateFinalized,
     63    };
     64
    5965public:
    6066    // Note: Initialization sequence is significant, since executablePool is a PassRefPtr.
     
    6672        , m_size(masm->m_assembler.size())
    6773#ifndef NDEBUG
    68         , m_completed(false)
     74        , m_state(StateInit)
    6975#endif
    7076    {
     
    7379    ~LinkBuffer()
    7480    {
    75         ASSERT(m_completed);
     81        ASSERT(m_state == StateFinalized);
     82    }
     83
     84    // After constructing a link buffer, a client must call allocationSuccessful() to check alloc did not return 0.
     85    bool allocationSuccessful()
     86    {
     87#ifndef NDEBUG
     88        ASSERT(m_state == StateInit);
     89        m_state = StateChecked;
     90#endif
     91
     92        return m_code;
    7693    }
    7794
     
    171188    {
    172189#ifndef NDEBUG
    173         ASSERT(!m_completed);
    174         m_completed = true;
     190        ASSERT(m_state == StateChecked);
     191        m_state = StateFinalized;
    175192#endif
    176193
     
    183200    size_t m_size;
    184201#ifndef NDEBUG
    185     bool m_completed;
     202    LinkBufferState m_state;
    186203#endif
    187204};
  • trunk/JavaScriptCore/assembler/MIPSAssembler.h

    r59527 r64608  
    690690    {
    691691        void *result = m_buffer.executableCopy(allocator);
    692         if (!result)
    693             return 0;
    694 
    695         relocateJumps(m_buffer.data(), result);
     692        if (result)
     693            relocateJumps(m_buffer.data(), result);
    696694        return result;
    697695    }
  • trunk/JavaScriptCore/assembler/X86Assembler.h

    r58562 r64608  
    16271627    void* executableCopy(ExecutablePool* allocator)
    16281628    {
    1629         void* copy = m_formatter.executableCopy(allocator);
    1630         ASSERT(copy);
    1631         return copy;
     1629        return m_formatter.executableCopy(allocator);
    16321630    }
    16331631
Note: See TracChangeset for help on using the changeset viewer.