Changeset 194591 in webkit
- Timestamp:
- Jan 5, 2016, 11:12:05 AM (10 years ago)
- 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]> 1 2016-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 35 2016-01-05 Mark Lam <[email protected]> 2 36 3 37 Add validation of JSC options to catch typos. -
trunk/Source/JavaScriptCore/jsc.cpp
r194590 r194591 1985 1985 1986 1986 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:"); 1988 1988 JSC::Options::ensureOptionsAreCoherent(); 1989 1989 if (needToExit) -
trunk/Source/JavaScriptCore/runtime/Options.cpp
r194590 r194591 128 128 } 129 129 130 bool 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 130 145 static unsigned computeNumberOfWorkerThreads(int maxNumberOfWorkerThreads, int minimum = 1) 131 146 { … … 386 401 #endif // PLATFORM(COCOA) 387 402 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 388 408 #if 0 389 409 ; // Deconfuse editors that do auto indentation … … 528 548 // Parses a single command line option in the format "<optionName>=<value>" 529 549 // (no spaces allowed) and set the specified option if appropriate. 530 bool Options::setOption (const char* arg)550 bool Options::setOptionWithoutAlias(const char* arg) 531 551 { 532 552 // arg should look like this: … … 560 580 } 561 581 582 static 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 592 bool 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 624 bool Options::setOption(const char* arg) 625 { 626 bool success = setOptionWithoutAlias(arg); 627 if (success) 628 return true; 629 return setAliasedOption(arg); 630 } 631 632 562 633 void Options::dumpAllOptions(StringBuilder& builder, DumpLevel level, const char* title, 563 634 const char* separator, const char* optionHeader, const char* optionFooter, DumpDefaultsOption dumpDefaultsOption) … … 584 655 StringBuilder builder; 585 656 dumpAllOptions(builder, level, title, nullptr, " ", "\n", DumpDefaults); 586 fprintf(stream, "%s", builder.toString(). ascii().data());657 fprintf(stream, "%s", builder.toString().utf8().data()); 587 658 } 588 659 -
trunk/Source/JavaScriptCore/runtime/Options.h
r194590 r194591 353 353 v(bool, exposeInternalModuleLoader, false, "expose the internal module loader object to the global space for debugging") \ 354 354 355 enum 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 355 394 class Options { 356 395 public: … … 439 478 const char* optionHeader, const char* optionFooter, DumpDefaultsOption); 440 479 480 static bool setOptionWithoutAlias(const char* arg); 481 static bool setAliasedOption(const char* arg); 482 static bool overrideAliasedOptionWithHeuristic(const char* name); 483 441 484 // Declare the singleton instance of the options store: 442 485 JS_EXPORTDATA static Entry s_options[numberOfOptions];
Note:
See TracChangeset
for help on using the changeset viewer.