Changeset f76ff0b for libcfa


Ignore:
Timestamp:
Sep 2, 2020, 1:13:28 PM (5 years ago)
Author:
m3zulfiq <m3zulfiq@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
3a4834b3, 73f1b1c
Parents:
f6fe597
Message:

alloc2.txt: added expected output file for test alloc2.cfa. heap.cfa: removed alignment bugs from realloc and resize with alignment. stdlib.hfa: removed debug prints from alloc interface. alloc2.cfa, malloc.cfa: uncommented tests that were previously commented because of a bug in realloc and resize.

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    rf6fe597 rf76ff0b  
    12391239        size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket
    12401240
    1241         if ( oalign <= nalign && (uintptr_t)oaddr % nalign == 0 ) { // <= alignment and new alignment happens to match
    1242                 if ( oalign > libAlign() ) {                                    // fake header ?
    1243                         headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    1244                 } // if
     1241        if ( oalign == nalign && size <= odsize && odsize <= size * 2 ) { // <= alignment and new alignment are same, allow 50% wasted storage for smaller size
     1242                header->kind.real.blockSize &= -2;                      // turn off 0 fill
     1243                header->kind.real.size = size;                          // reset allocation size
     1244                return oaddr;
     1245        } // if
     1246        if ( oalign < nalign && (uintptr_t)oaddr % nalign == 0 && oalign > libAlign() ) { // <= alignment and new alignment happens to match, and oaddr has a fake header
     1247                headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    12451248                if ( size <= odsize && odsize <= size * 2 ) {   // allow 50% wasted storage for smaller size
    12461249                        header->kind.real.blockSize &= -2;                      // turn off 0 fill
     
    12821285        headers( "realloc", oaddr, header, freeElem, bsize, oalign );
    12831286
    1284         if ( oalign <= nalign && (uintptr_t)oaddr % nalign == 0 ) { // <= alignment and new alignment happens to match
    1285                 if ( oalign > libAlign() ) {                                    // fake header ?
    1286                         headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    1287                 } // if
     1287        if ( oalign == nalign ) { // <= alignment and new alignment are same
     1288                return realloc( oaddr, size );
     1289        } // if
     1290        if ( oalign < nalign && (uintptr_t)oaddr % nalign == 0 && oalign > libAlign() ) { // <= alignment and new alignment happens to match, and oaddr has a fake header
     1291                headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    12881292                return realloc( oaddr, size );
    12891293        } // if
  • libcfa/src/stdlib.hfa

    rf6fe597 rf76ff0b  
    179179
    180180                if ( Resize ) {
    181 //printf("1. $alloc_internal got: %p %p %lu %lu\n", Resize, Realloc, Align, Dim); // these prints are temporary
    182181                        ptr = (T*) (void *) resize( (void *)Resize, Align, Dim * size );
    183182                } else if ( Realloc ) {
    184183                        if (Fill.tag != '0') copy_end = min(malloc_size( Realloc ), Dim * size);
    185 //printf("2. $alloc_internal got: %p %p %lu %lu\n", Resize, Realloc, Align, Dim);
    186184                        ptr = (T*) (void *) realloc( (void *)Realloc, Align, Dim * size );
    187185                } else {
    188 //printf("3. $alloc_internal got: %p %p %lu %lu\n", Resize, Realloc, Align, Dim);
    189186                        ptr = (T*) (void *) memalign( Align, Dim * size );
    190187                }
Note: See TracChangeset for help on using the changeset viewer.