CommonDefines.h 25 KB

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