CollectionState.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. namespace Memory
  7. {
  8. enum CollectionState
  9. {
  10. Collection_Mark = 0x00000001,
  11. Collection_Sweep = 0x00000002,
  12. Collection_Exit = 0x00000004,
  13. Collection_PreCollection = 0x00000008,
  14. // Mark related states
  15. Collection_ResetMarks = 0x00000010,
  16. Collection_FindRoots = 0x00000020,
  17. Collection_Rescan = 0x00000040,
  18. Collection_FinishMark = 0x00000080,
  19. // Sweep related states
  20. #if ENABLE_CONCURRENT_GC
  21. Collection_ConcurrentSweepSetup = 0x00000100,
  22. #endif
  23. Collection_TransferSwept = 0x00000200,
  24. // State attributes
  25. #if ENABLE_PARTIAL_GC
  26. Collection_Partial = 0x00001000,
  27. #endif
  28. #if ENABLE_CONCURRENT_GC
  29. Collection_Concurrent = 0x00002000,
  30. Collection_ExecutingConcurrent = 0x00004000,
  31. Collection_FinishConcurrent = 0x00008000,
  32. Collection_ConcurrentMark = Collection_Concurrent | Collection_Mark,
  33. Collection_ConcurrentSweep = Collection_Concurrent | Collection_Sweep,
  34. #endif
  35. Collection_Parallel = 0x00010000,
  36. Collection_PostCollectionCallback = 0x00020000,
  37. Collection_PostSweepRedeferralCallback = 0x00040000,
  38. Collection_WrapperCallback = 0x00080000,
  39. #if ENABLE_ALLOCATIONS_DURING_CONCURRENT_SWEEP
  40. // Please look at the documentation for PrepareForAllocationsDuringConcurrentSweep method for details on how the concurrent
  41. // sweep progresses when allocations are allowed during sweep.
  42. /* In Pass1 of the concurrent sweep we determine if a block is full or empty or needs to be swept. Leaf blocks will get
  43. swept immediately where as non-leaf blocks may get put onto the pendingSweepList. */
  44. Collection_ConcurrentSweepPass1 = 0x00100000,
  45. Collection_ConcurrentSweepPass1Wait = 0x00200000,
  46. /* In Pass2, all blocks will go through SweepPartialReusePages to determine if the page can be reused. Also, any blocks
  47. that were put in the pendingSweepList will be swept during this stage. */
  48. Collection_ConcurrentSweepPass2 = 0x00400000,
  49. Collection_ConcurrentSweepPass2Wait = 0x00800000,
  50. #endif
  51. Collection_WeakRefMark = 0x01000000,
  52. // Actual states
  53. CollectionStateNotCollecting = 0, // not collecting
  54. CollectionStateResetMarks = Collection_Mark | Collection_ResetMarks, // reset marks
  55. CollectionStateFindRoots = Collection_Mark | Collection_FindRoots, // finding roots
  56. CollectionStateMark = Collection_Mark, // marking (in thread)
  57. CollectionStateSweep = Collection_Sweep, // sweeping (in thread)
  58. CollectionStateTransferSwept = Collection_Sweep | Collection_TransferSwept, // transfer swept objects (after concurrent sweep)
  59. CollectionStateExit = Collection_Exit, // exiting concurrent thread
  60. // Generally, Rescan is available only when concurrent is enabled
  61. // But we need Rescan for mark on OOM too
  62. CollectionStateRescanFindRoots = Collection_Mark | Collection_Rescan | Collection_FindRoots, // rescan (after concurrent mark)
  63. CollectionStateRescanMark = Collection_Mark | Collection_Rescan, // rescan (after concurrent mark)
  64. #if ENABLE_CONCURRENT_GC
  65. CollectionStateConcurrentResetMarks = Collection_ConcurrentMark | Collection_ResetMarks | Collection_ExecutingConcurrent, // concurrent reset mark
  66. CollectionStateConcurrentFindRoots = Collection_ConcurrentMark | Collection_FindRoots | Collection_ExecutingConcurrent, // concurrent findroot
  67. CollectionStateConcurrentMark = Collection_ConcurrentMark | Collection_ExecutingConcurrent, // concurrent marking
  68. CollectionStateRescanWait = Collection_ConcurrentMark | Collection_FinishConcurrent, // rescan (after concurrent mark)
  69. CollectionStateConcurrentFinishMark = Collection_ConcurrentMark | Collection_ExecutingConcurrent | Collection_FinishConcurrent,
  70. CollectionStateSetupConcurrentSweep = Collection_Sweep | Collection_ConcurrentSweepSetup, // setting up concurrent sweep
  71. CollectionStateConcurrentSweep = Collection_ConcurrentSweep | Collection_ExecutingConcurrent, // concurrent sweep
  72. #if ENABLE_ALLOCATIONS_DURING_CONCURRENT_SWEEP
  73. CollectionStateConcurrentSweepPass1 = Collection_ConcurrentSweep | Collection_ConcurrentSweepPass1 | Collection_ExecutingConcurrent, // concurrent sweep Pass 1
  74. CollectionStateConcurrentSweepPass1Wait = Collection_ConcurrentSweep | Collection_ConcurrentSweepPass1Wait | Collection_FinishConcurrent, // concurrent sweep wait state after Pass 1 has finished
  75. CollectionStateConcurrentSweepPass2 = Collection_ConcurrentSweep | Collection_ConcurrentSweepPass2 | Collection_ExecutingConcurrent, // concurrent sweep Pass 2
  76. CollectionStateConcurrentSweepPass2Wait = Collection_ConcurrentSweep | Collection_ConcurrentSweepPass2Wait | Collection_FinishConcurrent, // concurrent sweep wait state after Pass 2 has finished
  77. #endif
  78. CollectionStateTransferSweptWait = Collection_ConcurrentSweep | Collection_FinishConcurrent, // transfer swept objects (after concurrent sweep)
  79. #endif
  80. CollectionStateParallelMark = Collection_Mark | Collection_Parallel,
  81. #if ENABLE_CONCURRENT_GC
  82. CollectionStateBackgroundParallelMark = Collection_ConcurrentMark | Collection_ExecutingConcurrent | Collection_Parallel,
  83. CollectionStateConcurrentWrapperCallback = Collection_Concurrent | Collection_ExecutingConcurrent | Collection_WrapperCallback,
  84. #endif
  85. CollectionStatePostSweepRedeferralCallback = Collection_PostSweepRedeferralCallback,
  86. CollectionStatePostCollectionCallback = Collection_PostCollectionCallback,
  87. CollectionStateConcurrentMarkWeakRef = Collection_ConcurrentMark | Collection_ExecutingConcurrent | Collection_WeakRefMark,
  88. };
  89. }