mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-12-18 20:06:15 +02:00
m1/perf/sched.c: added asserts and list poisoning
This commit is contained in:
parent
16b4a9a55b
commit
60cf6f5e9a
@ -22,6 +22,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <fpvm/is.h>
|
||||
#include <fpvm/fpvm.h>
|
||||
@ -135,6 +136,21 @@ static void get_registers(struct fpvm_fragment *fragment,
|
||||
* Use the naming conventions of include/linux/list.h
|
||||
*/
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static void list_poison(struct list *list)
|
||||
{
|
||||
list->next = list->prev = NULL;
|
||||
}
|
||||
|
||||
#else /* DEBUG */
|
||||
|
||||
#define list_poison(list)
|
||||
|
||||
#endif /* !DEBUG */
|
||||
|
||||
|
||||
static void list_init(struct list *list)
|
||||
{
|
||||
list->next = list->prev = list;
|
||||
@ -143,8 +159,10 @@ static void list_init(struct list *list)
|
||||
|
||||
static void list_del(struct list *item)
|
||||
{
|
||||
assert(item->next != item);
|
||||
item->prev->next = item->next;
|
||||
item->next->prev = item->prev;
|
||||
list_poison(item);
|
||||
}
|
||||
|
||||
|
||||
@ -186,7 +204,7 @@ static void list_concat(struct list *a, struct list *b)
|
||||
b->prev->next = a;
|
||||
a->prev = b->prev;
|
||||
}
|
||||
list_init(b);
|
||||
list_poison(b);
|
||||
}
|
||||
|
||||
|
||||
@ -249,12 +267,14 @@ static void put_reg(int vm_reg)
|
||||
return;
|
||||
|
||||
vm_idx = reg2idx(vm_reg);
|
||||
assert(sc->regs[vm_idx].refs);
|
||||
if (--sc->regs[vm_idx].refs)
|
||||
return;
|
||||
|
||||
Dprintf(" free reg %d\n", regs[vm_idx].pfpu_reg);
|
||||
|
||||
#ifdef REG_STATS
|
||||
assert(sc->curr_regs);
|
||||
sc->curr_regs--;
|
||||
#endif
|
||||
|
||||
@ -335,8 +355,6 @@ static struct vm_reg *add_data_ref(struct insn *insn, struct data_ref *ref,
|
||||
Dprintf("insn %lu: reg %d setter %lu unresolved %d\n",
|
||||
insn-sc->insns, reg_num, reg->setter-sc->insns,
|
||||
insn->unresolved);
|
||||
} else {
|
||||
list_init(&ref->more);
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
@ -428,6 +446,7 @@ static void issue(struct insn *insn, int cycle, unsigned *code)
|
||||
foreach (ref, &insn->dependants) {
|
||||
if (ref->insn->earliest <= end)
|
||||
ref->insn->earliest = end+1;
|
||||
assert(ref->insn->unresolved);
|
||||
if (!--ref->insn->unresolved) {
|
||||
Dprintf(" unlocked %lu -> %u\n", ref->insn-insns,
|
||||
ref->insn->earliest);
|
||||
@ -509,7 +528,7 @@ static int schedule(unsigned int *code)
|
||||
end = PFPU_PROGSIZE;
|
||||
while (i != end) {
|
||||
if (FIELD(code[i]).dest)
|
||||
last = i+1; /* @@@ ? */
|
||||
last = i+1;
|
||||
i++;
|
||||
}
|
||||
return last;
|
||||
|
Loading…
Reference in New Issue
Block a user