void ModelExecution::collectActions() {
//Compute minimal clock vector for all live threads
ClockVector *cvmin = computeMinimalCV();
- cvmin->print();
SnapVector<CycleNode *> * queue = new SnapVector<CycleNode *>();
modelclock_t maxtofree = priv->used_sequence_numbers - params->traceminsize;
islastact = !th->is_complete();
}
- if (act->is_read() && act->get_reads_from()->is_free()) {
- if (act->is_rmw()) {
- act->set_type(ATOMIC_WRITE);
- }
- removeAction(act);
- if (islastact) {
- fixupLastAct(act);
+ if (act->is_read()) {
+ if (act->get_reads_from()->is_free()) {
+ if (act->is_rmw()) {
+ //weaken to write
+ act->set_type(ATOMIC_WRITE);
+ } else {
+ removeAction(act);
+ if (islastact) {
+ fixupLastAct(act);
+ }
+ delete act;
+ continue;
+ }
}
- delete act;
+ }
+ const ModelAction *rel_fence =act->get_last_fence_release();
+ if (rel_fence != NULL) {
+ modelclock_t relfenceseq = rel_fence->get_seq_number();
+ thread_id_t relfence_tid = rel_fence->get_tid();
+ modelclock_t tid_clock = cvmin->getClock(relfence_tid);
+ //Remove references to irrelevant release fences
+ if (relfenceseq <= tid_clock)
+ act->set_last_fence_release(NULL);
}
}
for (;it != NULL;) {
}
if (act->is_read()) {
- if (act->is_rmw()) {
- act->set_type(ATOMIC_WRITE);
- } else if (act->get_reads_from()->is_free()) {
- removeAction(act);
- if (islastact) {
- fixupLastAct(act);
- }
- delete act;
- } else {
- const ModelAction *rel_fence =act->get_last_fence_release();
- if (rel_fence != NULL) {
- modelclock_t relfenceseq = rel_fence->get_seq_number();
- thread_id_t relfence_tid = rel_fence->get_tid();
- modelclock_t tid_clock = cvmin->getClock(relfence_tid);
- //Remove references to irrelevant release fences
- if (relfenceseq <= tid_clock)
- act->set_last_fence_release(NULL);
+ if (act->get_reads_from()->is_free()) {
+ if (act->is_rmw()) {
+ act->set_type(ATOMIC_WRITE);
+ } else {
+ removeAction(act);
+ if (islastact) {
+ fixupLastAct(act);
+ }
+ delete act;
+ continue;
}
}
} else if (act->is_free()) {
fixupLastAct(act);
}
delete act;
+ continue;
} else if (act->is_write()) {
//Do nothing with write that hasn't been marked to be freed
} else if (islastact) {
if (actseq <= tid_clock) {
removeAction(act);
delete act;
+ continue;
}
} else {
//need to deal with lock, annotation, wait, notify, thread create, start, join, yield, finish, nops
if (lastlock != act) {
removeAction(act);
delete act;
+ continue;
}
} else if (act->is_create()) {
if (act->get_thread_operand()->is_complete()) {
removeAction(act);
delete act;
+ continue;
}
} else {
removeAction(act);
delete act;
+ continue;
+ }
+ const ModelAction *rel_fence =act->get_last_fence_release();
+ if (rel_fence != NULL) {
+ modelclock_t relfenceseq = rel_fence->get_seq_number();
+ thread_id_t relfence_tid = rel_fence->get_tid();
+ modelclock_t tid_clock = cvmin->getClock(relfence_tid);
+ //Remove references to irrelevant release fences
+ if (relfenceseq <= tid_clock)
+ act->set_last_fence_release(NULL);
}
+
}
}
resize(capacity << 1);
struct hashlistnode<_Key, _Val> *search;
+ struct hashlistnode<_Key, _Val> *first = NULL;
- unsigned int index = hash_function(key);
+ unsigned int index = hash_function(key) & capacitymask;
+ unsigned int oindex = index;
do {
- index &= capacitymask;
search = &table[index];
if (!search->key) {
//key is null, probably done
- break;
+ if (!search->val)
+ break;
+ if (first == NULL)
+ first = search;
}
if (equals(search->key, key)) {
search->val = val;
return;
}
- index++;
+ index = (index + 1) & capacitymask;
+ if (index == oindex) {
+ if (first == NULL)
+ exit(-1);
+ break;
+ }
} while (true);
- search->key = key;
- search->val = val;
+ if (first != NULL) {
+ first->key = key;
+ first->val = val;
+ } else {
+ search->key = key;
+ search->val = val;
+ }
size++;
}
}
unsigned int oindex = hash_function(key) & capacitymask;
- unsigned int index=oindex;
+ unsigned int index = oindex;
do {
search = &table[index];
if (!search->key) {