CommonDefines.h 25 KB

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