Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8e8ab0c
Remove calling convention modifiers from cpuid sig (#83672)
am11 Mar 21, 2023
0b03ca6
SyntaxValueProvider: avoid performance issue with syntax list contain…
cston Mar 21, 2023
0c9568a
Improve RA for LowerBlockStore (#83627)
EgorBo Mar 21, 2023
beab6cd
Use BitOperations::PopCount() in genCountBits() (#83661)
kunalspathak Mar 21, 2023
12e9711
Cleanup some HWIntrinsic logic to ensure the right gtType and simdSiz…
tannergooding Mar 21, 2023
7b65174
Correct doc comment for IMultiplyOperators returns (#83693)
IDisposable Mar 21, 2023
17f576f
Localized file check-in by OneLocBuild Task: Build definition ID 679:…
dotnet-bot Mar 21, 2023
8c5cf11
[mono][jit] Adding compare all/any intrinsics. (#83515)
jandupej Mar 21, 2023
c1acb35
Replace a load with cheaper mov instruction when possible (#83458)
SwapnilGaikwad Mar 21, 2023
5896cbc
[tvOS] Bump to new OSX 13 AppleTV queue (#83272)
steveisok Mar 21, 2023
bb3dc9c
[mono][jit] Add vector horizontal sums and ToScalar on arm64. (#83675)
jandupej Mar 21, 2023
93dda3b
[browser] Fix encoding problem when publishing with AOT (#83510)
ilonatommy Mar 21, 2023
edb161a
[mono][aot] Load AOT module of a container assembly using assembly na…
kotlarmilos Mar 21, 2023
92f8abc
Revert "Formatting license files to match Unity legal standardization…
bholmes Mar 22, 2023
11c63d3
Merge from MSFT main
bholmes Mar 23, 2023
c046465
Update to net8.0 in the Unity files
bholmes Mar 22, 2023
759a329
Fixing Unity tests for Linux
bholmes Mar 23, 2023
c729824
Get Frozen Segment working with the Unity NULL GC
bholmes Mar 22, 2023
5522dd8
Unity GC write barrier patch
bholmes Mar 22, 2023
4828b6f
Revert "Unity GC write barrier patch"
bholmes Mar 24, 2023
2516f54
Force write barrier code to use the upper bounds
bholmes Mar 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Get Frozen Segment working with the Unity NULL GC
  • Loading branch information
bholmes committed Mar 23, 2023
commit c729824c7b16c46117ea81f3112a9ef5b33dea69
55 changes: 49 additions & 6 deletions unity/unitygc/unitygc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <cstdint>
#include <cstdlib>
#include <mutex>
#include <algorithm>
#include <vector>
#include <unordered_map>

#include "gcenv.base.h"
Expand All @@ -36,6 +38,15 @@ static const char* sUnityGC = "UnityGC";
#define UNITYGC_EXPORT
#endif

class heap_segment
{
public:
uint8_t* allocated;
uint8_t* committed;
uint8_t* reserved;
uint8_t* mem;
};

class GCHeap : public IGCHeap
{
public:
Expand Down Expand Up @@ -365,7 +376,10 @@ class GCHeap : public IGCHeap
// Returns true if this pointer points into a GC heap, false otherwise.
virtual bool IsHeapPointer(void* object, bool small_heap_only = false)
{
return m_pGlobalHeapStart <= object && object <= m_pGlobalHeapCurrent;
bool ret = m_pGlobalHeapStart <= object && object <= m_pGlobalHeapCurrent;
if (!ret)
return IsInFrozenSegment((Object*)object);
return ret;
}

// Return the generation that has been condemned by the current GC.
Expand Down Expand Up @@ -674,26 +688,55 @@ class GCHeap : public IGCHeap
===========================================================================
*/

std::vector<heap_segment*> m_segment_infos;

// Registers a frozen segment with the GC.
virtual segment_handle RegisterFrozenSegment(segment_info *pseginfo)
{
assert(0);
return NULL;
}
heap_segment * seg = (heap_segment*)malloc(sizeof(heap_segment));
if (!seg)
{
return NULL;
}

uint8_t* base_mem = (uint8_t*)pseginfo->pvMem;
seg->mem = base_mem + pseginfo->ibFirstObject;
seg->allocated = base_mem + pseginfo->ibAllocated;
seg->committed = base_mem + pseginfo->ibCommit;
seg->reserved = base_mem + pseginfo->ibReserved;

m_segment_infos.push_back(seg);
return reinterpret_cast< segment_handle >(seg);
}

// Unregisters a frozen segment.
virtual void UnregisterFrozenSegment(segment_handle seg)
{
assert(0);
heap_segment* sInfo = reinterpret_cast< heap_segment* >(seg);
auto foundItem = std::find(m_segment_infos.begin(), m_segment_infos.end(), sInfo);
assert(foundItem == m_segment_infos.end());
m_segment_infos.erase(foundItem);
free(sInfo);
}

// Indicates whether an object is in a frozen segment.
virtual bool IsInFrozenSegment(Object *object)
{
assert(0);
for (auto item = m_segment_infos.begin(), __end = m_segment_infos.end(); item != __end; ++item)
{
if((*item)->mem <= ((uint8_t*)object) && (*item)->reserved >= ((uint8_t*)object))
return true;
}
return false;
}

virtual void UpdateFrozenSegment(segment_handle seg, uint8_t* allocated, uint8_t* committed)
{
heap_segment* sInfo = reinterpret_cast< heap_segment* >(seg);
sInfo->committed = committed;
sInfo->allocated = allocated;
}

/*
===========================================================================
Routines for informing the GC about which events are enabled.
Expand Down