Skip to content

Commit 1488485

Browse files
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.
1 parent cab9c48 commit 1488485

3 files changed

Lines changed: 100 additions & 21 deletions

File tree

lib/Common/ConfigFlagsList.h

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -666,12 +666,16 @@ PHASE(All)
666666
// Default values for stings must be prefixed with 'L'. See AsmDumpMode
667667
// Scroll till the extreme right to see the default values
668668

669-
#if defined(FLAG) || defined(FLAG_REGOVR_EXP)
669+
#if defined(FLAG) || defined(FLAG_STRING) || defined(FLAG_REGOVR_EXP)
670670

671671
#ifndef FLAG
672672
#define FLAG(...)
673673
#endif
674674

675+
#ifndef FLAG_STRING
676+
#define FLAG_STRING(...)
677+
#endif
678+
675679
#ifndef FLAG_REGOVR_ASMJS
676680
#define FLAG_REGOVR_ASMJS FLAG
677681
#endif
@@ -686,13 +690,22 @@ PHASE(All)
686690
// Regular FLAG
687691
#define FLAGNR(Type, Name, String, Default) FLAG(Type, Name, String, Default, NoParent, FALSE)
688692

693+
// Flags with a default string provided
694+
#define FLAGNR_STRING(Name, String, DefaultString) FLAG_STRING(Name, String, DefaultString, NoParent, FALSE)
695+
689696
// Regular flag with acronym
690697
#ifndef FLAGNRA
691698
#define FLAGNRA(Type, Name, Acronym, String, Default) \
692699
FLAGNR(Type, Name, String, Default) \
693700
FLAGNR(Type, Acronym, String, Default)
694701
#endif
695702

703+
#ifndef FLAGNRA_STRING
704+
#define FLAGNRA_STRING(Name, Acronym, String, Default) \
705+
FLAGNR_STRING(Name, String, Default) \
706+
FLAGNR_STRING(Acronym, String, Default)
707+
#endif
708+
696709
// Child FLAG with PARENT FLAG
697710
#define FLAGPNR(Type, ParentName, Name, String, Default) FLAG(Type, Name, String, Default, ParentName, FALSE)
698711

@@ -701,12 +714,18 @@ PHASE(All)
701714

702715
#else
703716
#define FLAGNR(Type, Name, String, Default)
717+
#define FLAGNR_STRING(Name, String, Default)
704718

705719
#ifdef FLAGNRA
706720
#undef FLAGNRA
707721
#endif
708722
#define FLAGNRA(Type, Name, Acronym, String, Default)
709723

