@@ -365,7 +365,12 @@ class ImmixAllocator
365
365
{
366
366
#ifdef HXCPP_GC_NURSERY
367
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
368
372
unsigned char *buffer = alloc->spaceFirst ;
373
+ #endif
369
374
unsigned char *end = buffer + (inSize + 4 );
370
375
371
376
if ( end > alloc->spaceOversize )
@@ -383,49 +388,55 @@ class ImmixAllocator
383
388
((unsigned int *)buffer)[-1 ] = inSize;
384
389
}
385
390
391
+ #if defined(HXCPP_GC_CHECK_POINTER) && defined(HXCPP_GC_DEBUG_ALWAYS_MOVE)
392
+ hx::GCOnNewPointer (buffer);
393
+ #endif
394
+
386
395
#ifdef HXCPP_TELEMETRY
387
396
__hxt_gc_new ((hx::StackContext *)alloc,buffer, inSize, inName);
388
397
#endif
389
398
390
399
return buffer;
391
400
392
401
#else
393
- #ifndef HXCPP_ALIGN_ALLOC
394
- // Inline the fast-path if we can
395
- // We know the object can hold a pointer (vtable) and that the size is int-aligned
396
- int start = alloc->spaceStart ;
397
- int end = start + sizeof (int ) + inSize;
398
-
399
- if ( end <= alloc->spaceEnd )
400
- {
401
- alloc->spaceStart = end;
402
-
403
- unsigned int *buffer = (unsigned int *)(alloc->allocBase + start);
404
-
405
- int startRow = start>>IMMIX_LINE_BITS;
406
-
407
- alloc->allocStartFlags [ startRow ] |= gImmixStartFlag [start&127 ];
408
-
409
- if (inContainer)
410
- *buffer++ = (( (end+(IMMIX_LINE_LEN-1 ))>>IMMIX_LINE_BITS) -startRow) |
411
- (inSize<<IMMIX_ALLOC_SIZE_SHIFT) |
412
- hx::gMarkIDWithContainer ;
413
- else
414
- *buffer++ = (( (end+(IMMIX_LINE_LEN-1 ))>>IMMIX_LINE_BITS) -startRow) |
415
- (inSize<<IMMIX_ALLOC_SIZE_SHIFT) |
416
- hx::gMarkID ;
417
-
418
- #if defined(HXCPP_GC_CHECK_POINTER) && defined(HXCPP_GC_DEBUG_ALWAYS_MOVE)
419
- hx::GCOnNewPointer (buffer);
420
- #endif
421
-
422
- #ifdef HXCPP_TELEMETRY
423
- __hxt_gc_alloc (buffer, inSize);
424
- __hxt_gc_new ((hx::StackContext *)alloc,buffer, inSize, inName);
425
- #endif
426
- return buffer;
427
- }
428
- #endif // HXCPP_ALIGN_ALLOC
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 + 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)
422
+ *buffer++ = (( (end+(IMMIX_LINE_LEN-1 ))>>IMMIX_LINE_BITS) -startRow) |
423
+ (inSize<<IMMIX_ALLOC_SIZE_SHIFT) |
424
+ hx::gMarkIDWithContainer ;
425
+ else
426
+ *buffer++ = (( (end+(IMMIX_LINE_LEN-1 ))>>IMMIX_LINE_BITS) -startRow) |
427
+ (inSize<<IMMIX_ALLOC_SIZE_SHIFT) |
428
+ hx::gMarkID ;
429
+
430
+ #if defined(HXCPP_GC_CHECK_POINTER) && defined(HXCPP_GC_DEBUG_ALWAYS_MOVE)
431
+ hx::GCOnNewPointer (buffer);
432
+ #endif
433
+
434
+ #ifdef HXCPP_TELEMETRY
435
+ __hxt_gc_alloc (buffer, inSize);
436
+ __hxt_gc_new ((hx::StackContext *)alloc,buffer, inSize, inName);
437
+ #endif
438
+ return buffer;
439
+ }
429
440
430
441
// Fall back to external method
431
442
void *result = alloc->CallAlloc (inSize, inContainer ? IMMIX_ALLOC_IS_CONTAINER : 0 );
0 commit comments