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) {
99 IntHashSet * EPRecord::getReturnValueSet() {
103 return getSet(VC_FUNCOUTINDEX);
105 return getSet(VC_RMWOUTINDEX);
107 return getSet(VC_RFINDEX);
129 void EPRecord::print(int f) {
138 dprintf(f, "%s",eventToStr(event));
142 i=setarray[VC_RFINDEX];
145 i=setarray[VC_BASEINDEX];
148 i=setarray[VC_RMWOUTINDEX];
152 CGoalIterator *cit=completed->iterator();
154 while(cit->hasNext()) {
155 CGoal *goal=cit->next();
157 for(uint i=0;i<getNumFuncInputs();i++) {
158 dprintf(f,"%lu ", goal->getValue(i+VC_BASEINDEX));
160 dprintf(f,"=> %lu)", goal->getOutput());
170 IntIterator *it=i->iterator();
173 while(it->hasNext()) {
174 dprintf(f, "%lu ", it->next());
180 for(uint i=0;i<numinputs;i++) {
181 IntIterator *it=setarray[i]->iterator();
183 while(it->hasNext()) {
184 uint64_t v=it->next();
185 dprintf(f,"%lu ", v);
196 void EPRecord::print() {
197 model_print("%s",eventToStr(event));
199 model_print(" CR=%p ", this);
200 model_print(" NR=%p", nextRecord);
203 bool EPRecord::hasAddr(const void * addr) {
204 return getSet(VC_ADDRINDEX)->contains((uintptr_t)addr);
207 int EPRecord::getIndex(EPValue *val) {
208 for(unsigned int i=0;i<valuevector->size();i++) {
209 EPValue *epv=(*valuevector)[i];
216 int EPRecord::getIndex(uint64_t val) {
217 for(unsigned int i=0;i<valuevector->size();i++) {
218 EPValue *epv=(*valuevector)[i];
219 if (epv->getValue()==val)
225 bool EPRecord::hasValue(uint64_t val) {
226 for(unsigned int i=0;i<valuevector->size();i++) {
227 EPValue *epv=(*valuevector)[i];
228 if (epv->getValue()==val)
234 bool compatibleStoreLoad(EPRecord *store, EPRecord *load) {