Bug 43390 - Do not CRASH if we run out of room for jit code.
authorGavin Barraclough <barraclough@apple.com>
Wed, 4 Aug 2010 00:15:47 +0000 (00:15 +0000)
committerSimon Hausmann <simon.hausmann@nokia.com>
Thu, 23 Sep 2010 19:04:15 +0000 (21:04 +0200)
commit6839b667368aa0e0ad0de7455bba530e5e4e7841
treeae14b9ab037b958372e4a40e962e39aef41094a6
parent986ae02a26d43abaa26ec71c7f2f9ed351b9cf4f
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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64608 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/assembler/ARMAssembler.cpp
JavaScriptCore/assembler/ARMv7Assembler.h
JavaScriptCore/assembler/LinkBuffer.h
JavaScriptCore/assembler/MIPSAssembler.h
JavaScriptCore/assembler/X86Assembler.h
JavaScriptCore/bytecode/StructureStubInfo.h
JavaScriptCore/jit/ExecutableAllocator.cpp
JavaScriptCore/jit/ExecutableAllocator.h
JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp
JavaScriptCore/jit/JIT.cpp
JavaScriptCore/jit/JIT.h
JavaScriptCore/jit/JITOpcodes.cpp
JavaScriptCore/jit/JITOpcodes32_64.cpp
JavaScriptCore/jit/JITPropertyAccess.cpp
JavaScriptCore/jit/JITPropertyAccess32_64.cpp
JavaScriptCore/jit/JITStubs.cpp
JavaScriptCore/jit/JITStubs.h
JavaScriptCore/jit/SpecializedThunkJIT.h
JavaScriptCore/runtime/ExceptionHelpers.cpp
JavaScriptCore/runtime/ExceptionHelpers.h
JavaScriptCore/runtime/Executable.cpp
JavaScriptCore/wtf/PageAllocation.h
JavaScriptCore/yarr/RegexJIT.cpp