#include "predicate.h"
-inline bool operator==(const predicate_expr& expr_A, const predicate_expr& expr_B)
+Predicate::Predicate(FuncInst * func_inst) :
+ func_inst(func_inst)
+{}
+
+unsigned int pred_expr_hash(struct pred_expr * expr) {
+ return (unsigned int)((uintptr_t)hash);
+}
+
+bool pred_expr_equal(struct pred_expr * p1, struct pred_expr * p2)
{
- if (expr_A.token != expr_B.token)
+ if (p1->token != p2->token)
return false;
-
- if (expr_A.token == EQUALITY && expr_A.location != expr_B.location)
+ if (p1->token == EQUALITY && p1->location != p2->location)
return false;
-
- if (expr_A.value != expr_B.value)
+ if (p1->value != p2->value)
return false;
-
return true;
}
-void Predicate::add_predicate(predicate_expr predicate)
+void Predicate::add_predicate(token_t token, void * location, bool value)
{
- ModelList<predicate_expr>::iterator it;
- for (it = predicates.begin(); it != predicates.end(); it++) {
- if (predicate == *it)
- return;
- }
-
- predicates.push_back(predicate);
+ struct pred_expr = {token, location, value};
+ predicates.add(&predicate);
}
+#ifndef __PREDICTAE_H__
+#define __PREDICATE_H__
+
#include "funcinst.h"
+unsigned int pred_expr_hash (struct pred_expr *);
+bool pred_expr_equal(struct pred_expr *, struct pred_expr *);
+typedef HashSet<struct pred_expr *, uintptr_t, 0, model_malloc, model_calloc, model_free, pred_expr_hash, pred_expr_equal> PredicateSet;
+
typedef enum predicate_token {
EQUALITY, NULLITY
} token_t;
* this load should read the same value as the last value
* read at memory location specified in predicate_expr.
*/
-struct predicate_expr {
+struct pred_expr {
token_t token;
void * location;
bool value;
};
+
class Predicate {
public:
- Predicate();
+ Predicate(FuncInst * func_inst);
~Predicate();
FuncInst * get_func_inst() { return func_inst; }
- ModelList<predicate_expr> * get_predicates() { return &predicates; }
- void add_predicate(predicate_expr predicate);
+ PredicateSet * get_predicates() { return &predicates; }
+ void add_predicate(token_t token, void * location, bool value);
MEMALLOC
private:
FuncInst * func_inst;
/* may have multiple precicates */
- ModelList<predicate_expr> predicates;
+ PredicateSet predicates;
+ ModelVector<Predicate *> children;
};
+
+#endif /* __PREDICATE_H__ */
pthread_mutex_init(p_mutex, NULL);
cdsc::snapcondition_variable *v = execution->getCondMap()->get(p_cond);
- cdsc::snapmutex *m = execution->getMutexMap()->get(p_mutex);
+// cdsc::snapmutex *m = execution->getMutexMap()->get(p_mutex);
model->switch_to_master(new ModelAction(NOOP, std::memory_order_seq_cst, v));
// v->wait(*m);
delete v;
execution->getCondMap()->remove(p_cond);
}
+ return 0;
}