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

Side by Side Diff: src/profile-generator.cc

Issue 2822009: Heap profiler: publish API and add test. (Closed)
Patch Set: comments addressed Created 10 years, 6 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 | « src/profile-generator.h ('k') | src/v8.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 OS::Print("!!! unknown edge type: %d ", edge->type()); 1107 OS::Print("!!! unknown edge type: %d ", edge->type());
1108 } 1108 }
1109 edge->to()->Print(max_depth, indent + 2); 1109 edge->to()->Print(max_depth, indent + 2);
1110 } 1110 }
1111 } 1111 }
1112 1112
1113 1113
1114 const char* HeapEntry::TypeAsString() { 1114 const char* HeapEntry::TypeAsString() {
1115 switch (type_) { 1115 switch (type_) {
1116 case INTERNAL: return "/internal/"; 1116 case INTERNAL: return "/internal/";
1117 case JS_OBJECT: return "/object/"; 1117 case OBJECT: return "/object/";
1118 case CLOSURE: return "/closure/"; 1118 case CLOSURE: return "/closure/";
1119 case STRING: return "/string/"; 1119 case STRING: return "/string/";
1120 case CODE: return "/code/"; 1120 case CODE: return "/code/";
1121 case ARRAY: return "/array/"; 1121 case ARRAY: return "/array/";
1122 default: return "???"; 1122 default: return "???";
1123 } 1123 }
1124 } 1124 }
1125 1125
1126 1126
1127 HeapGraphPath::HeapGraphPath(const List<HeapGraphEdge*>& path) 1127 HeapGraphPath::HeapGraphPath(const List<HeapGraphEdge*>& path)
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 1255
1256 // Add new entry. 1256 // Add new entry.
1257 if (object->IsJSFunction()) { 1257 if (object->IsJSFunction()) {
1258 JSFunction* func = JSFunction::cast(object); 1258 JSFunction* func = JSFunction::cast(object);
1259 SharedFunctionInfo* shared = func->shared(); 1259 SharedFunctionInfo* shared = func->shared();
1260 String* name = String::cast(shared->name())->length() > 0 ? 1260 String* name = String::cast(shared->name())->length() > 0 ?
1261 String::cast(shared->name()) : shared->inferred_name(); 1261 String::cast(shared->name()) : shared->inferred_name();
1262 return AddEntry(object, HeapEntry::CLOSURE, collection_->GetName(name)); 1262 return AddEntry(object, HeapEntry::CLOSURE, collection_->GetName(name));
1263 } else if (object->IsJSObject()) { 1263 } else if (object->IsJSObject()) {
1264 return AddEntry(object, 1264 return AddEntry(object,
1265 HeapEntry::JS_OBJECT, 1265 HeapEntry::OBJECT,
1266 collection_->GetName( 1266 collection_->GetName(
1267 JSObject::cast(object)->constructor_name())); 1267 JSObject::cast(object)->constructor_name()));
1268 } else if (object->IsJSGlobalPropertyCell()) { 1268 } else if (object->IsJSGlobalPropertyCell()) {
1269 HeapEntry* value = GetEntry(JSGlobalPropertyCell::cast(object)->value()); 1269 HeapEntry* value = GetEntry(JSGlobalPropertyCell::cast(object)->value());
1270 // If GPC references an object that we have interest in, add the object. 1270 // If GPC references an object that we have interest in, add the object.
1271 // We don't store HeapEntries for GPCs. Instead, we make our hash map 1271 // We don't store HeapEntries for GPCs. Instead, we make our hash map
1272 // to point to object's HeapEntry by GPCs address. 1272 // to point to object's HeapEntry by GPCs address.
1273 if (value != NULL) AddEntryAlias(object, value); 1273 if (value != NULL) AddEntryAlias(object, value);
1274 return value; 1274 return value;
1275 } else if (object->IsString()) { 1275 } else if (object->IsString()) {
1276 return AddEntry(object, 1276 return AddEntry(object,
1277 HeapEntry::STRING, 1277 HeapEntry::STRING,
1278 collection_->GetName(String::cast(object))); 1278 collection_->GetName(String::cast(object)));
1279 } else if (object->IsCode() 1279 } else if (object->IsCode()) {
1280 || object->IsSharedFunctionInfo()
1281 || object->IsScript()) {
1282 return AddEntry(object, HeapEntry::CODE); 1280 return AddEntry(object, HeapEntry::CODE);
1281 } else if (object->IsSharedFunctionInfo()) {
1282 SharedFunctionInfo* shared = SharedFunctionInfo::cast(object);
1283 String* name = String::cast(shared->name())->length() > 0 ?
1284 String::cast(shared->name()) : shared->inferred_name();
1285 return AddEntry(object, HeapEntry::CODE, collection_->GetName(name));
1286 } else if (object->IsScript()) {
1287 Script* script = Script::cast(object);
1288 return AddEntry(object,
1289 HeapEntry::CODE,
1290 script->name()->IsString() ?
1291 collection_->GetName(String::cast(script->name())) : "");
1283 } else if (object->IsFixedArray()) { 1292 } else if (object->IsFixedArray()) {
1284 return AddEntry(object, HeapEntry::ARRAY); 1293 return AddEntry(object, HeapEntry::ARRAY);
1285 } 1294 }
1286 // No interest in this object. 1295 // No interest in this object.
1287 return NULL; 1296 return NULL;
1288 } 1297 }
1289 1298
1290 1299
1291 void HeapSnapshot::SetClosureReference(HeapEntry* parent, 1300 void HeapSnapshot::SetClosureReference(HeapEntry* parent,
1292 String* reference_name, 1301 String* reference_name,
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 uint32_t index = static_cast<uint32_t>(k->Number()); 1605 uint32_t index = static_cast<uint32_t>(k->Number());
1597 snapshot_->SetElementReference(entry, index, dictionary->ValueAt(i)); 1606 snapshot_->SetElementReference(entry, index, dictionary->ValueAt(i));
1598 } 1607 }
1599 } 1608 }
1600 } 1609 }
1601 } 1610 }
1602 1611
1603 } } // namespace v8::internal 1612 } } // namespace v8::internal
1604 1613
1605 #endif // ENABLE_LOGGING_AND_PROFILING 1614 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | src/v8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698