| 3714 | |
| 3715 | |
| 3716 | bool MoveBlocks(MoveBlockJob &inJob,BlockDataStats &ioStats) |
| 3717 | { |
| 3718 | BlockData *dest = 0; |
| 3719 | BlockDataInfo *destInfo = 0; |
| 3720 | unsigned int *destStarts = 0; |
| 3721 | int hole = -1; |
| 3722 | int holes = 0; |
| 3723 | int destPos = 0; |
| 3724 | int destLen = 0; |
| 3725 | |
| 3726 | int moveObjs = 0; |
| 3727 | int clearedBlocks = 0; |
| 3728 | |
| 3729 | while(true) |
| 3730 | { |
| 3731 | BlockDataInfo *from = inJob.getFrom(); |
| 3732 | if (!from) |
| 3733 | break; |
| 3734 | if (from->calcFragScore()>FRAG_THRESH) |
| 3735 | ioStats.fraggedBlocks--; |
| 3736 | ioStats.rowsInUse -= from->mUsedRows; |
| 3737 | if (!from->isEmpty()) |
| 3738 | ioStats.emptyBlocks ++; |
| 3739 | |
| 3740 | unsigned int *allocStart = from->allocStart; |
| 3741 | #ifdef SHOW_MEM_EVENTS |
| 3742 | //GCLOG("Move from %p (%d x %d)\n", from, from->mUsedRows, from->mHoles ); |
| 3743 | #endif |
| 3744 | |
| 3745 | const unsigned char *rowMarked = from->mPtr->mRowMarked; |
| 3746 | for(int r=IMMIX_HEADER_LINES;r<IMMIX_LINES;r++) |
| 3747 | { |
| 3748 | if (rowMarked[r]) |
| 3749 | { |
| 3750 | unsigned int starts = allocStart[r]; |
| 3751 | if (!starts) |
| 3752 | continue; |
| 3753 | for(int i=0;i<32;i++) |
| 3754 | { |
| 3755 | if ( starts & (1<<i)) |
| 3756 | { |
| 3757 | unsigned int *row = (unsigned int *)from->mPtr->mRow[r]; |
| 3758 | unsigned int &header = row[i]; |
| 3759 | |
| 3760 | if ((header&IMMIX_ALLOC_MARK_ID) == hx::gMarkID) |
| 3761 | { |
| 3762 | int size = ((header & IMMIX_ALLOC_SIZE_MASK) >> IMMIX_ALLOC_SIZE_SHIFT); |
| 3763 | int allocSize = size + sizeof(int); |
| 3764 | |
| 3765 | while(allocSize + ALIGN_PADDING(destPos)>destLen) |
| 3766 | { |
| 3767 | hole++; |
| 3768 | if (hole<holes) |
| 3769 | { |
| 3770 | destPos = destInfo->mRanges[hole].start; |
| 3771 | destLen = destInfo->mRanges[hole].length; |
| 3772 | } |
| 3773 | else |