There are three methods involved in G1 C1 pre-barrier and they are connected by the call-chain:
```
G1BarrierSetC1::pre_barrier
-> G1BarrierSetAssembler::gen_pre_barrier_stub
-> G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub
```
In `G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub`, it contains a is-marking-active check. Its caller, essentially `G1BarrierSetAssembler::gen_pre_barrier_stub` already knows marking is active, `// At this point we know that marking is in progress`, and actual check is in `G1BarrierSetC1::pre_barrier`.
Therefore, the following code (from x86, other arch have the same pattern) is redundant.
```
// Is marking still active?
if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
__ cmpl(queue_active, 0);
} else {
assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
__ cmpb(queue_active, 0);
}
__ jcc(Assembler::equal, done);
```
```
G1BarrierSetC1::pre_barrier
-> G1BarrierSetAssembler::gen_pre_barrier_stub
-> G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub
```
In `G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub`, it contains a is-marking-active check. Its caller, essentially `G1BarrierSetAssembler::gen_pre_barrier_stub` already knows marking is active, `// At this point we know that marking is in progress`, and actual check is in `G1BarrierSetC1::pre_barrier`.
Therefore, the following code (from x86, other arch have the same pattern) is redundant.
```
// Is marking still active?
if (in_bytes(SATBMarkQueue::byte_width_of_active()) == 4) {
__ cmpl(queue_active, 0);
} else {
assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "Assumption");
__ cmpb(queue_active, 0);
}
__ jcc(Assembler::equal, done);
```
- relates to
-
JDK-8293544 G1: Add comment in G1BarrierSetC1::pre_barrier
- Resolved
-
JDK-8293353 [BACKOUT] G1: Remove redundant is-marking-active checks in C1 barrier
- Closed