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