Changes between Version 8 and Version 9 of FTLJIT


Ignore:
Timestamp:
Jul 20, 2014 11:27:03 AM (6 years ago)
Author:
fpizlo@apple.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FTLJIT

    v8 v9  
    1 JavaScriptCore uses LLVM for a top-tier high-throughput optimizing JIT, which we call the FTL (Fourth Tier LLVM).  See https://bugs.webkit.org/show_bug.cgi?id=112840 for the bug that tracked this work.  It is now enabled by default on the Mac port.
     1JavaScriptCore uses LLVM for a top-tier high-throughput optimizing JIT, which we call the FTL (Fourth Tier LLVM).  See https://bugs.webkit.org/show_bug.cgi?id=112840 for the bug that tracked this work.  This was done as part of our effort to increase our latency-throughput adaptability range, and included other things like our concurrent JIT implementation; all of the tasks involved can be seen
     2in https://bugs.webkit.org/showdependencytree.cgi?id=112836&hide_resolved=0.  A lot of the future work to further improve the FTL JIT is tracked under https://bugs.webkit.org/show_bug.cgi?id=132356.
     3
     4The FTL JIT is now enabled by default on the Mac port.
     5
     6Two detailed blog posts have been written about the FTL; they currently serve as the best documentation of the FTL's architecture; see: https://www.webkit.org/blog/3362/introducing-the-webkit-ftl-jit/ and http://blog.llvm.org/2014/07/ftl-webkits-llvm-based-jit.html.
    27
    38= Overview
     
    813- Additional DFG phases are used.  Running in FTL mode causes the DFG to lower to SSA even before lowering to LLVM IR.  Additional optimizations like LICM are performed on the DFG-SSA IR.
    914
    10 The FTL JIT already supports key DFG concepts like OSR entry, OSR exit, and concurrent compilation.
     15The FTL JIT supports key DFG concepts like OSR entry, OSR exit, concurrent compilation, and self-modifying code for inline caches that we use for things like GetById (i.e. v = o.f), PutById (i.e. o.f = v), Call/Construct, and In (i.e. "foo" in o).
    1116
    1217= Try it out
     
    1419== Building
    1520
    16 You can try out the FTL JIT on the Mac port by doing:
     21The FTL JIT is enabled by default, so you shouldn't have to do anything special to build it.  All of the Apple WebKit ports' build modes support the FTL: it will be built and enabled via build-jsc, build-webkit, make, and building from Xcode.  This is made possible by including binary drops of known-good LLVM versions in the WebKit repository (more on that below).
     22
     23On non-"Apple WebKit" platforms, the FTL JIT is disabled, but the --ftl-jit flag will force it enabled.  Your mileage may vary, though, since currently only Mac and iOS is supported by the FTL JIT.  Here's an example of using the --ftl-jit flag:
    1724
    1825{{{
     
    2633}}}
    2734
    28 Note that this requires either having binary drops of LLVM headers and static libraries, or having your own LLVM checkout.
    29 
    30 Also note that building directly from Xcode is not supported at this time.
    31 
    3235=== Building from binary drops
    3336
    34 The WebKit repository includes LLVM binary drops for Mountain Lion in trunk/WebKitLibraries.  If you're on Mountain Lion and you use the --ftl-jit option to build-jsc, run-javascriptcore-tests, or build-webkit, the build system will automatically pull LLVM from those binary drops.
     37The WebKit repository includes LLVM binary drops for Mountain Lion and Mavericks in trunk/WebKitLibraries.  On those systems, the build system will automatically pull LLVM from those binary drops.  This is done in Tools/Scripts/copy-webkitlibraries-to-product-directory.
    3538
    3639=== Building from your own LLVM checkout
    3740
    38 The easiest way to build with your own LLVM checkout is to check out llvm into a directory called 'llvm' directly inside your checkout of WebKit.  If you do this, build-jsc and friends will automatically configure and make this LLVM tree and pull the binaries into WebKit's build.  LLVM's configure script is only run if we detect that you hadn't already run it.  The default configuration parameters are kept in Tools/Scripts/configure-llvm.
     41The easiest way to build with your own LLVM checkout is to check out llvm into a directory called 'llvm' directly inside your checkout of WebKit.  If you do this, build-jsc and friends will automatically configure and make this LLVM tree and pull the binaries into WebKit's build.  LLVM's configure script is only run if we detect that you hadn't already run it.  The default configuration parameters are kept in Tools/Scripts/copy-webkitlibraries-to-product-directory.  You can configure LLVM yourself, so long as you follow the same build directory structure as that script expects: within the llvm directory, we expect a "wkLLVMBuild" subdirectory.  This will be used as the build directory.
    3942
    4043Note that this handles dependencies pretty well.  For example, if you make changes in LLVM that lead to some libraries that WebKit depends on being recompiled, but don't change any LLVM headers, this will still cause the JavaScriptCore framework to be relinked.
     
    4851For further information, consult the Tools/Scripts/copy-webkitlibraries-to-product-directory script, which handles all of this magic.
    4952
    50 == Running
     53== Running and Testing
    5154
    52 The FTL JIT is runtime-disabled even when it is buildtime-enabled.  Hence to run a program with the FTL JIT you also need the --useExperimentalFTL=true option, like:
     55The FTL JIT is runtime-enabled on those platforms where it is build-time-enabled.  The --useFTLJIT flag can be used to disable it.  Note that the FTL only kicks in for functions that run many times - 100,000 executions is typically required to ensure that the function is FTL-compiled.  Because FTL compilation is queued up and done concurrently, for simple programs even 100,000 executions may not be enough to really trigger the FTL: the program may exit while the FTL compilation task is still queued or on-going.  You can disable this by doing:
    5356
    5457{{{
    55 DYLD_FRAMEWORK_PATH=WebKitBuild/Debug WebKitBuild/Debug/jsc --useExperimentalFTL=true <my JS program>
     58DYLD_FRAMEWORK_PATH=WebKitBuild/Debug WebKitBuild/Debug/jsc --enableConcurrentJIT=false <my JS program>
    5659}}}
    5760
     
    5962
    6063{{{
    61 export JSC_useExperimentalFTL=true
    62 }}}
    63 
    64 == Testing
    65 
    66 You can run the test suite including the FTL JIT by doing:
    67 
    68 {{{
    69 Tools/Scripts/run-javascriptcore-tests --debug --ftl-jit
    70 }}}
    71 
    72 or:
    73 
    74 {{{
    75 Tools/Scripts/run-javascriptcore-tests --release --ftl-jit
     64export JSC_enableConcurrentJIT=false
    7665}}}
    7766
     
    8372
    8473{{{
    85 DYLD_FRAMEWORK_PATH=WebKitBuild/Debug WebKitBuild/Debug/jsc --useExperimentalFTL=true --reportCompileTimes=true <my JS program>
     74DYLD_FRAMEWORK_PATH=WebKitBuild/Debug WebKitBuild/Debug/jsc --reportCompileTimes=true <my JS program>
    8675}}}
    8776
     
    8978
    9079{{{
    91 DYLD_FRAMEWORK_PATH=WebKitBuild/Debug WebKitBuild/Debug/jsc --useExperimentalFTL=true --dumpLLVMIR=true <my JS program>
     80DYLD_FRAMEWORK_PATH=WebKitBuild/Debug WebKitBuild/Debug/jsc --dumpLLVMIR=true <my JS program>
    9281}}}
    9382
     
    9584
    9685{{{
    97 DYLD_FRAMEWORK_PATH=WebKitBuild/Debug WebKitBuild/Debug/jsc --useExperimentalFTL=true --verboseCompilation=true <my JS program>
     86DYLD_FRAMEWORK_PATH=WebKitBuild/Debug WebKitBuild/Debug/jsc --verboseFTLCompilation=true <my JS program>
    9887}}}
    9988
     
    10392
    10493{{{
    105 DYLD_FRAMEWORK_PATH=WebKitBuild/Debug WebKitBuild/Debug/jsc --useExperimentalFTL=true --showDFGDisassembly=true <my JS program>
     94DYLD_FRAMEWORK_PATH=WebKitBuild/Debug WebKitBuild/Debug/jsc --showDFGDisassembly=true <my JS program>
    10695}}}
    10796