FTL: Soft-link LLVM as a workaround for LLVM's static initializers and exit-time...
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Oct 2013 22:19:00 +0000 (22:19 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Oct 2013 22:19:00 +0000 (22:19 +0000)
commit69b86fac460ab9be700a5e59bd25971d3609daac
treeb85abfac05be2b8ba60edc117821615878555b9f
parent95667126ef2e26d2c238cfbeffdf9470d071788c
FTL: Soft-link LLVM as a workaround for LLVM's static initializers and exit-time destructors
https://bugs.webkit.org/show_bug.cgi?id=122566

Source/JavaScriptCore:

Reviewed by Mark Rowe.

The JSC project now builds a libllvmForJSC.dylib. If FTL is enabled, this
gets copied into JavaScriptCore.framework/Versions/A/Libraries. JSC will
load the dylib by finding it using NSBundle APIs and then doing dlopen().
That will only happen lazily, when something happens that requires LLVM.

This mostly takes care of LLVM static initialization overhead by deferring
it until it's really needed.

This takes care of LLVM's exit-time destructors because inside
libllvmForJSC.dylib, we override __cxa_atexit.

* Configurations/JavaScriptCore.xcconfig:
* Configurations/LLVMForJSC.xcconfig: Added.
* JavaScriptCore.xcodeproj/project.pbxproj:
* dfg/DFGPlan.cpp:
(JSC::DFG::Plan::compileInThreadImpl):
* disassembler/LLVMDisassembler.cpp:
(JSC::tryToDisassembleWithLLVM):
* ftl/FTLAbbreviatedTypes.h:
* ftl/FTLAbbreviations.h:
(JSC::FTL::voidType):
(JSC::FTL::int1Type):
(JSC::FTL::int8Type):
(JSC::FTL::int16Type):
(JSC::FTL::int32Type):
(JSC::FTL::int64Type):
(JSC::FTL::intPtrType):
(JSC::FTL::floatType):
(JSC::FTL::doubleType):
(JSC::FTL::pointerType):
(JSC::FTL::structType):
(JSC::FTL::functionType):
(JSC::FTL::typeOf):
(JSC::FTL::mdKindID):
(JSC::FTL::mdString):
(JSC::FTL::mdNode):
(JSC::FTL::setMetadata):
(JSC::FTL::addFunction):
(JSC::FTL::setLinkage):
(JSC::FTL::setFunctionCallingConv):
(JSC::FTL::getParam):
(JSC::FTL::constInt):
(JSC::FTL::constReal):
(JSC::FTL::constIntToPtr):
(JSC::FTL::constBitCast):
(JSC::FTL::appendBasicBlock):
(JSC::FTL::insertBasicBlock):
(JSC::FTL::buildPhi):
(JSC::FTL::addIncoming):
(JSC::FTL::buildAlloca):
(JSC::FTL::buildAdd):
(JSC::FTL::buildSub):
(JSC::FTL::buildMul):
(JSC::FTL::buildDiv):
(JSC::FTL::buildRem):
(JSC::FTL::buildNeg):
(JSC::FTL::buildFAdd):
(JSC::FTL::buildFSub):
(JSC::FTL::buildFMul):
(JSC::FTL::buildFDiv):
(JSC::FTL::buildFRem):
(JSC::FTL::buildFNeg):
(JSC::FTL::buildAnd):
(JSC::FTL::buildOr):
(JSC::FTL::buildXor):
(JSC::FTL::buildShl):
(JSC::FTL::buildAShr):
(JSC::FTL::buildLShr):
(JSC::FTL::buildNot):
(JSC::FTL::buildLoad):
(JSC::FTL::buildStore):
(JSC::FTL::buildSExt):
(JSC::FTL::buildZExt):
(JSC::FTL::buildFPToSI):
(JSC::FTL::buildFPToUI):
(JSC::FTL::buildSIToFP):
(JSC::FTL::buildUIToFP):
(JSC::FTL::buildIntCast):
(JSC::FTL::buildFPCast):
(JSC::FTL::buildIntToPtr):
(JSC::FTL::buildPtrToInt):
(JSC::FTL::buildBitCast):
(JSC::FTL::buildICmp):
(JSC::FTL::buildFCmp):
(JSC::FTL::buildCall):
(JSC::FTL::setTailCall):
(JSC::FTL::buildExtractValue):
(JSC::FTL::buildSelect):
(JSC::FTL::buildBr):
(JSC::FTL::buildCondBr):
(JSC::FTL::buildSwitch):
(JSC::FTL::addCase):
(JSC::FTL::buildRet):
(JSC::FTL::buildUnreachable):
(JSC::FTL::dumpModule):
(JSC::FTL::verifyModule):
* ftl/FTLCompile.cpp:
(JSC::FTL::compile):
* ftl/FTLFail.cpp:
(JSC::FTL::fail):
* ftl/FTLJITCode.h:
* ftl/FTLJITFinalizer.h:
* ftl/FTLLink.cpp:
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::lower):
* ftl/FTLOutput.cpp:
(JSC::FTL::Output::Output):
(JSC::FTL::Output::~Output):
* ftl/FTLOutput.h:
(JSC::FTL::Output::appendTo):
* ftl/FTLState.cpp:
(JSC::FTL::State::State):
(JSC::FTL::State::~State):
* ftl/WebKitLLVMLibraryAnchor.cpp: Removed.
* jsc.cpp:
(jscmain):
* llvm: Added.
* llvm/InitializeLLVM.cpp: Added.
(JSC::initializeLLVM):
* llvm/InitializeLLVM.h: Added.
* llvm/InitializeLLVMMac.mm: Added.
(JSC::initializeLLVMImpl):
* llvm/InitializeLLVMPOSIX.cpp: Added.
(JSC::initializeLLVMPOSIX):
* llvm/InitializeLLVMPOSIX.h: Added.
* llvm/LLVMAPI.cpp: Added.
* llvm/LLVMAPI.h: Added.
* llvm/LLVMAPIFunctions.h: Added.
* llvm/LLVMHeaders.h: Added.
* llvm/library: Added.
* llvm/library/LLVMAnchor.cpp: Added.
* llvm/library/LLVMExports.cpp: Added.
(initializeAndGetJSCLLVMAPI):
* llvm/library/LLVMOverrides.cpp: Added.
(__cxa_atexit):
* llvm/library/config_llvm.h: Added.
* runtime/InitializeThreading.cpp:
(JSC::initializeThreadingOnce):
* runtime/Options.h:

