[heap] Avoid some inline definitions in Heap

Move obvious candidates to the cc file.

Bug: 
Change-Id: I9b2bca0ed1f2836a4873760d6677a9c0dff9c064
Reviewed-on: https://chromium-review.googlesource.com/538664
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46007}
This commit is contained in:
Michael Lippautz 2017-06-19 11:40:32 +02:00 committed by Commit Bot
parent 95882f0edc
commit 13869d7920
3 changed files with 66 additions and 68 deletions

View File

@ -526,38 +526,6 @@ Address* Heap::store_buffer_top_address() {
return store_buffer()->top_address();
}
bool Heap::AllowedToBeMigrated(HeapObject* obj, AllocationSpace dst) {
// Object migration is governed by the following rules:
//
// 1) Objects in new-space can be migrated to the old space
// that matches their target space or they stay in new-space.
// 2) Objects in old-space stay in the same space when migrating.
// 3) Fillers (two or more words) can migrate due to left-trimming of
// fixed arrays in new-space or old space.
// 4) Fillers (one word) can never migrate, they are skipped by
// incremental marking explicitly to prevent invalid pattern.
//
// Since this function is used for debugging only, we do not place
// asserts here, but check everything explicitly.
if (obj->map() == one_pointer_filler_map()) return false;
InstanceType type = obj->map()->instance_type();
MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address());
AllocationSpace src = chunk->owner()->identity();
switch (src) {
case NEW_SPACE:
return dst == src || dst == OLD_SPACE;
case OLD_SPACE:
return dst == src &&
(dst == OLD_SPACE || obj->IsFiller() || obj->IsExternalString());
case CODE_SPACE:
return dst == src && type == CODE_TYPE;
case MAP_SPACE:
case LO_SPACE:
return false;
}
UNREACHABLE();
}
void Heap::CopyBlock(Address dst, Address src, int byte_size) {
CopyWords(reinterpret_cast<Object**>(dst), reinterpret_cast<Object**>(src),
static_cast<size_t>(byte_size / kPointerSize));
@ -840,34 +808,6 @@ AlwaysAllocateScope::~AlwaysAllocateScope() {
heap_->always_allocate_scope_count_.Decrement(1);
}
void VerifyPointersVisitor::VisitPointers(HeapObject* host, Object** start,
Object** end) {
VerifyPointers(start, end);
}
void VerifyPointersVisitor::VisitRootPointers(Root root, Object** start,
Object** end) {
VerifyPointers(start, end);
}
void VerifyPointersVisitor::VerifyPointers(Object** start, Object** end) {
for (Object** current = start; current < end; current++) {
if ((*current)->IsHeapObject()) {
HeapObject* object = HeapObject::cast(*current);
CHECK(object->GetIsolate()->heap()->Contains(object));
CHECK(object->map()->IsMap());
} else {
CHECK((*current)->IsSmi());
}
}
}
void VerifySmisVisitor::VisitRootPointers(Root root, Object** start,
Object** end) {
for (Object** current = start; current < end; current++) {
CHECK((*current)->IsSmi());
}
}
} // namespace internal
} // namespace v8

View File

@ -6626,5 +6626,66 @@ const char* AllocationSpaceName(AllocationSpace space) {
return NULL;
}
void VerifyPointersVisitor::VisitPointers(HeapObject* host, Object** start,
Object** end) {
VerifyPointers(start, end);
}
void VerifyPointersVisitor::VisitRootPointers(Root root, Object** start,
Object** end) {
VerifyPointers(start, end);
}
void VerifyPointersVisitor::VerifyPointers(Object** start, Object** end) {
for (Object** current = start; current < end; current++) {
if ((*current)->IsHeapObject()) {
HeapObject* object = HeapObject::cast(*current);
CHECK(object->GetIsolate()->heap()->Contains(object));
CHECK(object->map()->IsMap());
} else {
CHECK((*current)->IsSmi());
}
}
}
void VerifySmisVisitor::VisitRootPointers(Root root, Object** start,
Object** end) {
for (Object** current = start; current < end; current++) {
CHECK((*current)->IsSmi());
}
}
bool Heap::AllowedToBeMigrated(HeapObject* obj, AllocationSpace dst) {
// Object migration is governed by the following rules:
//
// 1) Objects in new-space can be migrated to the old space
// that matches their target space or they stay in new-space.
// 2) Objects in old-space stay in the same space when migrating.
// 3) Fillers (two or more words) can migrate due to left-trimming of
// fixed arrays in new-space or old space.
// 4) Fillers (one word) can never migrate, they are skipped by
// incremental marking explicitly to prevent invalid pattern.
//
// Since this function is used for debugging only, we do not place
// asserts here, but check everything explicitly.
if (obj->map() == one_pointer_filler_map()) return false;
InstanceType type = obj->map()->instance_type();
MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address());
AllocationSpace src = chunk->owner()->identity();
switch (src) {
case NEW_SPACE:
return dst == src || dst == OLD_SPACE;
case OLD_SPACE:
return dst == src &&
(dst == OLD_SPACE || obj->IsFiller() || obj->IsExternalString());
case CODE_SPACE:
return dst == src && type == CODE_TYPE;
case MAP_SPACE:
case LO_SPACE:
return false;
}
UNREACHABLE();
}
} // namespace internal
} // namespace v8

View File

@ -813,7 +813,7 @@ class Heap {
// Checks whether the given object is allowed to be migrated from it's
// current space into the given destination space. Used for debugging.
inline bool AllowedToBeMigrated(HeapObject* object, AllocationSpace dest);
bool AllowedToBeMigrated(HeapObject* object, AllocationSpace dest);
void CheckHandleCount();
@ -2486,21 +2486,18 @@ class AlwaysAllocateScope {
// objects in a heap space but above the allocation pointer.
class VerifyPointersVisitor : public ObjectVisitor, public RootVisitor {
public:
inline void VisitPointers(HeapObject* host, Object** start,
Object** end) override;
inline void VisitRootPointers(Root root, Object** start,
Object** end) override;
void VisitPointers(HeapObject* host, Object** start, Object** end) override;
void VisitRootPointers(Root root, Object** start, Object** end) override;
private:
inline void VerifyPointers(Object** start, Object** end);
void VerifyPointers(Object** start, Object** end);
};
// Verify that all objects are Smis.
class VerifySmisVisitor : public RootVisitor {
public:
inline void VisitRootPointers(Root root, Object** start,
Object** end) override;
void VisitRootPointers(Root root, Object** start, Object** end) override;
};