Generate grokdump constants with 'make grokdump' now.

R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/21771002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16022 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a4770564
......@@ -192,6 +192,7 @@ endif
# ----------------- available targets: --------------------
# - "dependencies": pulls in external dependencies (currently: GYP)
# - "grokdump": rebuilds heap constants lists used by grokdump
# - any arch listed in ARCHES (see below)
# - any mode listed in MODES
# - every combination <arch>.<mode>, e.g. "ia32.release"
......@@ -392,7 +393,7 @@ endif
# Replaces the old with the new environment file if they're different, which
# will trigger GYP to regenerate Makefiles.
$(ENVFILE): $(ENVFILE).new
@if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) >/dev/null; \
@if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
then rm $(ENVFILE).new; \
else mv $(ENVFILE).new $(ENVFILE); fi
......@@ -401,6 +402,12 @@ $(ENVFILE).new:
@mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \
echo "CXX=$(CXX)" >> $(ENVFILE).new
# Heap constants for grokdump.
DUMP_FILE = tools/v8heapconst.py
grokdump: ia32.release
@cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
@$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
# Dependencies.
# Remember to keep these in sync with the DEPS file.
dependencies:
......
......@@ -1406,6 +1406,14 @@ bool Shell::SetOptions(int argc, char* argv[]) {
#else
options.num_parallel_files++;
#endif // V8_SHARED
} else if (strcmp(argv[i], "--dump-heap-constants") == 0) {
#ifdef V8_SHARED
printf("D8 with shared library does not support constant dumping\n");
return false;
#else
options.dump_heap_constants = true;
argv[i] = NULL;
#endif
}
#ifdef V8_SHARED
else if (strcmp(argv[i], "--dump-counters") == 0) {
......@@ -1560,6 +1568,63 @@ static void SetStandaloneFlagsViaCommandLine() {
#endif
#ifndef V8_SHARED
static void DumpHeapConstants(i::Isolate* isolate) {
i::Heap* heap = isolate->heap();
// Dump the INSTANCE_TYPES table to the console.
printf("# List of known V8 instance types.\n");
#define DUMP_TYPE(T) printf(" %d: \"%s\",\n", i::T, #T);
printf("INSTANCE_TYPES = {\n");
INSTANCE_TYPE_LIST(DUMP_TYPE)
printf("}\n");
#undef DUMP_TYPE
// Dump the KNOWN_MAP table to the console.
printf("\n# List of known V8 maps.\n");
#define ROOT_LIST_CASE(type, name, camel_name) \
if (o == heap->name()) n = #camel_name;
#define STRUCT_LIST_CASE(upper_name, camel_name, name) \
if (o == heap->name##_map()) n = #camel_name "Map";
i::HeapObjectIterator it(heap->map_space());
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) & 0xfffff;
int t = m->instance_type();
ROOT_LIST(ROOT_LIST_CASE)
STRUCT_LIST(STRUCT_LIST_CASE)
if (n == NULL) continue;
printf(" 0x%05" V8_PTR_PREFIX "x: (%d, \"%s\"),\n", p, t, n);
}
printf("}\n");
#undef STRUCT_LIST_CASE
#undef ROOT_LIST_CASE
// Dump the KNOWN_OBJECTS table to the console.
printf("\n# List of known V8 objects.\n");
#define ROOT_LIST_CASE(type, name, camel_name) \
if (o == heap->name()) n = #camel_name;
i::OldSpaces spit(heap);
printf("KNOWN_OBJECTS = {\n");
for (i::PagedSpace* s = spit.next(); s != NULL; s = spit.next()) {
i::HeapObjectIterator it(s);
const char* sname = AllocationSpaceName(s->identity());
for (i::Object* o = it.Next(); o != NULL; o = it.Next()) {
const char* n = NULL;
intptr_t p = reinterpret_cast<intptr_t>(o) & 0xfffff;
ROOT_LIST(ROOT_LIST_CASE)
if (n == NULL) continue;
printf(" (\"%s\", 0x%05" V8_PTR_PREFIX "x): \"%s\",\n", sname, p, n);
}
}
printf("}\n");
#undef ROOT_LIST_CASE
}
#endif // V8_SHARED
class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
virtual void* Allocate(size_t length) {
......@@ -1597,6 +1662,13 @@ int Shell::Main(int argc, char* argv[]) {
PerIsolateData data(isolate);
InitializeDebugger(isolate);
#ifndef V8_SHARED
if (options.dump_heap_constants) {
DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate));
return 0;
}
#endif
if (options.stress_opt || options.stress_deopt) {
Testing::SetStressRunType(options.stress_opt
? Testing::kStressTypeOpt
......
......@@ -231,6 +231,7 @@ class ShellOptions {
stress_deopt(false),
interactive_shell(false),
test_shell(false),
dump_heap_constants(false),
num_isolates(1),
isolate_sources(NULL) { }
......@@ -254,6 +255,7 @@ class ShellOptions {
bool stress_deopt;
bool interactive_shell;
bool test_shell;
bool dump_heap_constants;
int num_isolates;
SourceGroup* isolate_sources;
};
......
This diff is collapsed.
This diff is collapsed.
# Copyright 2013 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# This file is automatically generated from the V8 source and should not
# be modified manually, run 'make grokdump' instead to update this file.
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