| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 #endif | 952 #endif |
| 953 | 953 |
| 954 for (int i = 0; i < NumberOfHeaps; i++) | 954 for (int i = 0; i < NumberOfHeaps; i++) |
| 955 m_heaps[i]->prepareForSweep(); | 955 m_heaps[i]->prepareForSweep(); |
| 956 | 956 |
| 957 if (gcType == GCWithSweep) { | 957 if (gcType == GCWithSweep) { |
| 958 setGCState(EagerSweepScheduled); | 958 setGCState(EagerSweepScheduled); |
| 959 } else if (gcType == GCWithoutSweep) { | 959 } else if (gcType == GCWithoutSweep) { |
| 960 setGCState(LazySweepScheduled); | 960 setGCState(LazySweepScheduled); |
| 961 } else { | 961 } else { |
| 962 takeSnapshot(); | 962 takeSnapshot(SnapshotType::HeapSnapshot); |
| 963 | 963 |
| 964 // This unmarks all marked objects and marks all unmarked objects dead. | 964 // This unmarks all marked objects and marks all unmarked objects dead. |
| 965 makeConsistentForMutator(); | 965 makeConsistentForMutator(); |
| 966 | 966 |
| 967 takeSnapshot(SnapshotType::FreelistSnapshot); |
| 968 |
| 967 // Force setting NoGCScheduled to circumvent checkThread() | 969 // Force setting NoGCScheduled to circumvent checkThread() |
| 968 // in setGCState(). | 970 // in setGCState(). |
| 969 m_gcState = NoGCScheduled; | 971 m_gcState = NoGCScheduled; |
| 970 } | 972 } |
| 971 } | 973 } |
| 972 | 974 |
| 973 void ThreadState::preSweep() | 975 void ThreadState::preSweep() |
| 974 { | 976 { |
| 975 checkThread(); | 977 checkThread(); |
| 976 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled) | 978 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled) |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 m_vectorBackingHeapIndex = heapIndexOfVectorHeapLeastRecentlyExpanded(Ve
ctor1HeapIndex, Vector4HeapIndex); | 1368 m_vectorBackingHeapIndex = heapIndexOfVectorHeapLeastRecentlyExpanded(Ve
ctor1HeapIndex, Vector4HeapIndex); |
| 1367 } | 1369 } |
| 1368 | 1370 |
| 1369 void ThreadState::promptlyFreed(size_t gcInfoIndex) | 1371 void ThreadState::promptlyFreed(size_t gcInfoIndex) |
| 1370 { | 1372 { |
| 1371 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask; | 1373 size_t entryIndex = gcInfoIndex & likelyToBePromptlyFreedArrayMask; |
| 1372 // See the comment in vectorBackingHeap() for why this is +3. | 1374 // See the comment in vectorBackingHeap() for why this is +3. |
| 1373 m_likelyToBePromptlyFreed[entryIndex] += 3; | 1375 m_likelyToBePromptlyFreed[entryIndex] += 3; |
| 1374 } | 1376 } |
| 1375 | 1377 |
| 1376 void ThreadState::takeSnapshot() | 1378 void ThreadState::takeSnapshot(SnapshotType type) |
| 1377 { | 1379 { |
| 1378 ASSERT(isInGC()); | 1380 ASSERT(isInGC()); |
| 1379 | 1381 |
| 1380 int numberOfHeapsReported = 0; | 1382 int numberOfHeapsReported = 0; |
| 1381 #define SNAPSHOT_HEAP(HeapType)
\ | 1383 #define SNAPSHOT_HEAP(HeapType)
\ |
| 1382 {
\ | 1384 {
\ |
| 1383 numberOfHeapsReported++;
\ | 1385 numberOfHeapsReported++;
\ |
| 1384 String allocatorBaseName;
\ | 1386 String allocatorBaseName;
\ |
| 1385 allocatorBaseName = String::format("blink_gc/thread_%lu/heaps/" #HeapTyp
e, (unsigned long)(m_thread)); \ | 1387 allocatorBaseName = String::format("blink_gc/thread_%lu/heaps/" #HeapTyp
e, (unsigned long)(m_thread)); \ |
| 1386 m_heaps[HeapType##HeapIndex]->takeSnapshot(allocatorBaseName);
\ | 1388 switch (type) {
\ |
| 1389 case SnapshotType::HeapSnapshot:
\ |
| 1390 m_heaps[HeapType##HeapIndex]->takeSnapshot(allocatorBaseName);
\ |
| 1391 break;
\ |
| 1392 case SnapshotType::FreelistSnapshot:
\ |
| 1393 m_heaps[HeapType##HeapIndex]->takeFreelistSnapshot(allocatorBaseName
); \ |
| 1394 break;
\ |
| 1395 default:
\ |
| 1396 ASSERT_NOT_REACHED();
\ |
| 1397 }
\ |
| 1387 } | 1398 } |
| 1388 | 1399 |
| 1389 SNAPSHOT_HEAP(NormalPage1); | 1400 SNAPSHOT_HEAP(NormalPage1); |
| 1390 SNAPSHOT_HEAP(NormalPage2); | 1401 SNAPSHOT_HEAP(NormalPage2); |
| 1391 SNAPSHOT_HEAP(NormalPage3); | 1402 SNAPSHOT_HEAP(NormalPage3); |
| 1392 SNAPSHOT_HEAP(NormalPage4); | 1403 SNAPSHOT_HEAP(NormalPage4); |
| 1393 SNAPSHOT_HEAP(EagerSweep); | 1404 SNAPSHOT_HEAP(EagerSweep); |
| 1394 SNAPSHOT_HEAP(Vector1); | 1405 SNAPSHOT_HEAP(Vector1); |
| 1395 SNAPSHOT_HEAP(Vector2); | 1406 SNAPSHOT_HEAP(Vector2); |
| 1396 SNAPSHOT_HEAP(Vector3); | 1407 SNAPSHOT_HEAP(Vector3); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 json->beginArray(it->key.ascii().data()); | 1506 json->beginArray(it->key.ascii().data()); |
| 1496 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1507 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
| 1497 json->pushInteger(it->value.ages[age]); | 1508 json->pushInteger(it->value.ages[age]); |
| 1498 json->endArray(); | 1509 json->endArray(); |
| 1499 } | 1510 } |
| 1500 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); | 1511 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); |
| 1501 } | 1512 } |
| 1502 #endif | 1513 #endif |
| 1503 | 1514 |
| 1504 } // namespace blink | 1515 } // namespace blink |
| OLD | NEW |