Ignore:
Timestamp:
Feb 29, 2012, 9:46:20 PM (13 years ago)
Author:
[email protected]
Message:

The JIT should not crash the entire process just because there is not
enough executable memory, if the LLInt is enabled
https://bugs.webkit.org/show_bug.cgi?id=79962
<rdar://problem/10922215>

Reviewed by Gavin Barraclough.

Added the notion of JITCompilationEffort. If we're JIT'ing as a result of
a tier-up, then we set it to JITCompilationCanFail. Otherwise it's
JITCompilationMustSucceed. This preserves the old behavior of LLInt is
disabled or if we're compiling something that can't be interpreted (like
an OSR exit stub).

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • assembler/ARMAssembler.cpp:

(JSC::ARMAssembler::executableCopy):

  • assembler/ARMAssembler.h:

(ARMAssembler):

  • assembler/AssemblerBuffer.h:

(JSC::AssemblerBuffer::executableCopy):

  • assembler/LinkBuffer.h:

(JSC::LinkBuffer::LinkBuffer):
(JSC::LinkBuffer::~LinkBuffer):
(LinkBuffer):
(JSC::LinkBuffer::didFailToAllocate):
(JSC::LinkBuffer::isValid):
(JSC::LinkBuffer::linkCode):
(JSC::LinkBuffer::performFinalization):

  • assembler/MIPSAssembler.h:

(JSC::MIPSAssembler::executableCopy):

  • assembler/SH4Assembler.h:

(JSC::SH4Assembler::executableCopy):

  • assembler/X86Assembler.h:

(JSC::X86Assembler::executableCopy):
(JSC::X86Assembler::X86InstructionFormatter::executableCopy):

  • bytecode/CodeBlock.cpp:

(JSC::ProgramCodeBlock::jitCompileImpl):
(JSC::EvalCodeBlock::jitCompileImpl):
(JSC::FunctionCodeBlock::jitCompileImpl):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::jitCompile):
(CodeBlock):
(ProgramCodeBlock):
(EvalCodeBlock):
(FunctionCodeBlock):

  • dfg/DFGDriver.cpp:

(JSC::DFG::compile):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::compile):
(JSC::DFG::JITCompiler::compileFunction):

  • dfg/DFGJITCompiler.h:

(JITCompiler):

  • jit/ExecutableAllocator.cpp:

(JSC::DemandExecutableAllocator::allocateNewSpace):
(JSC::ExecutableAllocator::allocate):

  • jit/ExecutableAllocator.h:

(ExecutableAllocator):

  • jit/ExecutableAllocatorFixedVMPool.cpp:

(JSC::ExecutableAllocator::allocate):

  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • jit/JIT.h:

(JSC::JIT::compile):
(JIT):

  • jit/JITCompilationEffort.h: Added.

(JSC):

  • jit/JITDriver.h:

(JSC::jitCompileIfAppropriate):
(JSC::jitCompileFunctionIfAppropriate):

  • llint/LLIntSlowPaths.cpp:

(LLInt):
(JSC::LLInt::jitCompileAndSetHeuristics):
(JSC::LLInt::entryOSR):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • runtime/Executable.cpp:

(JSC::EvalExecutable::jitCompile):
(JSC::ProgramExecutable::jitCompile):
(JSC::FunctionExecutable::jitCompileForCall):
(JSC::FunctionExecutable::jitCompileForConstruct):

  • runtime/Executable.h:

(EvalExecutable):
(ProgramExecutable):
(FunctionExecutable):
(JSC::FunctionExecutable::jitCompileFor):

  • runtime/ExecutionHarness.h:

(JSC::prepareForExecution):
(JSC::prepareFunctionForExecution):

File:
1 edited

Legend:

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

    r108444 r109307  
    3535#define REGEXP_CODE_ID reinterpret_cast<void*>(static_cast<intptr_t>(-2))
    3636
     37#include "JITCompilationEffort.h"
    3738#include "MacroAssembler.h"
    3839#include <wtf/DataLog.h>
     
    7475
    7576public:
    76     LinkBuffer(JSGlobalData& globalData, MacroAssembler* masm, void* ownerUID)
     77    LinkBuffer(JSGlobalData& globalData, MacroAssembler* masm, void* ownerUID, JITCompilationEffort effort = JITCompilationMustSucceed)
    7778        : m_size(0)
    7879#if ENABLE(BRANCH_COMPACTION)
     
    8485#ifndef NDEBUG
    8586        , m_completed(false)
    86 #endif
    87     {
    88         linkCode(ownerUID);
     87        , m_effort(effort)
     88#endif
     89    {
     90        linkCode(ownerUID, effort);
    8991    }
    9092
    9193    ~LinkBuffer()
    9294    {
    93         ASSERT(m_completed);
    94     }
    95 
     95        ASSERT(m_completed || (!m_executableMemory && m_effort == JITCompilationCanFail));
     96    }
     97   
     98    bool didFailToAllocate() const
     99    {
     100        return !m_executableMemory;
     101    }
     102
     103    bool isValid() const
     104    {
     105        return !didFailToAllocate();
     106    }
     107   
    96108    // These methods are used to link or set values at code generation time.
    97109
     
    219231    }
    220232
    221     void linkCode(void* ownerUID)
     233    void linkCode(void* ownerUID, JITCompilationEffort effort)
    222234    {
    223235        ASSERT(!m_code);
    224236#if !ENABLE(BRANCH_COMPACTION)
    225         m_executableMemory = m_assembler->m_assembler.executableCopy(*m_globalData, ownerUID);
     237        m_executableMemory = m_assembler->m_assembler.executableCopy(*m_globalData, ownerUID, effort);
    226238        if (!m_executableMemory)
    227239            return;
     
    231243#else
    232244        m_initialSize = m_assembler->m_assembler.codeSize();
    233         m_executableMemory = m_globalData->executableAllocator.allocate(*m_globalData, m_initialSize, ownerUID);
     245        m_executableMemory = m_globalData->executableAllocator.allocate(*m_globalData, m_initialSize, ownerUID, effort);
    234246        if (!m_executableMemory)
    235247            return;
     
    308320#ifndef NDEBUG
    309321        ASSERT(!m_completed);
     322        ASSERT(isValid());
    310323        m_completed = true;
    311324#endif
     
    376389#ifndef NDEBUG
    377390    bool m_completed;
     391    JITCompilationEffort m_effort;
    378392#endif
    379393};
Note: See TracChangeset for help on using the changeset viewer.