[vm] Rename RawObject::Size to RawObject::HeapSize.

To avoid confusion between the heap size (includes header and rounding up) and number-of-elements size or payload size.

Change-Id: I714c4e8cec92d7ef963de39474d2a1bb23e5b4a3
Reviewed-on: https://dart-review.googlesource.com/c/92400
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Aart Bik <ajcbik@google.com>
This commit is contained in:
Ryan Macnak
2019-02-08 18:48:46 +00:00
committed by commit-bot@chromium.org
parent d136a35244
commit 128139be71
19 changed files with 92 additions and 95 deletions
+2 -2
View File
@@ -106,7 +106,7 @@ void CodeRelocator::FindInstructionAndCallLimits() {
for (intptr_t i = 0; i < code_objects_->length(); ++i) {
current_caller = (*code_objects_)[i];
const intptr_t size = current_caller.instructions()->Size();
const intptr_t size = current_caller.instructions()->HeapSize();
if (size > max_instructions_size_) {
max_instructions_size_ = size;
}
@@ -181,7 +181,7 @@ bool CodeRelocator::AddInstructionsToText(RawCode* code) {
}
text_offsets_.Insert({instructions, next_text_offset_});
commands_->Add(ImageWriterCommand(next_text_offset_, code));
next_text_offset_ += instructions->Size();
next_text_offset_ += instructions->HeapSize();
return true;
}
+2 -2
View File
@@ -60,7 +60,7 @@ static RawObject* GetForwardedObject(RawObject* object) {
}
static void ForwardObjectTo(RawObject* before_obj, RawObject* after_obj) {
const intptr_t size_before = before_obj->Size();
const intptr_t size_before = before_obj->HeapSize();
uword corpse_addr = reinterpret_cast<uword>(before_obj) - kHeapObjectTag;
ForwardingCorpse* forwarder =
@@ -70,7 +70,7 @@ static void ForwardObjectTo(RawObject* before_obj, RawObject* after_obj) {
FATAL("become: ForwardObjectTo failure.");
}
// Still need to be able to iterate over the forwarding corpse.
const intptr_t size_after = before_obj->Size();
const intptr_t size_after = before_obj->HeapSize();
if (size_before != size_after) {
FATAL("become: Before and after sizes do not match.");
}
+1 -1
View File
@@ -25,7 +25,7 @@ class ForwardingCorpse {
RawObject* target() const { return target_; }
void set_target(RawObject* target) { target_ = target; }
intptr_t Size() {
intptr_t HeapSize() {
intptr_t size = RawObject::SizeTag::decode(tags_);
if (size != 0) return size;
return *SizeAddress();
+2 -2
View File
@@ -425,7 +425,7 @@ uword CompactorTask::PlanBlock(uword first_object,
uword current = first_object;
while (current < block_end) {
RawObject* obj = RawObject::FromAddr(current);
intptr_t size = obj->Size();
intptr_t size = obj->HeapSize();
if (obj->IsMarked()) {
forwarding_block->RecordLive(current, size);
ASSERT(static_cast<intptr_t>(forwarding_block->Lookup(current)) ==
@@ -455,7 +455,7 @@ uword CompactorTask::SlideBlock(uword first_object,
uword old_addr = first_object;
while (old_addr < block_end) {
RawObject* old_obj = RawObject::FromAddr(old_addr);
intptr_t size = old_obj->Size();
intptr_t size = old_obj->HeapSize();
if (old_obj->IsMarked()) {
uword new_addr = forwarding_block->Lookup(old_addr);
if (new_addr != free_current_) {
+7 -7
View File
@@ -97,7 +97,7 @@ uword FreeList::TryAllocateLocked(intptr_t size, bool is_protected) {
// the call to SplitElementAfterAndEnqueue.
// If the remainder size is zero, only the element itself needs to
// be made writable.
intptr_t remainder_size = element->Size() - size;
intptr_t remainder_size = element->HeapSize() - size;
intptr_t region_size =
size + FreeListElement::HeaderSizeFor(remainder_size);
VirtualMemory::Protect(reinterpret_cast<void*>(element), region_size,
@@ -121,10 +121,10 @@ uword FreeList::TryAllocateLocked(intptr_t size, bool is_protected) {
// reset the search budget.
intptr_t tries_left = freelist_search_budget_ + (size >> kWordSizeLog2);
while (current != NULL) {
if (current->Size() >= size) {
if (current->HeapSize() >= size) {
// Found an element large enough to hold the requested size. Dequeue,
// split and enqueue the remainder.
intptr_t remainder_size = current->Size() - size;
intptr_t remainder_size = current->HeapSize() - size;
intptr_t region_size =
size + FreeListElement::HeaderSizeFor(remainder_size);
if (is_protected) {
@@ -306,10 +306,10 @@ void FreeList::PrintLarge() const {
MallocDirectChainedHashMap<NumbersKeyValueTrait<IntptrPair> > map;
FreeListElement* node;
for (node = free_lists_[kNumLists]; node != NULL; node = node->next()) {
IntptrPair* pair = map.Lookup(node->Size());
IntptrPair* pair = map.Lookup(node->HeapSize());
if (pair == NULL) {
large_sizes += 1;
map.Insert(IntptrPair(node->Size(), 1));
map.Insert(IntptrPair(node->HeapSize(), 1));
} else {
pair->set_second(pair->second() + 1);
}
@@ -345,7 +345,7 @@ void FreeList::SplitElementAfterAndEnqueue(FreeListElement* element,
// Precondition required by AsElement and EnqueueElement: either
// element->Size() == size, or else the (page containing the) header of
// the remainder element starting at element + size is writable.
intptr_t remainder_size = element->Size() - size;
intptr_t remainder_size = element->HeapSize() - size;
if (remainder_size == 0) return;
uword remainder_address = reinterpret_cast<uword>(element) + size;
@@ -379,7 +379,7 @@ FreeListElement* FreeList::TryAllocateLargeLocked(intptr_t minimum_size) {
freelist_search_budget_ + (minimum_size >> kWordSizeLog2);
while (current != NULL) {
FreeListElement* next = current->next();
if (current->Size() >= minimum_size) {
if (current->HeapSize() >= minimum_size) {
if (previous == NULL) {
free_lists_[kNumLists] = next;
} else {
+1 -1
View File
@@ -27,7 +27,7 @@ class FreeListElement {
void set_next(FreeListElement* next) { next_ = next; }
intptr_t Size() {
intptr_t HeapSize() {
intptr_t size = RawObject::SizeTag::decode(tags_);
if (size != 0) return size;
return *SizeAddress();
+1 -1
View File
@@ -71,7 +71,7 @@ void Heap::MakeTLABIterable(Thread* thread) {
if (size >= kObjectAlignment) {
// ForwardingCorpse(forwarding to default null) will work as filler.
ForwardingCorpse::AsForwarder(start, size);
ASSERT(RawObject::FromAddr(start)->Size() == size);
ASSERT(RawObject::FromAddr(start)->HeapSize() == size);
}
}
+2 -2
View File
@@ -310,7 +310,7 @@ class MarkingVisitorBase : public ObjectPointerVisitor {
!raw_key->IsMarked()) {
// Key was white. Enqueue the weak property.
EnqueueWeakProperty(raw_weak);
return raw_weak->Size();
return raw_weak->HeapSize();
}
// Key is gray or black. Make the weak property black.
return raw_weak->VisitPointersNonvirtual(this);
@@ -322,7 +322,7 @@ class MarkingVisitorBase : public ObjectPointerVisitor {
ASSERT(raw_obj->IsInstructions());
RawInstructions* instr = static_cast<RawInstructions*>(raw_obj);
if (TryAcquireMarkBit(instr)) {
intptr_t size = instr->Size();
intptr_t size = instr->HeapSize();
marked_bytes_ += size;
NOT_IN_PRODUCT(UpdateLiveOld(kInstructionsCid, size));
}
+4 -4
View File
@@ -113,7 +113,7 @@ void HeapPage::VisitObjects(ObjectVisitor* visitor) const {
while (obj_addr < end_addr) {
RawObject* raw_obj = RawObject::FromAddr(obj_addr);
visitor->VisitObject(raw_obj);
obj_addr += raw_obj->Size();
obj_addr += raw_obj->HeapSize();
}
ASSERT(obj_addr == end_addr);
}
@@ -197,7 +197,7 @@ RawObject* HeapPage::FindObject(FindObjectVisitor* visitor) const {
if (visitor->VisitRange(obj_addr, end_addr)) {
while (obj_addr < end_addr) {
RawObject* raw_obj = RawObject::FromAddr(obj_addr);
uword next_obj_addr = obj_addr + raw_obj->Size();
uword next_obj_addr = obj_addr + raw_obj->HeapSize();
if (visitor->VisitRange(obj_addr, next_obj_addr) &&
raw_obj->FindObject(visitor)) {
return raw_obj; // Found object, return it.
@@ -860,7 +860,7 @@ class HeapMapAsJSONVisitor : public ObjectVisitor {
public:
explicit HeapMapAsJSONVisitor(JSONArray* array) : array_(array) {}
virtual void VisitObject(RawObject* obj) {
array_->AddValue(obj->Size() / kObjectAlignment);
array_->AddValue(obj->HeapSize() / kObjectAlignment);
array_->AddValue(obj->GetClassId());
}
@@ -1297,7 +1297,7 @@ uword PageSpace::TryAllocateDataBumpInternal(intptr_t size,
return TryAllocateInFreshPage(size, HeapPage::kData, growth_policy,
is_locked);
}
intptr_t block_size = block->Size();
intptr_t block_size = block->HeapSize();
if (remaining > 0) {
if (is_locked) {
freelist_[HeapPage::kData].FreeLocked(bump_top_, remaining);
+4 -4
View File
@@ -134,7 +134,7 @@ class ScavengerVisitor : public ObjectPointerVisitor {
// Get the new location of the object.
new_addr = ForwardedAddr(header);
} else {
intptr_t size = raw_obj->Size();
intptr_t size = raw_obj->HeapSize();
NOT_IN_PRODUCT(intptr_t cid = raw_obj->GetClassId());
NOT_IN_PRODUCT(ClassTable* class_table = isolate()->class_table());
// Check whether object should be promoted.
@@ -768,7 +768,7 @@ uword Scavenger::ProcessWeakProperty(RawWeakProperty* raw_weak,
if (!IsForwarding(header)) {
// Key is white. Enqueue the weak property.
EnqueueWeakProperty(raw_weak);
return raw_weak->Size();
return raw_weak->HeapSize();
}
}
// Key is gray or black. Make the weak property black.
@@ -892,7 +892,7 @@ void Scavenger::VisitObjects(ObjectVisitor* visitor) const {
while (cur < top_) {
RawObject* raw_obj = RawObject::FromAddr(cur);
visitor->VisitObject(raw_obj);
cur += raw_obj->Size();
cur += raw_obj->HeapSize();
}
}
@@ -907,7 +907,7 @@ RawObject* Scavenger::FindObject(FindObjectVisitor* visitor) const {
if (visitor->VisitRange(cur, top_)) {
while (cur < top_) {
RawObject* raw_obj = RawObject::FromAddr(cur);
uword next = cur + raw_obj->Size();
uword next = cur + raw_obj->HeapSize();
if (visitor->VisitRange(cur, next) && raw_obj->FindObject(visitor)) {
return raw_obj; // Found object, return it.
}
+6 -6
View File
@@ -34,10 +34,10 @@ bool GCSweeper::SweepPage(HeapPage* page, FreeList* freelist, bool locked) {
if (raw_obj->IsMarked()) {
// Found marked object. Clear the mark bit and update swept bytes.
raw_obj->ClearMarkBit();
obj_size = raw_obj->Size();
obj_size = raw_obj->HeapSize();
used_in_bytes += obj_size;
} else {
uword free_end = current + raw_obj->Size();
uword free_end = current + raw_obj->HeapSize();
while (free_end < end) {
RawObject* next_obj = RawObject::FromAddr(free_end);
if (next_obj->IsMarked()) {
@@ -45,7 +45,7 @@ bool GCSweeper::SweepPage(HeapPage* page, FreeList* freelist, bool locked) {
break;
}
// Expand the free block by the size of this object.
free_end += next_obj->Size();
free_end += next_obj->HeapSize();
}
obj_size = free_end - current;
if (is_executable) {
@@ -86,17 +86,17 @@ intptr_t GCSweeper::SweepLargePage(HeapPage* page) {
ASSERT(HeapPage::Of(raw_obj) == page);
if (raw_obj->IsMarked()) {
raw_obj->ClearMarkBit();
words_to_end = (raw_obj->Size() >> kWordSizeLog2);
words_to_end = (raw_obj->HeapSize() >> kWordSizeLog2);
}
#ifdef DEBUG
// String::MakeExternal and Array::MakeFixedLength create trailing filler
// objects, but they are always unreachable. Verify that they are not marked.
uword current = RawObject::ToAddr(raw_obj) + raw_obj->Size();
uword current = RawObject::ToAddr(raw_obj) + raw_obj->HeapSize();
uword end = page->object_end();
while (current < end) {
RawObject* cur_obj = RawObject::FromAddr(current);
ASSERT(!cur_obj->IsMarked());
intptr_t obj_size = cur_obj->Size();
intptr_t obj_size = cur_obj->HeapSize();
memset(reinterpret_cast<void*>(current), Heap::kZapByte, obj_size);
current += obj_size;
}
+14 -19
View File
@@ -43,7 +43,7 @@ intptr_t ObjectOffsetTrait::Hashcode(Key key) {
ASSERT(!obj->IsSmi());
uword body = RawObject::ToAddr(obj) + sizeof(RawObject);
uword end = RawObject::ToAddr(obj) + obj->Size();
uword end = RawObject::ToAddr(obj) + obj->HeapSize();
uint32_t hash = obj->GetClassId();
// Don't include the header. Objects in the image are pre-marked, but objects
@@ -65,8 +65,8 @@ bool ObjectOffsetTrait::IsKeyEqual(Pair pair, Key key) {
return false;
}
intptr_t heap_size = a->Size();
if (b->Size() != heap_size) {
intptr_t heap_size = a->HeapSize();
if (b->HeapSize() != heap_size) {
return false;
}
@@ -106,7 +106,7 @@ void ImageWriter::PrepareForSerialization(
RawInstructions* instructions = Code::InstructionsOf(code);
const intptr_t offset = next_text_offset_;
instructions_.Add(InstructionsData(instructions, code, offset));
next_text_offset_ += instructions->Size();
next_text_offset_ += instructions->HeapSize();
ASSERT(heap_->GetObjectId(instructions) == 0);
heap_->SetObjectId(instructions, offset);
break;
@@ -141,7 +141,7 @@ void ImageWriter::SetupShared(ObjectOffsetMap* map, const void* shared_image) {
pair.object = raw_obj;
pair.offset = offset;
map->Insert(pair);
obj_addr += raw_obj->Size();
obj_addr += raw_obj->HeapSize();
}
ASSERT(obj_addr == end_addr);
}
@@ -172,7 +172,7 @@ int32_t ImageWriter::GetTextOffsetFor(RawInstructions* instructions,
offset = next_text_offset_;
heap_->SetObjectId(instructions, offset);
next_text_offset_ += instructions->Size();
next_text_offset_ += instructions->HeapSize();
instructions_.Add(InstructionsData(instructions, code, offset));
return offset;
@@ -189,7 +189,7 @@ bool ImageWriter::GetSharedDataOffsetFor(RawObject* raw_object,
}
uint32_t ImageWriter::GetDataOffsetFor(RawObject* raw_object) {
intptr_t heap_size = raw_object->Size();
intptr_t heap_size = raw_object->HeapSize();
intptr_t offset = next_data_offset_;
next_data_offset_ += heap_size;
objects_.Add(ObjectData(raw_object));
@@ -223,11 +223,6 @@ void ImageWriter::DumpInstructionsSizes() {
js.OpenArray();
for (intptr_t i = 0; i < instructions_.length(); i++) {
auto& data = instructions_[i];
if (data.code_->IsNull()) {
// TODO(34650): Type testing stubs are added to the serializer without
// their Code.
continue;
}
owner = data.code_->owner();
js.OpenObject();
if (owner.IsFunction()) {
@@ -239,7 +234,7 @@ void ImageWriter::DumpInstructionsSizes() {
js.PrintPropertyStr("c", name);
}
js.PrintProperty("n", data.code_->QualifiedName());
js.PrintProperty("s", data.insns_->raw()->Size());
js.PrintProperty("s", data.insns_->raw()->HeapSize());
js.CloseObject();
}
js.CloseArray();
@@ -334,7 +329,7 @@ void ImageWriter::WriteROData(WriteStream* stream) {
NoSafepointScope no_safepoint;
uword start = reinterpret_cast<uword>(obj.raw()) - kHeapObjectTag;
uword end = start + obj.raw()->Size();
uword end = start + obj.raw()->HeapSize();
// Write object header with the mark and VM heap bits set.
uword marked_tags = obj.raw()->ptr()->tags_;
@@ -475,10 +470,10 @@ void AssemblyImageWriter::WriteText(WriteStream* clustered_stream, bool vm) {
"Instructions",
/*name=*/nullptr);
profile_writer_->AttributeBytesTo({offset_space_, offset},
insns.raw()->Size());
insns.raw()->HeapSize());
}
ASSERT(insns.raw()->Size() % sizeof(uint64_t) == 0);
ASSERT(insns.raw()->HeapSize() % sizeof(uint64_t) == 0);
// 1. Write from the header to the entry point.
{
@@ -554,7 +549,7 @@ void AssemblyImageWriter::WriteText(WriteStream* clustered_stream, bool vm) {
NoSafepointScope no_safepoint;
uword beginning = reinterpret_cast<uword>(insns.raw_ptr());
uword entry = beginning + Instructions::HeaderSize();
uword payload_size = insns.raw()->Size() - insns.HeaderSize();
uword payload_size = insns.raw()->HeapSize() - insns.HeaderSize();
uword end = entry + payload_size;
ASSERT(Utils::IsAligned(beginning, sizeof(uword)));
@@ -564,7 +559,7 @@ void AssemblyImageWriter::WriteText(WriteStream* clustered_stream, bool vm) {
text_offset += WriteByteSequence(entry, end);
}
ASSERT((text_offset - instr_start) == insns.raw()->Size());
ASSERT((text_offset - instr_start) == insns.raw()->HeapSize());
}
FrameUnwindEpilogue();
@@ -755,7 +750,7 @@ void BlobImageWriter::WriteText(WriteStream* clustered_stream, bool vm) {
beginning += sizeof(uword);
text_offset += WriteByteSequence(beginning, end);
ASSERT((text_offset - instr_start) == insns.raw()->Size());
ASSERT((text_offset - instr_start) == insns.raw()->HeapSize());
}
}
+14 -13
View File
@@ -1119,9 +1119,9 @@ void Object::FinalizeReadOnlyObject(RawObject* object) {
String::SetCachedHash(str, hash);
}
intptr_t size = OneByteString::UnroundedSize(str);
ASSERT(size <= str->Size());
ASSERT(size <= str->HeapSize());
memset(reinterpret_cast<void*>(RawObject::ToAddr(str) + size), 0,
str->Size() - size);
str->HeapSize() - size);
} else if (cid == kTwoByteStringCid) {
RawTwoByteString* str = static_cast<RawTwoByteString*>(object);
if (String::GetCachedHash(str) == 0) {
@@ -1130,9 +1130,9 @@ void Object::FinalizeReadOnlyObject(RawObject* object) {
}
ASSERT(String::GetCachedHash(str) != 0);
intptr_t size = TwoByteString::UnroundedSize(str);
ASSERT(size <= str->Size());
ASSERT(size <= str->HeapSize());
memset(reinterpret_cast<void*>(RawObject::ToAddr(str) + size), 0,
str->Size() - size);
str->HeapSize() - size);
} else if (cid == kExternalOneByteStringCid) {
RawExternalOneByteString* str =
static_cast<RawExternalOneByteString*>(object);
@@ -1150,21 +1150,21 @@ void Object::FinalizeReadOnlyObject(RawObject* object) {
} else if (cid == kCodeSourceMapCid) {
RawCodeSourceMap* map = CodeSourceMap::RawCast(object);
intptr_t size = CodeSourceMap::UnroundedSize(map);
ASSERT(size <= map->Size());
ASSERT(size <= map->HeapSize());
memset(reinterpret_cast<void*>(RawObject::ToAddr(map) + size), 0,
map->Size() - size);
map->HeapSize() - size);
} else if (cid == kStackMapCid) {
RawStackMap* map = StackMap::RawCast(object);
intptr_t size = StackMap::UnroundedSize(map);
ASSERT(size <= map->Size());
ASSERT(size <= map->HeapSize());
memset(reinterpret_cast<void*>(RawObject::ToAddr(map) + size), 0,
map->Size() - size);
map->HeapSize() - size);
} else if (cid == kPcDescriptorsCid) {
RawPcDescriptors* desc = PcDescriptors::RawCast(object);
intptr_t size = PcDescriptors::UnroundedSize(desc);
ASSERT(size <= desc->Size());
ASSERT(size <= desc->HeapSize());
memset(reinterpret_cast<void*>(RawObject::ToAddr(desc) + size), 0,
desc->Size() - size);
desc->HeapSize() - size);
}
}
@@ -2120,7 +2120,7 @@ bool Object::IsNotTemporaryScopedHandle() const {
RawObject* Object::Clone(const Object& orig, Heap::Space space) {
const Class& cls = Class::Handle(orig.clazz());
intptr_t size = orig.raw()->Size();
intptr_t size = orig.raw()->HeapSize();
RawObject* raw_clone = Object::Allocate(cls.id(), size, space);
NoSafepointScope no_safepoint;
// Copy the body of the original into the clone.
@@ -14464,7 +14464,8 @@ RawCode* Code::FinalizeCode(const char* name,
if (FLAG_write_protect_code) {
uword address = RawObject::ToAddr(instrs.raw());
VirtualMemory::Protect(reinterpret_cast<void*>(address),
instrs.raw()->Size(), VirtualMemory::kReadExecute);
instrs.raw()->HeapSize(),
VirtualMemory::kReadExecute);
}
}
CPU::FlushICache(instrs.PayloadStart(), instrs.Size());
@@ -20065,7 +20066,7 @@ uint32_t Array::CanonicalizeHash() const {
RawArray* Array::New(intptr_t len, Heap::Space space) {
ASSERT(Isolate::Current()->object_store()->array_class() != Class::null());
RawArray* result = New(kClassId, len, space);
if (result->Size() > Heap::kNewAllocatableSize) {
if (result->HeapSize() > Heap::kNewAllocatableSize) {
ASSERT(result->IsOldObject());
result->SetCardRememberedBitUnsynchronized();
}
+4 -4
View File
@@ -135,7 +135,7 @@ intptr_t ObjectGraph::StackIterator::OffsetFromParentInWords() const {
ASSERT(child.obj == *child.ptr);
uword child_ptr_addr = reinterpret_cast<uword>(child.ptr);
intptr_t offset = child_ptr_addr - parent_start;
if (offset > 0 && offset < parent.obj->Size()) {
if (offset > 0 && offset < parent.obj->HeapSize()) {
ASSERT(Utils::IsAligned(offset, kWordSize));
return offset >> kWordSizeLog2;
} else {
@@ -272,7 +272,7 @@ class SizeVisitor : public ObjectGraph::Visitor {
if (ShouldSkip(obj)) {
return kBacktrack;
}
size_ += obj->Size();
size_ += obj->HeapSize();
return kProceed;
}
@@ -475,7 +475,7 @@ class InboundReferencesVisitor : public ObjectVisitor,
uword source_start = RawObject::ToAddr(source_);
uword current_ptr_addr = reinterpret_cast<uword>(current_ptr);
intptr_t offset = current_ptr_addr - source_start;
if (offset > 0 && offset < source_->Size()) {
if (offset > 0 && offset < source_->HeapSize()) {
ASSERT(Utils::IsAligned(offset, kWordSize));
*scratch_ = Smi::New(offset >> kWordSizeLog2);
} else {
@@ -583,7 +583,7 @@ class WriteGraphVisitor : public ObjectGraph::Visitor {
if ((roots_ == ObjectGraph::kVM) || obj.IsField() || obj.IsInstance() ||
obj.IsContext()) {
// Each object is a header + a zero-terminated list of its neighbors.
WriteHeader(raw_obj, raw_obj->Size(), obj.GetClassId(), stream_);
WriteHeader(raw_obj, raw_obj->HeapSize(), obj.GetClassId(), stream_);
raw_obj->VisitPointers(&ptr_writer_);
stream_->WriteUnsigned(0);
++count_;
+5 -5
View File
@@ -23,7 +23,7 @@ class CounterVisitor : public ObjectGraph::Visitor {
return kBacktrack;
}
++count_;
size_ += obj->Size();
size_ += obj->HeapSize();
return kProceed;
}
@@ -52,10 +52,10 @@ ISOLATE_UNIT_TEST_CASE(ObjectGraph) {
b.SetAt(0, c);
b.SetAt(1, d);
a.SetAt(11, d);
intptr_t a_size = a.raw()->Size();
intptr_t b_size = b.raw()->Size();
intptr_t c_size = c.raw()->Size();
intptr_t d_size = d.raw()->Size();
intptr_t a_size = a.raw()->HeapSize();
intptr_t b_size = b.raw()->HeapSize();
intptr_t c_size = c.raw()->HeapSize();
intptr_t d_size = d.raw()->HeapSize();
{
// No more allocation; raw pointers ahead.
SafepointOperationScope safepoint(thread);
+1 -1
View File
@@ -43,7 +43,7 @@ void Object::AddCommonObjectProperties(JSONObject* jsobj,
}
if (!ref) {
if (raw()->IsHeapObject()) {
jsobj->AddProperty("size", raw()->Size());
jsobj->AddProperty("size", raw()->HeapSize());
} else {
jsobj->AddProperty("size", (intptr_t)0);
}
+12 -12
View File
@@ -62,7 +62,7 @@ void RawObject::Validate(Isolate* isolate) const {
return;
}
intptr_t size_from_tags = SizeTag::decode(tags);
intptr_t size_from_class = SizeFromClass();
intptr_t size_from_class = HeapSizeFromClass();
if ((size_from_tags != 0) && (size_from_tags != size_from_class)) {
FATAL3(
"Inconsistent size encountered "
@@ -74,7 +74,7 @@ void RawObject::Validate(Isolate* isolate) const {
// Can't look at the class object because it can be called during
// compaction when the class objects are moving. Can use the class
// id in the header and the sizes in the Class Table.
intptr_t RawObject::SizeFromClass() const {
intptr_t RawObject::HeapSizeFromClass() const {
// Only reasonable to be called on heap objects.
ASSERT(IsHeapObject());
@@ -191,13 +191,13 @@ intptr_t RawObject::SizeFromClass() const {
case kFreeListElement: {
uword addr = RawObject::ToAddr(this);
FreeListElement* element = reinterpret_cast<FreeListElement*>(addr);
instance_size = element->Size();
instance_size = element->HeapSize();
break;
}
case kForwardingCorpse: {
uword addr = RawObject::ToAddr(this);
ForwardingCorpse* element = reinterpret_cast<ForwardingCorpse*>(addr);
instance_size = element->Size();
instance_size = element->HeapSize();
break;
}
default: {
@@ -285,17 +285,17 @@ intptr_t RawObject::VisitPointersPredefined(ObjectPointerVisitor* visitor,
case kFreeListElement: {
uword addr = RawObject::ToAddr(this);
FreeListElement* element = reinterpret_cast<FreeListElement*>(addr);
size = element->Size();
size = element->HeapSize();
break;
}
case kForwardingCorpse: {
uword addr = RawObject::ToAddr(this);
ForwardingCorpse* forwarder = reinterpret_cast<ForwardingCorpse*>(addr);
size = forwarder->Size();
size = forwarder->HeapSize();
break;
}
case kNullCid:
size = Size();
size = HeapSize();
break;
default:
OS::PrintErr("Class Id: %" Pd "\n", class_id);
@@ -305,13 +305,13 @@ intptr_t RawObject::VisitPointersPredefined(ObjectPointerVisitor* visitor,
#if defined(DEBUG)
ASSERT(size != 0);
const intptr_t expected_size = Size();
const intptr_t expected_size = HeapSize();
// In general we expect that visitors return exactly the same size that Size
// would compute. However in case of Arrays we might have a discrepancy when
// concurrently visiting an array that is being shrunk with
// In general we expect that visitors return exactly the same size that
// HeapSize would compute. However in case of Arrays we might have a
// discrepancy when concurrently visiting an array that is being shrunk with
// Array::MakeFixedLength: the visitor might have visited the full array while
// here we are observing a smaller Size().
// here we are observing a smaller HeapSize().
ASSERT(size == expected_size ||
(class_id == kArrayCid && size > expected_size));
return size; // Prefer larger size.
+9 -8
View File
@@ -363,17 +363,18 @@ class RawObject {
return IsHeapObject() ? GetClassId() : static_cast<intptr_t>(kSmiCid);
}
intptr_t Size() const {
intptr_t HeapSize() const {
ASSERT(IsHeapObject());
uint32_t tags = ptr()->tags_;
intptr_t result = SizeTag::decode(tags);
if (result != 0) {
#if defined(DEBUG)
// TODO(22501) Array::MakeFixedLength has a race with this code: we might
// have loaded tags field and then MakeFixedLength could have updated it
// leading to inconsistency between SizeFromClass() and
// leading to inconsistency between HeapSizeFromClass() and
// SizeTag::decode(tags). We are working around it by reloading tags_ and
// recomputing size from tags.
const intptr_t size_from_class = SizeFromClass();
const intptr_t size_from_class = HeapSizeFromClass();
if ((result > size_from_class) && (GetClassId() == kArrayCid) &&
(ptr()->tags_ != tags)) {
result = SizeTag::decode(ptr()->tags_);
@@ -382,13 +383,13 @@ class RawObject {
#endif
return result;
}
result = SizeFromClass();
result = HeapSizeFromClass();
ASSERT(result > SizeTag::kMaxSizeTag);
return result;
}
bool Contains(uword addr) const {
intptr_t this_size = Size();
intptr_t this_size = HeapSize();
uword this_addr = RawObject::ToAddr(this);
return (addr >= this_addr) && (addr < (this_addr + this_size));
}
@@ -407,7 +408,7 @@ class RawObject {
}
// Calculate the first and last raw object pointer fields.
intptr_t instance_size = Size();
intptr_t instance_size = HeapSize();
uword obj_addr = ToAddr(this);
uword from = obj_addr + sizeof(RawObject);
uword to = obj_addr + instance_size - kWordSize;
@@ -428,7 +429,7 @@ class RawObject {
}
// Calculate the first and last raw object pointer fields.
intptr_t instance_size = Size();
intptr_t instance_size = HeapSize();
uword obj_addr = ToAddr(this);
uword from = obj_addr + sizeof(RawObject);
uword to = obj_addr + instance_size - kWordSize;
@@ -493,7 +494,7 @@ class RawObject {
intptr_t VisitPointersPredefined(ObjectPointerVisitor* visitor,
intptr_t class_id);
intptr_t SizeFromClass() const;
intptr_t HeapSizeFromClass() const;
intptr_t GetClassId() const {
uint32_t tags = ptr()->tags_;
+1 -1
View File
@@ -4108,7 +4108,7 @@ class ContainsAddressVisitor : public FindObjectVisitor {
return false;
}
uword obj_begin = RawObject::ToAddr(obj);
uword obj_end = obj_begin + obj->Size();
uword obj_end = obj_begin + obj->HeapSize();
return obj_begin <= addr_ && addr_ < obj_end;
}