Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: test/mkgrokdump/mkgrokdump.cc

Issue 2824853003: Revert of Introduce mkgrokdump to update tools/v8heapconst.py. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mkgrokdump/DEPS ('k') | test/mkgrokdump/mkgrokdump.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stdio.h>
6
7 #include "include/libplatform/libplatform.h"
8 #include "include/v8.h"
9
10 #include "src/frames.h"
11 #include "src/heap/heap.h"
12 #include "src/heap/spaces.h"
13 #include "src/isolate.h"
14 #include "src/objects-inl.h"
15
16 namespace v8 {
17
18 static const char* kHeader =
19 "# Copyright 2017 the V8 project authors. All rights reserved.\n"
20 "# Use of this source code is governed by a BSD-style license that can\n"
21 "# be found in the LICENSE file.\n"
22 "\n"
23 "# This file is automatically generated by mkgrokdump and should not\n"
24 "# be modified manually.\n"
25 "\n"
26 "# List of known V8 instance types.\n";
27
28 // Non-snapshot builds allocate objects to different places.
29 // Debug builds emit debug code, affecting code object sizes.
30 #if defined(V8_USE_SNAPSHOT) && !defined(DEBUG)
31 static const char* kBuild = "shipping";
32 #else
33 static const char* kBuild = "non-shipping";
34 #endif
35
36 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
37 public:
38 void* Allocate(size_t length) override { return nullptr; }
39 void* AllocateUninitialized(size_t length) override { return nullptr; }
40 void Free(void* p, size_t) override {}
41 };
42
43 static int DumpHeapConstants(const char* argv0) {
44 // Start up V8.
45 v8::Platform* platform = v8::platform::CreateDefaultPlatform();
46 v8::V8::InitializePlatform(platform);
47 v8::V8::Initialize();
48 v8::V8::InitializeExternalStartupData(argv0);
49 Isolate::CreateParams create_params;
50 MockArrayBufferAllocator mock_arraybuffer_allocator;
51 create_params.array_buffer_allocator = &mock_arraybuffer_allocator;
52 Isolate* isolate = Isolate::New(create_params);
53 {
54 Isolate::Scope scope(isolate);
55 i::Heap* heap = reinterpret_cast<i::Isolate*>(isolate)->heap();
56 printf("%s", kHeader);
57 #define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T);
58 printf("INSTANCE_TYPES = {\n");
59 INSTANCE_TYPE_LIST(DUMP_TYPE)
60 printf("}\n");
61 #undef DUMP_TYPE
62
63 // Dump the KNOWN_MAP table to the console.
64 printf("\n# List of known V8 maps.\n");
65 #define ROOT_LIST_CASE(type, name, camel_name) \
66 if (n == NULL && o == heap->name()) n = #camel_name;
67 #define STRUCT_LIST_CASE(upper_name, camel_name, name) \
68 if (n == NULL && o == heap->name##_map()) n = #camel_name "Map";
69 i::HeapObjectIterator it(heap->map_space());
70 printf("KNOWN_MAPS = {\n");
71 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) {
72 i::Map* m = i::Map::cast(o);
73 const char* n = NULL;
74 intptr_t p = reinterpret_cast<intptr_t>(m) & 0x7ffff;
75 int t = m->instance_type();
76 ROOT_LIST(ROOT_LIST_CASE)
77 STRUCT_LIST(STRUCT_LIST_CASE)
78 if (n == NULL) continue;
79 printf(" 0x%05" V8PRIxPTR ": (%d, \"%s\"),\n", p, t, n);
80 }
81 printf("}\n");
82 #undef STRUCT_LIST_CASE
83 #undef ROOT_LIST_CASE
84
85 // Dump the KNOWN_OBJECTS table to the console.
86 printf("\n# List of known V8 objects.\n");
87 #define ROOT_LIST_CASE(type, name, camel_name) \
88 if (n == NULL && o == heap->name()) { \
89 n = #camel_name; \
90 i = i::Heap::k##camel_name##RootIndex; \
91 }
92 i::OldSpaces spit(heap);
93 printf("KNOWN_OBJECTS = {\n");
94 for (i::PagedSpace* s = spit.next(); s != NULL; s = spit.next()) {
95 i::HeapObjectIterator it(s);
96 const char* sname = AllocationSpaceName(s->identity());
97 for (i::Object* o = it.Next(); o != NULL; o = it.Next()) {
98 const char* n = NULL;
99 i::Heap::RootListIndex i = i::Heap::kStrongRootListLength;
100 intptr_t p = reinterpret_cast<intptr_t>(o) & 0x7ffff;
101 ROOT_LIST(ROOT_LIST_CASE)
102 if (n == NULL) continue;
103 if (!i::Heap::RootIsImmortalImmovable(i)) continue;
104 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n);
105 }
106 }
107 printf("}\n");
108 #undef ROOT_LIST_CASE
109
110 // Dump frame markers
111 printf("\n# List of known V8 Frame Markers.\n");
112 #define DUMP_MARKER(T, class) printf(" \"%s\",\n", #T);
113 printf("FRAME_MARKERS = (\n");
114 STACK_FRAME_TYPE_LIST(DUMP_MARKER)
115 printf(")\n");
116 #undef DUMP_TYPE
117 }
118
119 printf("\n# This set of constants is generated from a %s build.\n", kBuild);
120
121 // Teardown.
122 isolate->Dispose();
123 v8::V8::ShutdownPlatform();
124 delete platform;
125 return 0;
126 }
127
128 } // namespace v8
129
130 int main(int argc, char* argv[]) { return v8::DumpHeapConstants(argv[0]); }
OLDNEW
« no previous file with comments | « test/mkgrokdump/DEPS ('k') | test/mkgrokdump/mkgrokdump.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698