CommonDefines.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. #include "TargetVer.h"
  7. #include "Warnings.h"
  8. #include "ChakraCoreVersion.h"
  9. //----------------------------------------------------------------------------------------------------
  10. // Default debug/fretest/release flags values
  11. // - Set the default values of debug/fretest/release flags if it is not set by the command line
  12. //----------------------------------------------------------------------------------------------------
  13. #ifndef DBG_DUMP
  14. #define DBG_DUMP 0
  15. #endif
  16. #ifdef _DEBUG
  17. #ifdef DEBUG
  18. #undef DEBUG
  19. #endif
  20. #define DEBUG 1
  21. #endif
  22. // if test hook is enabled, debug config options are enabled too
  23. #ifdef ENABLE_TEST_HOOKS
  24. #ifndef ENABLE_DEBUG_CONFIG_OPTIONS
  25. #define ENABLE_DEBUG_CONFIG_OPTIONS 1
  26. #endif
  27. #endif
  28. // ENABLE_DEBUG_CONFIG_OPTIONS is enabled in debug build when DBG or DBG_DUMP is defined
  29. // It is enabled in fretest build (jscript9test.dll and jc.exe) in the build script
  30. #if DBG || DBG_DUMP
  31. #ifndef ENABLE_DEBUG_CONFIG_OPTIONS
  32. #define ENABLE_DEBUG_CONFIG_OPTIONS 1
  33. #endif
  34. // Flag to control availability of other flags to control regex debugging, tracing, profiling, etc. This is separate from
  35. // ENABLE_DEBUG_CONFIG_OPTIONS because enabling this flag may affect performance significantly, even with default values for
  36. // the regex flags this flag would make available.
  37. #ifndef ENABLE_REGEX_CONFIG_OPTIONS
  38. #define ENABLE_REGEX_CONFIG_OPTIONS 1
  39. #endif
  40. #endif
  41. // TODO: consider removing before RTM: keep for CHK/FRETEST but remove from FRE.
  42. // This will cause terminate process on AV/Assert rather that letting PDM (F12/debugger scenarios) eat exceptions.
  43. // At least for now, enable this even in FRE builds. See ReportError.h.
  44. #define ENABLE_DEBUG_API_WRAPPER 1
  45. //----------------------------------------------------------------------------------------------------
  46. // Define Architectures' aliases for Simplicity
  47. //----------------------------------------------------------------------------------------------------
  48. #if defined(_M_ARM) || defined(_M_ARM64)
  49. #define _M_ARM32_OR_ARM64 1
  50. #endif
  51. #if defined(_M_IX86) || defined(_M_ARM)
  52. #define _M_IX86_OR_ARM32 1
  53. #define TARGET_32 1
  54. #endif
  55. #if defined(_M_X64) || defined(_M_ARM64)
  56. #define _M_X64_OR_ARM64 1
  57. #define TARGET_64 1
  58. #endif
  59. // Memory Protections
  60. #ifdef _CONTROL_FLOW_GUARD
  61. #define PAGE_EXECUTE_RO_TARGETS_INVALID (PAGE_EXECUTE | PAGE_TARGETS_INVALID)
  62. #else
  63. #define PAGE_EXECUTE_RO_TARGETS_INVALID (PAGE_EXECUTE)
  64. #endif
  65. //----------------------------------------------------------------------------------------------------
  66. // Enabled features
  67. //----------------------------------------------------------------------------------------------------
  68. // NOTE: Disabling these might not work and are not fully supported and maintained
  69. // Even if it builds, it may not work properly. Disable at your own risk
  70. // Config options
  71. #define CONFIG_PARSE_CONFIG_FILE 1
  72. #ifdef _WIN32
  73. #define CONFIG_CONSOLE_AVAILABLE 1
  74. #define CONFIG_RICH_TRACE_FORMAT 1
  75. #else
  76. #define CONFIG_CONSOLE_AVAILABLE 0
  77. #define CONFIG_RICH_TRACE_FORMAT 0
  78. #endif
  79. // ByteCode
  80. #define VARIABLE_INT_ENCODING 1 // Byte code serialization variable size int field encoding
  81. #define BYTECODE_BRANCH_ISLAND // Byte code short branch and branch island
  82. #if defined(_WIN32) || defined(HAS_REAL_ICU)
  83. #define ENABLE_UNICODE_API 1 // Enable use of Unicode-related APIs
  84. #endif
  85. // Language features
  86. // xplat-todo: revisit these features
  87. #ifdef _WIN32
  88. #define ENABLE_INTL_OBJECT // Intl support
  89. #define ENABLE_JS_BUILTINS // Built In functions support
  90. #endif
  91. #define ENABLE_ES6_CHAR_CLASSIFIER // ES6 Unicode character classifier support
  92. // Type system features
  93. #define PERSISTENT_INLINE_CACHES // *** TODO: Won't build if disabled currently
  94. #define SUPPORT_FIXED_FIELDS_ON_PATH_TYPES // *** TODO: Won't build if disabled currently
  95. // xplat-todo: revisit these features
  96. #ifdef _WIN32
  97. // dep: TIME_ZONE_INFORMATION, DaylightTimeHelper, Windows.Globalization
  98. #define ENABLE_GLOBALIZATION
  99. // dep: IActiveScriptProfilerCallback, IActiveScriptProfilerHeapEnum
  100. #define ENABLE_SCRIPT_PROFILING
  101. #ifndef __clang__
  102. // xplat-todo: change DISABLE_SEH to ENABLE_SEH and move here
  103. #define ENABLE_SIMDJS
  104. #endif
  105. #define ENABLE_CUSTOM_ENTROPY
  106. #endif
  107. // dep: IDebugDocumentContext
  108. #define ENABLE_SCRIPT_DEBUGGING
  109. // GC features
  110. #define BUCKETIZE_MEDIUM_ALLOCATIONS 1 // *** TODO: Won't build if disabled currently
  111. #define SMALLBLOCK_MEDIUM_ALLOC 1 // *** TODO: Won't build if disabled currently
  112. #define LARGEHEAPBLOCK_ENCODING 1 // Large heap block metadata encoding
  113. #define IDLE_DECOMMIT_ENABLED 1 // Idle Decommit
  114. #define RECYCLER_PAGE_HEAP // PageHeap support
  115. #ifdef _WIN32
  116. #define SYSINFO_IMAGE_BASE_AVAILABLE 1
  117. #define ENABLE_CONCURRENT_GC 1
  118. #define ENABLE_ALLOCATIONS_DURING_CONCURRENT_SWEEP 1 // Only takes effect when ENABLE_CONCURRENT_GC is enabled.
  119. #define ENABLE_ALLOCATIONS_DURING_CONCURRENT_SWEEP_USE_SLIST 1 // Use Interlocked SLIST for allocableHeapBlockList
  120. #define SUPPORT_WIN32_SLIST 1
  121. #define ENABLE_JS_ETW // ETW support
  122. #else
  123. #define SYSINFO_IMAGE_BASE_AVAILABLE 0
  124. #ifndef ENABLE_VALGRIND
  125. #define ENABLE_CONCURRENT_GC 1
  126. #define ENABLE_ALLOCATIONS_DURING_CONCURRENT_SWEEP 1 // Only takes effect when ENABLE_CONCURRENT_GC is enabled.
  127. #else
  128. #define ENABLE_CONCURRENT_GC 0
  129. #define ENABLE_ALLOCATIONS_DURING_CONCURRENT_SWEEP 0 // Only takes effect when ENABLE_CONCURRENT_GC is enabled.
  130. #endif
  131. #define SUPPORT_WIN32_SLIST 0
  132. #define ENABLE_ALLOCATIONS_DURING_CONCURRENT_SWEEP_USE_SLIST 0 // Use Interlocked SLIST for allocableHeapBlockList
  133. #endif
  134. #define MAKE_HR(errnum) (MAKE_HRESULT(SEVERITY_ERROR, FACILITY_CONTROL, errnum))
  135. #if ENABLE_CONCURRENT_GC
  136. // Write-barrier refers to a software write barrier implementation using a card table.
  137. // Write watch refers to a hardware backed write-watch feature supported by the Windows memory manager.
  138. // Both are used for detecting changes to memory for concurrent and partial GC.
  139. // RECYCLER_WRITE_BARRIER controls the former, RECYCLER_WRITE_WATCH controls the latter.
  140. // GLOBAL_ENABLE_WRITE_BARRIER controls the smart pointer wrapper at compile time, every Field annotation on the
  141. // recycler allocated class will take effect if GLOBAL_ENABLE_WRITE_BARRIER is 1, otherwise only the class declared
  142. // with FieldWithBarrier annotations use the WriteBarrierPtr<>, see WriteBarrierMacros.h and RecyclerPointers.h for detail
  143. #define RECYCLER_WRITE_BARRIER // Write Barrier support
  144. #ifdef _WIN32
  145. #define RECYCLER_WRITE_WATCH // Support hardware write watch
  146. #endif
  147. #ifdef RECYCLER_WRITE_BARRIER
  148. #if !GLOBAL_ENABLE_WRITE_BARRIER
  149. #ifdef _WIN32
  150. #define GLOBAL_ENABLE_WRITE_BARRIER 0
  151. #else
  152. #define GLOBAL_ENABLE_WRITE_BARRIER 1
  153. #endif
  154. #endif
  155. #endif
  156. #define ENABLE_PARTIAL_GC 1
  157. #define ENABLE_BACKGROUND_PAGE_ZEROING 1
  158. #define ENABLE_BACKGROUND_PAGE_FREEING 1
  159. #define ENABLE_RECYCLER_TYPE_TRACKING 1
  160. #else
  161. #define ENABLE_PARTIAL_GC 0
  162. #define ENABLE_BACKGROUND_PAGE_ZEROING 0
  163. #define ENABLE_BACKGROUND_PAGE_FREEING 0
  164. #define ENABLE_RECYCLER_TYPE_TRACKING 0
  165. #endif
  166. #if ENABLE_BACKGROUND_PAGE_ZEROING && !ENABLE_BACKGROUND_PAGE_FREEING
  167. #error "Background page zeroing can't be turned on if freeing pages in the background is disabled"
  168. #endif
  169. // JIT features
  170. #if DISABLE_JIT
  171. #define ENABLE_NATIVE_CODEGEN 0
  172. #define ENABLE_PROFILE_INFO 0
  173. #define ENABLE_BACKGROUND_JOB_PROCESSOR 0
  174. #define ENABLE_BACKGROUND_PARSING 0 // Disable background parsing in this mode
  175. // We need to decouple the Jobs infrastructure out of
  176. // Backend to make background parsing work with JIT disabled
  177. #define DYNAMIC_INTERPRETER_THUNK 0
  178. #define DISABLE_DYNAMIC_PROFILE_DEFER_PARSE
  179. #define ENABLE_COPYONACCESS_ARRAY 0
  180. #else
  181. // By default, enable the JIT
  182. #define ENABLE_NATIVE_CODEGEN 1
  183. #define ENABLE_PROFILE_INFO 1
  184. #define ENABLE_BACKGROUND_JOB_PROCESSOR 1
  185. #define ENABLE_COPYONACCESS_ARRAY 1
  186. #ifndef DYNAMIC_INTERPRETER_THUNK
  187. #if defined(_M_IX86_OR_ARM32) || defined(_M_X64_OR_ARM64)
  188. #define DYNAMIC_INTERPRETER_THUNK 1
  189. #else
  190. #define DYNAMIC_INTERPRETER_THUNK 0
  191. #endif
  192. #endif
  193. // Only enable background parser in debug build.
  194. #ifdef DBG
  195. #define ENABLE_BACKGROUND_PARSING 1
  196. #endif
  197. #endif
  198. #if ENABLE_NATIVE_CODEGEN
  199. #ifdef _WIN32
  200. #define ENABLE_OOP_NATIVE_CODEGEN 1 // Out of process JIT
  201. #endif
  202. #if _WIN64
  203. #define ENABLE_FAST_ARRAYBUFFER 1
  204. #endif
  205. #endif
  206. // Other features
  207. // #define CHAKRA_CORE_DOWN_COMPAT 1
  208. // VS2015 RTM has bugs with constexpr, so require min of VS2015 Update 3 (known good version)
  209. #if !defined(_MSC_VER) || _MSC_FULL_VER >= 190024210
  210. #define HAS_CONSTEXPR 1
  211. #endif
  212. #ifdef HAS_CONSTEXPR
  213. #define OPT_CONSTEXPR constexpr
  214. #else
  215. #define OPT_CONSTEXPR
  216. #endif
  217. #if defined(ENABLE_DEBUG_CONFIG_OPTIONS) || defined(CHAKRA_CORE_DOWN_COMPAT)
  218. #define DELAYLOAD_SET_CFG_TARGET 1
  219. #endif
  220. #ifndef NTBUILD
  221. #define DELAYLOAD_SECTIONAPI 1
  222. #endif
  223. #ifdef NTBUILD
  224. #define ENABLE_PROJECTION
  225. #define ENABLE_FOUNDATION_OBJECT
  226. #define ENABLE_EXPERIMENTAL_FLAGS
  227. #define ENABLE_WININET_PROFILE_DATA_CACHE
  228. #define ENABLE_BASIC_TELEMETRY
  229. #define ENABLE_DOM_FAST_PATH
  230. #define EDIT_AND_CONTINUE
  231. #define ENABLE_JIT_CLAMP
  232. #endif
  233. // Telemetry flags
  234. #ifdef ENABLE_BASIC_TELEMETRY
  235. #define ENABLE_DIRECTCALL_TELEMETRY
  236. #endif
  237. // Telemetry features (non-DEBUG related)
  238. #ifdef ENABLE_BASIC_TELEMETRY
  239. // These defines can be "overridden" in other headers (e.g. ESBuiltInsTelemetryProvider.h) in case a specific telemetry provider wants to change an option for performance.
  240. #define TELEMETRY_OPCODE_OFFSET_ENABLED true // If the BytecodeOffset and FunctionId are logged.
  241. #define TELEMETRY_PROPERTY_OPCODE_FILTER(propertyId) true // Any filter to apply on a per propertyId basis in the opcode handler for GetProperty/TypeofProperty/GetMethodProperty/etc.
  242. #define TELEMETRY_OPCODE_GET_PROPERTY_VALUES true // If no telemetry providers need the values of properties then this option skips getting the value in the TypeofProperty opcode handler.
  243. // #define TELEMETRY_PROFILED // If telemetry should capture "Profiled*" operations
  244. // #define TELEMETRY_CACHEHIT // If telemetry should capture data that was gotten with a Cache Hit
  245. // #define TELEMETRY_JSO // If telemetry should capture JavascriptOperators (expensive, as it happens during JITed code too, not just interpreted mode)
  246. #define TELEMETRY_AddToCache // If telemetry should capture property-gets only when the propertyId is added to the cache (generally this means only the first usage of any feature is logged)
  247. // #define TELEMETRY_INTERPRETER // If telemetry should capture more interpreter events compared to just TELEMETRY_AddToCache
  248. #define TELEMETRY_TRACELOGGING // Telemetry output using TraceLogging
  249. // #define TELEMETRY_OUTPUTPRINT // Telemetry output using Output::Print
  250. // Enable/disable specific telemetry providers:
  251. #define TELEMETRY_ESB // Telemetry of ECMAScript Built-Ins usage or detection.
  252. // #define TELEMETRY_ARRAY_USAGE // Telemetry of Array usage statistics
  253. #define TELEMETRY_DateParse // Telemetry of `Date.parse`
  254. #ifdef TELEMETRY_ESB
  255. // Because ESB telemetry is in-production and has major performance implications, this redefines some of the #defines above to disable non-critical functionality to get more performance.
  256. #undef TELEMETRY_OPCODE_OFFSET_ENABLED // Disable the FunctionId+Offset tracker.
  257. #define TELEMETRY_OPCODE_OFFSET_ENABLED false
  258. #undef TELEMETRY_PROPERTY_OPCODE_FILTER // Redefine the Property Opcode filter to ignore non-built-in properties.
  259. #define TELEMETRY_PROPERTY_OPCODE_FILTER(propertyId) (propertyId < Js::PropertyIds::_countJSOnlyProperty)
  260. #undef TELEMETRY_OPCODE_GET_PROPERTY_VALUES
  261. #define TELEMETRY_OPCODE_GET_PROPERTY_VALUES false
  262. //#define TELEMETRY_ESB_GetConstructorPropertyPolyfillDetection // Whether telemetry will inspect the `.constructor` property of every Object instance to determine if it's a polyfill of a known ES built-in.
  263. #endif
  264. #else
  265. #define TELEMETRY_OPCODE_OFFSET_ENABLED false
  266. #define TELEMETRY_OPCODE_FILTER(propertyId) false
  267. #endif
  268. #if ENABLE_DEBUG_CONFIG_OPTIONS
  269. #define ENABLE_DIRECTCALL_TELEMETRY_STATS
  270. #endif
  271. //----------------------------------------------------------------------------------------------------
  272. // Debug and fretest features
  273. //----------------------------------------------------------------------------------------------------
  274. #ifdef ENABLE_DEBUG_CONFIG_OPTIONS
  275. #define BAILOUT_INJECTION
  276. #if ENABLE_PROFILE_INFO
  277. #define DYNAMIC_PROFILE_STORAGE
  278. #define DYNAMIC_PROFILE_MUTATOR
  279. #endif
  280. #define RUNTIME_DATA_COLLECTION
  281. #define SECURITY_TESTING
  282. // xplat-todo: Temporarily disable profile output on non-Win32 builds
  283. #ifdef _WIN32
  284. #define PROFILE_EXEC
  285. #endif
  286. #define BGJIT_STATS
  287. #define REJIT_STATS
  288. #define PERF_HINT
  289. #define POLY_INLINE_CACHE_SIZE_STATS
  290. #define JS_PROFILE_DATA_INTERFACE 1
  291. #define EXCEPTION_RECOVERY 1
  292. #define RECYCLER_TEST_SUPPORT
  293. #define ARENA_ALLOCATOR_FREE_LIST_SIZE
  294. // TODO (t-doilij) combine IR_VIEWER and ENABLE_IR_VIEWER
  295. #if 0
  296. #if ENABLE_NATIVE_CODEGEN
  297. #define IR_VIEWER
  298. #define ENABLE_IR_VIEWER
  299. #define ENABLE_IR_VIEWER_DBG_DUMP // TODO (t-doilij) disable this before check-in
  300. #endif
  301. #endif
  302. #ifdef ENABLE_JS_ETW
  303. #define TEST_ETW_EVENTS
  304. #endif
  305. // VTUNE profiling requires ETW trace
  306. #if defined(_M_IX86) || defined(_M_X64)
  307. #define VTUNE_PROFILING
  308. #endif
  309. #ifdef NTBUILD
  310. #define PERF_COUNTERS
  311. #define ENABLE_MUTATION_BREAKPOINT
  312. #endif
  313. #ifdef _CONTROL_FLOW_GUARD
  314. #define CONTROL_FLOW_GUARD_LOGGER
  315. #endif
  316. #ifndef ENABLE_TEST_HOOKS
  317. #define ENABLE_TEST_HOOKS
  318. #endif
  319. #endif // ENABLE_DEBUG_CONFIG_OPTIONS
  320. ////////
  321. //Time Travel flags
  322. //Include TTD code in the build when building for Chakra (except NT/Edge) or for debug/test builds
  323. #if !defined(NTBUILD) || defined(ENABLE_DEBUG_CONFIG_OPTIONS)
  324. #define ENABLE_TTD 1
  325. #else
  326. #define ENABLE_TTD 0
  327. #endif
  328. #if ENABLE_TTD
  329. #define TTDAssert(C, M) { if(!(C)) TTDAbort_fatal_error(M); }
  330. #else
  331. #define TTDAssert(C, M)
  332. #endif
  333. #if ENABLE_TTD
  334. //A workaround for profile based creation of Native Arrays -- we may or may not want to allow since it differs in record/replay and (currently) asserts in our snap compare
  335. #define TTD_NATIVE_PROFILE_ARRAY_WORK_AROUND 1
  336. //See also -- Disabled fast path on property enumeration, random number generation, disabled new/eval code cache, and others.
  337. // Disabled ActivationObjectEx and others.
  338. //Force debug or notjit mode
  339. #define TTD_FORCE_DEBUG_MODE 0
  340. #define TTD_FORCE_NOJIT_MODE 0
  341. //Enable various sanity checking features and asserts
  342. #if ENABLE_DEBUG_CONFIG_OPTIONS
  343. #define ENABLE_TTD_INTERNAL_DIAGNOSTICS 1
  344. #else
  345. #define ENABLE_TTD_INTERNAL_DIAGNOSTICS 0
  346. #endif
  347. #define TTD_LOG_READER TextFormatReader
  348. #define TTD_LOG_WRITER TextFormatWriter
  349. //For now always use the (lower performance) text format for snapshots for easier debugging etc.
  350. #define TTD_SNAP_READER TextFormatReader
  351. #define TTD_SNAP_WRITER TextFormatWriter
  352. //#if ENABLE_TTD_INTERNAL_DIAGNOSTICS
  353. //#define TTD_SNAP_READER TextFormatReader
  354. //#define TTD_SNAP_WRITER TextFormatWriter
  355. //#else
  356. //#define TTD_SNAP_READER BinaryFormatReader
  357. //#define TTD_SNAP_WRITER BinaryFormatWriter
  358. //#endif
  359. #if ENABLE_TTD_INTERNAL_DIAGNOSTICS
  360. #define ENABLE_SNAPSHOT_COMPARE 1
  361. #define ENABLE_OBJECT_SOURCE_TRACKING 0
  362. #define ENABLE_VALUE_TRACE 0
  363. #define ENABLE_BASIC_TRACE 0
  364. #define ENABLE_FULL_BC_TRACE 0
  365. #define ENABLE_CROSSSITE_TRACE 0
  366. #else
  367. #define ENABLE_SNAPSHOT_COMPARE 0
  368. #define ENABLE_OBJECT_SOURCE_TRACKING 0
  369. #define ENABLE_BASIC_TRACE 0
  370. #define ENABLE_FULL_BC_TRACE 0
  371. #define ENABLE_CROSSSITE_TRACE 0
  372. #endif
  373. #define ENABLE_TTD_DIAGNOSTICS_TRACING (ENABLE_OBJECT_SOURCE_TRACKING || ENABLE_BASIC_TRACE || ENABLE_FULL_BC_TRACE)
  374. //End Time Travel flags
  375. ////////
  376. #endif
  377. //----------------------------------------------------------------------------------------------------
  378. // Debug only features
  379. //----------------------------------------------------------------------------------------------------
  380. #ifdef DEBUG
  381. #define BYTECODE_TESTING
  382. // xplat-todo: revive FaultInjection on non-Win32 platforms
  383. // currently depends on io.h
  384. #ifdef _WIN32
  385. #define FAULT_INJECTION
  386. #endif
  387. #define RECYCLER_NO_PAGE_REUSE
  388. #ifdef NTBUILD
  389. #define INTERNAL_MEM_PROTECT_HEAP_ALLOC
  390. #define INTERNAL_MEM_PROTECT_HEAP_CMDLINE
  391. #endif
  392. #endif
  393. #ifdef DBG
  394. #define VALIDATE_ARRAY
  395. // xplat-todo: Do we need dump generation for non-Win32 platforms?
  396. #ifdef _WIN32
  397. #define GENERATE_DUMP
  398. #endif
  399. #endif
  400. #if DBG_DUMP
  401. #undef DBG_EXTRAFIELD // make sure we don't extra fields in free build.
  402. #define TRACK_DISPATCH
  403. #define BGJIT_STATS
  404. #define REJIT_STATS
  405. #define POLY_INLINE_CACHE_SIZE_STATS
  406. #define INLINE_CACHE_STATS
  407. #define FIELD_ACCESS_STATS
  408. #define MISSING_PROPERTY_STATS
  409. #define EXCEPTION_RECOVERY 1
  410. #define EXCEPTION_CHECK // Check exception handling.
  411. #ifdef _WIN32
  412. #define PROFILE_EXEC
  413. #endif
  414. #if !(defined(__clang__) && defined(_M_IX86))
  415. // todo: implement this for clang x86
  416. #define PROFILE_MEM
  417. #endif
  418. #define PROFILE_TYPES
  419. #define PROFILE_EVALMAP
  420. #define PROFILE_OBJECT_LITERALS
  421. #define PROFILE_BAILOUT_RECORD_MEMORY
  422. #define MEMSPECT_TRACKING
  423. #define PROFILE_RECYCLER_ALLOC
  424. // Needs to compile in debug mode
  425. // Just needs strings converted
  426. #define PROFILE_DICTIONARY 1
  427. #define PROFILE_STRINGS
  428. #define RECYCLER_SLOW_CHECK_ENABLED // This can be disabled to speed up the debug build's GC
  429. #define RECYCLER_STRESS
  430. #define RECYCLER_STATS
  431. #define RECYCLER_FINALIZE_CHECK
  432. #define RECYCLER_FREE_MEM_FILL
  433. #define RECYCLER_DUMP_OBJECT_GRAPH
  434. #define RECYCLER_MEMORY_VERIFY
  435. #define RECYCLER_ZERO_MEM_CHECK
  436. #define RECYCLER_TRACE
  437. #define RECYCLER_VERIFY_MARK
  438. #ifdef PERF_COUNTERS
  439. #define RECYCLER_PERF_COUNTERS
  440. #define HEAP_PERF_COUNTERS
  441. #endif // PERF_COUNTERS
  442. #define PAGEALLOCATOR_PROTECT_FREEPAGE
  443. #define ARENA_MEMORY_VERIFY
  444. #define SEPARATE_ARENA
  445. #ifndef _WIN32
  446. #ifdef _X64_OR_ARM64
  447. #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
  448. #define MEMORY_ALLOCATION_ALIGNMENT 16
  449. #else
  450. #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
  451. #define MEMORY_ALLOCATION_ALIGNMENT 8
  452. #endif
  453. #endif
  454. #define HEAP_TRACK_ALLOC
  455. #define CHECK_MEMORY_LEAK
  456. #define LEAK_REPORT
  457. #define PROJECTION_METADATA_TRACE
  458. #define ERROR_TRACE
  459. #define DEBUGGER_TRACE
  460. #define PROPERTY_RECORD_TRACE
  461. #define ARENA_ALLOCATOR_FREE_LIST_SIZE
  462. #ifdef DBG_EXTRAFIELD
  463. #define HEAP_ENUMERATION_VALIDATION
  464. #endif
  465. #endif // DBG_DUMP
  466. //----------------------------------------------------------------------------------------------------
  467. // Special build features
  468. // - features that can be enabled on private builds for debugging
  469. //----------------------------------------------------------------------------------------------------
  470. #ifdef ENABLE_JS_ETW
  471. // #define ETW_MEMORY_TRACKING // ETW events for internal allocations
  472. #endif
  473. // #define OLD_ITRACKER // Switch to the old IE8 ITracker GUID
  474. // #define LOG_BYTECODE_AST_RATIO // log the ratio between AST size and bytecode generated.
  475. // #define DUMP_FRAGMENTATION_STATS // Display HeapBucket fragmentation stats after sweep
  476. // ----- Fretest or free build special build features (already enabled in debug builds) -----
  477. // #define TRACK_DISPATCH
  478. // #define BGJIT_STATS
  479. // Profile defines that can be enabled in release build
  480. // #define PROFILE_EXEC
  481. // #define PROFILE_MEM
  482. // #define PROFILE_STRINGS
  483. // #define PROFILE_TYPES
  484. // #define PROFILE_OBJECT_LITERALS
  485. // #define PROFILE_RECYCLER_ALLOC
  486. // #define MEMSPECT_TRACKING
  487. // #define HEAP_TRACK_ALLOC
  488. // Recycler defines that can be enabled in release build
  489. // #define RECYCLER_STRESS
  490. // #define RECYCLER_STATS
  491. // #define RECYCLER_FINALIZE_CHECK
  492. // #define RECYCLER_FREE_MEM_FILL
  493. // #define RECYCLER_DUMP_OBJECT_GRAPH
  494. // #define RECYCLER_MEMORY_VERIFY
  495. // #define RECYCLER_TRACE
  496. // #define RECYCLER_VERIFY_MARK
  497. // #ifdef PERF_COUNTERS
  498. // #define RECYCLER_PERF_COUNTERS
  499. // #define HEAP_PERF_COUNTERS
  500. // #endif //PERF_COUNTERS
  501. // Other defines that can be enabled in release build
  502. // #define PAGEALLOCATOR_PROTECT_FREEPAGE
  503. // #define ARENA_MEMORY_VERIFY
  504. // #define SEPARATE_ARENA
  505. // #define LEAK_REPORT
  506. // #define CHECK_MEMORY_LEAK
  507. // #define RECYCLER_MARK_TRACK
  508. // #define INTERNAL_MEM_PROTECT_HEAP_ALLOC
  509. #define NO_SANITIZE_ADDRESS
  510. #if defined(__has_feature)
  511. #if __has_feature(address_sanitizer)
  512. #undef NO_SANITIZE_ADDRESS
  513. #define NO_SANITIZE_ADDRESS __attribute__((no_sanitize("address")))
  514. #define NO_SANITIZE_ADDRESS_FIXVC
  515. #endif
  516. #endif
  517. //----------------------------------------------------------------------------------------------------
  518. // Disabled features
  519. //----------------------------------------------------------------------------------------------------
  520. //Enable/disable dom properties
  521. #define DOMEnabled 0
  522. //----------------------------------------------------------------------------------------------------
  523. // Platform dependent flags
  524. //----------------------------------------------------------------------------------------------------
  525. #ifndef INT32VAR
  526. #if defined(_M_X64_OR_ARM64)
  527. #define INT32VAR 1
  528. #else
  529. #define INT32VAR 0
  530. #endif
  531. #endif
  532. #ifndef FLOATVAR
  533. #if defined(_M_X64)
  534. #define FLOATVAR 1
  535. #else
  536. #define FLOATVAR 0
  537. #endif
  538. #endif
  539. #if (defined(_M_IX86) || defined(_M_X64)) && !defined(DISABLE_JIT)
  540. #define ASMJS_PLAT
  541. #endif
  542. #if defined(ASMJS_PLAT)
  543. // xplat-todo: once all the wasm tests are passing on xplat, enable it for release builds
  544. #if defined(_WIN32) || (defined(__clang__) && defined(ENABLE_DEBUG_CONFIG_OPTIONS))
  545. #define ENABLE_WASM
  546. #ifdef CAN_BUILD_WABT
  547. #define ENABLE_WABT
  548. #endif
  549. #endif
  550. #endif
  551. #if _M_IX86
  552. #define I386_ASM 1
  553. #endif //_M_IX86
  554. #ifndef PDATA_ENABLED
  555. #if defined(_M_ARM32_OR_ARM64) || defined(_M_X64)
  556. #define PDATA_ENABLED 1
  557. #define ALLOC_XDATA (true)
  558. #else
  559. #define PDATA_ENABLED 0
  560. #define ALLOC_XDATA (false)
  561. #endif
  562. #endif
  563. #ifndef _WIN32
  564. #define DISABLE_SEH 1
  565. #endif
  566. //----------------------------------------------------------------------------------------------------
  567. // Dependent flags
  568. // - flags values that are dependent on other flags
  569. //----------------------------------------------------------------------------------------------------
  570. #if !ENABLE_CONCURRENT_GC
  571. #undef IDLE_DECOMMIT_ENABLED // Currently idle decommit can only be enabled if concurrent gc is enabled
  572. #endif
  573. #ifdef BAILOUT_INJECTION
  574. #define ENABLE_PREJIT
  575. #endif
  576. #if defined(ENABLE_DEBUG_CONFIG_OPTIONS)
  577. // Enable Output::Trace
  578. #define ENABLE_TRACE
  579. #endif
  580. #if !(defined(__clang__) && defined(_M_ARM32_OR_ARM64)) // xplat-todo: ARM
  581. #if DBG || defined(CHECK_MEMORY_LEAK) || defined(LEAK_REPORT) || defined(TRACK_DISPATCH) || defined(ENABLE_TRACE) || defined(RECYCLER_PAGE_HEAP)
  582. #define STACK_BACK_TRACE
  583. #endif
  584. #endif
  585. // ENABLE_DEBUG_STACK_BACK_TRACE is for capturing stack back trace for debug only.
  586. // (STACK_BACK_TRACE is enabled on release build, used by RECYCLER_PAGE_HEAP.)
  587. #if ENABLE_DEBUG_CONFIG_OPTIONS && defined(STACK_BACK_TRACE)
  588. #define ENABLE_DEBUG_STACK_BACK_TRACE 1
  589. #endif
  590. #if defined(STACK_BACK_TRACE) || defined(CONTROL_FLOW_GUARD_LOGGER)
  591. #ifdef _WIN32
  592. #define DBGHELP_SYMBOL_MANAGER
  593. #endif
  594. #endif
  595. #if defined(TRACK_DISPATCH) || defined(CHECK_MEMORY_LEAK) || defined(LEAK_REPORT)
  596. #define TRACK_JS_DISPATCH
  597. #endif
  598. // LEAK_REPORT and CHECK_MEMORY_LEAK requires RECYCLER_DUMP_OBJECT_GRAPH
  599. // HEAP_TRACK_ALLOC and RECYCLER_STATS
  600. #if defined(LEAK_REPORT) || defined(CHECK_MEMORY_LEAK)
  601. #define RECYCLER_DUMP_OBJECT_GRAPH
  602. #define HEAP_TRACK_ALLOC
  603. #define RECYCLER_STATS
  604. #endif
  605. // PROFILE_RECYCLER_ALLOC requires PROFILE_MEM
  606. #if defined(PROFILE_RECYCLER_ALLOC) && !defined(PROFILE_MEM)
  607. #define PROFILE_MEM
  608. #endif
  609. // RECYCLER_DUMP_OBJECT_GRAPH is needed when using PROFILE_RECYCLER_ALLOC
  610. #if defined(PROFILE_RECYCLER_ALLOC) && !defined(RECYCLER_DUMP_OBJECT_GRAPH)
  611. #define RECYCLER_DUMP_OBJECT_GRAPH
  612. #endif
  613. #if defined(HEAP_TRACK_ALLOC) || defined(PROFILE_RECYCLER_ALLOC)
  614. #define TRACK_ALLOC
  615. #define TRACE_OBJECT_LIFETIME // track a particular object's lifetime
  616. #endif
  617. #if defined(USED_IN_STATIC_LIB)
  618. #undef FAULT_INJECTION
  619. #undef RECYCLER_DUMP_OBJECT_GRAPH
  620. #undef HEAP_TRACK_ALLOC
  621. #undef RECYCLER_STATS
  622. #undef PERF_COUNTERS
  623. #endif
  624. // Not having the config options enabled trumps all the above logic for these switches
  625. #ifndef ENABLE_DEBUG_CONFIG_OPTIONS
  626. #undef ARENA_MEMORY_VERIFY
  627. #undef RECYCLER_MEMORY_VERIFY
  628. #undef PROFILE_MEM
  629. #undef PROFILE_DICTIONARY
  630. #undef PROFILE_RECYCLER_ALLOC
  631. #undef PROFILE_EXEC
  632. #undef PROFILE_EVALMAP
  633. #undef FAULT_INJECTION
  634. #undef RECYCLER_STRESS
  635. #undef RECYCLER_SLOW_VERIFY
  636. #undef RECYCLER_VERIFY_MARK
  637. #undef RECYCLER_STATS
  638. #undef RECYCLER_FINALIZE_CHECK
  639. #undef RECYCLER_DUMP_OBJECT_GRAPH
  640. #undef DBG_DUMP
  641. #undef BGJIT_STATS
  642. #undef EXCEPTION_RECOVERY
  643. #undef PROFILE_STRINGS
  644. #undef PROFILE_TYPES
  645. #undef PROFILE_OBJECT_LITERALS
  646. #undef SECURITY_TESTING
  647. #undef LEAK_REPORT
  648. #endif
  649. //----------------------------------------------------------------------------------------------------
  650. // Default flags values
  651. // - Set the default values of flags if it is not set by the command line or above
  652. //----------------------------------------------------------------------------------------------------
  653. #ifndef JS_PROFILE_DATA_INTERFACE
  654. #define JS_PROFILE_DATA_INTERFACE 0
  655. #endif
  656. #define JS_REENTRANCY_FAILFAST 1
  657. #if DBG || JS_REENTRANCY_FAILFAST
  658. #define ENABLE_JS_REENTRANCY_CHECK 1
  659. #else
  660. #define ENABLE_JS_REENTRANCY_CHECK 0
  661. #endif
  662. #ifndef PROFILE_DICTIONARY
  663. #define PROFILE_DICTIONARY 0
  664. #endif
  665. #ifndef THREAD_LOCAL
  666. #ifndef __APPLE__
  667. #if defined(_MSC_VER) && _MSC_VER <= 1800 // VS2013?
  668. #define THREAD_LOCAL __declspec(thread)
  669. #else // VS2015+, linux Clang etc.
  670. #define THREAD_LOCAL thread_local
  671. #endif // VS2013?
  672. #else // __APPLE__
  673. #ifndef __IOS__
  674. #define THREAD_LOCAL _Thread_local
  675. #else
  676. #define THREAD_LOCAL
  677. #endif
  678. #endif // __APPLE__
  679. #endif // THREAD_LOCAL