blob: 0c1cd2d1145a3bde713a0bf70b50b16cdec540dd [file] [log] [blame]
Mathieu Chartier2b82db42012-11-14 17:29:05 -08001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_GC_COLLECTOR_STICKY_MARK_SWEEP_H_
18#define ART_RUNTIME_GC_COLLECTOR_STICKY_MARK_SWEEP_H_
Mathieu Chartier2b82db42012-11-14 17:29:05 -080019
Elliott Hughes76160052012-12-12 16:31:20 -080020#include "base/macros.h"
Mathieu Chartier2b82db42012-11-14 17:29:05 -080021#include "partial_mark_sweep.h"
Mathieu Chartier2b82db42012-11-14 17:29:05 -080022
Dmitrii Ishcheikin2a245692024-01-09 15:34:02 +000023namespace art HIDDEN {
Ian Rogers1d54e732013-05-02 21:10:01 -070024namespace gc {
25namespace collector {
Mathieu Chartier2b82db42012-11-14 17:29:05 -080026
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010027class StickyMarkSweep final : public PartialMarkSweep {
Mathieu Chartier2b82db42012-11-14 17:29:05 -080028 public:
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010029 GcType GetGcType() const override {
Mathieu Chartier2b82db42012-11-14 17:29:05 -080030 return kGcTypeSticky;
31 }
32
Roland Levillain3887c462015-08-12 18:15:42 +010033 StickyMarkSweep(Heap* heap, bool is_concurrent, const std::string& name_prefix = "");
Ian Rogers1d54e732013-05-02 21:10:01 -070034 ~StickyMarkSweep() {}
Mathieu Chartier2b82db42012-11-14 17:29:05 -080035
Roland Levillainf73caca2018-08-24 17:19:07 +010036 void MarkConcurrentRoots(VisitRootFlags flags) override
neo.chaea2d1b282016-11-08 08:40:46 +090037 REQUIRES(Locks::heap_bitmap_lock_)
38 REQUIRES(!mark_stack_lock_)
39 REQUIRES_SHARED(Locks::mutator_lock_);
40
Brian Carlstrom02c8cc62013-07-18 15:54:44 -070041 protected:
Ian Rogers1d54e732013-05-02 21:10:01 -070042 // Bind the live bits to the mark bits of bitmaps for all spaces, all spaces other than the
43 // alloc space will be marked as immune.
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010044 void BindBitmaps() override REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers1d54e732013-05-02 21:10:01 -070045
Mathieu Chartier1ac1c2b2015-09-22 14:53:32 -070046 void MarkReachableObjects()
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010047 override
Mathieu Chartier1ac1c2b2015-09-22 14:53:32 -070048 REQUIRES(Locks::heap_bitmap_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070049 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier2b82db42012-11-14 17:29:05 -080050
Mathieu Chartier1ac1c2b2015-09-22 14:53:32 -070051 void Sweep(bool swap_bitmaps)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010052 override
Mathieu Chartier1ac1c2b2015-09-22 14:53:32 -070053 REQUIRES(Locks::heap_bitmap_lock_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070054 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier2b82db42012-11-14 17:29:05 -080055
Mathieu Chartier02e25112013-08-14 16:14:24 -070056 private:
Mathieu Chartier3130cdf2015-05-03 15:20:23 -070057 DISALLOW_IMPLICIT_CONSTRUCTORS(StickyMarkSweep);
Mathieu Chartier2b82db42012-11-14 17:29:05 -080058};
59
Ian Rogers1d54e732013-05-02 21:10:01 -070060} // namespace collector
61} // namespace gc
Mathieu Chartier2b82db42012-11-14 17:29:05 -080062} // namespace art
63
Brian Carlstromfc0e3212013-07-17 14:40:12 -070064#endif // ART_RUNTIME_GC_COLLECTOR_STICKY_MARK_SWEEP_H_