aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/Core/Memory.cpp
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2018-09-12 14:58:11 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2020-02-19 12:05:22 +0000
commit9cfa329a77d3dfec4746ca307c6da1b3e904cbfa (patch)
treec9379a0ab0b5afdf740fae0a01c67bf76d061d86 /lib/Core/Memory.cpp
parent86ab439d589d0afb1b710ef58296d07a263092e3 (diff)
downloadklee-9cfa329a77d3dfec4746ca307c6da1b3e904cbfa.tar.gz
Use `ref<>` for UpdateNode
Remove additional reference counting as part of UpdateNodeList and UpdateNode. Simplifies code.
Diffstat (limited to 'lib/Core/Memory.cpp')
-rw-r--r--lib/Core/Memory.cpp35
1 files changed, 5 insertions, 30 deletions
diff --git a/lib/Core/Memory.cpp b/lib/Core/Memory.cpp
index c7e7a928..37e6646b 100644
--- a/lib/Core/Memory.cpp
+++ b/lib/Core/Memory.cpp
@@ -11,7 +11,6 @@
#include "Context.h"
#include "MemoryManager.h"
-#include "ObjectHolder.h"
#include "klee/Expr/ArrayCache.h"
#include "klee/Expr/Expr.h"
@@ -42,27 +41,6 @@ namespace {
/***/
-ObjectHolder::ObjectHolder(const ObjectHolder &b) : os(b.os) {
- if (os) ++os->refCount;
-}
-
-ObjectHolder::ObjectHolder(ObjectState *_os) : os(_os) {
- if (os) ++os->refCount;
-}
-
-ObjectHolder::~ObjectHolder() {
- if (os && --os->refCount==0) delete os;
-}
-
-ObjectHolder &ObjectHolder::operator=(const ObjectHolder &b) {
- if (b.os) ++b.os->refCount;
- if (os && --os->refCount==0) delete os;
- os = b.os;
- return *this;
-}
-
-/***/
-
int MemoryObject::counter = 0;
MemoryObject::~MemoryObject() {
@@ -96,7 +74,6 @@ void MemoryObject::getAllocInfo(std::string &result) const {
ObjectState::ObjectState(const MemoryObject *mo)
: copyOnWriteOwner(0),
- refCount(0),
object(mo),
concreteStore(new uint8_t[mo->size]),
concreteMask(0),
@@ -118,7 +95,6 @@ ObjectState::ObjectState(const MemoryObject *mo)
ObjectState::ObjectState(const MemoryObject *mo, const Array *array)
: copyOnWriteOwner(0),
- refCount(0),
object(mo),
concreteStore(new uint8_t[mo->size]),
concreteMask(0),
@@ -134,7 +110,6 @@ ObjectState::ObjectState(const MemoryObject *mo, const Array *array)
ObjectState::ObjectState(const ObjectState &os)
: copyOnWriteOwner(0),
- refCount(0),
object(os.object),
concreteStore(new uint8_t[os.size]),
concreteMask(os.concreteMask ? new BitArray(*os.concreteMask, os.size) : 0),
@@ -188,10 +163,10 @@ const UpdateList &ObjectState::getUpdates() const {
// FIXME: We should be able to do this more efficiently, we just need to be
// careful to get the interaction with the cache right. In particular we
// should avoid creating UpdateNode instances we never use.
- unsigned NumWrites = updates.head ? updates.head->getSize() : 0;
+ unsigned NumWrites = updates.head.isNull() ? 0 : updates.head->getSize();
std::vector< std::pair< ref<Expr>, ref<Expr> > > Writes(NumWrites);
- const UpdateNode *un = updates.head;
- for (unsigned i = NumWrites; i != 0; un = un->next) {
+ const auto *un = updates.head.get();
+ for (unsigned i = NumWrites; i != 0; un = un->next.get()) {
--i;
Writes[i] = std::make_pair(un->index, un->value);
}
@@ -257,7 +232,7 @@ void ObjectState::makeConcrete() {
}
void ObjectState::makeSymbolic() {
- assert(!updates.head &&
+ assert(updates.head.isNull() &&
"XXX makeSymbolic of objects with symbolic values is unsupported");
// XXX simplify this, can just delete various arrays I guess
@@ -612,7 +587,7 @@ void ObjectState::print() const {
}
llvm::errs() << "\tUpdates:\n";
- for (const UpdateNode *un=updates.head; un; un=un->next) {
+ for (const auto *un = updates.head.get(); un; un = un->next.get()) {
llvm::errs() << "\t\t[" << un->index << "] = " << un->value << "\n";
}
}