diff options
Diffstat (limited to 'runtime/gc/heap.h')
| -rw-r--r-- | runtime/gc/heap.h | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h index aa123d8736..3484e0297d 100644 --- a/runtime/gc/heap.h +++ b/runtime/gc/heap.h @@ -26,17 +26,14 @@ #include "arch/instruction_set.h" #include "atomic.h" #include "base/time_utils.h" -#include "gc/accounting/atomic_stack.h" -#include "gc/accounting/card_table.h" -#include "gc/accounting/read_barrier_table.h" #include "gc/gc_cause.h" #include "gc/collector/gc_type.h" +#include "gc/collector/iteration.h" #include "gc/collector_type.h" #include "gc/space/large_object_space.h" #include "globals.h" #include "handle.h" #include "obj_ptr.h" -#include "object_callbacks.h" #include "offsets.h" #include "process_state.h" #include "safe_map.h" @@ -45,13 +42,18 @@ namespace art { class ConditionVariable; +class IsMarkedVisitor; class Mutex; +class RootVisitor; class StackVisitor; class Thread; class ThreadPool; class TimingLogger; class VariableSizedHandleScope; +// Same as in object_callbacks.h. Just avoid the include. +typedef void (ObjectCallback)(mirror::Object* obj, void* arg); + namespace mirror { class Class; class Object; @@ -67,8 +69,12 @@ class TaskProcessor; class Verification; namespace accounting { + template <typename T> class AtomicStack; + typedef AtomicStack<mirror::Object> ObjectStack; + class CardTable; class HeapBitmap; class ModUnionTable; + class ReadBarrierTable; class RememberedSet; } // namespace accounting @@ -99,13 +105,6 @@ namespace space { class ZygoteSpace; } // namespace space -class AgeCardVisitor { - public: - uint8_t operator()(uint8_t card) const { - return (card == accounting::CardTable::kCardDirty) ? card - 1 : 0; - } -}; - enum HomogeneousSpaceCompactResult { // Success. kSuccess, @@ -1190,9 +1189,12 @@ class Heap { // Task processor, proxies heap trim requests to the daemon threads. std::unique_ptr<TaskProcessor> task_processor_; - // True while the garbage collector is running. + // Collector type of the running GC. volatile CollectorType collector_type_running_ GUARDED_BY(gc_complete_lock_); + // Cause of the last running GC. + volatile GcCause last_gc_cause_ GUARDED_BY(gc_complete_lock_); + // The thread currently running the GC. volatile Thread* thread_running_gc_ GUARDED_BY(gc_complete_lock_); @@ -1237,10 +1239,20 @@ class Heap { // old_native_bytes_allocated_ and new_native_bytes_allocated_. Atomic<size_t> old_native_bytes_allocated_; - // Used for synchronization of blocking GCs triggered by - // RegisterNativeAllocation. + // Used for synchronization when multiple threads call into + // RegisterNativeAllocation and require blocking GC. + // * If a previous blocking GC is in progress, all threads will wait for + // that GC to complete, then wait for one of the threads to complete another + // blocking GC. + // * If a blocking GC is assigned but not in progress, a thread has been + // assigned to run a blocking GC but has not started yet. Threads will wait + // for the assigned blocking GC to complete. + // * If a blocking GC is not assigned nor in progress, the first thread will + // run a blocking GC and signal to other threads that blocking GC has been + // assigned. Mutex* native_blocking_gc_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; std::unique_ptr<ConditionVariable> native_blocking_gc_cond_ GUARDED_BY(native_blocking_gc_lock_); + bool native_blocking_gc_is_assigned_ GUARDED_BY(native_blocking_gc_lock_); bool native_blocking_gc_in_progress_ GUARDED_BY(native_blocking_gc_lock_); uint32_t native_blocking_gcs_finished_ GUARDED_BY(native_blocking_gc_lock_); |