Source/WTF:

Reviewed by Mark Rowe.

Remove all LLVM stuff from WTF since to get LLVM you need to soft-link and it's
entirely the responsibility of JSC to do that.

Also fixed an export goof that I found after fixing the weak thingy script in JSC.

* WTF.xcodeproj/project.pbxproj:
* wtf/LLVMHeaders.h: Removed.
* wtf/text/CString.h:
(WTF::CStringHash::hash):

Tools:

Reviewed by Mark Rowe.

* Scripts/configure-llvm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157260 268f45cc-cd09-0410-ab3c-d52691b4dbfc
38 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Configurations/JavaScriptCore.xcconfig
Source/JavaScriptCore/Configurations/LLVMForJSC.xcconfig [new file with mode: 0644]
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/dfg/DFGPlan.cpp
Source/JavaScriptCore/disassembler/LLVMDisassembler.cpp
Source/JavaScriptCore/ftl/FTLAbbreviatedTypes.h
Source/JavaScriptCore/ftl/FTLAbbreviations.h
Source/JavaScriptCore/ftl/FTLCompile.cpp
Source/JavaScriptCore/ftl/FTLFail.cpp
Source/JavaScriptCore/ftl/FTLJITCode.h
Source/JavaScriptCore/ftl/FTLJITFinalizer.h
Source/JavaScriptCore/ftl/FTLLink.cpp
Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp
Source/JavaScriptCore/ftl/FTLOutput.cpp
Source/JavaScriptCore/ftl/FTLOutput.h
Source/JavaScriptCore/ftl/FTLState.cpp
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/llvm/InitializeLLVM.cpp [new file with mode: 0644]
Source/JavaScriptCore/llvm/InitializeLLVM.h [new file with mode: 0644]
Source/JavaScriptCore/llvm/InitializeLLVMMac.mm [new file with mode: 0644]
Source/JavaScriptCore/llvm/InitializeLLVMPOSIX.cpp [new file with mode: 0644]
Source/JavaScriptCore/llvm/InitializeLLVMPOSIX.h [new file with mode: 0644]
Source/JavaScriptCore/llvm/LLVMAPI.cpp [new file with mode: 0644]
Source/JavaScriptCore/llvm/LLVMAPI.h [new file with mode: 0644]
Source/JavaScriptCore/llvm/LLVMAPIFunctions.h [new file with mode: 0644]
Source/JavaScriptCore/llvm/LLVMHeaders.h [moved from Source/WTF/wtf/LLVMHeaders.h with 96% similarity]
Source/JavaScriptCore/llvm/library/LLVMAnchor.cpp [moved from Source/JavaScriptCore/ftl/WebKitLLVMLibraryAnchor.cpp with 96% similarity]
Source/JavaScriptCore/llvm/library/LLVMExports.cpp [new file with mode: 0644]
Source/JavaScriptCore/llvm/library/LLVMOverrides.cpp [new file with mode: 0644]
Source/JavaScriptCore/llvm/library/config_llvm.h [new file with mode: 0644]
Source/JavaScriptCore/runtime/InitializeThreading.cpp
Source/JavaScriptCore/runtime/Options.h
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/text/CString.h
Tools/ChangeLog
Tools/Scripts/configure-llvm