forked from OSchip/llvm-project
Revised implementation of BatchReadOwnedPtrs() that deserializes an
array of pointers to not allocate a second array to contain the pointer ids. Fixed bug in the same member function where deserialized pointers were not being registered with the backpatcher. llvm-svn: 43855
This commit is contained in:
parent
766fc8c14a
commit
8f74abd34a
|
@ -168,17 +168,20 @@ public:
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs) {
|
||||
llvm::SmallVector<unsigned,20> PtrIDs;
|
||||
PtrIDs.reserve(NumPtrs);
|
||||
|
||||
void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, bool AutoRegister=true) {
|
||||
for (unsigned i = 0; i < NumPtrs; ++i)
|
||||
PtrIDs.push_back(ReadInt());
|
||||
|
||||
for (unsigned i = 0; i < NumPtrs; ++i)
|
||||
Ptrs[i] = PtrIDs[i] ? SerializeTrait<T>::Materialize(*this) : NULL;
|
||||
}
|
||||
reinterpret_cast<uintptr_t&>(Ptrs[i]) = ReadInt();
|
||||
|
||||
for (unsigned i = 0; i < NumPtrs; ++i) {
|
||||
unsigned PtrID = reinterpret_cast<uintptr_t>(Ptrs[i]);
|
||||
T* p = PtrID ? SerializeTrait<T>::Materialize(*this) : NULL;
|
||||
|
||||
if (PtrID && AutoRegister)
|
||||
RegisterPtr(PtrID,p);
|
||||
|
||||
Ptrs[i] = p;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) {
|
||||
|
|
Loading…
Reference in New Issue