Ignore:
Timestamp:
Jul 22, 2014, 9:33:37 PM (11 years ago)
Author:
[email protected]
Message:

Merge r169628 from ftlopt.

2014-06-04 Matthew Mirman <[email protected]>


Added system for inlining native functions via the FTL.
https://bugs.webkit.org/show_bug.cgi?id=131515


Reviewed by Filip Pizlo.


Also fixed the build to not compress the bitcode and to
include all of the relevant runtime. With GCC_GENERATE_DEBUGGING_SYMBOLS = NO,
the produced bitcode files are a 100th the size they were before.
Now we can include all of the relevant runtime files with only a 3mb overhead.
This is the same overhead as for two compressed files before,
but done more efficiently (on both ends) and with less code.


Deciding whether to inline native functions is left up to LLVM.
The entire module containing the function is linked into the current
compiled JS so that inlining the native functions shouldn't make them smaller.


Rather than loading Runtime.symtbl at runtime FTLState.cpp now generates a file
InlineRuntimeSymbolTable.h which statically builds the symbol table hash table.


  • JavaScriptCore.xcodeproj/project.pbxproj: Added back runtime files to compile.
  • build-symbol-table-index.py: Changed bitcode suffix. Added inclusion of only tested symbols. Added output to InlineRuntimeSymbolTable.h.
  • build-symbol-table-index.sh: Changed bitcode suffix.
  • copy-llvm-ir-to-derived-sources.sh: Removed gzip compression.
  • tested-symbols.symlst: Added.
  • dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleCall): Now sets the knownFunction of the call node if such a function exists and emits a check that during runtime the callee is in fact known.
  • dfg/DFGNode.h: Added functions to set the known function of a call node. (JSC::DFG::Node::canBeKnownFunction): Added. (JSC::DFG::Node::hasKnownFunction): Added. (JSC::DFG::Node::knownFunction): Added. (JSC::DFG::Node::giveKnownFunction): Added.
  • ftl/FTLAbbreviatedTypes.h: Added a typedef for LLVMMemoryBufferRef
  • ftl/FTLAbbreviations.h: Added some abbreviations.
  • ftl/FTLLowerDFGToLLVM.cpp: (JSC::FTL::LowerDFGToLLVM::isInlinableSize): Added. Hardcoded threshold to 275. (JSC::FTL::LowerDFGToLLVM::getModuleByPathForSymbol): Added. (JSC::FTL::LowerDFGToLLVM::getFunctionBySymbol): Added. (JSC::FTL::LowerDFGToLLVM::possiblyCompileInlineableNativeCall): Added. (JSC::FTL::LowerDFGToLLVM::compileCallOrConstruct): Added call to possiblyCompileInlineableNativeCall
  • ftl/FTLOutput.h: (JSC::FTL::Output::allocaName): Added. Useful for debugging.
  • ftl/FTLState.cpp: (JSC::FTL::State::State): Added an include for InlineRuntimeSymbolTable.h
  • ftl/FTLState.h: Added symbol table hash table.
  • ftl/FTLCompile.cpp: (JSC::FTL::compile): Added inlining and dead function elimination passes.
  • heap/HandleStack.h: Added JS_EXPORT_PRIVATE to a few functions to get inlining to compile.
  • llvm/InitializeLLVMMac.mm: Deleted.
  • llvm/InitializeLLVMMac.cpp: Added.
  • llvm/LLVMAPIFunctions.h: Added macros to include Bitcode parsing and linking functions.
  • llvm/LLVMHeaders.h: Added includes for Bitcode parsing and linking.
  • runtime/BundlePath.h: Added.
  • runtime/BundlePath.mm: Added.
  • runtime/DateInstance.h: Added JS_EXPORT_PRIVATE to a few functions to get inlining to compile.
  • runtime/DateInstance.h: ditto.
  • runtime/DateConversion.h: ditto.
  • runtime/ExceptionHelpers.h: ditto.
  • runtime/JSCJSValue.h: ditto.
  • runtime/JSArray.h: ditto.
  • runtime/JSDateMath.h: ditto.
  • runtime/JSObject.h: ditto.
  • runtime/JSObject.h: ditto.
  • runtime/RegExp.h: ditto.
  • runtime/Structure.h: ditto.
  • runtime/Options.h: Added maximumLLVMInstructionCountForNativeInlining.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/build-symbol-table-index.py

    r167087 r171391  
    55import subprocess
    66import sys
     7from sets import Set
    78from operator import itemgetter
    89
     
    2324framework_directory = os.path.join(os.getenv("BUILT_PRODUCTS_DIR"), os.getenv("JAVASCRIPTCORE_RESOURCES_DIR"), "Runtime", current_arch)
    2425
     26
    2527symbol_table_location = os.path.join(framework_directory, "Runtime.symtbl")
    2628
     
    3436    symbol_table_modification_time = os.path.getmtime(symbol_table_location)
    3537
    36 file_suffix = "bc.gz"
     38file_suffix = "bc"
    3739file_suffix_length = len(file_suffix)
     40
     41tested_symbols_location = "./tested-symbols.symlst"
     42include_symbol_table_location = os.path.join(os.getenv("SHARED_DERIVED_FILE_DIR"), "JavaScriptCore/InlineRuntimeSymbolTable.h")
     43
     44tested_symbols = Set([])
     45
     46if os.path.isfile(tested_symbols_location):
     47    with open(tested_symbols_location, 'r') as file:
     48        print("Loading tested symbols")
     49        for line in file:
     50            tested_symbols.add(line[:-1])
    3851
    3952for bitcode_file in glob.iglob(os.path.join(framework_directory, "*." + file_suffix)):
     
    4962
    5063    for symbol in lines:
    51         if symbol[:2] == "__" and symbol[-3:] != ".eh":
    52             symbol_table[symbol] = bitcode_basename[1:]
     64        if symbol[:2] == "__" and symbol[-3:] != ".eh" and symbol in tested_symbols:
     65            symbol_table[symbol[1:]] = bitcode_basename
    5366
    5467if not symbol_table_is_out_of_date:
     
    6881print("Writing symbol table")
    6982
    70 with open(symbol_table_location, "w") as file:
    71     for symbol, location in symbol_list:
    72         file.write("{} {}\n".format(symbol, location))
    73 
     83with open(symbol_table_location, "w") as symbol_file:
     84    with open(include_symbol_table_location, "w") as include_file:
     85        include_file.write("#define FOR_EACH_LIBRARY_SYMBOL(macro)")
     86        for symbol, location in symbol_list:
     87            symbol_file.write("{} {}\n".format(symbol, location))
     88            include_file.write(" \\\nmacro(\"{}\", \"{}\")".format(symbol, location))
     89        include_file.write("\n")
    7490print("Done")
Note: See TracChangeset for help on using the changeset viewer.