Changeset 194591 in webkit


Ignore:
Timestamp:
Jan 5, 2016, 11:12:05 AM (10 years ago)
Author:
[email protected]
Message:

Add support for aliasing JSC Options.
https://bugs.webkit.org/show_bug.cgi?id=152551

Reviewed by Filip Pizlo.

This allows us to use old options names as well. This is for the benefit of
third party tools which may have been built to rely on those old options. The
old option names will be mapped to the current option names in setOption().

For some options, the old option name specifies the inverse boolean value of the
current option name. setOption() will take care of inverting the value before
applying it to the option.

  • jsc.cpp:

(CommandLine::parseArguments):

  • Switch to dumping only overridden options here. Verbose dumping is too much for common usage.
  • runtime/Options.cpp:

(JSC::overrideOptionWithHeuristic):
(JSC::Options::overrideAliasedOptionWithHeuristic):
(JSC::computeNumberOfWorkerThreads):
(JSC::Options::initialize):
(JSC::Options::setOptionWithoutAlias):
(JSC::invertBoolOptionValue):
(JSC::Options::setAliasedOption):
(JSC::Options::setOption):
(JSC::Options::dumpAllOptions):

  • String.ascii() converts newline characters to '?', and this was messing up the printing of the options. Switched to using String.utf8() instead.

