MarkContextWrapper.h 1.3 KB

123456789101112131415161718192021222324252627282930
  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. #include "Core/RecyclerHeapMarkingContext.h"
  6. // Class used to wrap a MarkContext so that calls to MarkObjects during IRecyclerVisitedObject::Trace
  7. // can mark with the correct contextual template parameters
  8. template<bool parallel>
  9. class MarkContextWrapper : public IRecyclerHeapMarkingContext
  10. {
  11. public:
  12. MarkContextWrapper(MarkContext* context) : markContext(context) {}
  13. void MarkObjects(void** objects, size_t count, void* parent) override
  14. {
  15. for (size_t i = 0; i < count; i++)
  16. {
  17. // We pass true for interior, since we expect a majority of the pointers being marked by
  18. // external objects to themselves be external (and thus candidates for interior pointers).
  19. markContext->Mark<parallel, /*interior*/true, /*doSpecialMark*/ false>(objects[i], parent);
  20. }
  21. }
  22. private:
  23. // Should only be created on the stack
  24. void* operator new(size_t);
  25. MarkContext* markContext;
  26. };