These allocate the function using the garbage-collected malloc
| 362 | |
| 363 | // These allocate the function using the garbage-collected malloc |
| 364 | inline static void *alloc(ImmixAllocator *alloc, size_t inSize, bool inContainer, const char *inName ) |
| 365 | { |
| 366 | #ifdef HXCPP_GC_NURSERY |
| 367 | |
| 368 | #ifdef HXCPP_ALIGN_ALLOC |
| 369 | // make sure buffer is 8-byte aligned |
| 370 | unsigned char *buffer = alloc->spaceFirst + ( (size_t)alloc->spaceFirst & 4 ); |
| 371 | #else |
| 372 | unsigned char *buffer = alloc->spaceFirst; |
| 373 | #endif |
| 374 | unsigned char *end = buffer + (inSize + 4); |
| 375 | |
| 376 | if ( end > alloc->spaceOversize ) |
| 377 | { |
| 378 | // Fall back to external method |
| 379 | buffer = (unsigned char *)alloc->CallAlloc(inSize, inContainer ? IMMIX_ALLOC_IS_CONTAINER : 0); |
| 380 | } |
| 381 | else |
| 382 | { |
| 383 | alloc->spaceFirst = end; |
| 384 | |
| 385 | if (inContainer) |
| 386 | ((unsigned int *)buffer)[-1] = inSize | IMMIX_ALLOC_IS_CONTAINER; |
| 387 | else |
| 388 | ((unsigned int *)buffer)[-1] = inSize; |
| 389 | } |
| 390 | |
| 391 | #if defined(HXCPP_GC_CHECK_POINTER) && defined(HXCPP_GC_DEBUG_ALWAYS_MOVE) |
| 392 | hx::GCOnNewPointer(buffer); |
| 393 | #endif |
| 394 | |
| 395 | #ifdef HXCPP_TELEMETRY |
| 396 | __hxt_gc_new((hx::StackContext *)alloc,buffer, inSize, inName); |
| 397 | #endif |
| 398 | |
| 399 | return buffer; |
| 400 | |
| 401 | #else |
| 402 | // Inline the fast-path if we can |
| 403 | // We know the object can hold a pointer (vtable) and that the size is int-aligned |
| 404 | int start = alloc->spaceStart; |
| 405 | #ifdef HXCPP_ALIGN_ALLOC |
| 406 | // Ensure odd alignment in 8 bytes |
| 407 | start += 4 - (start & 4); |
| 408 | #endif |
| 409 | int end = start + (int)(sizeof(int) + inSize); |
| 410 | |
| 411 | if ( end <= alloc->spaceEnd ) |
| 412 | { |
| 413 | alloc->spaceStart = end; |
| 414 | |
| 415 | unsigned int *buffer = (unsigned int *)(alloc->allocBase + start); |
| 416 | |
| 417 | int startRow = start>>IMMIX_LINE_BITS; |
| 418 | |
| 419 | alloc->allocStartFlags[ startRow ] |= gImmixStartFlag[start&127]; |
| 420 | |
| 421 | if (inContainer) |
nothing calls this directly
no test coverage detected