Heap explorer: Show representation of strings.

* src/profile-generator.cc (V8HeapExplorer::GetSystemEntryName): For
  maps of strings, return a name that encodes the representation
  strategy used for the strings.
  (V8HeapExplorer::ExtractReferences): For strings, visit the maps as
  well, so that the user can see what representation is used for their
  strings.

See http://wingolog.org/pub/string-representations.png for an example of what it looks like.

BUG=

Review URL: https://chromiumcodereview.appspot.com/11344021
Patch from Andy Wingo <wingo@igalia.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12973 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
verwaest@chromium.org 2012-11-15 13:35:05 +00:00
parent 3699616609
commit 111630350c

View File

@ -1774,7 +1774,14 @@ void V8HeapExplorer::AddRootEntries(SnapshotFillerInterface* filler) {
const char* V8HeapExplorer::GetSystemEntryName(HeapObject* object) { const char* V8HeapExplorer::GetSystemEntryName(HeapObject* object) {
switch (object->map()->instance_type()) { switch (object->map()->instance_type()) {
case MAP_TYPE: return "system / Map"; case MAP_TYPE:
switch (Map::cast(object)->instance_type()) {
#define MAKE_STRING_MAP_CASE(instance_type, size, name, Name) \
case instance_type: return "system / Map (" #Name ")";
STRING_TYPE_LIST(MAKE_STRING_MAP_CASE)
#undef MAKE_STRING_MAP_CASE
default: return "system / Map";
}
case JS_GLOBAL_PROPERTY_CELL_TYPE: return "system / JSGlobalPropertyCell"; case JS_GLOBAL_PROPERTY_CELL_TYPE: return "system / JSGlobalPropertyCell";
case FOREIGN_TYPE: return "system / Foreign"; case FOREIGN_TYPE: return "system / Foreign";
case ODDBALL_TYPE: return "system / Oddball"; case ODDBALL_TYPE: return "system / Oddball";
@ -1851,7 +1858,6 @@ void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
ExtractJSObjectReferences(entry, JSObject::cast(obj)); ExtractJSObjectReferences(entry, JSObject::cast(obj));
} else if (obj->IsString()) { } else if (obj->IsString()) {
ExtractStringReferences(entry, String::cast(obj)); ExtractStringReferences(entry, String::cast(obj));
extract_indexed_refs = false;
} else if (obj->IsContext()) { } else if (obj->IsContext()) {
ExtractContextReferences(entry, Context::cast(obj)); ExtractContextReferences(entry, Context::cast(obj));
} else if (obj->IsMap()) { } else if (obj->IsMap()) {
@ -1966,11 +1972,14 @@ void V8HeapExplorer::ExtractJSObjectReferences(
void V8HeapExplorer::ExtractStringReferences(int entry, String* string) { void V8HeapExplorer::ExtractStringReferences(int entry, String* string) {
if (string->IsConsString()) { if (string->IsConsString()) {
ConsString* cs = ConsString::cast(string); ConsString* cs = ConsString::cast(string);
SetInternalReference(cs, entry, "first", cs->first()); SetInternalReference(cs, entry, "first", cs->first(),
SetInternalReference(cs, entry, "second", cs->second()); ConsString::kFirstOffset);
SetInternalReference(cs, entry, "second", cs->second(),
ConsString::kSecondOffset);
} else if (string->IsSlicedString()) { } else if (string->IsSlicedString()) {
SlicedString* ss = SlicedString::cast(string); SlicedString* ss = SlicedString::cast(string);
SetInternalReference(ss, entry, "parent", ss->parent()); SetInternalReference(ss, entry, "parent", ss->parent(),
SlicedString::kParentOffset);
} }
} }