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 2690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2701 List<Handle<JSGlobalObject> > objects_; | 2701 List<Handle<JSGlobalObject> > objects_; |
2702 }; | 2702 }; |
2703 | 2703 |
2704 | 2704 |
2705 // Modifies heap. Must not be run during heap traversal. | 2705 // Modifies heap. Must not be run during heap traversal. |
2706 void V8HeapExplorer::TagGlobalObjects() { | 2706 void V8HeapExplorer::TagGlobalObjects() { |
2707 HandleScope scope; | 2707 HandleScope scope; |
2708 Isolate* isolate = Isolate::Current(); | 2708 Isolate* isolate = Isolate::Current(); |
2709 GlobalObjectsEnumerator enumerator; | 2709 GlobalObjectsEnumerator enumerator; |
2710 isolate->global_handles()->IterateAllRoots(&enumerator); | 2710 isolate->global_handles()->IterateAllRoots(&enumerator); |
2711 Handle<String> document_string = | |
2712 isolate->factory()->NewStringFromAscii(CStrVector("document")); | |
2713 Handle<String> url_string = | |
2714 isolate->factory()->NewStringFromAscii(CStrVector("URL")); | |
2715 const char** urls = NewArray<const char*>(enumerator.count()); | 2711 const char** urls = NewArray<const char*>(enumerator.count()); |
2716 for (int i = 0, l = enumerator.count(); i < l; ++i) { | 2712 for (int i = 0, l = enumerator.count(); i < l; ++i) { |
2717 if (global_object_name_resolver_) { | 2713 if (global_object_name_resolver_) { |
2718 HandleScope scope; | 2714 HandleScope scope; |
2719 Handle<JSGlobalObject> global_obj = enumerator.at(i); | 2715 Handle<JSGlobalObject> global_obj = enumerator.at(i); |
2720 urls[i] = global_object_name_resolver_->GetName( | 2716 urls[i] = global_object_name_resolver_->GetName( |
2721 Utils::ToLocal(Handle<JSObject>::cast(global_obj))); | 2717 Utils::ToLocal(Handle<JSObject>::cast(global_obj))); |
2722 } else { | 2718 } else { |
2723 // TODO(yurys): This branch is going to be removed once Chromium migrates | |
2724 // to the new name resolver. | |
2725 urls[i] = NULL; | 2719 urls[i] = NULL; |
2726 HandleScope scope; | |
2727 Handle<JSGlobalObject> global_obj = enumerator.at(i); | |
2728 Object* obj_document; | |
2729 if (global_obj->GetProperty(*document_string)->ToObject(&obj_document) && | |
2730 obj_document->IsJSObject()) { | |
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 } | |
2741 } | |
2742 } | 2720 } |
2743 } | 2721 } |
2744 | 2722 |
2745 AssertNoAllocation no_allocation; | 2723 AssertNoAllocation no_allocation; |
2746 for (int i = 0, l = enumerator.count(); i < l; ++i) { | 2724 for (int i = 0, l = enumerator.count(); i < l; ++i) { |
2747 objects_tags_.SetTag(*enumerator.at(i), urls[i]); | 2725 objects_tags_.SetTag(*enumerator.at(i), urls[i]); |
2748 } | 2726 } |
2749 | 2727 |
2750 DeleteArray(urls); | 2728 DeleteArray(urls); |
2751 } | 2729 } |
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3601 | 3579 |
3602 | 3580 |
3603 void HeapSnapshotJSONSerializer::SortHashMap( | 3581 void HeapSnapshotJSONSerializer::SortHashMap( |
3604 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3582 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
3605 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3583 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
3606 sorted_entries->Add(p); | 3584 sorted_entries->Add(p); |
3607 sorted_entries->Sort(SortUsingEntryValue); | 3585 sorted_entries->Sort(SortUsingEntryValue); |
3608 } | 3586 } |
3609 | 3587 |
3610 } } // namespace v8::internal | 3588 } } // namespace v8::internal |
OLD | NEW |