1 /* Copyright (c) 2015 Regents of the University of California
3 * Author: Brian Demsky <bdemsky@uci.edu>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
15 EPRecord::EPRecord(EventType _event, ExecPoint *_execpoint, EPValue *_branch, uintptr_t _offset, unsigned int _numinputs, uint _len, bool _anyvalue) :
16 valuevector(new ValueVector()),
17 execpoint(_execpoint),
20 setarray((IntHashSet **)model_malloc(sizeof(IntHashSet *)*(_numinputs+VC_BASEINDEX))),
26 jointhread(THREAD_ID_T_NONE),
27 numinputs(_numinputs+VC_BASEINDEX),
33 func_shares_goalset(false),
36 for(unsigned int i=0;i<numinputs;i++)
37 setarray[i]=new IntHashSet();
40 EPRecord::~EPRecord() {
41 if (!func_shares_goalset && (completed != NULL))
44 if (completed != NULL)
46 if (philooptable!=NULL) {
47 EPRecordIDIterator *rit=philooptable->iterator();
48 while(rit->hasNext()) {
49 struct RecordIDPair *val=rit->next();
58 const char * eventToStr(EventType event) {
101 IntHashSet * EPRecord::getReturnValueSet() {
105 return getSet(VC_FUNCOUTINDEX);
107 return getSet(VC_RMWOUTINDEX);
109 return getSet(VC_RFINDEX);
132 void EPRecord::print(int f) {
135 model_dprintf(f, "add");
137 model_dprintf(f, "exc");
139 model_dprintf(f, "cas");
141 model_dprintf(f, "%s",eventToStr(event));
145 i=setarray[VC_RFINDEX];
148 i=setarray[VC_BASEINDEX];
151 i=setarray[VC_RMWOUTINDEX];
155 CGoalIterator *cit=completed->iterator();
156 model_dprintf(f, "{");
157 while(cit->hasNext()) {
158 CGoal *goal=cit->next();
159 model_dprintf(f,"(");
160 for(uint i=0;i<getNumFuncInputs();i++) {
161 model_dprintf(f,"%llu ", goal->getValue(i+VC_BASEINDEX));
163 model_dprintf(f,"=> %llu)", goal->getOutput());
173 IntIterator *it=i->iterator();
174 model_dprintf(f, "{");
176 while(it->hasNext()) {
177 model_dprintf(f, "%llu ", it->next());
179 model_dprintf(f, "}");
183 for(uint i=0;i<numinputs;i++) {
184 IntIterator *it=setarray[i]->iterator();
185 model_dprintf(f,"{");
186 while(it->hasNext()) {
187 uint64_t v=it->next();
188 model_dprintf(f,"%llu ", v);
190 model_dprintf(f,"}");
198 void EPRecord::print() {
199 model_print("%s",eventToStr(event));
201 model_print(" CR=%p ", this);
202 model_print(" NR=%p", nextRecord);
205 bool EPRecord::hasAddr(const void * addr) {
206 return getSet(VC_ADDRINDEX)->contains((uintptr_t)addr);
209 int EPRecord::getIndex(EPValue *val) {
210 for(unsigned int i=0;i<valuevector->size();i++) {
211 EPValue *epv=(*valuevector)[i];
218 int EPRecord::getIndex(uint64_t val) {
219 for(unsigned int i=0;i<valuevector->size();i++) {
220 EPValue *epv=(*valuevector)[i];
221 if (epv->getValue()==val)
227 bool EPRecord::hasValue(uint64_t val) {
228 for(unsigned int i=0;i<valuevector->size();i++) {
229 EPValue *epv=(*valuevector)[i];
230 if (epv->getValue()==val)
236 bool compatibleStoreLoad(EPRecord *store, EPRecord *load) {