Title: [194591] trunk/Source/_javascript_Core
Revision
194591
Author
[email protected]
Date
2016-01-05 11:12:05 -0800 (Tue, 05 Jan 2016)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (194590 => 194591)


--- trunk/Source/_javascript_Core/ChangeLog	2016-01-05 19:03:07 UTC (rev 194590)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-01-05 19:12:05 UTC (rev 194591)
@@ -1,5 +1,39 @@
-2015-12-24  Mark Lam  <[email protected]>
+2016-01-05  Mark Lam  <[email protected]>
 
+        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:
+
+2016-01-05  Mark Lam  <[email protected]>
+
         Add validation of JSC options to catch typos.
         https://bugs.webkit.org/show_bug.cgi?id=152549
 

Modified: trunk/Source/_javascript_Core/jsc.cpp (194590 => 194591)


--- trunk/Source/_javascript_Core/jsc.cpp	2016-01-05 19:03:07 UTC (rev 194590)
+++ trunk/Source/_javascript_Core/jsc.cpp	2016-01-05 19:12:05 UTC (rev 194591)
@@ -1984,7 +1984,7 @@
         m_arguments.append(argv[i]);
 
     if (needToDumpOptions)
-        JSC::Options::dumpAllOptions(stderr, JSC::Options::DumpLevel::Verbose, "All JSC runtime options:");
+        JSC::Options::dumpAllOptions(stderr, JSC::Options::DumpLevel::Overridden, "All JSC runtime options:");
     JSC::Options::ensureOptionsAreCoherent();
     if (needToExit)
         jscExit(EXIT_SUCCESS);

Modified: trunk/Source/_javascript_Core/runtime/Options.cpp (194590 => 194591)


--- trunk/Source/_javascript_Core/runtime/Options.cpp	2016-01-05 19:03:07 UTC (rev 194590)
+++ trunk/Source/_javascript_Core/runtime/Options.cpp	2016-01-05 19:12:05 UTC (rev 194591)
@@ -127,6 +127,21 @@
     return false;
 }
 
