Bladeren bron

Added macro FLAG_STRING to ConfigFlagsList.

Added a new FLAG_STRING macro. These are specifically for ConfigFlags with string default values, so that we can use the correct string type depending on the platform.
Hitesh Kanwathirtha 10 jaren geleden
bovenliggende
commit
14884856a6
3 gewijzigde bestanden met toevoegingen van 100 en 21 verwijderingen
  1. 30 8
      lib/Common/ConfigFlagsList.h
  2. 58 6
      lib/Common/Core/ConfigFlagsTable.cpp
  3. 12 7
      lib/Common/Core/ConfigFlagsTable.h

+ 30 - 8
lib/Common/ConfigFlagsList.h

@@ -666,12 +666,16 @@ PHASE(All)
 // Default values for stings must be prefixed with 'L'. See AsmDumpMode
 // Scroll till the extreme right to see the default values
 
-#if defined(FLAG) || defined(FLAG_REGOVR_EXP)
+#if defined(FLAG) || defined(FLAG_STRING) || defined(FLAG_REGOVR_EXP)
 
 #ifndef FLAG
 #define FLAG(...)
 #endif
 
+#ifndef FLAG_STRING
+#define FLAG_STRING(...)
+#endif
+
 #ifndef FLAG_REGOVR_ASMJS
 #define FLAG_REGOVR_ASMJS FLAG
 #endif
@@ -686,6 +690,9 @@ PHASE(All)
 // Regular FLAG
 #define FLAGNR(Type, Name, String, Default)                 FLAG(Type, Name, String, Default, NoParent, FALSE)
 
+// Flags with a default string provided
+#define FLAGNR_STRING(Name, String, DefaultString)          FLAG_STRING(Name, String, DefaultString, NoParent, FALSE)
+
 // Regular flag with acronym
 #ifndef FLAGNRA
     #define FLAGNRA(Type, Name, Acronym, String, Default) \
@@ -693,6 +700,12 @@ PHASE(All)
         FLAGNR(Type, Acronym, String, Default)
 #endif
 
+#ifndef FLAGNRA_STRING
+    #define FLAGNRA_STRING(Name, Acronym, String, Default) \
+        FLAGNR_STRING(Name, String, Default) \
+        FLAGNR_STRING(Acronym, String, Default)
+#endif
+
 // Child FLAG with PARENT FLAG
 #define FLAGPNR(Type, ParentName, Name, String, Default)    FLAG(Type, Name, String, Default, ParentName, FALSE)
 
@@ -701,12 +714,18 @@ PHASE(All)
 
 #else
 #define FLAGNR(Type, Name, String, Default)
+#define FLAGNR_STRING(Name, String, Default)
 
 #ifdef FLAGNRA
     #undef FLAGNRA
 #endif
 #define FLAGNRA(Type, Name, Acronym, String, Default)
 
+#ifdef FLAGNRA_STRING
+    #undef FLAGNRA_STRING
+#endif
+#define FLAGNRA_STRING(Name, Acronym, String, Default)
+
 #define FLAGPNR(Type, ParentName, Name, String, Default)
 #define FLAGNRC(Type, Name, String, Default)
 #endif
