| 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 | 645 |
| 646 void ThreadState::scheduleGCIfNeeded() | 646 void ThreadState::scheduleGCIfNeeded() |
| 647 { | 647 { |
| 648 checkThread(); | 648 checkThread(); |
| 649 // Allocation is allowed during sweeping, but those allocations should not | 649 // Allocation is allowed during sweeping, but those allocations should not |
| 650 // trigger nested GCs. | 650 // trigger nested GCs. |
| 651 if (isSweepingInProgress()) | 651 if (isSweepingInProgress()) |
| 652 return; | 652 return; |
| 653 ASSERT(!sweepForbidden()); | 653 ASSERT(!sweepForbidden()); |
| 654 | 654 |
| 655 #if ENABLE(GC_PROFILING) | 655 Heap::reportMemoryUsageForTracing(); |
| 656 // These values are divided by 1024 to avoid overflow in practical cases (TR
ACE_COUNTER values are 32-bit ints). | |
| 657 // They are capped to INT_MAX just in case. | |
| 658 TRACE_COUNTER1("blink_gc", "Heap::estimatedLiveObjectSizeKB", std::min(Heap:
:estimatedLiveObjectSize() / 1024, static_cast<size_t>(INT_MAX))); | |
| 659 TRACE_COUNTER1("blink_gc", "Heap::allocatedObjectSizeKB", std::min(Heap::all
ocatedObjectSize() / 1024, static_cast<size_t>(INT_MAX))); | |
| 660 TRACE_COUNTER1("blink_gc", "Heap::markedObjectSizeKB", std::min(Heap::marked
ObjectSize() / 1024, static_cast<size_t>(INT_MAX))); | |
| 661 TRACE_COUNTER1("blink_gc", "Partitions::totalSizeOfCommittedPagesKB", std::m
in(WTF::Partitions::totalSizeOfCommittedPages() / 1024, static_cast<size_t>(INT_
MAX))); | |
| 662 #endif | |
| 663 | 656 |
| 664 if (shouldForceConservativeGC()) { | 657 if (shouldForceConservativeGC()) { |
| 665 Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::Conserva
tiveGC); | 658 Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::Conserva
tiveGC); |
| 666 return; | 659 return; |
| 667 } | 660 } |
| 668 if (shouldSchedulePreciseGC()) | 661 if (shouldSchedulePreciseGC()) |
| 669 schedulePreciseGC(); | 662 schedulePreciseGC(); |
| 670 else if (shouldScheduleIdleGC()) | 663 else if (shouldScheduleIdleGC()) |
| 671 scheduleIdleGC(); | 664 scheduleIdleGC(); |
| 672 } | 665 } |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 | 1085 |
| 1093 if (isMainThread()) | 1086 if (isMainThread()) |
| 1094 ScriptForbiddenScope::exit(); | 1087 ScriptForbiddenScope::exit(); |
| 1095 } | 1088 } |
| 1096 | 1089 |
| 1097 postSweep(); | 1090 postSweep(); |
| 1098 } | 1091 } |
| 1099 | 1092 |
| 1100 void ThreadState::postSweep() | 1093 void ThreadState::postSweep() |
| 1101 { | 1094 { |
| 1095 Heap::reportMemoryUsageForTracing(); |
| 1096 |
| 1102 if (isMainThread()) { | 1097 if (isMainThread()) { |
| 1103 // At the point where the main thread finishes lazy sweeping, | 1098 // At the point where the main thread finishes lazy sweeping, |
| 1104 // we estimate the live object size. Heap::markedObjectSize() | 1099 // we estimate the live object size. Heap::markedObjectSize() |
| 1105 // may be underestimated if any other thread has not finished | 1100 // may be underestimated if any other thread has not finished |
| 1106 // lazy sweeping. | 1101 // lazy sweeping. |
| 1107 Heap::setEstimatedLiveObjectSize(Heap::markedObjectSize() + Heap::extern
alObjectSizeAtLastGC()); | 1102 Heap::setEstimatedLiveObjectSize(Heap::markedObjectSize() + Heap::extern
alObjectSizeAtLastGC()); |
| 1108 } | 1103 } |
| 1109 | 1104 |
| 1110 switch (gcState()) { | 1105 switch (gcState()) { |
| 1111 case Sweeping: | 1106 case Sweeping: |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 json->beginArray(it->key.ascii().data()); | 1464 json->beginArray(it->key.ascii().data()); |
| 1470 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1465 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
| 1471 json->pushInteger(it->value.ages[age]); | 1466 json->pushInteger(it->value.ages[age]); |
| 1472 json->endArray(); | 1467 json->endArray(); |
| 1473 } | 1468 } |
| 1474 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); | 1469 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); |
| 1475 } | 1470 } |
| 1476 #endif | 1471 #endif |
| 1477 | 1472 |
| 1478 } // namespace blink | 1473 } // namespace blink |
| OLD | NEW |