+bool Options::overrideAliasedOptionWithHeuristic(const char* name)
+{
+    const char* stringValue = getenv(name);
+    if (!stringValue)
+        return false;
+
+    String aliasedOption;
+    aliasedOption = String(&name[4]) + "=" + stringValue;
+    if (Options::setOption(aliasedOption.utf8().data()))
+        return true;
+
+    fprintf(stderr, "WARNING: failed to parse %s=%s\n", name, stringValue);
+    return false;
+}
+
 static unsigned computeNumberOfWorkerThreads(int maxNumberOfWorkerThreads, int minimum = 1)
 {
     int cpusToUse = std::min(WTF::numberOfProcessorCores(), maxNumberOfWorkerThreads);
@@ -385,6 +400,11 @@
 #undef FOR_EACH_OPTION
 #endif // PLATFORM(COCOA)
 
+#define FOR_EACH_OPTION(aliasedName_, unaliasedName_, equivalence_) \
+            overrideAliasedOptionWithHeuristic("JSC_" #aliasedName_);
+            JSC_ALIASED_OPTIONS(FOR_EACH_OPTION)
+#undef FOR_EACH_OPTION
+
 #if 0
                 ; // Deconfuse editors that do auto indentation
 #endif
@@ -527,7 +547,7 @@
 
 // Parses a single command line option in the format "<optionName>=<value>"
 // (no spaces allowed) and set the specified option if appropriate.
-bool Options::setOption(const char* arg)
+bool Options::setOptionWithoutAlias(const char* arg)
 {
     // arg should look like this:
     //   <jscOptionName>=<appropriate value>
@@ -559,6 +579,57 @@
     return false; // No option matched.
 }
 
+static bool invertBoolOptionValue(const char* valueStr, const char*& invertedValueStr)
+{
+    bool boolValue;
+    if (!parse(valueStr, boolValue))
+        return false;
+    invertedValueStr = boolValue ? "false" : "true";
+    return true;
+}
+
+
+bool Options::setAliasedOption(const char* arg)
+{
+    // arg should look like this:
+    //   <jscOptionName>=<appropriate value>
+    const char* equalStr = strchr(arg, '=');
+    if (!equalStr)
+        return false;
+
+    // For each option, check if the specify arg is a match. If so, set the arg
+    // if the value makes sense. Otherwise, move on to checking the next option.
+#define FOR_EACH_OPTION(aliasedName_, unaliasedName_, equivalence) \
+    if (strlen(#aliasedName_) == static_cast<size_t>(equalStr - arg)    \
+        && !strncmp(arg, #aliasedName_, equalStr - arg)) {              \
+        String unaliasedOption(#unaliasedName_);                        \
+        if (equivalence == SameOption)                                  \
+            unaliasedOption = unaliasedOption + equalStr;               \
+        else {                                                          \
+            ASSERT(equivalence == InvertedOption);                      \
+            const char* invertedValueStr = nullptr;                     \
+            if (!invertBoolOptionValue(equalStr + 1, invertedValueStr)) \
+                return false;                                           \
+            unaliasedOption = unaliasedOption + "=" + invertedValueStr; \
+        }                                                               \
+        return setOptionWithoutAlias(unaliasedOption.utf8().data());   \
+    }
+
+    JSC_ALIASED_OPTIONS(FOR_EACH_OPTION)
+#undef FOR_EACH_OPTION
+
+    return false; // No option matched.
+}
+
+bool Options::setOption(const char* arg)
+{
+    bool success = setOptionWithoutAlias(arg);
+    if (success)
+        return true;
+    return setAliasedOption(arg);
+}
+
+
 void Options::dumpAllOptions(StringBuilder& builder, DumpLevel level, const char* title,
     const char* separator, const char* optionHeader, const char* optionFooter, DumpDefaultsOption dumpDefaultsOption)
 {
@@ -583,7 +654,7 @@
 {
     StringBuilder builder;
     dumpAllOptions(builder, level, title, nullptr, "   ", "\n", DumpDefaults);
-    fprintf(stream, "%s", builder.toString().ascii().data());
+    fprintf(stream, "%s", builder.toString().utf8().data());
 }
 
 void Options::dumpOption(StringBuilder& builder, DumpLevel level, OptionID id,

Modified: trunk/Source/_javascript_Core/runtime/Options.h (194590 => 194591)


--- trunk/Source/_javascript_Core/runtime/Options.h	2016-01-05 19:03:07 UTC (rev 194590)
+++ trunk/Source/_javascript_Core/runtime/Options.h	2016-01-05 19:12:05 UTC (rev 194591)
@@ -352,6 +352,45 @@
     v(bool, dumpModuleLoadingState, false, nullptr) \
     v(bool, exposeInternalModuleLoader, false, "expose the internal module loader object to the global space for debugging") \
 
+enum OptionEquivalence {
+    SameOption,
+    InvertedOption,
+};
+
+#define JSC_ALIASED_OPTIONS(v) \
+    v(enableFunctionDotArguments, useFunctionDotArguments, SameOption) \
+    v(enableTailCalls, useTailCalls, SameOption) \
+    v(showDisassembly, dumpDisassembly, SameOption) \
+    v(showDFGDisassembly, dumpDFGDisassembly, SameOption) \
+    v(showFTLDisassembly, dumpFTLDisassembly, SameOption) \
+    v(showAllDFGNodes, dumpAllDFGNodes, SameOption) \
+    v(alwaysDoFullCollection, useGenerationalGC, InvertedOption) \
+    v(enableOSREntryToDFG, useOSREntryToDFG, SameOption) \
+    v(enableOSREntryToFTL, useOSREntryToFTL, SameOption) \
+    v(enableLLVMFastISel, useLLVMFastISel, SameOption) \
+    v(enableAccessInlining, useAccessInlining, SameOption) \
+    v(enablePolyvariantDevirtualization, usePolyvariantDevirtualization, SameOption) \
+    v(enablePolymorphicAccessInlining, usePolymorphicAccessInlining, SameOption) \
+    v(enablePolymorphicCallInlining, usePolymorphicCallInlining, SameOption) \
+    v(enableMovHintRemoval, useMovHintRemoval, SameOption) \
+    v(enableObjectAllocationSinking, useObjectAllocationSinking, SameOption) \
+    v(enableCopyBarrierOptimization, useCopyBarrierOptimization, SameOption) \
+    v(enableConcurrentJIT, useConcurrentJIT, SameOption) \
+    v(enableProfiler, useProfiler, SameOption) \
+    v(enableArchitectureSpecificOptimizations, useArchitectureSpecificOptimizations, SameOption) \
+    v(enablePolyvariantCallInlining, usePolyvariantCallInlining, SameOption) \
+    v(enablePolyvariantByIdInlining, usePolyvariantByIdInlining, SameOption) \
+    v(enableMaximalFlushInsertionPhase, useMaximalFlushInsertionPhase, SameOption) \
+    v(objectsAreImmortal, useImmortalObjects, SameOption) \
+    v(showObjectStatistics, dumpObjectStatistics, SameOption) \
+    v(disableGC, useGC, InvertedOption) \
+    v(enableTypeProfiler, useTypeProfiler, SameOption) \
+    v(enableControlFlowProfiler, useControlFlowProfiler, SameOption) \
+    v(enableExceptionFuzz, useExceptionFuzz, SameOption) \
+    v(enableExecutableAllocationFuzz, useExecutableAllocationFuzz, SameOption) \
+    v(enableOSRExitFuzz, useOSRExitFuzz, SameOption) \
+    v(enableDollarVM, useDollarVM, SameOption) \
+
 class Options {
 public:
     enum class DumpLevel {
@@ -438,6 +477,10 @@
     static void dumpOption(StringBuilder&, DumpLevel, OptionID,
         const char* optionHeader, const char* optionFooter, DumpDefaultsOption);
 
+    static bool setOptionWithoutAlias(const char* arg);
+    static bool setAliasedOption(const char* arg);
+    static bool overrideAliasedOptionWithHeuristic(const char* name);
+
     // Declare the singleton instance of the options store:
     JS_EXPORTDATA static Entry s_options[numberOfOptions];
     static Entry s_defaultOptions[numberOfOptions];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to