@@ -827,7 +846,7 @@ FLAGNR(Boolean, NoDynamicProfileInMemoryCache, "Enable in-memory cache for dynam
 FLAGNR(Boolean, ProfileBasedSpeculativeJit, "Enable dynamic profile based speculative JIT", DEFAULT_CONFIG_ProfileBasedSpeculativeJit)
 FLAGNR(Number,  ProfileBasedSpeculationCap, "In the presence of dynamic profile speculative JIT is capped to this many bytecode instructions", DEFAULT_CONFIG_ProfileBasedSpeculationCap)
 #ifdef DYNAMIC_PROFILE_MUTATOR
-FLAGNR(String,  DynamicProfileMutatorDll , "Path of the mutator DLL", L"DynamicProfileMutatorImpl.dll")
+FLAGNR_STRING(DynamicProfileMutatorDll , "Path of the mutator DLL", "DynamicProfileMutatorImpl.dll")
 FLAGNR(String,  DynamicProfileMutator , "Type of local, temp, return, param, loop implicit flag and implicit flag. \n\t\t\t\t\ti.e local=LikelyArray_NoMissingValues_NonInts_NonFloats;temp=Int8Array;param=LikelyNumber;return=LikelyString;loopimplicitflag=ImplicitCall_ToPrimitive;implicitflag=ImplicitCall_None\n\t\t\t\t\tor pass DynamicProfileMutator:random\n\t\t\t\t\tSee DynamicProfileInfo.h for enum values", nullptr)
 #endif
 FLAGNR(Boolean, ExecuteByteCodeBufferReturnsInvalidByteCode, "Serialized byte code execution always returns SCRIPT_E_INVALID_BYTECODE", false)
@@ -965,9 +984,9 @@ FLAGNR(Number,  FaultInjectionCount   , "Injects an out of memory at the specifi
 FLAGNR(String,  FaultInjectionType    , "FaultType (flag values) -  1 (Throw), 2 (NoThrow), 4 (MarkThrow), 8 (MarkNoThrow), FFFFFFFF (All)", nullptr)
 FLAGNR(String,  FaultInjectionFilter  , "A string to restrict the fault injection, the string can be like ArenaAllocator name", nullptr)
 FLAGNR(Number,  FaultInjectionAllocSize, "Do fault injection only this size", -1)
-FLAGNR(String,  FaultInjectionStackFile   , "Stacks to match, default: stack.txt in current directory", L"stack.txt")
+FLAGNR_STRING(FaultInjectionStackFile   , "Stacks to match, default: stack.txt in current directory", "stack.txt")
 FLAGNR(Number,  FaultInjectionStackLineCount   , "Count of lines in the stack file used for matching", -1)
-FLAGNR(String,  FaultInjectionStackHash, "Match stacks hash on Chakra frames to inject the fault, hex string", L"0")
+FLAGNR_STRING(FaultInjectionStackHash, "Match stacks hash on Chakra frames to inject the fault, hex string", "0")
 FLAGNR(Number,  FaultInjectionScriptContextToTerminateCount, "Script context# COUNT % (Number of script contexts) to terminate", 1)
 #endif
 FLAGNR(Number, InduceCodeGenFailure, "Probability of a codegen job failing.", DEFAULT_CONFIG_InduceCodeGenFailure)
@@ -1045,7 +1064,7 @@ FLAGR (Number,  AutoProfilingInterpreter1Limit, "Limit after which to transition
 FLAGR (Number,  SimpleJitLimit, "Limit after which to transition to the next execution mode", DEFAULT_CONFIG_SimpleJitLimit)
 FLAGR (Number,  ProfilingInterpreter1Limit, "Limit after which to transition to the next execution mode", DEFAULT_CONFIG_ProfilingInterpreter1Limit)
 
-FLAGNRA(String, ExecutionModeLimits,        Eml,  "Execution mode limits in th form: AutoProfilingInterpreter0.ProfilingInterpreter0.AutoProfilingInterpreter1.SimpleJit.ProfilingInterpreter1 - Example: -ExecutionModeLimits:12.4.0.132.12", L"")
+FLAGNRA_STRING(ExecutionModeLimits,        Eml,  "Execution mode limits in th form: AutoProfilingInterpreter0.ProfilingInterpreter0.AutoProfilingInterpreter1.SimpleJit.ProfilingInterpreter1 - Example: -ExecutionModeLimits:12.4.0.132.12", "")
 FLAGRA(Boolean, EnforceExecutionModeLimits, Eeml, "Enforces the execution mode limits such that they are never exceeded.", false)
 
 FLAGNRA(Number, SimpleJitAfter        , Sja, "Number of calls to a function after which to simple-JIT the function", 0)
@@ -1081,8 +1100,8 @@ FLAGNR(Boolean, NoWinRTFastSig        , "Disable fast call for common WinRT func
 FLAGNR(Phases,  Off                   , "Turn off specific phases or feature.(Might not work for all phases)", )
 FLAGNR(Phases,  OffProfiledByteCode   , "Turn off specific byte code for phases or feature.(Might not work for all phases)", )
 FLAGNR(Phases,  On                    , "Turn on specific phases or feature.(Might not work for all phases)", )
-FLAGNR(String,  OutputFile            , "Log the output to a specified file. Default: output.log in the working directory.", L"output.log")
-FLAGNR(String,  OutputFileOpenMode    , "File open mode for OutputFile. Default: wt, specify 'at' for append", L"wt")
+FLAGNR_STRING(OutputFile            , "Log the output to a specified file. Default: output.log in the working directory.", "output.log")
+FLAGNR_STRING(OutputFileOpenMode    , "File open mode for OutputFile. Default: wt, specify 'at' for append", "wt")
 #ifdef ENABLE_TRACE
 FLAGNR(Boolean, InMemoryTrace         , "Enable in-memory trace (investigate crash using trace in dump file). Use !jd.dumptrace to print it.", DEFAULT_CONFIG_InMemoryTrace)
 FLAGNR(Number,  InMemoryTraceBufferSize, "The size of circular buffer for in-memory trace (the units used is: number of trace calls). ", DEFAULT_CONFIG_InMemoryTraceBufferSize)
@@ -1268,7 +1287,7 @@ FLAGNR(Boolean, ChangeTypeOnProto, "When becoming a prototype should the object
 FLAGNR(Boolean, ShareInlineCaches, "Determines whether inline caches are shared between all loads (or all stores) of the same property ID", DEFAULT_CONFIG_ShareInlineCaches)
 FLAGNR(Boolean, DisableDebugObject, "Disable test only Debug object properties", DEFAULT_CONFIG_DisableDebugObject)
 FLAGNR(Boolean, DumpHeap, "enable Debug.dumpHeap even when DisableDebugObject is set", DEFAULT_CONFIG_DumpHeap)
-FLAGNR(String, autoProxy, "enable creating proxy for each object creation", L"__msTestHandler")
+FLAGNR_STRING(autoProxy, "enable creating proxy for each object creation", "__msTestHandler")
 FLAGNR(Number,  PerfHintLevel, "Specifies the perf-hint level (1,2) 1 == critical, 2 == only noisy", DEFAULT_CONFIG_PerfHintLevel)
 #ifdef INTERNAL_MEM_PROTECT_HEAP_ALLOC
 FLAGNR(Boolean, MemProtectHeap, "Use the mem protect heap as the default heap", DEFAULT_CONFIG_MemProtectHeap)
@@ -1338,12 +1357,15 @@ FLAGNR(Boolean, CFG, "Force enable CFG on jshost. version in the jshost's manife
 #undef FLAG_REGOVR_ASMJS
 
 #undef FLAG
+#undef FLAG_STRING
 #undef FLAGP
 
 #undef FLAGRA
 
 #undef FLAGNR
+#undef FLAGNR_STRING
 #undef FLAGNRA
+#undef FLAGNRA_STRING
 #undef FLAGPNR
 
 #endif

+ 58 - 6
lib/Common/Core/ConfigFlagsTable.cpp

@@ -65,7 +65,7 @@ namespace Js
         this->pszValue = NULL;
     }
 
-    String::String(__in_opt LPWSTR psz)
+    String::String(__in_opt const wchar16* psz)
     {
         this->pszValue = NULL;
         Set(psz);
@@ -89,7 +89,7 @@ namespace Js
     ///----------------------------------------------------------------------------
 
     void
-    String::Set(__in_opt LPWSTR pszValue)
+    String::Set(__in_opt const wchar16* pszValue)
     {
         if(NULL != this->pszValue)
         {
@@ -205,8 +205,10 @@ namespace Js
     const wchar16* const FlagNames[FlagCount + 1] =
     {
     #define FLAG(type, name, ...) CH_WSTR(#name),
+    #define FLAG_STRING(name, ...) CH_WSTR(#name),
     #include "ConfigFlagsList.h"
         NULL
+    #undef FLAG_STRING
     #undef FLAG
     };
 
@@ -230,9 +232,11 @@ namespace Js
     const wchar16* const FlagDescriptions[FlagCount + 1] =
     {
     #define FLAG(type, name, description, ...) CH_WSTR(description),
+    #define FLAG_STRING(name, description, ...) CH_WSTR(description),
     #include "ConfigFlagsList.h"
         NULL
     #undef FLAG
+    #undef FLAG_STRING
     };
 
     //
@@ -241,9 +245,11 @@ namespace Js
     const Flag FlagParents[FlagCount + 1] =
     {
     #define FLAG(type, name, description, defaultValue, parentName, ...) parentName##Flag,
+    #define FLAG_STRING(name, description, defaultValue, parentName, ...) parentName##Flag,
     #include "ConfigFlagsList.h"
         InvalidFlag
     #undef FLAG
+    #undef FLAG_STRING
     };
 
     ///
@@ -270,9 +276,14 @@ namespace Js
         \
         name ## ( ## defaultValue ##), \
 
+#define FLAG_STRING(name, description, defaultValue, ...) \
+        \
+        name ## ( ## CH_WSTR(defaultValue) ##),     \
+
     ConfigFlagsTable::ConfigFlagsTable():
         #include "ConfigFlagsList.h"
 #undef FLAG
+#undef FLAG_STRING
         nDummy(0)
     {
         for(int i=0; i < FlagCount; flagPresent[i++] = false);
@@ -281,9 +292,12 @@ namespace Js
         ZeroMemory(this->flagIsParent, sizeof(this->flagIsParent));
 #define FLAG(type, name, description, defaultValue, parentName, ...) \
         if ((int)parentName##Flag < FlagCount) this->flagIsParent[(int) parentName##Flag] = true;
+#define FLAG_STRING(name, description, defaultValue, parentName, ...) \
+        if ((int)parentName##Flag < FlagCount) this->flagIsParent[(int) parentName##Flag] = true;
 #include "ConfigFlagsList.h"
 #undef FLAG
-
+#undef FLAG_STRING
+        
         // set all parent flags to their default (setting all child flags to their right values)
         this->SetAllParentFlagsAsDefaultValue();
     }
@@ -391,12 +405,19 @@ namespace Js
     {
         // Transfer acronym flag configuration into the corresponding actual flag
     #define FLAG(...)
+    #define FLAG_STRING(...)
     #define FLAGNRA(Type, Name, Acronym, ...) \
         if(!IsEnabled(Name##Flag) && IsEnabled(Acronym##Flag)) \
         { \
             Enable(Name##Flag); \
             Name = Acronym; \
         }
+    #define FLAGNRA_STRING(Name, Acronym, ...) \
+        if(!IsEnabled(Name##Flag) && IsEnabled(Acronym##Flag)) \
+        { \
+            Enable(Name##Flag); \
+            Name = Acronym; \
+        }
     #if ENABLE_DEBUG_CONFIG_OPTIONS
         #define FLAGRA(Type, Name, Acronym, ...) FLAGNRA(Type, Name, Acronym, __VA_ARGS__)
     #endif
@@ -449,6 +470,7 @@ namespace Js
         VerifyExecutionModeLimits();
 
     #if ENABLE_DEBUG_CONFIG_OPTIONS
+    #if !DISABLE_JIT
         if(ForceDynamicProfile)
         {
             Force.Enable(DynamicProfilePhase);
@@ -457,11 +479,14 @@ namespace Js
         {
             Force.Enable(JITLoopBodyPhase);
         }
+    #endif
         if(NoDeferParse)
         {
             Off.Enable(DeferParsePhase);
         }
-
+    #endif
+        
+    #if ENABLE_DEBUG_CONFIG_OPTIONS && !DISABLE_JIT
         bool dontEnforceLimitsForSimpleJitAfterOrFullJitAfter = false;
         if((IsEnabled(MinInterpretCountFlag) || IsEnabled(MaxInterpretCountFlag)) &&
             !(IsEnabled(SimpleJitAfterFlag) || IsEnabled(FullJitAfterFlag)))
@@ -491,7 +516,7 @@ namespace Js
                     SimpleJitAfter = MinInterpretCount;
                     dontEnforceLimitsForSimpleJitAfterOrFullJitAfter = true;
                 }
-                if(IsEnabled(MinInterpretCountFlag) && IsEnabled(MinSimpleJitRunCountFlag) ||
+                if((IsEnabled(MinInterpretCountFlag) && IsEnabled(MinSimpleJitRunCountFlag)) ||
                     IsEnabled(MaxSimpleJitRunCountFlag))
                 {
                     Enable(FullJitAfterFlag);
@@ -852,6 +877,10 @@ namespace Js
     #define FLAG(type, name, ...) \
             case name##Flag : \
                 return Flag##type; \
+                
+    #define FLAG_STRING(name, ...) \
+            case name##Flag : \
+                return FlagString; \
 
     #include "ConfigFlagsList.h"
 
@@ -881,6 +910,11 @@ namespace Js
             case name##Flag : \
                 return reinterpret_cast<void*>(const_cast<type*>(&##name)); \
 
+        #define FLAG_STRING(name, ...) \
+            \
+            case name##Flag : \
+                return reinterpret_cast<void*>(const_cast<String*>(&##name)); \
+            
         #include "ConfigFlagsList.h"
 
             default:
@@ -913,11 +947,26 @@ namespace Js
             case FlagNumber: \
                 Output::Print(CH_WSTR(":%d"), *GetAsNumber(name##Flag)); \
                 break; \
+            default: \
+                break; \
             }; \
             Output::Print(CH_WSTR("\n")); \
         }
+
+#define FLAG_STRING(name, ...)     \
+        if (IsEnabled(name##Flag)) \
+        { \
+            Output::Print(CH_WSTR("-%s"), CH_WSTR(#name));              \
+            if (GetAsString(name##Flag) != nullptr)                     \
+            {                                                           \
+                Output::Print(CH_WSTR(":%s"), (LPCWSTR)*GetAsString(name##Flag)); \
+            }                                                           \
+            Output::Print(CH_WSTR("\n"));                               \
+        }
+        
 #include "ConfigFlagsList.h"
 #undef FLAG
+#undef FLAG_STRING
     }
 
     ///----------------------------------------------------------------------------
@@ -936,6 +985,7 @@ namespace Js
         switch (flag)
         {
 #define FLAG(type, name, description, defaultValue, ...) FLAGDEFAULT##type(name, defaultValue)
+#define FLAG_STRING(name, description, defaultValue, ...) FLAGDEFAULTString(name, defaultValue)
             // define an overload for each FlagTypes - type
             //   * all defaults we don't care about
 #define FLAGDEFAULTPhases(name, defaultValue)
@@ -1028,6 +1078,7 @@ namespace Js
 #ifdef ENABLE_DEBUG_CONFIG_OPTIONS
         // in case the flag is marked as 'callback' - to call the method
 #define FLAG(type, name, description, defaultValue, parentName, hasCallback) FLAGCALLBACK##hasCallback(type, name)
+#define FLAG_STRING(name, description, defaultValue, parentName, hasCallback) FLAGCALLBACK##hasCallback(String, name)
 #define FLAGCALLBACKFALSE(type, name)
 #define FLAGCALLBACKTRUE(type, name)    FLAGDOCALLBACK##type(name)
 
@@ -1053,7 +1104,8 @@ namespace Js
 #undef FLAGDOCALLBACKPhases
 #undef FLAGCALLBACKTRUE
 #undef FLAGCALLBACKFALSE
-#undef FLAG
+#undef FLAG_STRING
+#undef FLAG        
 #endif
     }
 

+ 12 - 7
lib/Common/Core/ConfigFlagsTable.h

@@ -52,9 +52,12 @@ namespace Js
     ///----------------------------------------------------------------------------
 
 
-    enum Flag
+    enum Flag: unsigned short
     {
 #define FLAG(type, name, ...) name##Flag,
+
+#define FLAG_STRING(name, ...) name##Flag,
+
 #include "ConfigFlagsList.h"
         FlagCount,
         InvalidFlag,
@@ -75,7 +78,7 @@ namespace Js
     ///----------------------------------------------------------------------------
 
 
-    enum Phase
+    enum Phase: unsigned short
     {
 #define PHASE(name) name##Phase,
 #include "ConfigFlagsList.h"
@@ -117,12 +120,12 @@ namespace Js
 
     // Data
     private:
-                LPWSTR           pszValue;
+        wchar16*           pszValue;
 
     // Construction
     public:
         inline String();
-        inline String(__in_opt LPWSTR psz);
+        inline String(__in_opt const wchar16* psz);
         inline ~String();
 
 
@@ -135,7 +138,7 @@ namespace Js
         ///
         ///----------------------------------------------------------------------------
 
-        String& operator=(__in_opt LPWSTR psz)
+        String& operator=(__in_opt const wchar16* psz)
         {
             Set(psz);
             return *this;
@@ -152,14 +155,14 @@ namespace Js
         ///
         ///----------------------------------------------------------------------------
 
-        operator LPCWSTR () const
+        operator const wchar16* () const
         {
             return this->pszValue;
         }
 
     // Implementation
     private:
-        void Set(__in_opt LPWSTR pszValue);
+        void Set(__in_opt const wchar16* pszValue);
     };
 
     class NumberSet
@@ -437,6 +440,8 @@ namespace Js
             \
             type name;\
 
+        #define FLAG_STRING(name, ...) String name;
+
         #include "ConfigFlagsList.h"
 
                 bool            flagPresent[FlagCount];