| 163 | } |
| 164 | |
| 165 | void fxOptimize(txMachine* the) |
| 166 | { |
| 167 | txLinker* linker = (txLinker*)(the->context); |
| 168 | txInteger instanceCount = 0, instanceIndex; |
| 169 | txID keyCount = the->keyIndex, keyIndex; |
| 170 | txConflictTable** conflictTables = fxNewLinkerChunkClear(linker, keyCount * sizeof(txConflictTable*)); |
| 171 | txColorTable** colorTables = NULL; |
| 172 | txFlag* flags = fxNewLinkerChunk(linker, keyCount * sizeof(txFlag)); |
| 173 | txSlot* heap = the->firstHeap; |
| 174 | txLinkerProjection** projectionAddress = &linker->firstProjection; |
| 175 | txLinkerProjection* projection; |
| 176 | txInteger projectionIndex = 0, projectionCount, holes, color; |
| 177 | while (heap) { |
| 178 | txSlot* slot = heap + 1; |
| 179 | txSlot* limit = heap->value.reference; |
| 180 | projection = fxNewLinkerChunkClear(linker, sizeof(txLinkerProjection) + (mxPtrDiff(limit - slot) * sizeof(txInteger))); |
| 181 | projection->heap = heap; |
| 182 | projection->limit = limit; |
| 183 | *projectionAddress = projection; |
| 184 | projectionAddress = &projection->nextProjection; |
| 185 | while (slot < limit) { |
| 186 | if (slot->kind == XS_INSTANCE_KIND) |
| 187 | instanceCount++; |
| 188 | slot++; |
| 189 | } |
| 190 | heap = heap->next; |
| 191 | } |
| 192 | colorTables = fxNewLinkerChunkClear(linker, instanceCount * sizeof(txColorTable*)); |
| 193 | instanceIndex = 0; |
| 194 | heap = the->firstHeap; |
| 195 | while (heap) { |
| 196 | txSlot* slot = heap + 1; |
| 197 | txSlot* limit = heap->value.reference; |
| 198 | while (slot < limit) { |
| 199 | if (slot->kind == XS_INSTANCE_KIND) { |
| 200 | txColorTable* colorTable = colorTables[instanceIndex] = fxNewColorTable(linker, slot); |
| 201 | txSlot* property = slot->next; |
| 202 | while (property) { |
| 203 | if (((property->flag & XS_INTERNAL_FLAG) == 0) && (property->ID != XS_NO_ID)) { |
| 204 | txColorEntry* colorEntry = fxNewColorEntry(linker, property); |
| 205 | txConflictEntry* conflictEntry = fxNewConflictEntry(linker, colorTable); |
| 206 | txID id = property->ID; |
| 207 | txConflictTable* conflictTable = conflictTables[id]; |
| 208 | if (!conflictTable) { |
| 209 | conflictTable = conflictTables[id] = fxNewConflictTable(linker, id); |
| 210 | } |
| 211 | fxLinkColorEntry(colorTable, colorEntry); |
| 212 | fxLinkConflictEntry(conflictTable, conflictEntry); |
| 213 | colorEntry->conflictTable = conflictTable; |
| 214 | } |
| 215 | property = property->next; |
| 216 | } |
| 217 | instanceIndex++; |
| 218 | } |
| 219 | slot++; |
| 220 | } |
| 221 | heap = heap->next; |
| 222 | } |
no test coverage detected