| 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 AtomicallyInitializedStaticReference(Mutex, mutex, new Mutex); | 523 AtomicallyInitializedStaticReference(Mutex, mutex, new Mutex); |
| 524 return mutex; | 524 return mutex; |
| 525 } | 525 } |
| 526 | 526 |
| 527 // TODO(haraken): We should improve the GC heuristics. | 527 // TODO(haraken): We should improve the GC heuristics. |
| 528 // These heuristics affect performance significantly. | 528 // These heuristics affect performance significantly. |
| 529 bool ThreadState::shouldScheduleIdleGC() | 529 bool ThreadState::shouldScheduleIdleGC() |
| 530 { | 530 { |
| 531 if (gcState() != NoGCScheduled) | 531 if (gcState() != NoGCScheduled) |
| 532 return false; | 532 return false; |
| 533 #if ENABLE(OILPAN) | 533 #if ENABLE(IDLE_GC) |
| 534 // The estimated size is updated when the main thread finishes lazy | 534 // The estimated size is updated when the main thread finishes lazy |
| 535 // sweeping. If this thread reaches here before the main thread finishes | 535 // sweeping. If this thread reaches here before the main thread finishes |
| 536 // lazy sweeping, the thread will use the estimated size of the last GC. | 536 // lazy sweeping, the thread will use the estimated size of the last GC. |
| 537 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); | 537 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); |
| 538 size_t allocatedObjectSize = Heap::allocatedObjectSize(); | 538 size_t allocatedObjectSize = Heap::allocatedObjectSize(); |
| 539 // Heap::markedObjectSize() may be underestimated if any thread has not | 539 // Heap::markedObjectSize() may be underestimated if any thread has not |
| 540 // finished completeSweep(). | 540 // finished completeSweep(). |
| 541 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() +
WTF::Partitions::totalSizeOfCommittedPages(); | 541 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() +
WTF::Partitions::totalSizeOfCommittedPages(); |
| 542 // Schedule an idle GC if Oilpan has allocated more than 1 MB since | 542 // Schedule an idle GC if Oilpan has allocated more than 1 MB since |
| 543 // the last GC and the current memory usage is >50% larger than | 543 // the last GC and the current memory usage is >50% larger than |
| 544 // the estimated live memory usage. | 544 // the estimated live memory usage. |
| 545 return allocatedObjectSize >= 1024 * 1024 && currentObjectSize > estimatedLi
veObjectSize * 3 / 2; | 545 return allocatedObjectSize >= 1024 * 1024 && currentObjectSize > estimatedLi
veObjectSize * 3 / 2; |
| 546 #else | 546 #else |
| 547 return false; | 547 return false; |
| 548 #endif | 548 #endif |
| 549 } | 549 } |
| 550 | 550 |
| 551 // TODO(haraken): We should improve the GC heuristics. | 551 // TODO(haraken): We should improve the GC heuristics. |
| 552 // These heuristics affect performance significantly. | 552 // These heuristics affect performance significantly. |
| 553 bool ThreadState::shouldSchedulePreciseGC() | 553 bool ThreadState::shouldSchedulePreciseGC() |
| 554 { | 554 { |
| 555 if (gcState() != NoGCScheduled) | 555 if (gcState() != NoGCScheduled) |
| 556 return false; | 556 return false; |
| 557 #if ENABLE(OILPAN) | 557 #if ENABLE(IDLE_GC) |
| 558 return false; | 558 return false; |
| 559 #else | 559 #else |
| 560 // The estimated size is updated when the main thread finishes lazy | 560 // The estimated size is updated when the main thread finishes lazy |
| 561 // sweeping. If this thread reaches here before the main thread finishes | 561 // sweeping. If this thread reaches here before the main thread finishes |
| 562 // lazy sweeping, the thread will use the estimated size of the last GC. | 562 // lazy sweeping, the thread will use the estimated size of the last GC. |
| 563 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); | 563 size_t estimatedLiveObjectSize = Heap::estimatedLiveObjectSize(); |
| 564 size_t allocatedObjectSize = Heap::allocatedObjectSize(); | 564 size_t allocatedObjectSize = Heap::allocatedObjectSize(); |
| 565 // Heap::markedObjectSize() may be underestimated if any thread has not | 565 // Heap::markedObjectSize() may be underestimated if any thread has not |
| 566 // finished completeSweep(). | 566 // finished completeSweep(). |
| 567 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() +
WTF::Partitions::totalSizeOfCommittedPages(); | 567 size_t currentObjectSize = allocatedObjectSize + Heap::markedObjectSize() +
WTF::Partitions::totalSizeOfCommittedPages(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 Platform::current()->currentThread()->scheduler()->postNonNestableIdleTask(F
ROM_HERE, WTF::bind<double>(&ThreadState::performIdleGC, this)); | 692 Platform::current()->currentThread()->scheduler()->postNonNestableIdleTask(F
ROM_HERE, WTF::bind<double>(&ThreadState::performIdleGC, this)); |
| 693 setGCState(IdleGCScheduled); | 693 setGCState(IdleGCScheduled); |
| 694 } | 694 } |
| 695 | 695 |
| 696 void ThreadState::scheduleIdleLazySweep() | 696 void ThreadState::scheduleIdleLazySweep() |
| 697 { | 697 { |
| 698 // Idle complete sweep is supported only in the main thread. | 698 // Idle complete sweep is supported only in the main thread. |
| 699 if (!isMainThread()) | 699 if (!isMainThread()) |
| 700 return; | 700 return; |
| 701 | 701 |
| 702 #if ENABLE_LAZY_SWEEPING | 702 #if ENABLE(LAZY_SWEEPING) |
| 703 Platform::current()->currentThread()->scheduler()->postIdleTask(FROM_HERE, W
TF::bind<double>(&ThreadState::performIdleLazySweep, this)); | 703 Platform::current()->currentThread()->scheduler()->postIdleTask(FROM_HERE, W
TF::bind<double>(&ThreadState::performIdleLazySweep, this)); |
| 704 #endif | 704 #endif |
| 705 } | 705 } |
| 706 | 706 |
| 707 void ThreadState::schedulePreciseGC() | 707 void ThreadState::schedulePreciseGC() |
| 708 { | 708 { |
| 709 if (isSweepingInProgress()) { | 709 if (isSweepingInProgress()) { |
| 710 setGCState(SweepingAndPreciseGCScheduled); | 710 setGCState(SweepingAndPreciseGCScheduled); |
| 711 return; | 711 return; |
| 712 } | 712 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 } | 919 } |
| 920 | 920 |
| 921 #if defined(ADDRESS_SANITIZER) | 921 #if defined(ADDRESS_SANITIZER) |
| 922 // TODO(Oilpan): enable the poisoning always. | 922 // TODO(Oilpan): enable the poisoning always. |
| 923 #if ENABLE(OILPAN) | 923 #if ENABLE(OILPAN) |
| 924 for (int i = 0; i < NumberOfHeaps; i++) | 924 for (int i = 0; i < NumberOfHeaps; i++) |
| 925 m_heaps[i]->poisonUnmarkedObjects(); | 925 m_heaps[i]->poisonUnmarkedObjects(); |
| 926 #endif | 926 #endif |
| 927 #endif | 927 #endif |
| 928 | 928 |
| 929 #if ENABLE_LAZY_SWEEPING | 929 #if ENABLE(LAZY_SWEEPING) |
| 930 if (gcState() == EagerSweepScheduled) { | 930 if (gcState() == EagerSweepScheduled) { |
| 931 // Eager sweeping should happen only in testing. | 931 // Eager sweeping should happen only in testing. |
| 932 setGCState(Sweeping); | 932 setGCState(Sweeping); |
| 933 completeSweep(); | 933 completeSweep(); |
| 934 } else { | 934 } else { |
| 935 // The default behavior is lazy sweeping. | 935 // The default behavior is lazy sweeping. |
| 936 setGCState(Sweeping); | 936 setGCState(Sweeping); |
| 937 eagerSweep(); | 937 eagerSweep(); |
| 938 scheduleIdleLazySweep(); | 938 scheduleIdleLazySweep(); |
| 939 } | 939 } |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 json->beginArray(it->key.ascii().data()); | 1351 json->beginArray(it->key.ascii().data()); |
| 1352 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1352 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
| 1353 json->pushInteger(it->value.ages[age]); | 1353 json->pushInteger(it->value.ages[age]); |
| 1354 json->endArray(); | 1354 json->endArray(); |
| 1355 } | 1355 } |
| 1356 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); | 1356 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); |
| 1357 } | 1357 } |
| 1358 #endif | 1358 #endif |
| 1359 | 1359 |
| 1360 } // namespace blink | 1360 } // namespace blink |
| OLD | NEW |