-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…to facilitate tracing of objects which relate to scriptable types Merge pull request #3846 from BoCupp:build/pcupp/recycler_visited_host_heap This change exposes functions that will allocate memory inside of Chakra's GC. This memory can be precisely traced or leaf, and either finalizable or not. Traced objects will have IRecyclerVisitedObject::Trace called on them during ProcessMark if they were added to a new type of mark stack during Mark. Trace implementations will use a new API to tell the marking context to add a set of pointers to the appropriate mark stack. Finalizable objects will have Dispose called when the the object is no longer reachable, in order to perform unmanaged resource cleanup. These objects (except for non-finalizable leaf objects) will all live inside a new heap block type. Currently there is only support for small and medium blocks. GCStress has been updated to allocate objects of the various new types. Finalizable objects hold onto some unmanaged heap resources which would point out (via OOM) if objects are not correctly being cleaned up. More details: - Add support for small and medium RecyclerVisitedHostHeapBlockTypes - For now, add failfast for RecyclerVisitedObjects that are placed in the LargeHeapBlock - Publish IRecyclerVisitedObject interface which adds new method (compared to FinalizableObject) for precise tracing support - The old FinalizableObject is now a specialization of RecyclerVisitedObject and is used internally by Chakra - For host allocations, the host is expected to provide an appropriate implementation of IRecyclerVisitedObject - Publish IRecyclerHeapMarkingContext (used as the argument to IRecyclerVisitedObject::Trace) - The host must implement precisely tracing the (non-leaf) memory it allocates by calling IRecyclerHeapMarkingContext::MarkObjects from inside its implementation of IRecyclerVisitedObject::Trace - It is implemented by a stack wrapper on MarkContext that captures the parallel and interior template parameters from MarkContext::ProcessMark. We always use false for doSpecialMark, since all calls to Mark that originate from ProcessMark would pass false (the only place we pass true is when scanning the stack) - Create Chakra exports for allocation and rootaddref/release functions - Introduce a new RecyclerHeap lib in chakra that defines the exports in the cpp and declares them in the h - Add support for RecyclerVisitedObjects in GCStress Note: this change is derived from a rebase of work done by Daniel Libby - all credit to him for the work to enable this concept.
- Loading branch information
Showing
37 changed files
with
1,189 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//------------------------------------------------------------------------------------------------------- | ||
// Copyright (C) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. | ||
//------------------------------------------------------------------------------------------------------- | ||
#pragma once | ||
|
||
interface IRecyclerHeapMarkingContext | ||
{ | ||
virtual void MarkObjects(void** objects, size_t count, void* parent) = 0; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//------------------------------------------------------------------------------------------------------- | ||
// Copyright (C) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. | ||
//------------------------------------------------------------------------------------------------------- | ||
#pragma once | ||
|
||
interface IRecyclerHeapMarkingContext; | ||
typedef void* RecyclerHeapHandle; | ||
|
||
interface IRecyclerVisitedObject | ||
{ | ||
// Called right after finish marking and this object is determined to be dead. | ||
// Should contain only simple clean up code. | ||
// Can't run another script | ||
// Can't cause a re-entrant collection | ||
virtual void Finalize(bool isShutdown) = 0; | ||
|
||
// Call after sweeping is done. | ||
// Can call other script or cause another collection. | ||
virtual void Dispose(bool isShutdown) = 0; | ||
|
||
// Used only by TrackableObjects (created with TrackedBit on by RecyclerNew*Tracked) | ||
virtual void Mark(RecyclerHeapHandle recycler) = 0; | ||
|
||
// Special behavior on certain GC's | ||
virtual void OnMark() = 0; | ||
|
||
// Used only by RecyclerVisitedHost objects (created with RecyclerAllocVistedHost_Traced*) | ||
virtual void Trace(IRecyclerHeapMarkingContext* markingContext) = 0; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.