| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 void HeapSnapshotsCollection::RemoveSnapshot(HeapSnapshot* snapshot) { | 1555 void HeapSnapshotsCollection::RemoveSnapshot(HeapSnapshot* snapshot) { |
| 1556 snapshots_.RemoveElement(snapshot); | 1556 snapshots_.RemoveElement(snapshot); |
| 1557 unsigned uid = snapshot->uid(); | 1557 unsigned uid = snapshot->uid(); |
| 1558 snapshots_uids_.Remove(reinterpret_cast<void*>(uid), | 1558 snapshots_uids_.Remove(reinterpret_cast<void*>(uid), |
| 1559 static_cast<uint32_t>(uid)); | 1559 static_cast<uint32_t>(uid)); |
| 1560 } | 1560 } |
| 1561 | 1561 |
| 1562 | 1562 |
| 1563 Handle<HeapObject> HeapSnapshotsCollection::FindHeapObjectById(uint64_t id) { | 1563 Handle<HeapObject> HeapSnapshotsCollection::FindHeapObjectById(uint64_t id) { |
| 1564 // First perform a full GC in order to avoid dead objects. | 1564 // First perform a full GC in order to avoid dead objects. |
| 1565 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask); | 1565 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
| 1566 "HeapSnapshotsCollection::FindHeapObjectById"); |
| 1566 AssertNoAllocation no_allocation; | 1567 AssertNoAllocation no_allocation; |
| 1567 HeapObject* object = NULL; | 1568 HeapObject* object = NULL; |
| 1568 HeapIterator iterator(HeapIterator::kFilterUnreachable); | 1569 HeapIterator iterator(HeapIterator::kFilterUnreachable); |
| 1569 // Make sure that object with the given id is still reachable. | 1570 // Make sure that object with the given id is still reachable. |
| 1570 for (HeapObject* obj = iterator.next(); | 1571 for (HeapObject* obj = iterator.next(); |
| 1571 obj != NULL; | 1572 obj != NULL; |
| 1572 obj = iterator.next()) { | 1573 obj = iterator.next()) { |
| 1573 if (ids_.FindObject(obj->address()) == id) { | 1574 if (ids_.FindObject(obj->address()) == id) { |
| 1574 ASSERT(object == NULL); | 1575 ASSERT(object == NULL); |
| 1575 object = obj; | 1576 object = obj; |
| (...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3041 }; | 3042 }; |
| 3042 | 3043 |
| 3043 | 3044 |
| 3044 bool HeapSnapshotGenerator::GenerateSnapshot() { | 3045 bool HeapSnapshotGenerator::GenerateSnapshot() { |
| 3045 v8_heap_explorer_.TagGlobalObjects(); | 3046 v8_heap_explorer_.TagGlobalObjects(); |
| 3046 | 3047 |
| 3047 // TODO(1562) Profiler assumes that any object that is in the heap after | 3048 // TODO(1562) Profiler assumes that any object that is in the heap after |
| 3048 // full GC is reachable from the root when computing dominators. | 3049 // full GC is reachable from the root when computing dominators. |
| 3049 // This is not true for weakly reachable objects. | 3050 // This is not true for weakly reachable objects. |
| 3050 // As a temporary solution we call GC twice. | 3051 // As a temporary solution we call GC twice. |
| 3051 Isolate::Current()->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask); | 3052 Isolate::Current()->heap()->CollectAllGarbage( |
| 3052 Isolate::Current()->heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask); | 3053 Heap::kMakeHeapIterableMask, |
| 3054 "HeapSnapshotGenerator::GenerateSnapshot"); |
| 3055 Isolate::Current()->heap()->CollectAllGarbage( |
| 3056 Heap::kMakeHeapIterableMask, |
| 3057 "HeapSnapshotGenerator::GenerateSnapshot"); |
| 3053 | 3058 |
| 3054 #ifdef DEBUG | 3059 #ifdef DEBUG |
| 3055 Heap* debug_heap = Isolate::Current()->heap(); | 3060 Heap* debug_heap = Isolate::Current()->heap(); |
| 3056 ASSERT(!debug_heap->old_data_space()->was_swept_conservatively()); | 3061 ASSERT(!debug_heap->old_data_space()->was_swept_conservatively()); |
| 3057 ASSERT(!debug_heap->old_pointer_space()->was_swept_conservatively()); | 3062 ASSERT(!debug_heap->old_pointer_space()->was_swept_conservatively()); |
| 3058 ASSERT(!debug_heap->code_space()->was_swept_conservatively()); | 3063 ASSERT(!debug_heap->code_space()->was_swept_conservatively()); |
| 3059 ASSERT(!debug_heap->cell_space()->was_swept_conservatively()); | 3064 ASSERT(!debug_heap->cell_space()->was_swept_conservatively()); |
| 3060 ASSERT(!debug_heap->map_space()->was_swept_conservatively()); | 3065 ASSERT(!debug_heap->map_space()->was_swept_conservatively()); |
| 3061 #endif | 3066 #endif |
| 3062 | 3067 |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3659 | 3664 |
| 3660 | 3665 |
| 3661 void HeapSnapshotJSONSerializer::SortHashMap( | 3666 void HeapSnapshotJSONSerializer::SortHashMap( |
| 3662 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3667 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 3663 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3668 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 3664 sorted_entries->Add(p); | 3669 sorted_entries->Add(p); |
| 3665 sorted_entries->Sort(SortUsingEntryValue); | 3670 sorted_entries->Sort(SortUsingEntryValue); |
| 3666 } | 3671 } |
| 3667 | 3672 |
| 3668 } } // namespace v8::internal | 3673 } } // namespace v8::internal |
| OLD | NEW |