CommonDefines.h 26 KB

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