]> foleosoft.com Git - QAnsel.git/commitdiff
Fri Aug 2 08:59:05 PM EDT 2024
authormiha-q <>
Sat, 3 Aug 2024 00:59:05 +0000 (20:59 -0400)
committermiha-q <>
Sat, 3 Aug 2024 00:59:05 +0000 (20:59 -0400)
src/bytecode.c

index 5413a98cbb76d738154d90a7d978df9b8ad33846..4cf466f0f2712ddb380d7b873e840cbf4289e4e3 100644 (file)
@@ -1155,6 +1155,7 @@ void qansel_reorder(QAnselContext* ctx, unsigned char* program, int programSize)
                ramInstrLen++;
                PC += next;
        }
+
        for (int i = 0; i < ramInstrLen; i++)
        {
                if (i == 0)
@@ -1216,7 +1217,6 @@ void qansel_reorder(QAnselContext* ctx, unsigned char* program, int programSize)
        {
                while (1)
                {
-                       head[reorid] = 0;
                        //find the next unchecked instruction
                        int found = -1;
                        int idx = head[reorid];
@@ -1275,13 +1275,27 @@ void qansel_reorder(QAnselContext* ctx, unsigned char* program, int programSize)
 
                                if (idx == -1)
                                {
+                                       //idx.next.prev = found
+                                       //found.next = head
+                                       //found.prev = -1
+                                       //head = found
                                        reordered[reorid][head[reorid]].prev = found;
                                        reordered[reorid][found].next = head[reorid];
                                        reordered[reorid][found].prev = -1;
                                        head[reorid] = found;
+                                       //printf("head: %i\n", found);
                                }
                                else
                                {
+                                       /*
+                                               [idx].next -> .prev <- o
+                                               found
+                                       
+                                       */
+                                       //idx.next.prev = found
+                                       //found.next = idx.next
+                                       //found.prev = idx
+                                       //idx.next = found
                                        reordered[reorid][ reordered[reorid][idx].next ].prev = found;
                                        reordered[reorid][found].next = reordered[reorid][idx].next;
                                        reordered[reorid][found].prev = idx;
@@ -1289,7 +1303,16 @@ void qansel_reorder(QAnselContext* ctx, unsigned char* program, int programSize)
                                }
                                if (reorid == 1)
                                {
+                                       /*
+                                       printf("%i\n", head[reorid]);
+                                       for (int i = 0; i < ramInstrLen; i++)
+                                       {
+                                               printf("%i -> %i\n", i, reordered[reorid][i].next);
+                                       }
+                                       printf("===========================\n");
+                                       */
                                        int tmpeff = qansel_efficiency(reordered[reorid], ramInstrLen, head[reorid]);
+                                       head[reorid] = 0; //correct?
                                        if (tmpeff >= efficiency)
                                        {
                                                efficiency = tmpeff;