Remove ancient hack that was emulating move semantics with reference counting.

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217808 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2014-09-15 19:20:52 +00:00
parent 85deed0525
commit 9d38b2f76c

View File

@ -37,29 +37,22 @@ typedef generic_gep_type_iterator<User::const_op_iterator> gep_type_iterator;
// stack, which causes the dtor to be run, which frees all the alloca'd memory.
//
class AllocaHolder {
friend class AllocaHolderHandle;
std::vector<void*> Allocations;
unsigned RefCnt;
std::vector<void *> Allocations;
public:
AllocaHolder() : RefCnt(0) {}
void add(void *mem) { Allocations.push_back(mem); }
~AllocaHolder() {
for (unsigned i = 0; i < Allocations.size(); ++i)
free(Allocations[i]);
AllocaHolder() {}
// Make this type move-only.
AllocaHolder(AllocaHolder &&RHS) : Allocations(std::move(RHS.Allocations)) {}
AllocaHolder &operator=(AllocaHolder &&RHS) {
Allocations = std::move(RHS.Allocations);
}
};
// AllocaHolderHandle gives AllocaHolder value semantics so we can stick it into
// a vector...
//
class AllocaHolderHandle {
AllocaHolder *H;
public:
AllocaHolderHandle() : H(new AllocaHolder()) { H->RefCnt++; }
AllocaHolderHandle(const AllocaHolderHandle &AH) : H(AH.H) { H->RefCnt++; }
~AllocaHolderHandle() { if (--H->RefCnt == 0) delete H; }
~AllocaHolder() {
for (void *Allocation : Allocations)
free(Allocation);
}
void add(void *mem) { H->add(mem); }
void add(void *Mem) { Allocations.push_back(Mem); }
};
typedef std::vector<GenericValue> ValuePlaneTy;
@ -75,7 +68,7 @@ struct ExecutionContext {
std::vector<GenericValue> VarArgs; // Values passed through an ellipsis
CallSite Caller; // Holds the call that called subframes.
// NULL if main func or debugger invoked fn
AllocaHolderHandle Allocas; // Track memory allocated by alloca
AllocaHolder Allocas; // Track memory allocated by alloca
};
// Interpreter - This class represents the entirety of the interpreter.