724+
#ifdef FLAGNRA_STRING
725+
#undef FLAGNRA_STRING
726+
#endif
727+
#define FLAGNRA_STRING(Name, Acronym, String, Default)
728+
710729
#define FLAGPNR(Type, ParentName, Name, String, Default)
711730
#define FLAGNRC(Type, Name, String, Default)
712731
#endif
@@ -827,7 +846,7 @@ FLAGNR(Boolean, NoDynamicProfileInMemoryCache, "Enable in-memory cache for dynam
827846
FLAGNR(Boolean, ProfileBasedSpeculativeJit, "Enable dynamic profile based speculative JIT", DEFAULT_CONFIG_ProfileBasedSpeculativeJit)
828847
FLAGNR(Number, ProfileBasedSpeculationCap, "In the presence of dynamic profile speculative JIT is capped to this many bytecode instructions", DEFAULT_CONFIG_ProfileBasedSpeculationCap)
829848
#ifdef DYNAMIC_PROFILE_MUTATOR
830-
FLAGNR(String, DynamicProfileMutatorDll , "Path of the mutator DLL", L"DynamicProfileMutatorImpl.dll")
849+
FLAGNR_STRING(DynamicProfileMutatorDll , "Path of the mutator DLL", "DynamicProfileMutatorImpl.dll")
831850
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)
832851
#endif
833852
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
965984
FLAGNR(String, FaultInjectionType , "FaultType (flag values) - 1 (Throw), 2 (NoThrow), 4 (MarkThrow), 8 (MarkNoThrow), FFFFFFFF (All)", nullptr)
966985
FLAGNR(String, FaultInjectionFilter , "A string to restrict the fault injection, the string can be like ArenaAllocator name", nullptr)
967986
FLAGNR(Number, FaultInjectionAllocSize, "Do fault injection only this size", -1)
968-
FLAGNR(String, FaultInjectionStackFile , "Stacks to match, default: stack.txt in current directory", L"stack.txt")
987+
FLAGNR_STRING(FaultInjectionStackFile , "Stacks to match, default: stack.txt in current directory", "stack.txt")
969988
FLAGNR(Number, FaultInjectionStackLineCount , "Count of lines in the stack file used for matching", -1)
970-
FLAGNR(String, FaultInjectionStackHash, "Match stacks hash on Chakra frames to inject the fault, hex string", L"0")
989+
FLAGNR_STRING(FaultInjectionStackHash, "Match stacks hash on Chakra frames to inject the fault, hex string", "0")
971990
FLAGNR(Number, FaultInjectionScriptContextToTerminateCount, "Script context# COUNT % (Number of script contexts) to terminate", 1)
972991
#endif
973992
FLAGNR(Number, InduceCodeGenFailure, "Probability of a codegen job failing.", DEFAULT_CONFIG_InduceCodeGenFailure)
@@ -1045,7 +1064,7 @@ FLAGR (Number, AutoProfilingInterpreter1Limit, "Limit after which to transition
10451064
FLAGR (Number, SimpleJitLimit, "Limit after which to transition to the next execution mode", DEFAULT_CONFIG_SimpleJitLimit)
10461065
FLAGR (Number, ProfilingInterpreter1Limit, "Limit after which to transition to the next execution mode", DEFAULT_CONFIG_ProfilingInterpreter1Limit)
10471066

1048-
FLAGNRA(String, ExecutionModeLimits, Eml, "Execution mode limits in th form: AutoProfilingInterpreter0.ProfilingInterpreter0.AutoProfilingInterpreter1.SimpleJit.ProfilingInterpreter1 - Example: -ExecutionModeLimits:12.4.0.132.12", L"")
1067+
FLAGNRA_STRING(ExecutionModeLimits, Eml, "Execution mode limits in th form: AutoProfilingInterpreter0.ProfilingInterpreter0.AutoProfilingInterpreter1.SimpleJit.ProfilingInterpreter1 - Example: -ExecutionModeLimits:12.4.0.132.12", "")
10491068
FLAGRA(Boolean, EnforceExecutionModeLimits, Eeml, "Enforces the execution mode limits such that they are never exceeded.", false)
10501069

10511070
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
10811100
FLAGNR(Phases, Off , "Turn off specific phases or feature.(Might not work for all phases)", )
10821101
FLAGNR(Phases, OffProfiledByteCode , "Turn off specific byte code for phases or feature.(Might not work for all phases)", )
10831102
FLAGNR(Phases, On , "Turn on specific phases or feature.(Might not work for all phases)", )
1084-
FLAGNR(String, OutputFile , "Log the output to a specified file. Default: output.log in the working directory.", L"output.log")
1085-
FLAGNR(String, OutputFileOpenMode , "File open mode for OutputFile. Default: wt, specify 'at' for append", L"wt")
1103+
FLAGNR_STRING(OutputFile , "Log the output to a specified file. Default: output.log in the working directory.", "output.log")
1104+
FLAGNR_STRING(OutputFileOpenMode , "File open mode for OutputFile. Default: wt, specify 'at' for append", "wt")
10861105
#ifdef ENABLE_TRACE
10871106
FLAGNR(Boolean, InMemoryTrace , "Enable in-memory trace (investigate crash using trace in dump file). Use !jd.dumptrace to print it.", DEFAULT_CONFIG_InMemoryTrace)
10881107
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
12681287
FLAGNR(Boolean, ShareInlineCaches, "Determines whether inline caches are shared between all loads (or all stores) of the same property ID", DEFAULT_CONFIG_ShareInlineCaches)
12691288
FLAGNR(Boolean, DisableDebugObject, "Disable test only Debug object properties", DEFAULT_CONFIG_DisableDebugObject)
12701289
FLAGNR(Boolean, DumpHeap, "enable Debug.dumpHeap even when DisableDebugObject is set", DEFAULT_CONFIG_DumpHeap)
1271-
FLAGNR(String, autoProxy, "enable creating proxy for each object creation", L"__msTestHandler")
1290+
FLAGNR_STRING(autoProxy, "enable creating proxy for each object creation", "__msTestHandler")
12721291
FLAGNR(Number, PerfHintLevel, "Specifies the perf-hint level (1,2) 1 == critical, 2 == only noisy", DEFAULT_CONFIG_PerfHintLevel)
12731292
#ifdef INTERNAL_MEM_PROTECT_HEAP_ALLOC
12741293
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
13381357
#undef FLAG_REGOVR_ASMJS
13391358

13401359
#undef FLAG
1360+
#undef FLAG_STRING
13411361
#undef FLAGP
13421362

13431363
#undef FLAGRA
13441364

13451365
#undef FLAGNR
1366+
#undef FLAGNR_STRING
13461367
#undef FLAGNRA
1368+
#undef FLAGNRA_STRING
13471369
#undef FLAGPNR
13481370

13491371
#endif

lib/Common/Core/ConfigFlagsTable.cpp

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace Js
6565
this->pszValue = NULL;
6666
}
6767

