Commit 56f7c23f authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

Update mkgrokdump so that it can see maps/objects in RO_SPACE

Also annotate maps with the space, now that this can be RO_SPACE as well
as MAP_SPACE.

Bug: v8:7464
Change-Id: Id597b2195c179b38f93b0e1c6b2ce9ef04e4f0e4
Reviewed-on: https://chromium-review.googlesource.com/980554
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52251}
parent 6e02204d
......@@ -6352,6 +6352,10 @@ void Heap::RecordWritesIntoCode(Code* code) {
PagedSpace* PagedSpaces::next() {
switch (counter_++) {
case RO_SPACE:
// skip NEW_SPACE
counter_++;
return heap_->read_only_space();
case OLD_SPACE:
return heap_->old_space();
case CODE_SPACE:
......
......@@ -2796,11 +2796,17 @@ class VerifySmisVisitor : public RootVisitor {
};
// Space iterator for iterating over all the paged spaces of the heap: Map
// space, old space, code space and cell space. Returns
// each space in turn, and null when it is done.
// space, old space, code space and optionally read only space. Returns each
// space in turn, and null when it is done.
class V8_EXPORT_PRIVATE PagedSpaces BASE_EMBEDDED {
public:
explicit PagedSpaces(Heap* heap) : heap_(heap), counter_(OLD_SPACE) {}
enum class SpacesSpecifier { kSweepablePagedSpaces, kAllPagedSpaces };
explicit PagedSpaces(Heap* heap, SpacesSpecifier specifier =
SpacesSpecifier::kSweepablePagedSpaces)
: heap_(heap),
counter_(specifier == SpacesSpecifier::kAllPagedSpaces ? RO_SPACE
: OLD_SPACE) {}
PagedSpace* next();
private:
......
......@@ -40,6 +40,29 @@ class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
void Free(void* p, size_t) override {}
};
#define ROOT_LIST_CASE(type, name, camel_name) \
if (n == NULL && o == space->heap()->name()) n = #camel_name;
#define STRUCT_LIST_CASE(upper_name, camel_name, name) \
if (n == NULL && o == space->heap()->name##_map()) n = #camel_name "Map";
static void DumpMaps(i::PagedSpace* space) {
i::HeapObjectIterator it(space);
for (i::Object* o = it.Next(); o != NULL; o = it.Next()) {
if (!o->IsMap()) continue;
i::Map* m = i::Map::cast(o);
const char* n = NULL;
intptr_t p = reinterpret_cast<intptr_t>(m) & 0x7FFFF;
int t = m->instance_type();
ROOT_LIST(ROOT_LIST_CASE)
STRUCT_LIST(STRUCT_LIST_CASE)
if (n == NULL) continue;
const char* sname = AllocationSpaceName(space->identity());
i::PrintF(" (\"%s\", 0x%05" V8PRIxPTR "): (%d, \"%s\"),\n", sname, p, t,
n);
}
}
#undef STRUCT_LIST_CASE
#undef ROOT_LIST_CASE
static int DumpHeapConstants(const char* argv0) {
// Start up V8.
std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
......@@ -62,25 +85,10 @@ static int DumpHeapConstants(const char* argv0) {
// Dump the KNOWN_MAP table to the console.
i::PrintF("\n# List of known V8 maps.\n");
#define ROOT_LIST_CASE(type, name, camel_name) \
if (n == NULL && o == heap->name()) n = #camel_name;
#define STRUCT_LIST_CASE(upper_name, camel_name, name) \
if (n == NULL && o == heap->name##_map()) n = #camel_name "Map";
i::HeapObjectIterator it(heap->map_space());
i::PrintF("KNOWN_MAPS = {\n");
for (i::Object* o = it.Next(); o != NULL; o = it.Next()) {
i::Map* m = i::Map::cast(o);
const char* n = NULL;
intptr_t p = reinterpret_cast<intptr_t>(m) & 0x7FFFF;
int t = m->instance_type();
ROOT_LIST(ROOT_LIST_CASE)
STRUCT_LIST(STRUCT_LIST_CASE)
if (n == NULL) continue;
i::PrintF(" 0x%05" V8PRIxPTR ": (%d, \"%s\"),\n", p, t, n);
}
DumpMaps(heap->read_only_space());
DumpMaps(heap->map_space());
i::PrintF("}\n");
#undef STRUCT_LIST_CASE
#undef ROOT_LIST_CASE
// Dump the KNOWN_OBJECTS table to the console.
i::PrintF("\n# List of known V8 objects.\n");
......@@ -89,7 +97,7 @@ static int DumpHeapConstants(const char* argv0) {
n = #camel_name; \
i = i::Heap::k##camel_name##RootIndex; \
}
i::PagedSpaces spit(heap);
i::PagedSpaces spit(heap, i::PagedSpaces::SpacesSpecifier::kAllPagedSpaces);
i::PrintF("KNOWN_OBJECTS = {\n");
for (i::PagedSpace* s = spit.next(); s != NULL; s = spit.next()) {
i::HeapObjectIterator it(s);
......@@ -98,6 +106,8 @@ static int DumpHeapConstants(const char* argv0) {
continue;
const char* sname = AllocationSpaceName(s->identity());
for (i::Object* o = it.Next(); o != NULL; o = it.Next()) {
// Skip maps in RO_SPACE since they will be reported elsewhere.
if (o->IsMap()) continue;
const char* n = NULL;
i::Heap::RootListIndex i = i::Heap::kStrongRootListLength;
intptr_t p = reinterpret_cast<intptr_t>(o) & 0x7FFFF;
......@@ -116,7 +126,7 @@ static int DumpHeapConstants(const char* argv0) {
i::PrintF("FRAME_MARKERS = (\n");
STACK_FRAME_TYPE_LIST(DUMP_MARKER)
i::PrintF(")\n");
#undef DUMP_TYPE
#undef DUMP_MARKER
}
i::PrintF("\n# This set of constants is generated from a %s build.\n",
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment