Skip to content

Commit a4110d9

Browse files
authored
Select barrier based on active plan (#225)
* Add barrier configuration to PlanConstraints * Remove `needs_write_barrier`
1 parent f010965 commit a4110d9

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/plan/barriers.rs

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ use crate::scheduler::WorkBucketStage;
44
use crate::util::*;
55
use crate::MMTK;
66

7+
#[derive(Copy, Clone, Debug)]
8+
pub enum BarrierSelector {
9+
NoBarrier,
10+
ObjectBarrier,
11+
}
12+
713
/// For field writes in HotSpot, we cannot always get the source object pointer and the field address
814
pub enum WriteTarget {
915
Object(ObjectReference),

src/plan/gencopy/global.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use super::gc_work::{GenCopyCopyContext, GenCopyMatureProcessEdges, GenCopyNurseryProcessEdges};
22
use super::mutator::ALLOCATOR_MAPPING;
3-
use crate::mmtk::MMTK;
43
use crate::plan::global::BasePlan;
54
use crate::plan::global::CommonPlan;
65
use crate::plan::global::GcStatus;
@@ -25,6 +24,7 @@ use crate::util::side_metadata::meta_bytes_per_chunk;
2524
use crate::util::OpaquePointer;
2625
use crate::vm::ObjectModel;
2726
use crate::vm::*;
27+
use crate::{mmtk::MMTK, plan::barriers::BarrierSelector};
2828
use enum_map::EnumMap;
2929
use std::sync::atomic::{AtomicBool, Ordering};
3030
use std::sync::Arc;
@@ -49,7 +49,7 @@ pub const GENCOPY_CONSTRAINTS: PlanConstraints = PlanConstraints {
4949
gc_header_bits: 2,
5050
gc_header_words: 0,
5151
num_specialized_scans: 1,
52-
needs_write_barrier: true,
52+
barrier: BarrierSelector::ObjectBarrier,
5353
..PlanConstraints::default()
5454
};
5555

src/plan/plan_constraints.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::plan::barriers::BarrierSelector;
12
use crate::util::constants::*;
23

34
/// This struct defines plan-specific constraints.
@@ -10,9 +11,9 @@ pub struct PlanConstraints {
1011
pub gc_header_words: usize,
1112
pub num_specialized_scans: usize,
1213
pub max_non_los_copy_bytes: usize,
13-
pub needs_write_barrier: bool,
1414
pub needs_log_bit_in_header: bool,
1515
pub needs_log_bit_in_header_num: usize,
16+
pub barrier: BarrierSelector,
1617
// the following seems unused for now
1718
pub needs_linear_scan: bool,
1819
pub needs_concurrent_workers: bool,
@@ -28,13 +29,13 @@ impl PlanConstraints {
2829
gc_header_words: 0,
2930
num_specialized_scans: 0,
3031
max_non_los_copy_bytes: MAX_INT,
31-
needs_write_barrier: false,
3232
needs_log_bit_in_header: false,
3333
needs_log_bit_in_header_num: 0,
3434
needs_linear_scan: SUPPORT_CARD_SCANNING || LAZY_SWEEP,
3535
needs_concurrent_workers: false,
3636
generate_gc_trace: false,
3737
needs_forward_after_liveness: false,
38+
barrier: BarrierSelector::NoBarrier,
3839
}
3940
}
4041
}

0 commit comments

Comments
 (0)