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];