Implemented deserialization of references. References are handled

just like pointers, except that they cannot be backpatched.  This
means that references are essentially non-owning pointers where the
referred object must be deserialized prior to the reference being
deserialized.  Because of the nature of references, this ordering of
objects is always possible.

Fixed a bug in backpatching code (returning the backpatched pointer
would accidentally include a bit flag).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43570 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek
2007-10-31 19:58:32 +00:00
parent 8aac61cff0
commit eb9409dbb9
2 changed files with 34 additions and 6 deletions

View File

@ -115,7 +115,7 @@ void Deserializer::ReadUIntPtr(uintptr_t& PtrRef) {
BPatchEntry& E = BPatchMap[PtrId];
if (E.hasFinalPtr())
PtrRef = E.getRawPtr();
PtrRef = E.getFinalPtr();
else {
// Register backpatch. Check the freelist for a BPNode.
BPNode* N;
@ -132,6 +132,18 @@ void Deserializer::ReadUIntPtr(uintptr_t& PtrRef) {
}
}
uintptr_t Deserializer::ReadInternalRefPtr() {
unsigned PtrId = ReadInt();
assert (PtrId != 0 && "References cannot refer the NULL address.");
BPatchEntry& E = BPatchMap[PtrId];
assert (E.hasFinalPtr() &&
"Cannot backpatch references. Object must be already deserialized.");
return E.getFinalPtr();
}
void Deserializer::BPatchEntry::setFinalPtr(BPNode*& FreeList, void* P) {
assert (!hasFinalPtr());