MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / MarkObjectAllocUnchecked

Method MarkObjectAllocUnchecked

src/hx/gc/Immix.cpp:2118–2228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2116}
2117
2118void MarkObjectAllocUnchecked(hx::Object *inPtr,hx::MarkContext *__inCtx)
2119{
2120 size_t ptr_i = ((size_t)inPtr)-sizeof(int);
2121 unsigned int flags = *((unsigned int *)ptr_i);
2122 #ifdef HXCPP_GC_NURSERY
2123 if (!(flags & 0xff000000))
2124 {
2125 #if defined(HX_GC_VERIFY_GENERATIONAL)
2126 if (sGcVerifyGenerational)
2127 {
2128 printf("Nursery object escaped generational collection %p\n", inPtr);
2129 DebuggerTrap();
2130 }
2131 #endif
2132
2133
2134 int size = flags & 0xffff;
2135 int start = (int)(ptr_i & IMMIX_BLOCK_OFFSET_MASK);
2136 int startRow = start>>IMMIX_LINE_BITS;
2137 int blockId = *(BlockIdType *)(ptr_i & IMMIX_BLOCK_BASE_MASK);
2138 BlockDataInfo *info = (*gBlockInfo)[blockId];
2139
2140 int endRow = (start + size + sizeof(int) + IMMIX_LINE_LEN-1)>>IMMIX_LINE_BITS;
2141 *(unsigned int *)ptr_i = flags = (flags & IMMIX_HEADER_PRESERVE) |
2142 (endRow -startRow) |
2143 (size<<IMMIX_ALLOC_SIZE_SHIFT) |
2144 gMarkID;
2145
2146 unsigned int *pos = info->allocStart + startRow;
2147 unsigned int val = *pos;
2148 while(_hx_atomic_compare_exchange( (volatile int *)pos, val, val|gImmixStartFlag[start&127]) != val)
2149 val = *pos;
2150 #ifdef HXCPP_GC_GENERATIONAL
2151 info->mHasSurvivor = true;
2152 #endif
2153 }
2154 else
2155 #endif
2156 ((unsigned char *)inPtr)[HX_ENDIAN_MARK_ID_BYTE] = gByteMarkID;
2157
2158 int rows = flags & IMMIX_ALLOC_ROW_COUNT;
2159 if (rows)
2160 {
2161 char *block = (char *)(ptr_i & IMMIX_BLOCK_BASE_MASK);
2162 char *rowMark = block + ((ptr_i & IMMIX_BLOCK_OFFSET_MASK)>>IMMIX_LINE_BITS);
2163 #if HXCPP_GC_DEBUG_LEVEL>0
2164 if ( ((ptr_i & IMMIX_BLOCK_OFFSET_MASK)>>IMMIX_LINE_BITS) + rows > IMMIX_LINES) DebuggerTrap();
2165 #endif
2166
2167 *rowMark = 1;
2168 if (rows>1)
2169 {
2170 rowMark[1] = 1;
2171 if (rows>2)
2172 {
2173 rowMark[2] = 1;
2174 if (rows>3)
2175 {

Callers

nothing calls this directly

Calls 7

DebuggerTrapFunction · 0.85
GetPtrMethod · 0.80
TraceMethod · 0.80
pushObjMethod · 0.80
__GetClassMethod · 0.45
__MarkMethod · 0.45

Tested by

no test coverage detected