68-
String::String(__in_opt LPWSTR psz)
68+
String::String(__in_opt const wchar16* psz)
6969
{
7070
this->pszValue = NULL;
7171
Set(psz);
@@ -89,7 +89,7 @@ namespace Js
8989
///----------------------------------------------------------------------------
9090

9191
void
92-
String::Set(__in_opt LPWSTR pszValue)
92+
String::Set(__in_opt const wchar16* pszValue)
9393
{
9494
if(NULL != this->pszValue)
9595
{
@@ -205,8 +205,10 @@ namespace Js
205205
const wchar16* const FlagNames[FlagCount + 1] =
206206
{
207207
#define FLAG(type, name, ...) CH_WSTR(#name),
208+
#define FLAG_STRING(name, ...) CH_WSTR(#name),
208209
#include "ConfigFlagsList.h"
209210
NULL
211+
#undef FLAG_STRING
210212
#undef FLAG
211213
};
212214

@@ -230,9 +232,11 @@ namespace Js
230232
const wchar16* const FlagDescriptions[FlagCount + 1] =
231233
{
232234
#define FLAG(type, name, description, ...) CH_WSTR(description),
235+
#define FLAG_STRING(name, description, ...) CH_WSTR(description),
233236
#include "ConfigFlagsList.h"
234237
NULL
235238
#undef FLAG
239+
#undef FLAG_STRING
236240
};
237241

238242
//
@@ -241,9 +245,11 @@ namespace Js
241245
const Flag FlagParents[FlagCount + 1] =
242246
{
243247
#define FLAG(type, name, description, defaultValue, parentName, ...) parentName##Flag,
248+
#define FLAG_STRING(name, description, defaultValue, parentName, ...) parentName##Flag,
244249
#include "ConfigFlagsList.h"
245250
InvalidFlag
246251
#undef FLAG
252+
#undef FLAG_STRING
247253
};
248254

249255
///
@@ -270,9 +276,14 @@ namespace Js
270276
\
271277
name ## ( ## defaultValue ##), \
272278

279+
#define FLAG_STRING(name, description, defaultValue, ...) \
280+
\
281+
name ## ( ## CH_WSTR(defaultValue) ##), \
282+
273283
ConfigFlagsTable::ConfigFlagsTable():
274284
#include "ConfigFlagsList.h"
275285
#undef FLAG
286+
#undef FLAG_STRING
276287
nDummy(0)
277288
{
278289
for(int i=0; i < FlagCount; flagPresent[i++] = false);
@@ -281,9 +292,12 @@ namespace Js
281292
ZeroMemory(this->flagIsParent, sizeof(this->flagIsParent));
282293
#define FLAG(type, name, description, defaultValue, parentName, ...) \
283294
if ((int)parentName##Flag < FlagCount) this->flagIsParent[(int) parentName##Flag] = true;
295+
#define FLAG_STRING(name, description, defaultValue, parentName, ...) \
296+
if ((int)parentName##Flag < FlagCount) this->flagIsParent[(int) parentName##Flag] = true;
284297
#include "ConfigFlagsList.h"
285298
#undef FLAG
286-
299+
#undef FLAG_STRING
300+
287301
// set all parent flags to their default (setting all child flags to their right values)
288302
this->SetAllParentFlagsAsDefaultValue();
289303
}
@@ -391,12 +405,19 @@ namespace Js
391405
{
392406
// Transfer acronym flag configuration into the corresponding actual flag
393407
#define FLAG(...)
408+
#define FLAG_STRING(...)
394409
#define FLAGNRA(Type, Name, Acronym, ...) \
395410
if(!IsEnabled(Name##Flag) && IsEnabled(Acronym##Flag)) \
396411
{ \
397412
Enable(Name##Flag); \
398413
Name = Acronym; \
399414
}
415+
#define FLAGNRA_STRING(Name, Acronym, ...) \
416+
if(!IsEnabled(Name##Flag) && IsEnabled(Acronym##Flag)) \
417+
{ \
418+
Enable(Name##Flag); \
419+
Name = Acronym; \
420+
}
400421
#if ENABLE_DEBUG_CONFIG_OPTIONS
401422
#define FLAGRA(Type, Name, Acronym, ...) FLAGNRA(Type, Name, Acronym, __VA_ARGS__)
402423
#endif
@@ -449,6 +470,7 @@ namespace Js
449470
VerifyExecutionModeLimits();
450471

451472
#if ENABLE_DEBUG_CONFIG_OPTIONS
473+
#if !DISABLE_JIT
452474
if(ForceDynamicProfile)
453475
{
454476
Force.Enable(DynamicProfilePhase);
@@ -457,11 +479,14 @@ namespace Js
457479
{
458480
Force.Enable(JITLoopBodyPhase);
459481
}
482+
#endif
460483
if(NoDeferParse)
461484
{
462485
Off.Enable(DeferParsePhase);
463486
}
464-
487+
#endif
488+
489+
#if ENABLE_DEBUG_CONFIG_OPTIONS && !DISABLE_JIT
465490
bool dontEnforceLimitsForSimpleJitAfterOrFullJitAfter = false;
466491
if((IsEnabled(MinInterpretCountFlag) || IsEnabled(MaxInterpretCountFlag)) &&
467492
!(IsEnabled(SimpleJitAfterFlag) || IsEnabled(FullJitAfterFlag)))
@@ -491,7 +516,7 @@ namespace Js
491516
SimpleJitAfter = MinInterpretCount;
492517
dontEnforceLimitsForSimpleJitAfterOrFullJitAfter = true;
493518
}
494-
if(IsEnabled(MinInterpretCountFlag) && IsEnabled(MinSimpleJitRunCountFlag) ||
519+
if((IsEnabled(MinInterpretCountFlag) && IsEnabled(MinSimpleJitRunCountFlag)) ||
495520
IsEnabled(MaxSimpleJitRunCountFlag))
496521
{
497522
Enable(FullJitAfterFlag);
@@ -852,6 +877,10 @@ namespace Js
852877
#define FLAG(type, name, ...) \
853878
case name##Flag : \
854879
return Flag##type; \
880+
881+
#define FLAG_STRING(name, ...) \
882+
case name##Flag : \
883+
return FlagString; \
855884

856885
#include "ConfigFlagsList.h"
857886

@@ -881,6 +910,11 @@ namespace Js
881910
case name##Flag : \
882911
return reinterpret_cast<void*>(const_cast<type*>(&##name)); \
883912

913+
#define FLAG_STRING(name, ...) \
914+
\
915+
case name##Flag : \
916+
return reinterpret_cast<void*>(const_cast<String*>(&##name)); \
917+
884918
#include "ConfigFlagsList.h"
885919

886920
default:
@@ -913,11 +947,26 @@ namespace Js
913947
case FlagNumber: \
914948
Output::Print(CH_WSTR(":%d"), *GetAsNumber(name##Flag)); \
915949
break; \
950+
default: \
951+
break; \
916952
}; \
917953
Output::Print(CH_WSTR("\n")); \
918954
}
955+
956+
#define FLAG_STRING(name, ...) \
957+
if (IsEnabled(name##Flag)) \
958+
{ \
959+
Output::Print(CH_WSTR("-%s"), CH_WSTR(#name)); \
960+
if (GetAsString(name##Flag) != nullptr) \
961+
{ \
962+
Output::Print(CH_WSTR(":%s"), (LPCWSTR)*GetAsString(name##Flag)); \
963+
} \
964+
Output::Print(CH_WSTR("\n")); \
965+
}
966+
919967
#include "ConfigFlagsList.h"
920968
#undef FLAG
969+
#undef FLAG_STRING
921970
}
922971

923972
///----------------------------------------------------------------------------
@@ -936,6 +985,7 @@ namespace Js
936985
switch (flag)
937986
{
938987
#define FLAG(type, name, description, defaultValue, ...) FLAGDEFAULT##type(name, defaultValue)
988+
#define FLAG_STRING(name, description, defaultValue, ...) FLAGDEFAULTString(name, defaultValue)
939989
// define an overload for each FlagTypes - type
940990
// * all defaults we don't care about
941991
#define FLAGDEFAULTPhases(name, defaultValue)
@@ -1028,6 +1078,7 @@ namespace Js
10281078
#ifdef ENABLE_DEBUG_CONFIG_OPTIONS
10291079
// in case the flag is marked as 'callback' - to call the method
10301080
#define FLAG(type, name, description, defaultValue, parentName, hasCallback) FLAGCALLBACK##hasCallback(type, name)
1081+
#define FLAG_STRING(name, description, defaultValue, parentName, hasCallback) FLAGCALLBACK##hasCallback(String, name)
10311082
#define FLAGCALLBACKFALSE(type, name)
10321083
#define FLAGCALLBACKTRUE(type, name) FLAGDOCALLBACK##type(name)
10331084

@@ -1053,7 +1104,8 @@ namespace Js
10531104
#undef FLAGDOCALLBACKPhases
10541105
#undef FLAGCALLBACKTRUE
10551106
#undef FLAGCALLBACKFALSE
1056-
#undef FLAG
1107+
#undef FLAG_STRING
1108+
#undef FLAG
10571109
#endif
10581110
}
10591111

0 commit comments

Comments
 (0)