Changeset b4aa1ab
- Timestamp:
- Dec 13, 2020, 10:10:15 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 55885dd
- Parents:
- 4803a901
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/heap.cfa
r4803a901 rb4aa1ab 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 11 07:36:34202013 // Update Count : 9 7012 // Last Modified On : Sun Dec 13 22:04:10 2020 13 // Update Count : 984 14 14 // 15 15 … … 490 490 // If the size requested is bigger than the current remaining storage, increase the size of the heap. 491 491 492 size_t increase = ceiling2( size > heapExpand ? size : heapExpand, libAlign());492 size_t increase = ceiling2( size > heapExpand ? size : heapExpand, pageSize ); 493 493 if ( sbrk( increase ) == (void *)-1 ) { // failed, no memory ? 494 494 unlock( extlock ); 495 495 abort( NO_MEMORY_MSG, size ); // give up 496 } // if 497 if ( mprotect( (char *)heapEnd + heapRemaining, increase, PROT_READ | PROT_WRITE | PROT_EXEC ) ) { 498 enum { BufferSize = 128 }; 499 char helpText[BufferSize]; 500 // Do not call strerror( errno ) as it may call malloc. 501 int len = snprintf( helpText, BufferSize, "internal error, extend(), mprotect failure, heapEnd:%p size:%zd, errno:%d.", heapEnd, increase, errno ); 502 __cfaabi_bits_write( STDERR_FILENO, helpText, len ); 496 503 } // if 497 504 #ifdef __STATISTICS__ … … 568 575 #endif // __STATISTICS__ 569 576 570 block = (HeapManager.Storage *)mmap( 0, tsize, PROT_READ | PROT_WRITE , MAP_PRIVATE | MAP_ANONYMOUS, mmapFd, 0 );577 block = (HeapManager.Storage *)mmap( 0, tsize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, mmapFd, 0 ); 571 578 if ( block == (HeapManager.Storage *)MAP_FAILED ) { // failed ? 572 579 if ( errno == ENOMEM ) abort( NO_MEMORY_MSG, tsize ); // no memory 573 580 // Do not call strerror( errno ) as it may call malloc. 574 abort( "(HeapManager &)0x%p.doMalloc() : internal error, mmap failure, size:%zu err or:%d.", &heapManager, tsize, errno );581 abort( "(HeapManager &)0x%p.doMalloc() : internal error, mmap failure, size:%zu errno:%d.", &heapManager, tsize, errno ); 575 582 } //if 576 583 #ifdef __CFA_DEBUG__ … … 669 676 for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0p; p = p->header.kind.real.next ) { 670 677 #else 671 // for ( HeapManager.Storage * p = top( freeLists[i].freeList ); p != 0p; p = (p)`next->top ) { 678 for(;;) { 679 // for ( HeapManager.Storage * p = top( freeLists[i].freeList ); p != 0p; p = (p)`next->top ) { 672 680 // for ( HeapManager.Storage * p = top( freeLists[i].freeList ); p != 0p; /* p = getNext( p )->top */) { 673 for ( HeapManager.Storage * p ;; /* p = getNext( p )->top */) { 674 HeapManager.Storage * temp = p->header.kind.real.next.top; // FIX ME: direct assignent fails, initialization works` 681 // HeapManager.Storage * temp = p->header.kind.real.next.top; // FIX ME: direct assignent fails, initialization works` 675 682 // typeof(p) temp = (( p )`next)->top; // FIX ME: direct assignent fails, initialization works` 676 683 // p = temp; … … 716 723 717 724 char * end = (char *)sbrk( 0 ); 718 heapBegin = heapEnd = sbrk( (char *)ceiling2( (long unsigned int)end, libAlign()) - end ); // move start of heap to multiple of alignment725 heapBegin = heapEnd = sbrk( (char *)ceiling2( (long unsigned int)end, pageSize ) - end ); // move start of heap to multiple of alignment 719 726 } // HeapManager 720 727
Note: See TracChangeset
for help on using the changeset viewer.