(JSC::Options::dumpOption):

  • runtime/Options.h:
Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r194590 r194591  
    1 2015-12-24  Mark Lam  <[email protected]>
     12016-01-05  Mark Lam  <[email protected]>
     2
     3        Add support for aliasing JSC Options.
     4        https://bugs.webkit.org/show_bug.cgi?id=152551
     5
     6        Reviewed by Filip Pizlo.
     7
     8        This allows us to use old options names as well.  This is for the benefit of
     9        third party tools which may have been built to rely on those old options.  The
     10        old option names will be mapped to the current option names in setOption().
     11
     12        For some options, the old option name specifies the inverse boolean value of the
     13        current option name.  setOption() will take care of inverting the value before
     14        applying it to the option.
     15
     16        * jsc.cpp:
     17        (CommandLine::parseArguments):
     18        - Switch to dumping only overridden options here.  Verbose dumping is too much
     19          for common usage.
     20        * runtime/Options.cpp:
     21        (JSC::overrideOptionWithHeuristic):
     22        (JSC::Options::overrideAliasedOptionWithHeuristic):
     23        (JSC::computeNumberOfWorkerThreads):
     24        (JSC::Options::initialize):
     25        (JSC::Options::setOptionWithoutAlias):
     26        (JSC::invertBoolOptionValue):
     27        (JSC::Options::setAliasedOption):
     28        (JSC::Options::setOption):
     29        (JSC::Options::dumpAllOptions):
     30        - String.ascii() converts newline characters to '?', and this was messing up the
     31          printing of the options.  Switched to using String.utf8() instead.
     32        (JSC::Options::dumpOption):
     33        * runtime/Options.h:
     34
     352016-01-05  Mark Lam  <[email protected]>
    236
    337        Add validation of JSC options to catch typos.
  • trunk/Source/JavaScriptCore/jsc.cpp

    r194590 r194591  
    19851985
    19861986    if (needToDumpOptions)
    1987         JSC::Options::dumpAllOptions(stderr, JSC::Options::DumpLevel::Verbose, "All JSC runtime options:");
     1987        JSC::Options::dumpAllOptions(stderr, JSC::Options::DumpLevel::Overridden, "All JSC runtime options:");
    19881988    JSC::Options::ensureOptionsAreCoherent();
    19891989    if (needToExit)
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r194590 r194591  
    128128}
    129129
     130bool Options::overrideAliasedOptionWithHeuristic(const char* name)
     131{
     132    const char* stringValue = getenv(name);
     133    if (!stringValue)
     134        return false;
     135
     136    String aliasedOption;
     137    aliasedOption = String(&name[4]) + "=" + stringValue;
     138    if (Options::setOption(aliasedOption.utf8().data()))
     139        return true;
     140
     141    fprintf(stderr, "WARNING: failed to parse %s=%s\n", name, stringValue);
     142    return false;
     143}
     144
    130145static unsigned computeNumberOfWorkerThreads(int maxNumberOfWorkerThreads, int minimum = 1)
    131146{
     
    386401#endif // PLATFORM(COCOA)
    387402
     403#define FOR_EACH_OPTION(aliasedName_, unaliasedName_, equivalence_) \
     404            overrideAliasedOptionWithHeuristic("JSC_" #aliasedName_);
     405            JSC_ALIASED_OPTIONS(FOR_EACH_OPTION)
     406#undef FOR_EACH_OPTION
     407
    388408#if 0
    389409                ; // Deconfuse editors that do auto indentation
     
    528548// Parses a single command line option in the format "<optionName>=<value>"
    529549// (no spaces allowed) and set the specified option if appropriate.
    530 bool Options::setOption(const char* arg)
     550bool Options::setOptionWithoutAlias(const char* arg)
    531551{
    532552    // arg should look like this:
     
    560580}
    561581
     582static bool invertBoolOptionValue(const char* valueStr, const char*& invertedValueStr)
     583{
     584    bool boolValue;
     585    if (!parse(valueStr, boolValue))
     586        return false;
     587    invertedValueStr = boolValue ? "false" : "true";
     588    return true;
     589}
     590
     591
     592bool Options::setAliasedOption(const char* arg)
     593{
     594    // arg should look like this:
     595    //   <jscOptionName>=<appropriate value>
     596    const char* equalStr = strchr(arg, '=');
     597    if (!equalStr)
     598        return false;
     599
     600    // For each option, check if the specify arg is a match. If so, set the arg
     601    // if the value makes sense. Otherwise, move on to checking the next option.
     602#define FOR_EACH_OPTION(aliasedName_, unaliasedName_, equivalence) \
     603    if (strlen(#aliasedName_) == static_cast<size_t>(equalStr - arg)    \
     604        && !strncmp(arg, #aliasedName_, equalStr - arg)) {              \
     605        String unaliasedOption(#unaliasedName_);                        \
     606        if (equivalence == SameOption)                                  \
     607            unaliasedOption = unaliasedOption + equalStr;               \
     608        else {                                                          \
     609            ASSERT(equivalence == InvertedOption);                      \
     610            const char* invertedValueStr = nullptr;                     \
     611            if (!invertBoolOptionValue(equalStr + 1, invertedValueStr)) \
     612                return false;                                           \
     613            unaliasedOption = unaliasedOption + "=" + invertedValueStr; \
     614        }                                                               \
     615        return setOptionWithoutAlias(unaliasedOption.utf8().data());   \
     616    }
     617
     618    JSC_ALIASED_OPTIONS(FOR_EACH_OPTION)
     619#undef FOR_EACH_OPTION
     620
     621    return false; // No option matched.
     622}
     623
     624bool Options::setOption(const char* arg)
     625{
     626    bool success = setOptionWithoutAlias(arg);
     627    if (success)
     628        return true;
     629    return setAliasedOption(arg);
     630}
     631
     632
    562633void Options::dumpAllOptions(StringBuilder& builder, DumpLevel level, const char* title,
    563634    const char* separator, const char* optionHeader, const char* optionFooter, DumpDefaultsOption dumpDefaultsOption)
     
    584655    StringBuilder builder;
    585656    dumpAllOptions(builder, level, title, nullptr, "   ", "\n", DumpDefaults);
    586     fprintf(stream, "%s", builder.toString().ascii().data());
     657    fprintf(stream, "%s", builder.toString().utf8().data());
    587658}
    588659
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r194590 r194591  
    353353    v(bool, exposeInternalModuleLoader, false, "expose the internal module loader object to the global space for debugging") \
    354354
     355enum OptionEquivalence {
     356    SameOption,
     357    InvertedOption,
     358};
     359
     360#define JSC_ALIASED_OPTIONS(v) \
     361    v(enableFunctionDotArguments, useFunctionDotArguments, SameOption) \
     362    v(enableTailCalls, useTailCalls, SameOption) \
     363    v(showDisassembly, dumpDisassembly, SameOption) \
     364    v(showDFGDisassembly, dumpDFGDisassembly, SameOption) \
     365    v(showFTLDisassembly, dumpFTLDisassembly, SameOption) \
     366    v(showAllDFGNodes, dumpAllDFGNodes, SameOption) \
     367    v(alwaysDoFullCollection, useGenerationalGC, InvertedOption) \
     368    v(enableOSREntryToDFG, useOSREntryToDFG, SameOption) \
     369    v(enableOSREntryToFTL, useOSREntryToFTL, SameOption) \
     370    v(enableLLVMFastISel, useLLVMFastISel, SameOption) \
     371    v(enableAccessInlining, useAccessInlining, SameOption) \
     372    v(enablePolyvariantDevirtualization, usePolyvariantDevirtualization, SameOption) \
     373    v(enablePolymorphicAccessInlining, usePolymorphicAccessInlining, SameOption) \
     374    v(enablePolymorphicCallInlining, usePolymorphicCallInlining, SameOption) \
     375    v(enableMovHintRemoval, useMovHintRemoval, SameOption) \
     376    v(enableObjectAllocationSinking, useObjectAllocationSinking, SameOption) \
     377    v(enableCopyBarrierOptimization, useCopyBarrierOptimization, SameOption) \
     378    v(enableConcurrentJIT, useConcurrentJIT, SameOption) \
     379    v(enableProfiler, useProfiler, SameOption) \
     380    v(enableArchitectureSpecificOptimizations, useArchitectureSpecificOptimizations, SameOption) \
     381    v(enablePolyvariantCallInlining, usePolyvariantCallInlining, SameOption) \
     382    v(enablePolyvariantByIdInlining, usePolyvariantByIdInlining, SameOption) \
     383    v(enableMaximalFlushInsertionPhase, useMaximalFlushInsertionPhase, SameOption) \
     384    v(objectsAreImmortal, useImmortalObjects, SameOption) \
     385    v(showObjectStatistics, dumpObjectStatistics, SameOption) \
     386    v(disableGC, useGC, InvertedOption) \
     387    v(enableTypeProfiler, useTypeProfiler, SameOption) \
     388    v(enableControlFlowProfiler, useControlFlowProfiler, SameOption) \
     389    v(enableExceptionFuzz, useExceptionFuzz, SameOption) \
     390    v(enableExecutableAllocationFuzz, useExecutableAllocationFuzz, SameOption) \
     391    v(enableOSRExitFuzz, useOSRExitFuzz, SameOption) \
     392    v(enableDollarVM, useDollarVM, SameOption) \
     393
    355394class Options {
    356395public:
     
    439478        const char* optionHeader, const char* optionFooter, DumpDefaultsOption);
    440479
     480    static bool setOptionWithoutAlias(const char* arg);
     481    static bool setAliasedOption(const char* arg);
     482    static bool overrideAliasedOptionWithHeuristic(const char* name);
     483
    441484    // Declare the singleton instance of the options store:
    442485    JS_EXPORTDATA static Entry s_options[numberOfOptions];
Note: See TracChangeset for help on using the changeset viewer.