OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1637 HeapObject* const V8HeapExplorer::kFirstGcSubrootObject = | 1637 HeapObject* const V8HeapExplorer::kFirstGcSubrootObject = |
1638 reinterpret_cast<HeapObject*>( | 1638 reinterpret_cast<HeapObject*>( |
1639 static_cast<intptr_t>(HeapObjectsMap::kGcRootsFirstSubrootId)); | 1639 static_cast<intptr_t>(HeapObjectsMap::kGcRootsFirstSubrootId)); |
1640 HeapObject* const V8HeapExplorer::kLastGcSubrootObject = | 1640 HeapObject* const V8HeapExplorer::kLastGcSubrootObject = |
1641 reinterpret_cast<HeapObject*>( | 1641 reinterpret_cast<HeapObject*>( |
1642 static_cast<intptr_t>(HeapObjectsMap::kFirstAvailableObjectId)); | 1642 static_cast<intptr_t>(HeapObjectsMap::kFirstAvailableObjectId)); |
1643 | 1643 |
1644 | 1644 |
1645 V8HeapExplorer::V8HeapExplorer( | 1645 V8HeapExplorer::V8HeapExplorer( |
1646 HeapSnapshot* snapshot, | 1646 HeapSnapshot* snapshot, |
1647 SnapshottingProgressReportingInterface* progress) | 1647 SnapshottingProgressReportingInterface* progress, |
1648 v8::HeapProfiler::ObjectNameResolver* resolver) | |
1648 : heap_(Isolate::Current()->heap()), | 1649 : heap_(Isolate::Current()->heap()), |
1649 snapshot_(snapshot), | 1650 snapshot_(snapshot), |
1650 collection_(snapshot_->collection()), | 1651 collection_(snapshot_->collection()), |
1651 progress_(progress), | 1652 progress_(progress), |
1652 filler_(NULL) { | 1653 filler_(NULL), |
1654 global_object_name_resolver_(resolver) { | |
1653 } | 1655 } |
1654 | 1656 |
1655 | 1657 |
1656 V8HeapExplorer::~V8HeapExplorer() { | 1658 V8HeapExplorer::~V8HeapExplorer() { |
1657 } | 1659 } |
1658 | 1660 |
1659 | 1661 |
1660 HeapEntry* V8HeapExplorer::AllocateEntry(HeapThing ptr) { | 1662 HeapEntry* V8HeapExplorer::AllocateEntry(HeapThing ptr) { |
1661 return AddEntry(reinterpret_cast<HeapObject*>(ptr)); | 1663 return AddEntry(reinterpret_cast<HeapObject*>(ptr)); |
1662 } | 1664 } |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2705 HandleScope scope; | 2707 HandleScope scope; |
2706 Isolate* isolate = Isolate::Current(); | 2708 Isolate* isolate = Isolate::Current(); |
2707 GlobalObjectsEnumerator enumerator; | 2709 GlobalObjectsEnumerator enumerator; |
2708 isolate->global_handles()->IterateAllRoots(&enumerator); | 2710 isolate->global_handles()->IterateAllRoots(&enumerator); |
2709 Handle<String> document_string = | 2711 Handle<String> document_string = |
2710 isolate->factory()->NewStringFromAscii(CStrVector("document")); | 2712 isolate->factory()->NewStringFromAscii(CStrVector("document")); |
2711 Handle<String> url_string = | 2713 Handle<String> url_string = |
2712 isolate->factory()->NewStringFromAscii(CStrVector("URL")); | 2714 isolate->factory()->NewStringFromAscii(CStrVector("URL")); |
2713 const char** urls = NewArray<const char*>(enumerator.count()); | 2715 const char** urls = NewArray<const char*>(enumerator.count()); |
2714 for (int i = 0, l = enumerator.count(); i < l; ++i) { | 2716 for (int i = 0, l = enumerator.count(); i < l; ++i) { |
2715 urls[i] = NULL; | 2717 if (global_object_name_resolver_) { |
2716 HandleScope scope; | 2718 HandleScope scope; |
2717 Handle<JSGlobalObject> global_obj = enumerator.at(i); | 2719 Handle<JSGlobalObject> global_obj = enumerator.at(i); |
2718 Object* obj_document; | 2720 urls[i] = global_object_name_resolver_->GetName( |
2719 if (global_obj->GetProperty(*document_string)->ToObject(&obj_document) && | 2721 Utils::ToLocal(Handle<JSObject>::cast(global_obj))); |
2720 obj_document->IsJSObject()) { | 2722 } else { |
2721 // FixMe: Workaround: SharedWorker's current Isolate has NULL context. | 2723 // This branch is going to be removed once Chromium migrates to the |
alph
2012/12/03 18:31:15
nit: TODO
yurys
2012/12/03 18:36:06
Done.
| |
2722 // As result GetProperty(*url_string) will crash. | 2724 // new name resolver. |
2723 if (!Isolate::Current()->context() && obj_document->IsJSGlobalProxy()) | 2725 urls[i] = NULL; |
2724 continue; | 2726 HandleScope scope; |
2725 JSObject* document = JSObject::cast(obj_document); | 2727 Handle<JSGlobalObject> global_obj = enumerator.at(i); |
2726 Object* obj_url; | 2728 Object* obj_document; |
2727 if (document->GetProperty(*url_string)->ToObject(&obj_url) && | 2729 if (global_obj->GetProperty(*document_string)->ToObject(&obj_document) && |
2728 obj_url->IsString()) { | 2730 obj_document->IsJSObject()) { |
2729 urls[i] = collection_->names()->GetName(String::cast(obj_url)); | 2731 // FixMe: Workaround: SharedWorker's current Isolate has NULL context. |
2732 // As result GetProperty(*url_string) will crash. | |
2733 if (!Isolate::Current()->context() && obj_document->IsJSGlobalProxy()) | |
2734 continue; | |
2735 JSObject* document = JSObject::cast(obj_document); | |
2736 Object* obj_url; | |
2737 if (document->GetProperty(*url_string)->ToObject(&obj_url) && | |
2738 obj_url->IsString()) { | |
2739 urls[i] = collection_->names()->GetName(String::cast(obj_url)); | |
2740 } | |
2730 } | 2741 } |
2731 } | 2742 } |
2732 } | 2743 } |
2733 | 2744 |
2734 AssertNoAllocation no_allocation; | 2745 AssertNoAllocation no_allocation; |
2735 for (int i = 0, l = enumerator.count(); i < l; ++i) { | 2746 for (int i = 0, l = enumerator.count(); i < l; ++i) { |
2736 objects_tags_.SetTag(*enumerator.at(i), urls[i]); | 2747 objects_tags_.SetTag(*enumerator.at(i), urls[i]); |
2737 } | 2748 } |
2738 | 2749 |
2739 DeleteArray(urls); | 2750 DeleteArray(urls); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3074 child_entry); | 3085 child_entry); |
3075 } | 3086 } |
3076 | 3087 |
3077 private: | 3088 private: |
3078 HeapSnapshot* snapshot_; | 3089 HeapSnapshot* snapshot_; |
3079 HeapSnapshotsCollection* collection_; | 3090 HeapSnapshotsCollection* collection_; |
3080 HeapEntriesMap* entries_; | 3091 HeapEntriesMap* entries_; |
3081 }; | 3092 }; |
3082 | 3093 |
3083 | 3094 |
3084 HeapSnapshotGenerator::HeapSnapshotGenerator(HeapSnapshot* snapshot, | 3095 HeapSnapshotGenerator::HeapSnapshotGenerator( |
3085 v8::ActivityControl* control) | 3096 HeapSnapshot* snapshot, |
3097 v8::ActivityControl* control, | |
3098 v8::HeapProfiler::ObjectNameResolver* resolver) | |
3086 : snapshot_(snapshot), | 3099 : snapshot_(snapshot), |
3087 control_(control), | 3100 control_(control), |
3088 v8_heap_explorer_(snapshot_, this), | 3101 v8_heap_explorer_(snapshot_, this, resolver), |
3089 dom_explorer_(snapshot_, this) { | 3102 dom_explorer_(snapshot_, this) { |
3090 } | 3103 } |
3091 | 3104 |
3092 | 3105 |
3093 bool HeapSnapshotGenerator::GenerateSnapshot() { | 3106 bool HeapSnapshotGenerator::GenerateSnapshot() { |
3094 v8_heap_explorer_.TagGlobalObjects(); | 3107 v8_heap_explorer_.TagGlobalObjects(); |
3095 | 3108 |
3096 // TODO(1562) Profiler assumes that any object that is in the heap after | 3109 // TODO(1562) Profiler assumes that any object that is in the heap after |
3097 // full GC is reachable from the root when computing dominators. | 3110 // full GC is reachable from the root when computing dominators. |
3098 // This is not true for weakly reachable objects. | 3111 // This is not true for weakly reachable objects. |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3588 | 3601 |
3589 | 3602 |
3590 void HeapSnapshotJSONSerializer::SortHashMap( | 3603 void HeapSnapshotJSONSerializer::SortHashMap( |
3591 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3604 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
3592 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3605 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
3593 sorted_entries->Add(p); | 3606 sorted_entries->Add(p); |
3594 sorted_entries->Sort(SortUsingEntryValue); | 3607 sorted_entries->Sort(SortUsingEntryValue); |
3595 } | 3608 } |
3596 | 3609 |
3597 } } // namespace v8::internal | 3610 } } // namespace v8::internal |
OLD | NEW |