CommonDefines.h 26 KB

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