Changeset 251400 in webkit
- Timestamp:
- Oct 21, 2019 5:17:50 PM (4 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 9 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/glib/JSCOptions.cpp
r251226 r251400 169 169 #define SET_OPTION_VALUE(type_, name_, defaultValue_, availability_, description_) \ 170 170 if (!g_strcmp0(#name_, option)) { \ 171 Option Types::type_ valueToSet; \171 OptionEntry::type_ valueToSet; \ 172 172 if (!valueFromGValue(value, valueToSet)) \ 173 173 return FALSE; \ … … 187 187 #define GET_OPTION_VALUE(type_, name_, defaultValue_, availability_, description_) \ 188 188 if (!g_strcmp0(#name_, option)) { \ 189 Option Types::type_ valueToGet = Options::name_(); \189 OptionEntry::type_ valueToGet = Options::name_(); \ 190 190 valueToGValue(valueToGet, value); \ 191 191 return TRUE; \ … … 617 617 #define VISIT_OPTION(type_, name_, defaultValue_, availability_, description_) \ 618 618 if (Options::Availability::availability_ == Options::Availability::Normal \ 619 || Options::isAvailable(Option ID::name_, Options::Availability::availability_)) { \620 Option Types::type_ defaultValue { }; \619 || Options::isAvailable(Options::name_##ID, Options::Availability::availability_)) { \ 620 OptionEntry::type_ defaultValue { }; \ 621 621 auto optionType = jscOptionsType(defaultValue); \ 622 622 if (function (#name_, optionType, description_, userData)) \ … … 667 667 #define REGISTER_OPTION(type_, name_, defaultValue_, availability_, description_) \ 668 668 if (Options::Availability::availability_ == Options::Availability::Normal \ 669 || Options::isAvailable(Option ID::name_, Options::Availability::availability_)) { \669 || Options::isAvailable(Options::name_##ID, Options::Availability::availability_)) { \ 670 670 GUniquePtr<char> name(g_strdup_printf("jsc-%s", #name_)); \ 671 671 entries = g_array_set_size(entries, entries->len + 1); \ -
trunk/Source/JavaScriptCore/CMakeLists.txt
r251226 r251400 921 921 runtime/ObjectPrototype.h 922 922 runtime/Operations.h 923 runtime/OptionEntry.h 923 924 runtime/Options.h 924 925 runtime/OptionsList.h -
trunk/Source/JavaScriptCore/ChangeLog
r251399 r251400 1 2019-10-21 Mark Lam <mark.lam@apple.com> 2 3 Rolling out r251226: Causes a build speed regression. 4 https://bugs.webkit.org/show_bug.cgi?id=203219 5 6 Not reviewed. 7 8 Apparently, compilers aren't very fast at compiling constexpr function invocations. 9 Rolling this out while I rework the patch to not have this build speed regression. 10 11 * API/glib/JSCOptions.cpp: 12 (jscOptionsSetValue): 13 (jscOptionsGetValue): 14 (jsc_options_foreach): 15 (jsc_options_get_option_group): 16 * CMakeLists.txt: 17 * JavaScriptCore.xcodeproj/project.pbxproj: 18 * Sources.txt: 19 * runtime/JSCConfig.h: 20 * runtime/OptionEntry.h: Copied from Source/JavaScriptCore/runtime/OptionEntry.h. 21 * runtime/Options.cpp: 22 (JSC::Options::isAvailable): 23 (JSC::overrideOptionWithHeuristic): 24 (JSC::scaleJITPolicy): 25 (JSC::recomputeDependentOptions): 26 (JSC::Options::initialize): 27 (JSC::Options::setOptionWithoutAlias): 28 (JSC::Options::dumpAllOptions): 29 (JSC::Options::dumpOption): 30 (JSC::Option::dump const): 31 (JSC::Option::operator== const): 32 (JSC::optionTypeSpecificIndex): Deleted. 33 (JSC::Option::Option): Deleted. 34 (JSC::Option::defaultOption const): Deleted. 35 * runtime/Options.h: 36 (JSC::Option::Option): 37 (JSC::Option::id const): 38 (JSC::Option::name const): 39 (JSC::Option::description const): 40 (JSC::Option::type const): 41 (JSC::Option::availability const): 42 (JSC::Option::isOverridden const): 43 (JSC::Option::defaultOption const): 44 (JSC::Option::boolVal): 45 (JSC::Option::unsignedVal): 46 (JSC::Option::doubleVal): 47 (JSC::Option::int32Val): 48 (JSC::Option::optionRangeVal): 49 (JSC::Option::optionStringVal): 50 (JSC::Option::gcLogLevelVal): 51 (JSC::Option::idIndex const): Deleted. 52 (JSC::optionTypeSpecificIndex): Deleted. 53 * runtime/OptionsList.h: 54 (JSC::OptionRange::operator= ): Deleted. 55 (JSC::OptionRange::rangeString const): Deleted. 56 (JSC::countNumberOfJSCOptionsOfType): Deleted. 57 1 58 2019-10-21 Mark Lam <mark.lam@apple.com> 2 59 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r251226 r251400 1865 1865 FE1BD0251E72053800134BC9 /* HeapVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1BD0231E72052F00134BC9 /* HeapVerifier.h */; }; 1866 1866 FE1C0FFD1B193E9800B53FCA /* Exception.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1C0FFC1B193E9800B53FCA /* Exception.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1867 FE1D6D4523580E1F007A5C26 /* Options.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FE228EA1436AB2300196C48 /* Options.cpp */; };1868 1867 FE1E2C3F2240DD5800F6B729 /* MacroAssemblerARM64E.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1E2C3E2240D30B00F6B729 /* MacroAssemblerARM64E.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1869 1868 FE1E2C402240DD6200F6B729 /* ARM64EAssembler.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1E2C3D2240D2F600F6B729 /* ARM64EAssembler.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 1874 1873 FE318FE01CAC982F00DFCC54 /* ECMAScriptSpecInternalFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = FE318FDE1CAC8C5300DFCC54 /* ECMAScriptSpecInternalFunctions.h */; }; 1875 1874 FE3422121D6B81C30032BE88 /* ThrowScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3422111D6B818C0032BE88 /* ThrowScope.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1875 FE3842322324D51B009DD445 /* OptionEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3842302324D51A009DD445 /* OptionEntry.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1876 1876 FE3842332324D51B009DD445 /* OptionsList.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3842312324D51B009DD445 /* OptionsList.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1877 1877 FE384EE61ADDB7AD0055DE2C /* JSDollarVM.h in Headers */ = {isa = PBXBuildFile; fileRef = FE384EE21ADDB7AD0055DE2C /* JSDollarVM.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 5074 5074 FE35C2FB21B1E6C7000F4CA8 /* OpcodeGroup.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = OpcodeGroup.rb; sourceTree = "<group>"; }; 5075 5075 FE35C2FC21B1E6C7000F4CA8 /* Metadata.rb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.ruby; path = Metadata.rb; sourceTree = "<group>"; }; 5076 FE3842302324D51A009DD445 /* OptionEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionEntry.h; sourceTree = "<group>"; }; 5076 5077 FE3842312324D51B009DD445 /* OptionsList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionsList.h; sourceTree = "<group>"; }; 5077 5078 FE384EE11ADDB7AD0055DE2C /* JSDollarVM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDollarVM.cpp; sourceTree = "<group>"; }; … … 7382 7383 F692A8770255597D01FF60F7 /* Operations.cpp */, 7383 7384 F692A8780255597D01FF60F7 /* Operations.h */, 7385 FE3842302324D51A009DD445 /* OptionEntry.h */, 7384 7386 0FE228EA1436AB2300196C48 /* Options.cpp */, 7385 7387 0FE228EB1436AB2300196C48 /* Options.h */, … … 9904 9906 A70447EA17A0BD4600F5898E /* OperandsInlines.h in Headers */, 9905 9907 BC18C4480E16F5CD00B34460 /* Operations.h in Headers */, 9908 FE3842322324D51B009DD445 /* OptionEntry.h in Headers */, 9906 9909 0FE228ED1436AB2700196C48 /* Options.h in Headers */, 9907 9910 FE3842332324D51B009DD445 /* OptionsList.h in Headers */, … … 11132 11135 536B315C1F71C5990037FC33 /* UnifiedSource88.cpp in Sources */, 11133 11136 536B31621F71C5990037FC33 /* UnifiedSource89.cpp in Sources */, 11134 FE1D6D4523580E1F007A5C26 /* Options.cpp in Sources */,11135 11137 536B31421F71C5990037FC33 /* UnifiedSource90.cpp in Sources */, 11136 11138 536B31491F71C5990037FC33 /* UnifiedSource91.cpp in Sources */, -
trunk/Source/JavaScriptCore/Sources.txt
r251226 r251400 905 905 runtime/ObjectToStringAdaptiveStructureWatchpoint.cpp 906 906 runtime/Operations.cpp 907 runtime/Options.cpp @no-unify907 runtime/Options.cpp 908 908 runtime/ProgramExecutable.cpp 909 909 runtime/PromiseDeferredTimer.cpp -
trunk/Source/JavaScriptCore/runtime/JSCConfig.h
r251226 r251400 26 26 #pragma once 27 27 28 #include "OptionEntry.h" 28 29 #include "OptionsList.h" 29 30 #include <wtf/StdLibExtras.h> … … 36 37 #if CPU(ARM64) || PLATFORM(WATCHOS) 37 38 constexpr size_t PageSize = 16 * KB; 38 constexpr size_t ConfigSizeToProtect = 1 * PageSize;39 39 #else 40 40 constexpr size_t PageSize = 4 * KB; 41 constexpr size_t ConfigSizeToProtect = 1 * PageSize;42 41 #endif 42 43 constexpr size_t ConfigSizeToProtect = 32 * KB; 43 44 44 45 #if ENABLE(SEPARATED_WX_HEAP) … … 82 83 #endif 83 84 84 bool typeBoolOptions[NumberOfBoolOptions]; 85 bool typeBoolDefaultOptions[NumberOfBoolOptions]; 86 87 GCLogging::Level typeGCLogLevelOptions[NumberOfGCLogLevelOptions]; 88 GCLogging::Level typeGCLogLevelDefaultOptions[NumberOfGCLogLevelOptions]; 89 90 int32_t typeInt32Options[NumberOfInt32Options]; 91 int32_t typeInt32DefaultOptions[NumberOfInt32Options]; 92 93 unsigned typeUnsignedOptions[NumberOfUnsignedOptions]; 94 unsigned typeUnsignedDefaultOptions[NumberOfUnsignedOptions]; 95 96 double typeDoubleOptions[NumberOfDoubleOptions]; 97 double typeDoubleDefaultOptions[NumberOfDoubleOptions]; 98 99 size_t typeSizeOptions[NumberOfSizeOptions]; 100 size_t typeSizeDefaultOptions[NumberOfSizeOptions]; 101 102 const char* typeOptionStringOptions[NumberOfOptionStringOptions]; 103 const char* typeOptionStringDefaultOptions[NumberOfOptionStringOptions]; 104 105 OptionRange typeOptionRangeOptions[NumberOfOptionRangeOptions]; 106 OptionRange typeOptionRangeDefaultOptions[NumberOfOptionRangeOptions]; 85 OptionEntry options[NumberOfOptions]; 86 OptionEntry defaultOptions[NumberOfOptions]; 107 87 }; 108 88 char ensureSize[ConfigSizeToProtect]; -
trunk/Source/JavaScriptCore/runtime/Options.cpp
r251276 r251400 133 133 } 134 134 135 bool Options::isAvailable(Option ID id, Options::Availability availability)135 bool Options::isAvailable(Options::ID id, Options::Availability availability) 136 136 { 137 137 if (availability == Availability::Restricted) … … 141 141 UNUSED_PARAM(id); 142 142 #if !defined(NDEBUG) 143 if (id == OptionID::maxSingleAllocationSize)143 if (id == maxSingleAllocationSizeID) 144 144 return true; 145 145 #endif 146 146 #if OS(DARWIN) 147 if (id == OptionID::useSigillCrashAnalyzer)147 if (id == useSigillCrashAnalyzerID) 148 148 return true; 149 149 #endif 150 150 #if ENABLE(ASSEMBLER) && OS(LINUX) 151 if (id == OptionID::logJITCodeForPerf)152 return true; 153 #endif 154 if (id == OptionID::traceLLIntExecution)151 if (id == logJITCodeForPerfID) 152 return true; 153 #endif 154 if (id == traceLLIntExecutionID) 155 155 return !!LLINT_TRACING; 156 if (id == OptionID::traceLLIntSlowPath)156 if (id == traceLLIntSlowPathID) 157 157 return !!LLINT_TRACING; 158 158 return false; … … 160 160 161 161 template<typename T> 162 bool overrideOptionWithHeuristic(T& variable, Option ID id, const char* name, Options::Availability availability)162 bool overrideOptionWithHeuristic(T& variable, Options::ID id, const char* name, Options::Availability availability) 163 163 { 164 164 bool available = (availability == Options::Availability::Normal) … … 283 283 } 284 284 285 // FIXME: This is a workaround for MSVC's inability to handle large sources.286 // Once the MSVC bug has been fixed, we can remove this snippet of code and287 // make its counterpart in Options.h unconditional.288 // See https://developercommunity.visualstudio.com/content/problem/653301/fatal-error-c1002-compiler-is-out-of-heap-space-in.html289 #if COMPILER(MSVC)290 291 template<OptionTypeID type, OptionID id>292 constexpr size_t optionTypeSpecificIndex()293 {294 size_t index = 0;295 index = 0; // MSVC (16.3.5) improperly optimizes away the inline initialization of index, so use an explicit assignment.296 297 #define COUNT_INDEX_AND_FIND_MATCH(type_, name_, defaultValue_, availability_, description_) \298 if (id == OptionID::name_) \299 return index; \300 if (type == OptionTypeID::type_) \301 index++;302 303 FOR_EACH_JSC_OPTION(COUNT_INDEX_AND_FIND_MATCH);304 #undef COUNT_INDEX_AND_FIND_MATCH305 return InvalidOptionIndex;306 }307 308 #define DEFINE_OPTION_ACCESSORS(type_, name_, defaultValue_, availability_, description_) \309 JS_EXPORT_PRIVATE OptionTypes::type_& Options::name_() \310 { \311 return g_jscConfig.type##type_##Options[optionTypeSpecificIndex<OptionTypeID::type_, OptionID::name_>()]; \312 } \313 JS_EXPORT_PRIVATE OptionTypes::type_& Options::name_##Default() \314 { \315 return g_jscConfig.type##type_##DefaultOptions[optionTypeSpecificIndex<OptionTypeID::type_, OptionID::name_>()]; \316 }317 FOR_EACH_JSC_OPTION(DEFINE_OPTION_ACCESSORS)318 #undef DEFINE_OPTION_ACCESSORS319 320 #endif // COMPILER(MSVC)321 322 285 // Realize the names for each of the options: 323 const Options::EntryInfo Options::s_optionsInfo[ NumberOfOptions] = {286 const Options::EntryInfo Options::s_optionsInfo[Options::numberOfOptions] = { 324 287 #define FILL_OPTION_INFO(type_, name_, defaultValue_, availability_, description_) \ 325 { #name_, description_, Option TypeID::type_, Availability::availability_, optionTypeSpecificIndex<OptionTypeID::type_, OptionID::name_>()},288 { #name_, description_, Options::Type::type_, Availability::availability_ }, 326 289 FOR_EACH_JSC_OPTION(FILL_OPTION_INFO) 327 290 #undef FILL_OPTION_INFO … … 337 300 338 301 struct OptionToScale { 339 size_t index;302 Options::ID id; 340 303 int32_t minVal; 341 304 }; 342 305 343 306 static const OptionToScale optionsToScale[] = { 344 { optionTypeSpecificIndex<OptionTypeID::Int32, OptionID::thresholdForJITAfterWarmUp>(), 0 },345 { optionTypeSpecificIndex<OptionTypeID::Int32, OptionID::thresholdForJITSoon>(), 0 },346 { optionTypeSpecificIndex<OptionTypeID::Int32, OptionID::thresholdForOptimizeAfterWarmUp>(), 1 },347 { optionTypeSpecificIndex<OptionTypeID::Int32, OptionID::thresholdForOptimizeAfterLongWarmUp>(), 1 },348 { optionTypeSpecificIndex<OptionTypeID::Int32, OptionID::thresholdForOptimizeSoon>(), 1 },349 { optionTypeSpecificIndex<OptionTypeID::Int32, OptionID::thresholdForFTLOptimizeSoon>(), 2 },350 { optionTypeSpecificIndex<OptionTypeID::Int32, OptionID::thresholdForFTLOptimizeAfterWarmUp>(), 2 },307 { Options::thresholdForJITAfterWarmUpID, 0 }, 308 { Options::thresholdForJITSoonID, 0 }, 309 { Options::thresholdForOptimizeAfterWarmUpID, 1 }, 310 { Options::thresholdForOptimizeAfterLongWarmUpID, 1 }, 311 { Options::thresholdForOptimizeSoonID, 1 }, 312 { Options::thresholdForFTLOptimizeSoonID, 2 }, 313 { Options::thresholdForFTLOptimizeAfterWarmUpID, 2 } 351 314 }; 352 315 353 const exprint numberOfOptionsToScale = sizeof(optionsToScale) / sizeof(OptionToScale);316 const int numberOfOptionsToScale = sizeof(optionsToScale) / sizeof(OptionToScale); 354 317 for (int i = 0; i < numberOfOptionsToScale; i++) { 355 int32_t& optionValue = g_jscConfig.typeInt32Options[optionsToScale[i].index]; 356 optionValue *= scaleFactor; 357 optionValue = std::max(optionValue, optionsToScale[i].minVal); 318 Option option(optionsToScale[i].id); 319 ASSERT(option.type() == Options::Type::Int32); 320 option.int32Val() *= scaleFactor; 321 option.int32Val() = std::max(option.int32Val(), optionsToScale[i].minVal); 358 322 } 359 323 } … … 478 442 Options::collectContinuously() = false; 479 443 480 if (Option(Option ID::jitPolicyScale).isOverridden())444 if (Option(Options::jitPolicyScaleID).isOverridden()) 481 445 scaleJITPolicy(); 482 446 … … 559 523 #endif 560 524 // Initialize each of the options with their default values: 561 #define INIT_OPTION(type_, name_, defaultValue_, availability_, description_) { \ 562 auto value = defaultValue_; \ 563 name_() = value; \ 564 name_##Default() = value; \ 565 } 525 #define INIT_OPTION(type_, name_, defaultValue_, availability_, description_) \ 526 name_() = defaultValue_; \ 527 name_##Default() = defaultValue_; 566 528 FOR_EACH_JSC_OPTION(INIT_OPTION) 567 529 #undef INIT_OPTION … … 587 549 #else // PLATFORM(COCOA) 588 550 #define OVERRIDE_OPTION_WITH_HEURISTICS(type_, name_, defaultValue_, availability_, description_) \ 589 overrideOptionWithHeuristic(name_(), OptionID::name_, "JSC_" #name_, Availability::availability_);551 overrideOptionWithHeuristic(name_(), name_##ID, "JSC_" #name_, Availability::availability_); 590 552 FOR_EACH_JSC_OPTION(OVERRIDE_OPTION_WITH_HEURISTICS) 591 553 #undef OVERRIDE_OPTION_WITH_HEURISTICS … … 766 728 const char* valueStr = equalStr + 1; 767 729 768 // For each option, check if the specif iedarg is a match. If so, set the arg730 // For each option, check if the specify arg is a match. If so, set the arg 769 731 // if the value makes sense. Otherwise, move on to checking the next option. 770 732 #define SET_OPTION_IF_MATCH(type_, name_, defaultValue_, availability_, description_) \ 771 733 if (strlen(#name_) == static_cast<size_t>(equalStr - arg) \ 772 734 && !strncmp(arg, #name_, equalStr - arg)) { \ 773 if (Availability::availability_ != Availability::Normal \774 && !isAvailable( OptionID::name_, Availability::availability_)) \735 if (Availability::availability_ != Availability::Normal \ 736 && !isAvailable(name_##ID, Availability::availability_)) \ 775 737 return false; \ 776 OptionTypes::type_ value; \ 738 OptionEntry::type_ value; \ 739 value = (defaultValue_); \ 777 740 bool success = parse(valueStr, value); \ 778 741 if (success) { \ … … 854 817 } 855 818 856 for ( size_t id = 0; id < NumberOfOptions; id++) {819 for (int id = 0; id < numberOfOptions; id++) { 857 820 if (separator && id) 858 821 builder.append(separator); 859 dumpOption(builder, level, static_cast< OptionID>(id), optionHeader, optionFooter, dumpDefaultsOption);822 dumpOption(builder, level, static_cast<ID>(id), optionHeader, optionFooter, dumpDefaultsOption); 860 823 } 861 824 } … … 873 836 } 874 837 875 void Options::dumpOption(StringBuilder& builder, DumpLevel level, Option ID id,838 void Options::dumpOption(StringBuilder& builder, DumpLevel level, Options::ID id, 876 839 const char* header, const char* footer, DumpDefaultsOption dumpDefaultsOption) 877 840 { 878 if ( static_cast<size_t>(id) >= NumberOfOptions)841 if (id >= numberOfOptions) 879 842 return; // Illegal option. 880 843 … … 918 881 } 919 882 920 Option::Option(OptionID id) 921 : m_id(id) 922 { 923 unsigned index = static_cast<unsigned>(m_id); 924 unsigned typeSpecificIndex = Options::s_optionsInfo[index].typeSpecificIndex; 925 OptionTypeID type = Options::s_optionsInfo[index].type; 926 927 switch (type) { 928 929 #define HANDLE_CASE(OptionType_, type_) \ 930 case OptionTypeID::OptionType_: \ 931 ASSERT(typeSpecificIndex < NumberOf##OptionType_##Options); \ 932 m_val##OptionType_ = g_jscConfig.type##OptionType_##Options[typeSpecificIndex]; \ 883 void Option::dump(StringBuilder& builder) const 884 { 885 switch (type()) { 886 case Options::Type::Bool: 887 builder.append(m_entry.valBool ? "true" : "false"); 933 888 break; 934 935 FOR_EACH_JSC_OPTION_TYPE(HANDLE_CASE) 936 #undef HANDLE_CASE 937 } 938 } 939 940 const Option Option::defaultOption() const 941 { 942 Option result; 943 unsigned index = static_cast<unsigned>(m_id); 944 unsigned typeSpecificIndex = Options::s_optionsInfo[index].typeSpecificIndex; 945 OptionTypeID type = Options::s_optionsInfo[index].type; 946 947 result.m_id = m_id; 948 switch (type) { 949 950 #define HANDLE_CASE(OptionType_, type_) \ 951 case OptionTypeID::OptionType_: \ 952 ASSERT(typeSpecificIndex < NumberOf##OptionType_##Options); \ 953 result.m_val##OptionType_ = g_jscConfig.type##OptionType_##DefaultOptions[typeSpecificIndex]; \ 889 case Options::Type::Unsigned: 890 builder.appendNumber(m_entry.valUnsigned); 954 891 break; 955 956 FOR_EACH_JSC_OPTION_TYPE(HANDLE_CASE) 957 #undef HANDLE_CASE 958 } 959 return result; 960 } 961 962 void Option::dump(StringBuilder& builder) const 963 { 964 switch (type()) { 965 case OptionTypeID::Bool: 966 builder.append(m_valBool ? "true" : "false"); 892 case Options::Type::Size: 893 builder.appendNumber(m_entry.valSize); 967 894 break; 968 case Option TypeID::Unsigned:969 builder.append Number(m_valUnsigned);895 case Options::Type::Double: 896 builder.appendFixedPrecisionNumber(m_entry.valDouble); 970 897 break; 971 case Option TypeID::Size:972 builder.appendNumber(m_ valSize);898 case Options::Type::Int32: 899 builder.appendNumber(m_entry.valInt32); 973 900 break; 974 case Option TypeID::Double:975 builder.append FixedPrecisionNumber(m_valDouble);901 case Options::Type::OptionRange: 902 builder.append(m_entry.valOptionRange.rangeString()); 976 903 break; 977 case OptionTypeID::Int32: 978 builder.appendNumber(m_valInt32); 979 break; 980 case OptionTypeID::OptionRange: 981 builder.append(m_valOptionRange.rangeString()); 982 break; 983 case OptionTypeID::OptionString: { 984 const char* option = m_valOptionString; 904 case Options::Type::OptionString: { 905 const char* option = m_entry.valOptionString; 985 906 if (!option) 986 907 option = ""; … … 990 911 break; 991 912 } 992 case Option TypeID::GCLogLevel: {993 builder.append(GCLogging::levelAsString(m_ valGCLogLevel));913 case Options::Type::GCLogLevel: { 914 builder.append(GCLogging::levelAsString(m_entry.valGCLogLevel)); 994 915 break; 995 916 } … … 1000 921 { 1001 922 switch (type()) { 1002 case Option TypeID::Bool:1003 return m_ valBool == other.m_valBool;1004 case Option TypeID::Unsigned:1005 return m_ valUnsigned == other.m_valUnsigned;1006 case Option TypeID::Size:1007 return m_ valSize == other.m_valSize;1008 case Option TypeID::Double:1009 return (m_ valDouble == other.m_valDouble) || (std::isnan(m_valDouble) && std::isnan(other.m_valDouble));1010 case Option TypeID::Int32:1011 return m_ valInt32 == other.m_valInt32;1012 case Option TypeID::OptionRange:1013 return m_ valOptionRange.rangeString() == other.m_valOptionRange.rangeString();1014 case Option TypeID::OptionString:1015 return (m_ valOptionString == other.m_valOptionString)1016 || (m_ valOptionString && other.m_valOptionString && !strcmp(m_valOptionString, other.m_valOptionString));1017 case Option TypeID::GCLogLevel:1018 return m_ valGCLogLevel == other.m_valGCLogLevel;923 case Options::Type::Bool: 924 return m_entry.valBool == other.m_entry.valBool; 925 case Options::Type::Unsigned: 926 return m_entry.valUnsigned == other.m_entry.valUnsigned; 927 case Options::Type::Size: 928 return m_entry.valSize == other.m_entry.valSize; 929 case Options::Type::Double: 930 return (m_entry.valDouble == other.m_entry.valDouble) || (std::isnan(m_entry.valDouble) && std::isnan(other.m_entry.valDouble)); 931 case Options::Type::Int32: 932 return m_entry.valInt32 == other.m_entry.valInt32; 933 case Options::Type::OptionRange: 934 return m_entry.valOptionRange.rangeString() == other.m_entry.valOptionRange.rangeString(); 935 case Options::Type::OptionString: 936 return (m_entry.valOptionString == other.m_entry.valOptionString) 937 || (m_entry.valOptionString && other.m_entry.valOptionString && !strcmp(m_entry.valOptionString, other.m_entry.valOptionString)); 938 case Options::Type::GCLogLevel: 939 return m_entry.valGCLogLevel == other.m_entry.valGCLogLevel; 1019 940 } 1020 941 return false; -
trunk/Source/JavaScriptCore/runtime/Options.h
r251226 r251400 30 30 #include <stdint.h> 31 31 #include <stdio.h> 32 #include <wtf/PrintStream.h> 32 33 #include <wtf/StdLibExtras.h> 33 34 … … 53 54 class Options { 54 55 public: 55 enum class DumpLevel : uint8_t{56 enum class DumpLevel { 56 57 None = 0, 57 58 Overridden, … … 60 61 }; 61 62 62 enum class Availability : uint8_t{63 enum class Availability { 63 64 Normal = 0, 64 65 Restricted, … … 66 67 }; 67 68 69 #define DECLARE_OPTION_ID(type_, name_, defaultValue_, availability_, description_) \ 70 name_##ID, 71 72 enum ID { 73 FOR_EACH_JSC_OPTION(DECLARE_OPTION_ID) 74 numberOfOptions 75 }; 76 #undef DECLARE_OPTION_ID 77 78 enum class Type { 79 Bool, 80 Unsigned, 81 Double, 82 Int32, 83 Size, 84 OptionRange, 85 OptionString, 86 GCLogLevel, 87 }; 88 68 89 JS_EXPORT_PRIVATE static void initialize(); 69 90 … … 81 102 JS_EXPORT_PRIVATE static void ensureOptionsAreCoherent(); 82 103 83 // FIXME: This is a workaround for MSVC's inability to handle large sources.84 // See https://developercommunity.visualstudio.com/content/problem/653301/fatal-error-c1002-compiler-is-out-of-heap-space-in.html85 #if COMPILER(MSVC)86 #define OPTION_ACCESSOR_LINKAGE JS_EXPORT_PRIVATE87 #else88 #define OPTION_ACCESSOR_LINKAGE ALWAYS_INLINE89 #endif90 91 104 #define DECLARE_OPTION_ACCESSORS(type_, name_, defaultValue_, availability_, description_) \ 92 OPTION_ACCESSOR_LINKAGE static OptionTypes::type_& name_(); \ 93 OPTION_ACCESSOR_LINKAGE static OptionTypes::type_& name_##Default(); 105 ALWAYS_INLINE static OptionEntry::type_& name_() { return g_jscConfig.options[name_##ID].val##type_; } \ 106 ALWAYS_INLINE static OptionEntry::type_& name_##Default() { return g_jscConfig.defaultOptions[name_##ID].val##type_; } 107 94 108 FOR_EACH_JSC_OPTION(DECLARE_OPTION_ACCESSORS) 95 109 #undef DECLARE_OPTION_ACCESSORS 96 110 97 static bool isAvailable( OptionID, Availability);111 static bool isAvailable(ID, Availability); 98 112 99 113 private: … … 103 117 const char* name; 104 118 const char* description; 105 OptionTypeIDtype;119 Type type; 106 120 Availability availability; 107 unsigned typeSpecificIndex;108 121 }; 109 122 … … 117 130 static void dumpAllOptions(StringBuilder&, DumpLevel, const char* title, 118 131 const char* separator, const char* optionHeader, const char* optionFooter, DumpDefaultsOption); 119 static void dumpOption(StringBuilder&, DumpLevel, OptionID,132 static void dumpOption(StringBuilder&, DumpLevel, ID, 120 133 const char* optionHeader, const char* optionFooter, DumpDefaultsOption); 121 134 … … 124 137 static bool overrideAliasedOptionWithHeuristic(const char* name); 125 138 126 static const EntryInfo s_optionsInfo[ NumberOfOptions];139 static const EntryInfo s_optionsInfo[numberOfOptions]; 127 140 128 141 friend class Option; … … 131 144 class Option { 132 145 public: 133 Option(OptionID); 134 146 Option(Options::ID id) 147 : m_id(id) 148 , m_entry(g_jscConfig.options[m_id]) 149 { 150 } 151 135 152 void dump(StringBuilder&) const; 136 153 … … 138 155 bool operator!=(const Option& other) const { return !(*this == other); } 139 156 140 Option ID id() const { return m_id; }141 const char* name() const { return Options::s_optionsInfo[idIndex()].name; }142 const char* description() const { return Options::s_optionsInfo[idIndex()].description; }143 Option TypeID type() const { return Options::s_optionsInfo[idIndex()].type; }144 Options::Availability availability() const { return Options::s_optionsInfo[idIndex()].availability; }145 bool isOverridden() const { return *this != defaultOption(); }157 Options::ID id() const { return m_id; } 158 const char* name() const; 159 const char* description() const; 160 Options::Type type() const; 161 Options::Availability availability() const; 162 bool isOverridden() const; 146 163 const Option defaultOption() const; 147 148 #define DECLARE_ACCESSOR(OptionType_, type_) \ 149 type_ val##OptionType_() const { return m_val##OptionType_; } 150 FOR_EACH_JSC_OPTION_TYPE(DECLARE_ACCESSOR) 151 #undef DECLARE_ACCESSOR 152 164 165 bool& boolVal(); 166 unsigned& unsignedVal(); 167 double& doubleVal(); 168 int32_t& int32Val(); 169 OptionRange optionRangeVal(); 170 const char* optionStringVal(); 171 GCLogging::Level& gcLogLevelVal(); 172 153 173 private: 154 Option() { } 155 156 size_t idIndex() const { return static_cast<size_t>(m_id); } 157 158 OptionID m_id; 159 union { 160 161 #define DECLARE_MEMBER(OptionType_, type_) \ 162 type_ m_val##OptionType_; 163 FOR_EACH_JSC_OPTION_TYPE(DECLARE_MEMBER) 164 #undef DECLARE_MEMBER 165 166 }; 174 // Only used for constructing default Options. 175 Option(Options::ID id, OptionEntry& entry) 176 : m_id(id) 177 , m_entry(entry) 178 { 179 } 180 181 Options::ID m_id; 182 OptionEntry& m_entry; 167 183 }; 168 184 169 // FIXME: This is a workaround for MSVC's inability to handle large sources. 170 // Once the MSVC bug has been fixed, we can make the following unconditional and 171 // remove its counterpart MSVC version in Options.cpp. 172 // See https://developercommunity.visualstudio.com/content/problem/653301/fatal-error-c1002-compiler-is-out-of-heap-space-in.html 173 #if !COMPILER(MSVC) 174 175 template<OptionTypeID type, OptionID id> 176 constexpr size_t optionTypeSpecificIndex() 177 { 178 size_t index = 0; 179 #define COUNT_INDEX_AND_FIND_MATCH(type_, name_, defaultValue_, availability_, description_) \ 180 if (id == OptionID::name_) \ 181 return index; \ 182 if (type == OptionTypeID::type_) \ 183 index++; 184 185 FOR_EACH_JSC_OPTION(COUNT_INDEX_AND_FIND_MATCH); 186 #undef COUNT_INDEX_AND_FIND_MATCH 187 return InvalidOptionIndex; 188 } 189 190 #define DEFINE_OPTION_ACCESSORS(type_, name_, defaultValue_, availability_, description_) \ 191 ALWAYS_INLINE OptionTypes::type_& Options::name_() \ 192 { \ 193 return g_jscConfig.type##type_##Options[optionTypeSpecificIndex<OptionTypeID::type_, OptionID::name_>()]; \ 194 } \ 195 ALWAYS_INLINE OptionTypes::type_& Options::name_##Default() \ 196 { \ 197 return g_jscConfig.type##type_##DefaultOptions[optionTypeSpecificIndex<OptionTypeID::type_, OptionID::name_>()]; \ 198 } 199 FOR_EACH_JSC_OPTION(DEFINE_OPTION_ACCESSORS) 200 #undef DEFINE_OPTION_ACCESSORS 201 202 #endif // !COMPILER(MSVC) 185 inline const char* Option::name() const 186 { 187 return Options::s_optionsInfo[m_id].name; 188 } 189 190 inline const char* Option::description() const 191 { 192 return Options::s_optionsInfo[m_id].description; 193 } 194 195 inline Options::Type Option::type() const 196 { 197 return Options::s_optionsInfo[m_id].type; 198 } 199 200 inline Options::Availability Option::availability() const 201 { 202 return Options::s_optionsInfo[m_id].availability; 203 } 204 205 inline bool Option::isOverridden() const 206 { 207 return *this != defaultOption(); 208 } 209 210 inline const Option Option::defaultOption() const 211 { 212 return Option(m_id, g_jscConfig.defaultOptions[m_id]); 213 } 214 215 inline bool& Option::boolVal() 216 { 217 return m_entry.valBool; 218 } 219 220 inline unsigned& Option::unsignedVal() 221 { 222 return m_entry.valUnsigned; 223 } 224 225 inline double& Option::doubleVal() 226 { 227 return m_entry.valDouble; 228 } 229 230 inline int32_t& Option::int32Val() 231 { 232 return m_entry.valInt32; 233 } 234 235 inline OptionRange Option::optionRangeVal() 236 { 237 return m_entry.valOptionRange; 238 } 239 240 inline const char* Option::optionStringVal() 241 { 242 return m_entry.valOptionString; 243 } 244 245 inline GCLogging::Level& Option::gcLogLevelVal() 246 { 247 return m_entry.valGCLogLevel; 248 } 203 249 204 250 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/OptionsList.h
r251226 r251400 26 26 #pragma once 27 27 28 #include "GCLogging.h"29 #include <wtf/PrintStream.h>30 31 28 namespace JSC { 32 29 … … 35 32 // The FOR_EACH_JSC_OPTION() macro below defines a list of all JSC options in use, 36 33 // along with their types and default values. The options values are actually 37 // realized as a rrays of each of the OptionTypes in JSC::Config.34 // realized as an array of OptionEntry elements in JSC::Config. 38 35 // 39 // Options::initialize() will initialize the array sof options values with36 // Options::initialize() will initialize the array of options values with 40 37 // the defaults specified in FOR_EACH_JSC_OPTION() below. After that, the values can 41 38 // be programmatically read and written to using an accessor method with the … … 58 55 // values after the sanity checks (for your own testing), then you're liable to 59 56 // ensure that the new values set are sane and reasonable for your own run. 60 //61 // Any modifications to options must be done before the first VM is instantiate.62 // On instantiation of the first VM instance, the Options will be write protected63 // and cannot be modified thereafter.64 65 class OptionRange {66 private:67 enum RangeState { Uninitialized, InitError, Normal, Inverted };68 public:69 OptionRange& operator= (const int& rhs)70 { // Only needed for initialization71 if (!rhs) {72 m_state = Uninitialized;73 m_rangeString = 0;74 m_lowLimit = 0;75 m_highLimit = 0;76 }77 return *this;78 }79 80 bool init(const char*);81 bool isInRange(unsigned);82 const char* rangeString() const { return (m_state > InitError) ? m_rangeString : s_nullRangeStr; }83 84 void dump(PrintStream& out) const;85 86 private:87 static const char* const s_nullRangeStr;88 89 RangeState m_state;90 const char* m_rangeString;91 unsigned m_lowLimit;92 unsigned m_highLimit;93 };94 95 #define FOR_EACH_JSC_OPTION_TYPE(v) \96 v(Bool, bool) \97 v(Unsigned, unsigned) \98 v(Double, double) \99 v(Int32, int32_t) \100 v(Size, size_t) \101 v(OptionRange, OptionRange) \102 v(OptionString, const char*) \103 v(GCLogLevel, GCLogging::Level) \104 105 namespace OptionTypes {106 107 #define DECLARE_TYPES(OptionType_, type_) \108 using OptionType_ = type_;109 FOR_EACH_JSC_OPTION_TYPE(DECLARE_TYPES)110 #undef DECLARE_TYPES111 112 } // namespace OptionTypes113 114 enum class OptionTypeID : uint8_t {115 116 #define DECLARE_TYPEID(OptionType_, type_) \117 OptionType_,118 FOR_EACH_JSC_OPTION_TYPE(DECLARE_TYPEID)119 #undef DECLARE_TYPEID120 121 };122 57 123 58 #define FOR_EACH_JSC_OPTION(v) \ … … 576 511 v(maximumInliningCallerSize, maximumInliningCallerBytecodeCost, SameOption) \ 577 512 578 #define DECLARE_OPTION_ID(type_, name_, defaultValue_, availability_, description_) \579 name_,580 enum class OptionID : uint16_t {581 FOR_EACH_JSC_OPTION(DECLARE_OPTION_ID)582 };583 #undef DECLARE_OPTION_ID584 585 static constexpr size_t InvalidOptionIndex = std::numeric_limits<size_t>::max();586 513 587 514 constexpr size_t countNumberOfJSCOptions() … … 596 523 constexpr size_t NumberOfOptions = countNumberOfJSCOptions(); 597 524 598 constexpr size_t countNumberOfJSCOptionsOfType(OptionTypeID type)599 {600 size_t count = 0;601 #define COUNT_OPTION(type_, name_, defaultValue_, availability_, description_) \602 if (type == OptionTypeID::type_) \603 count++;604 FOR_EACH_JSC_OPTION(COUNT_OPTION);605 #undef COUNT_OPTION606 return count;607 }608 609 constexpr size_t NumberOfBoolOptions = countNumberOfJSCOptionsOfType(OptionTypeID::Bool);610 constexpr size_t NumberOfUnsignedOptions = countNumberOfJSCOptionsOfType(OptionTypeID::Unsigned);611 constexpr size_t NumberOfDoubleOptions = countNumberOfJSCOptionsOfType(OptionTypeID::Double);612 constexpr size_t NumberOfInt32Options = countNumberOfJSCOptionsOfType(OptionTypeID::Int32);613 constexpr size_t NumberOfSizeOptions = countNumberOfJSCOptionsOfType(OptionTypeID::Size);614 constexpr size_t NumberOfOptionRangeOptions = countNumberOfJSCOptionsOfType(OptionTypeID::OptionRange);615 constexpr size_t NumberOfOptionStringOptions = countNumberOfJSCOptionsOfType(OptionTypeID::OptionString);616 constexpr size_t NumberOfGCLogLevelOptions = countNumberOfJSCOptionsOfType(OptionTypeID::GCLogLevel);617 618 525 } // namespace JSC 526
Note: See TracChangeset
for help on using the changeset viewer.