2
0

CommonDefines.h 25 KB

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