| 207 | } |
| 208 | |
| 209 | RACell* RAPass::_newStackCell(uint32_t size, uint32_t alignment) { |
| 210 | RACell* cell = static_cast<RACell*>(_zone->alloc(sizeof(RACell))); |
| 211 | if (ASMJIT_UNLIKELY(!cell)) return nullptr; |
| 212 | |
| 213 | if (alignment == 0) |
| 214 | alignment = RAGetDefaultAlignment(size); |
| 215 | |
| 216 | if (alignment > 64) |
| 217 | alignment = 64; |
| 218 | |
| 219 | ASMJIT_ASSERT(Utils::isPowerOf2(alignment)); |
| 220 | size = Utils::alignTo<uint32_t>(size, alignment); |
| 221 | |
| 222 | // Insert it sorted according to the alignment and size. |
| 223 | { |
| 224 | RACell** pPrev = &_memStackCells; |
| 225 | RACell* cur = *pPrev; |
| 226 | |
| 227 | while (cur && ((cur->alignment > alignment) || (cur->alignment == alignment && cur->size > size))) { |
| 228 | pPrev = &cur->next; |
| 229 | cur = *pPrev; |
| 230 | } |
| 231 | |
| 232 | cell->next = cur; |
| 233 | cell->offset = 0; |
| 234 | cell->size = size; |
| 235 | cell->alignment = alignment; |
| 236 | |
| 237 | *pPrev = cell; |
| 238 | _memStackCellsUsed++; |
| 239 | |
| 240 | _memMaxAlign = std::max<uint32_t>(_memMaxAlign, alignment); |
| 241 | _memStackTotal += size; |
| 242 | } |
| 243 | |
| 244 | return cell; |
| 245 | } |
| 246 | |
| 247 | Error RAPass::resolveCellOffsets() { |
| 248 | RACell* varCell = _memVarCells; |
nothing calls this directly
no test coverage detected