本文整理汇总了C++中PolyObject::ContainsForwardingPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ PolyObject::ContainsForwardingPtr方法的具体用法?C++ PolyObject::ContainsForwardingPtr怎么用?C++ PolyObject::ContainsForwardingPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PolyObject
的用法示例。
在下文中一共展示了PolyObject::ContainsForwardingPtr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ScanAddressesInRegion
void ScanAddress::ScanAddressesInRegion(PolyWord *region, PolyWord *end)
{
PolyWord *pt = region;
while (pt < end)
{
pt++; // Skip length word.
// pt actually points AT the object here.
PolyObject *obj = (PolyObject*)pt;
if (obj->ContainsForwardingPtr()) /* skip over moved object */
{
// We can now get multiple forwarding pointers as a result
// of applying ShareData repeatedly. Perhaps we should
// turn the forwarding pointers back into normal words in
// an extra pass.
while (obj->ContainsForwardingPtr())
obj = obj->GetForwardingPtr();
ASSERT(obj->ContainsNormalLengthWord());
CheckObject(obj);
pt += obj->Length();
}
else
{
ASSERT(obj->ContainsNormalLengthWord());
POLYUNSIGNED length = obj->Length();
if (pt+length > end)
Crash("Malformed object at %p - length %lu\n", pt, length);
if (length != 0)
ScanAddressesInObject(obj);
pt += length;
}
}
}
示例2: GetNewAddress
// Returns the new address if the argument is the address of an object that
// has moved, otherwise returns the original.
PolyWord SaveFixupAddress::GetNewAddress(PolyWord old)
{
if (old.IsTagged() || old == PolyWord::FromUnsigned(0) || gMem.IsIOPointer(old.AsAddress()))
return old; // Nothing to do.
// When we are updating addresses in the stack or in code segments we may have
// code pointers.
if (old.IsCodePtr())
{
// Find the start of the code segment
PolyObject *oldObject = ObjCodePtrToPtr(old.AsCodePtr());
// Calculate the byte offset of this value within the code object.
POLYUNSIGNED offset = old.AsCodePtr() - (byte*)oldObject;
PolyWord newObject = GetNewAddress(oldObject);
return PolyWord::FromCodePtr(newObject.AsCodePtr() + offset);
}
ASSERT(old.IsDataPtr());
PolyObject *obj = old.AsObjPtr();
if (obj->ContainsForwardingPtr()) // tombstone is a pointer to a moved object
{
PolyObject *newp = obj->GetForwardingPtr();
ASSERT (newp->ContainsNormalLengthWord());
return newp;
}
ASSERT (obj->ContainsNormalLengthWord()); // object is not moved
return old;
}
示例3: TestForScan
// Tests if this needs to be scanned. It marks it if it has not been marked
// unless it has to be scanned.
bool MTGCProcessMarkPointers::TestForScan(PolyWord *pt)
{
if ((*pt).IsTagged())
return false;
// This could contain a forwarding pointer if it points into an
// allocation area and has been moved by the minor GC.
// We have to be a little careful. Another thread could also
// be following any forwarding pointers here. However it's safe
// because they will update it with the same value.
PolyObject *obj = (*pt).AsObjPtr();
if (obj->ContainsForwardingPtr())
{
obj = FollowForwarding(obj);
*pt = obj;
}
if (gMem.LocalSpaceForAddress(obj) == 0)
return false; // Ignore it if it points to a permanent area
POLYUNSIGNED L = obj->LengthWord();
if (L & _OBJ_GC_MARK)
return false; // Already marked
if (debugOptions & DEBUG_GC_DETAIL)
Log("GC: Mark: %p %" POLYUFMT " %u\n", obj, OBJ_OBJECT_LENGTH(L), GetTypeBits(L));
if (OBJ_IS_BYTE_OBJECT(L))
{
obj->SetLengthWord(L | _OBJ_GC_MARK); // Mark it
return false; // We've done as much as we need
}
return true;
}
示例4: TestForScan
bool GetSharing::TestForScan(PolyWord *pt)
{
PolyObject *obj;
// This may be a forwarding pointer left over from a minor GC that did
// not complete or it may be a sharing chain pointer that we've set up.
while (1)
{
PolyWord p = *pt;
ASSERT(p.IsDataPtr());
obj = p.AsObjPtr();
PolyWord *lengthWord = ((PolyWord*)obj) - 1;
LocalMemSpace *space = gMem.LocalSpaceForAddress(lengthWord);
if (space == 0)
return false; // Ignore it if it points to a permanent area
if (space->bitmap.TestBit(space->wordNo(lengthWord)))
return false;
// Wasn't marked - must be a forwarding pointer.
if (obj->ContainsForwardingPtr())
{
obj = obj->GetForwardingPtr();
*pt = obj;
}
else break;
}
ASSERT(obj->ContainsNormalLengthWord());
totalVisited += 1;
totalSize += obj->Length() + 1;
return true;
}
示例5: SetBitmaps
static void SetBitmaps(LocalMemSpace *space, PolyWord *pt, PolyWord *top)
{
while (pt < top)
{
PolyObject *obj = (PolyObject*)++pt;
// If it has been copied by a minor collection skip it
if (obj->ContainsForwardingPtr())
{
obj = FollowForwarding(obj);
ASSERT(obj->ContainsNormalLengthWord());
pt += obj->Length();
}
else
{
POLYUNSIGNED L = obj->LengthWord();
POLYUNSIGNED n = OBJ_OBJECT_LENGTH(L);
if (L & _OBJ_GC_MARK)
{
obj->SetLengthWord(L & ~(_OBJ_GC_MARK));
POLYUNSIGNED bitno = space->wordNo(pt);
space->bitmap.SetBits(bitno - 1, n + 1);
if (OBJ_IS_MUTABLE_OBJECT(L))
space->m_marked += n + 1;
else
space->i_marked += n + 1;
if ((PolyWord*)obj <= space->fullGCLowerLimit)
space->fullGCLowerLimit = (PolyWord*)obj-1;
if (OBJ_IS_WEAKREF_OBJECT(L))
{
// Add this to the limits for the containing area.
PolyWord *baseAddr = (PolyWord*)obj;
PolyWord *startAddr = baseAddr-1; // Must point AT length word.
PolyWord *endObject = baseAddr + n;
if (startAddr < space->lowestWeak) space->lowestWeak = startAddr;
if (endObject > space->highestWeak) space->highestWeak = endObject;
}
}
pt += n;
}
}
}
示例6: GetNewAddress
// Returns the new address if the argument is the address of an object that
// has moved, otherwise returns the original.
PolyWord ProcessFixupAddress::GetNewAddress(PolyWord old)
{
if (old.IsTagged() || old == PolyWord::FromUnsigned(0) || gMem.IsIOPointer(old.AsAddress()))
return old; // Nothing to do.
// When we are updating addresses in the stack or in code segments we may have
// code pointers.
if (old.IsCodePtr())
{
// Find the start of the code segment
PolyObject *oldObject = ObjCodePtrToPtr(old.AsCodePtr());
// Calculate the byte offset of this value within the code object.
POLYUNSIGNED offset = old.AsCodePtr() - (byte*)oldObject;
PolyWord newObject = GetNewAddress(oldObject);
return PolyWord::FromCodePtr(newObject.AsCodePtr() + offset);
}
ASSERT(old.IsDataPtr());
PolyObject *obj = old.AsObjPtr();
POLYUNSIGNED L = obj->LengthWord();
// Generally each address will point to an object processed at a lower depth.
// The exception is if we have a cycle and have assigned the rest of the
// structure to a higher depth.
// N.B. We return the original address here but this could actually share
// with something else and not be retained.
if (OBJ_IS_DEPTH(L))
return old;
if (obj->ContainsForwardingPtr()) // tombstone is a pointer to a shared object
{
PolyObject *newp = obj->GetForwardingPtr();
// ASSERT (newp->ContainsNormalLengthWord());
return newp;
}
ASSERT (obj->ContainsNormalLengthWord()); // object is not shared
return old;
}