Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
306 commits
Select commit Hold shift + click to select a range
cbc9e44
Fix Windows builds
shipilev May 4, 2021
41ed846
Fix Region Promotion
May 6, 2021
c6740a8
More promotion fixes
May 14, 2021
207da43
Abandon old gen cset candidates upon global collection
May 14, 2021
627ca10
Allow committers to review Shenandoah changes
May 25, 2021
27732e5
Collect old humongous regions immediately at end of concurrent old mark
May 25, 2021
a21de22
Mixed evacuation fixes
May 25, 2021
fff87a6
Fix verifier handling of weak references when scanning the remembered…
May 25, 2021
6f1f29a
Encode phase for each generation separately
May 26, 2021
9011a4b
Check explicitly for affiliation when updating references
May 27, 2021
0b3dc74
Fix 32-bit builds
shipilev Jun 14, 2021
ded735f
Do old satb during interrupting young
kdnilsen Jul 19, 2021
d775516
Concurrent remembered set scanning
kdnilsen Jul 22, 2021
5ebe8d1
Check that pointer is in heap before checking the affiliation of owni…
Aug 6, 2021
be67d44
Generational support for weak roots and references
Aug 9, 2021
6ee7458
Enable skip update references
Aug 10, 2021
b96a883
Re-enable class unloading
Aug 10, 2021
df8c056
Make immediate trash of old regions with no live objects
Aug 16, 2021
c02907e
Fix Zero builds
shipilev Aug 19, 2021
7dc7537
Update alloc liveness data during final mark of old generation
Aug 20, 2021
9f0f23b
Preserve and restore original element count for card table barrier
Aug 20, 2021
4d10061
Add generational full gc support
kdnilsen Aug 27, 2021
0a72c50
Fix ShenandoahFullGC worker stats handling
shipilev Sep 2, 2021
f01e568
Fix misuse of atomic flag
Sep 2, 2021
ad15b6b
Merge openjdk/jdk:master
Sep 9, 2021
aa7ff7c
Enable remembered set verification during global collections
Sep 9, 2021
40174b8
Remove log message that could access an out of bounds region
Sep 10, 2021
dd7af29
Fix handling of weak references during verification
Sep 15, 2021
6a802c2
Fix full gc with class unloading
kdnilsen Sep 15, 2021
1c2ee14
Reset task queue stats before rset scan
Sep 16, 2021
fd27542
Fix loop error when reconstructing remembered set for humongous objects
Sep 17, 2021
52973cc
Track promotion rate into old generation
Sep 20, 2021
f9e068d
Fix failing jtreg tests
Sep 22, 2021
ea8469a
Also register filler object for retired gclabs
Sep 29, 2021
7fe11a2
Only register retired plab waste in old regions
Sep 30, 2021
85592d9
Full region promotion
kdnilsen Oct 4, 2021
2493e37
Coalesce and fill unmarked objects during global degenerated cycle
Oct 4, 2021
4d8ce22
Decouple generational heuristics
Oct 5, 2021
6a1eebb
Improve handling of promotion and old generation evacuation failures
Oct 6, 2021
a910ee8
Age cycle periodically
kdnilsen Oct 6, 2021
d59d18e
Add an option to stream region sampling data to a file
Oct 7, 2021
7765c14
Inline usage of pointer_delta
Oct 7, 2021
fb788c8
Register filler objects when non-lab allocations are backed out
Oct 11, 2021
deb452d
Update heap usage tallies for generations after full GC compaction
Oct 12, 2021
5ccbfbc
Remove vestigial command line options and removed unused code
Oct 12, 2021
aa775e9
Preempt old preparation
kdnilsen Oct 13, 2021
6d8ebd7
Do not coalesce dead objects in global cycle if GC was cancelled
Oct 14, 2021
8caba42
Replace 'HEY!' comments with TODO and remove unnecessary usages
Oct 14, 2021
8c87aa9
Reset coalesce and fill boundary during global collect
Oct 15, 2021
ca939b6
Degenerate to young cycles for out of cycle allocation failures
Oct 19, 2021
e2c8047
Initialize promotion failed member to false
Oct 19, 2021
7bc0d2b
Make region sampling aware of full collections
Oct 21, 2021
e442388
Enforce maximum capacity of young generation when allocating
Oct 21, 2021
ad4ad1f
Align plabs on card boundaries
kdnilsen Oct 27, 2021
5cba4ba
Fix preempt old preparation
kdnilsen Nov 1, 2021
c5af3b9
Padding used for alignment must fit an object
Nov 10, 2021
641e665
Remove assert that plab allocation must succeed
Nov 16, 2021
191dd79
Clear young generation reference to old mark queues when starting glo…
Nov 18, 2021
0dfb0a3
Split Generational Shenandoah memory pools
alvdavi Nov 29, 2021
da7bbab
Add missing override keyword to fix MacOS (clang) builds
Nov 30, 2021
58064aa
Only verify last object start for marked objects
Dec 6, 2021
3e53234
Reset top bitmap when region is immediately made into trash
Jan 12, 2022
7d0a45c
Degenerate to marking phase if cancellation detected after final mark
Jan 27, 2022
915bea8
Update card table when cycle degenerates during root scan
Jan 27, 2022
e91c55c
Simplify crossing map implementation
kdnilsen Feb 1, 2022
006e14e
Coalesce and fill objects immediately after final mark
Feb 1, 2022
b233fe7
Improve handling of cancellation after final mark
Feb 4, 2022
c4bafae
Coalesce and fill dead objects after class unloading
Feb 8, 2022
e1d15c1
Borrow from old gen
kdnilsen Feb 8, 2022
dc9d7d0
Fix two errors in recent commit
kdnilsen Feb 8, 2022
cd0d9c1
Use active generation, rather than young exclusively when preparing f…
Feb 9, 2022
47ca07c
Fixes for running in non-generational modes
Feb 10, 2022
0a5a369
Merge openjdk/jdk:master
Feb 15, 2022
a9a9f13
Coalesce dead objects in pinned old regions during full gc
Feb 22, 2022
2132a6d
Mutator may fail to evacuate
kdnilsen Feb 22, 2022
0a57127
Clear cards for old regions when they are put into service
Feb 23, 2022
b54dca1
Remove young generation access to old generation mark queues earlier
Mar 1, 2022
98b2132
Reset update watermark for cycles degenerated during evacuation
Mar 2, 2022
a2b5be2
Age objects before installing forwarding pointer to them
Mar 4, 2022
958ea3b
Allow old collections to span degenerated young collections
Mar 16, 2022
576b7dc
Generational ShenandoahGC on PPC64
TheRealMDoerr Mar 17, 2022
71fe3e5
Do not abort coalesce and fill during fullgc
kdnilsen Mar 21, 2022
ca6fa69
Global mark is not old mark
Mar 21, 2022
5fd9764
Balance evacuation
kdnilsen Mar 24, 2022
54f1e49
Relax enforcement of evacuation budget
Apr 6, 2022
278ecdc
Cool down regulator after request to start GC is accepted
Apr 12, 2022
ca2cf6b
Improved timing reports
Apr 14, 2022
199e808
Include mark worker performance in report for concurrent mark phase
Apr 15, 2022
b759dab
Fix concurrent mark worker timings
Apr 20, 2022
5ec87a5
Use state from collection set to know if mixed collection is in progress
Apr 20, 2022
bdd7667
Only clear requested gc cause when it is handled
Apr 22, 2022
b4ad354
Allow regulator to schedule global cycles for the purpose of class un…
Apr 29, 2022
10ebe4e
Include mixed and abbreviated cycle counts in summary report
Apr 29, 2022
469df3e
Have adaptive heuristic include only full cycles in average cycle time
May 4, 2022
58ea106
Filter out invalid pointers picked up by old gen SATB
May 12, 2022
5473b07
Start young collect instead of old if mixed evacuations are pending
May 18, 2022
ea3191d
Reserve regions for the collector according to generational reserves
Jun 9, 2022
a8676f6
Fix fullgc
kdnilsen Jun 13, 2022
a5aa413
Improve humongous remset scan
kdnilsen Jun 17, 2022
bd13ba3
Pack old evacuations tightly
kdnilsen Jun 24, 2022
0fefe70
Remove unnecessary checks identified by reviewer
kdnilsen Jun 24, 2022
3c066d4
Adaptive heuristic should take reserved memory into account
Jun 28, 2022
4de4c3e
cli options for young/old ShenandoahMinFreeThreshold
caojoshua Jul 6, 2022
09d6ab5
Windows compiler does not support variable length arrays
Jul 6, 2022
013b2f6
Include a version identifier in region sampling protocol for visualizer
Jul 12, 2022
d47c60e
Refactor budgeting to make the logic cleaner
kdnilsen Jul 13, 2022
16a9ab6
Load balance remembered set scanning
kdnilsen Aug 1, 2022
60e43d0
Merge openjdk/jdk:master
Aug 2, 2022
afe4d0a
Include old humongous start regions when counting immediate garbage
Aug 9, 2022
6acf4e5
Handle old, pinned regions
Aug 9, 2022
b4ff060
Fix budgeting assertion
kdnilsen Aug 13, 2022
270e8b8
Use only up to ConcGCThreads for concurrent RS scanning.
Aug 29, 2022
2bc25de
Log rotation
cfumiwu Sep 1, 2022
7bf65f1
Merge openjdk/jdk:master
Sep 2, 2022
791b74d
Fix off-by-one error when verifying object registrations
Sep 2, 2022
a3799c8
Shenandoah unified logging
cfumiwu Sep 6, 2022
79a4bd1
Merge openjdk/jdk:master
Oct 24, 2022
067173a
Merge openjdk/jdk:master
Oct 25, 2022
22ff4b9
Fix assertion error with advance promotion budgeting
kdnilsen Nov 1, 2022
50c5458
Fix preemption of coalesce and fill
kdnilsen Nov 2, 2022
998f68b
Improve evacuation instrumentation
Nov 7, 2022
a0b7ce0
Merge openjdk/jdk:master
Nov 10, 2022
1b110a4
Improve some defaults and remove unused options for generational mode
Nov 10, 2022
419a3a2
Change affiliation representation
kdnilsen Nov 16, 2022
3da2fd5
Merge openjdk/jdk:master
Nov 18, 2022
fe51a9b
Do not apply evacuation budgets in non-generational mode
Nov 18, 2022
264f9c2
Load balance remset scan
kdnilsen Nov 18, 2022
b594e54
Various build fixes
Nov 19, 2022
f90a770
Merge openjdk/jdk:master
Nov 30, 2022
6ce5f22
Merge openjdk/jdk:master
Dec 6, 2022
2546928
Enforce max regions
kdnilsen Dec 7, 2022
ee49a48
Generation resizing
Dec 8, 2022
7a3ebbc
Generation sizing fixes
Dec 14, 2022
35b26d6
Allow adjusted capacity and used regions size to be equal
Dec 14, 2022
3901a71
Merge openjdk/jdk:master
Dec 15, 2022
abedbc1
Merge openjdk/jdk:master
Dec 16, 2022
bbd4ef3
8298597: HdrSeq: support for a merge() method
Dec 19, 2022
1a96238
Use CardTable::card_size_in_words rather than hard coded constant
Dec 19, 2022
9114616
Shrink tlab to capacity
kdnilsen Dec 20, 2022
da95011
Initial sizing refactor
Dec 21, 2022
d793fd1
Avoid divide by zero error, improve variable names
Dec 21, 2022
6c8fa0f
8297796: GenShen: instrument the remembered set scan
Dec 28, 2022
301d822
Merge openjdk/jdk:master
Dec 29, 2022
ba80849
Allow heuristic trigger to increase capacity instead of running a col…
Jan 4, 2023
6daaa75
Enforce that generation sizes align with region sizes
kdnilsen Jan 4, 2023
7e9a1d4
Fix allocate aligned
kdnilsen Jan 5, 2023
cb70d29
Fix use of uninitialized double
Jan 5, 2023
c5774a0
Plab fallback to minsize
kdnilsen Jan 6, 2023
bbd3994
Merge openjdk/jdk:master
Jan 9, 2023
aca12fc
Fix verification of remembered set at mark start
kdnilsen Jan 11, 2023
0be422b
Broaden plab region search
kdnilsen Jan 12, 2023
0e15cb6
Fix fullgc assertion
kdnilsen Jan 13, 2023
ec3e5ef
Use whole number of regions when resizing generations
Jan 13, 2023
bfeccbd
Merge openjdk/jdk:master
Jan 14, 2023
2cab4e7
Do not reset learning cycles after resizing
Jan 18, 2023
800c0c8
8298647: GenShen require heap size 2MB granularity
Jan 24, 2023
1974f58
Merge openjdk/jdk:master
Jan 26, 2023
13b8341
Merge openjdk/jdk:master
Jan 27, 2023
60861ba
Revert unnecessary changes to unified logging
Jan 27, 2023
1813266
Tune heuristic defaults and behavior for improved stability
Jan 31, 2023
8a67ed0
Combine bitmap clearing with region resetting closure
Jan 31, 2023
a2963b1
Age objects during degeneration
kdnilsen Jan 31, 2023
998ea70
Loan from old should align on region size
kdnilsen Feb 1, 2023
0a7d893
Fullgc should honor aging cycle
kdnilsen Feb 1, 2023
3e8f765
Following abbreviated cycle, only increment region age if aging cycle
kdnilsen Feb 1, 2023
d40ba7d
Bootstrap old gc should honor aging cycle
kdnilsen Feb 1, 2023
4ec2cd9
Update vestigial comment
Feb 1, 2023
75811f9
8299703: GenShen: improvements in card scanning
Feb 2, 2023
d258034
Merge openjdk/jdk:master
Feb 10, 2023
779314b
Merge openjdk/jdk:master
Feb 14, 2023
0dbacdf
Remove unused visualizer option
Feb 16, 2023
c778125
Merge openjdk/jdk:master
Feb 17, 2023
ebc1fd1
Merge openjdk/jdk:master
Mar 1, 2023
a1270d7
Performance improvements for non-generational modes
Mar 6, 2023
87bf68f
Use relevant variables in log messages, remove unused import
Mar 10, 2023
b4ee731
Fix incorrect assert logic
Mar 13, 2023
b909ec3
Merge openjdk/jdk:master
Mar 13, 2023
bfc07d8
Fix off-by-one error when handling pinned regions in a mixed collection
Mar 17, 2023
bfa248a
Merge openjdk/jdk:master
Mar 17, 2023
d367909
Do not visit gc threads during shutdown
Mar 20, 2023
1b6d6b2
Fix error in alignment of plabs
kdnilsen Mar 20, 2023
a853a7a
Separate young and old regions in age census at end of each GC
kdnilsen Mar 21, 2023
1a3dcaa
Put regulator thread stop after gc thread iteration is prevented
Mar 23, 2023
a5d1a9d
Lower logging of collection set details to debug and use cset tag
Mar 23, 2023
aa15723
Merge openjdk/jdk:master
Mar 28, 2023
2785875
Restrict generational mode to adaptive heuristic
Mar 29, 2023
f7cede9
Recompute generation accounts after fullgc
kdnilsen Mar 30, 2023
ba4161d
Fix satb barrier for object array copy
kdnilsen Mar 31, 2023
f75b50b
Abandon mixed collections if all candidates are pinned
Mar 31, 2023
d0e1f51
8305334: GenShen: reference processing needs a card-marking barrier
Mar 31, 2023
b7f37c4
Merge openjdk/jdk:master
Apr 1, 2023
1143dbe
Allow transition from any old generation state to idle
Apr 3, 2023
fc20c90
Disable redundant generation usage after fullgc
kdnilsen Apr 4, 2023
ab9a397
Fix build error on MacOS / Clang 14.0.0
shipilev Apr 4, 2023
72b67ad
Remove assertions constraining card marking for reference processing
Apr 4, 2023
3a03d7d
Fix Zero builds
shipilev Apr 5, 2023
d6df935
Update copyright lines
shipilev Apr 6, 2023
365e46a
Merge openjdk/jdk:master
Apr 10, 2023
461f083
Move affiliation and mode out of ShenandoahGenerationalMode
shipilev Apr 10, 2023
c9a6355
Cleanups, TODOs, asserts (part 1)
shipilev Apr 11, 2023
9d87724
Restore event descriptions immortality
shipilev Apr 13, 2023
9f256a5
Cleanups, TODOs, asserts (part 2)
shipilev Apr 13, 2023
b262350
Reduce the number of new product flags
shipilev Apr 13, 2023
dad2a5b
Merge openjdk/jdk:master
Apr 13, 2023
7df4136
Disable assertions in code that is expected to be replaced soon
Apr 14, 2023
b5e2102
Disable failing tests while fixes are in progress
Apr 17, 2023
42da31c
Disable verification of adjusted capacity
Apr 18, 2023
79bbb5a
Account for humongous object waste
Apr 18, 2023
016bf07
Specialize ShenandoahGenerationType to avoid generational check penal…
shipilev Apr 18, 2023
5984bd2
Add unique ticket number for each disabled test
Apr 19, 2023
badb738
Eliminate TODO in ShenandoahHeuristics::select_aged_regions
shipilev Apr 21, 2023
64d14f3
8306334: Handle preemption of old cycle between filling and bootstrap…
Apr 24, 2023
d59effc
Use state of mark context itself to track stability of old mark bitmap
Apr 25, 2023
d254fb2
Usage tracking cleanup
Apr 26, 2023
b442302
Remove redundant initialization code
kdnilsen Apr 26, 2023
58fa141
Cleanup NumberSeq additions
shipilev May 1, 2023
6f71ef6
Add generations to freeset
kdnilsen May 2, 2023
21982fc
Merge openjdk/jdk:master
May 2, 2023
4e1ad18
Remove the remaining unclean upstream difference
shipilev May 3, 2023
90a1c9b
Use distinct "end of cycle" message for each Shenandoah pause
May 3, 2023
84c36e6
Alphabetize includes
May 3, 2023
c966d9a
Remove passing tests from ProblemList.txt
May 8, 2023
28f7c5d
Merge openjdk/jdk:master
May 9, 2023
f969d53
Increase card offset mask
May 10, 2023
a2ab997
Assert that region usage accounting is only accessed in generational …
May 10, 2023
e48977a
Use static assert to validate card offset encoding mask
May 15, 2023
238fb7a
Use soft max capacity only for trigger calculations
May 18, 2023
77885b1
Improve mixed collection logging
May 19, 2023
d7a706e
Merge openjdk/jdk:master
May 19, 2023
e33ecfa
Make generational mode experimental
May 24, 2023
8d4f58c
Merge openjdk/jdk:master
May 26, 2023
57fdc18
Expand old on demand
kdnilsen May 26, 2023
fe4ced3
Merge remote-tracking branch 'shenandoah/master' into merge-generatio…
kdnilsen May 26, 2023
0c62f9c
Remove early planning docs from PR
kdnilsen May 26, 2023
aa85a90
Revert changes to jcheck configuration
kdnilsen May 30, 2023
eb656ec
Make the order of young/old collector checks consistent (#1)
earthling-amzn Jun 1, 2023
5bf6e7e
Assert bounds only when allocations succeed, increase test timeouts (#2)
earthling-amzn Jun 2, 2023
d4d2f1c
Force PLAB sizes to align on card-table size
kdnilsen Jun 2, 2023
8d80780
Remove three asserts making comparisons between atomic volatile varia…
kdnilsen Jun 4, 2023
9811d2a
Remove an inappropriate copyright notice
kdnilsen Jun 6, 2023
cc14990
Exit during initialization on unsupported platforms
kdnilsen Jun 6, 2023
8f9e2a8
Improve efficiency of card-size alignment calculations
kdnilsen Jun 6, 2023
f6c073a
Update copyright notices
kdnilsen Jun 7, 2023
221c88f
Remove one more extraneous Amazon copyright
kdnilsen Jun 7, 2023
8895866
JDK-8309322: [GenShen] TestAllocOutOfMemory#large failed
kdnilsen Jun 7, 2023
8e5c3b7
Remove more extraneous copyright notices
kdnilsen Jun 7, 2023
01c6251
Remove a few more unneeded copyright notices
kdnilsen Jun 7, 2023
240d413
Simplify test logic, fail if name of Shenandoah young gen pool change…
earthling-amzn Jun 7, 2023
612072a
Merge branch 'master' of https://git.openjdk.org/jdk into merge-gener…
kdnilsen Jun 7, 2023
19e62fe
Fix budgeting assertion to allow equal or greater than
kdnilsen Jun 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved.
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -88,10 +89,19 @@ LIR_Opr ShenandoahBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess& access, LI
LIR_Opr result = gen->new_register(T_INT);

__ append(new LIR_OpShenandoahCompareAndSwap(addr, cmp_value.result(), new_value.result(), t1, t2, result));

post_barrier(access, access.resolved_addr(), new_value.result());
return result;
}
}
return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);

LIR_Opr result = BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);

if (access.is_oop()) {
post_barrier(access, access.resolved_addr(), new_value.result());
}

return result;
}

LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value) {
Expand Down Expand Up @@ -119,6 +129,7 @@ LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRIt
pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr,
result /* pre_val */);
}
post_barrier(access, access.resolved_addr(), result);
}

return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018, 2022, Red Hat, Inc. All rights reserved.
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -31,6 +32,7 @@
#include "gc/shenandoah/shenandoahRuntime.hpp"
#include "gc/shenandoah/shenandoahThreadLocalData.hpp"
#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp"
#include "gc/shenandoah/mode/shenandoahMode.hpp"
#include "interpreter/interpreter.hpp"
#include "interpreter/interp_masm.hpp"
#include "runtime/javaThread.hpp"
Expand Down Expand Up @@ -60,7 +62,7 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, Dec
if (ShenandoahSATBBarrier && dest_uninitialized) {
__ tbz(rscratch1, ShenandoahHeap::HAS_FORWARDED_BITPOS, done);
} else {
__ mov(rscratch2, ShenandoahHeap::HAS_FORWARDED | ShenandoahHeap::MARKING);
__ mov(rscratch2, ShenandoahHeap::HAS_FORWARDED | ShenandoahHeap::YOUNG_MARKING | ShenandoahHeap::OLD_MARKING);
__ tst(rscratch1, rscratch2);
__ br(Assembler::EQ, done);
}
Expand All @@ -77,6 +79,13 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, Dec
}
}

void ShenandoahBarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
Register start, Register count, Register tmp, RegSet saved_regs) {
if (is_oop) {
gen_write_ref_array_post_barrier(masm, decorators, start, count, tmp, saved_regs);
}
}

void ShenandoahBarrierSetAssembler::shenandoah_write_barrier_pre(MacroAssembler* masm,
Register obj,
Register pre_val,
Expand Down Expand Up @@ -375,6 +384,28 @@ void ShenandoahBarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet d
}
}

void ShenandoahBarrierSetAssembler::store_check(MacroAssembler* masm, Register obj) {
if (!ShenandoahHeap::heap()->mode()->is_generational()) {
return;
}

__ lsr(obj, obj, CardTable::card_shift());

assert(CardTable::dirty_card_val() == 0, "must be");

__ load_byte_map_base(rscratch1);

if (UseCondCardMark) {
Label L_already_dirty;
__ ldrb(rscratch2, Address(obj, rscratch1));
__ cbz(rscratch2, L_already_dirty);
__ strb(zr, Address(obj, rscratch1));
__ bind(L_already_dirty);
} else {
__ strb(zr, Address(obj, rscratch1));
}
}

void ShenandoahBarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
Address dst, Register val, Register tmp1, Register tmp2, Register tmp3) {
bool on_oop = is_reference_type(type);
Expand Down Expand Up @@ -411,6 +442,7 @@ void ShenandoahBarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet
__ mov(new_val, val);
}
BarrierSetAssembler::store_at(masm, decorators, type, Address(tmp3, 0), val, noreg, noreg, noreg);
store_check(masm, r3);
}

}
Expand Down Expand Up @@ -595,6 +627,37 @@ void ShenandoahBarrierSetAssembler::cmpxchg_oop(MacroAssembler* masm,
}
}

void ShenandoahBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
Register start, Register count, Register scratch, RegSet saved_regs) {
if (!ShenandoahHeap::heap()->mode()->is_generational()) {
return;
}

Label L_loop, L_done;
const Register end = count;

// Zero count? Nothing to do.
__ cbz(count, L_done);

// end = start + count << LogBytesPerHeapOop
// last element address to make inclusive
__ lea(end, Address(start, count, Address::lsl(LogBytesPerHeapOop)));
__ sub(end, end, BytesPerHeapOop);
__ lsr(start, start, CardTable::card_shift());
__ lsr(end, end, CardTable::card_shift());

// number of bytes to copy
__ sub(count, end, start);

__ load_byte_map_base(scratch);
__ add(start, start, scratch);
__ bind(L_loop);
__ strb(zr, Address(start, count));
__ subs(count, count, 1);
__ br(Assembler::GE, L_loop);
__ bind(L_done);
}

#undef __

#ifdef COMPILER1
Expand Down Expand Up @@ -695,7 +758,13 @@ void ShenandoahBarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAss
// Is marking still active?
Address gc_state(thread, in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
__ ldrb(tmp, gc_state);
__ tbz(tmp, ShenandoahHeap::MARKING_BITPOS, done);
if (!ShenandoahHeap::heap()->mode()->is_generational()) {
__ tbz(tmp, ShenandoahHeap::YOUNG_MARKING_BITPOS, done);
} else {
__ mov(rscratch2, ShenandoahHeap::YOUNG_MARKING | ShenandoahHeap::OLD_MARKING);
__ tst(tmp, rscratch2);
__ br(Assembler::EQ, done);
}

// Can we store original value in the thread's buffer?
__ ldr(tmp, queue_index);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved.
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -55,10 +56,16 @@ class ShenandoahBarrierSetAssembler: public BarrierSetAssembler {
bool tosca_live,
bool expand_call);

void store_check(MacroAssembler* masm, Register obj);

void resolve_forward_pointer(MacroAssembler* masm, Register dst, Register tmp = noreg);
void resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst, Register tmp = noreg);
void load_reference_barrier(MacroAssembler* masm, Register dst, Address load_addr, DecoratorSet decorators);

void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
Register start, Register count,
Register scratch, RegSet saved_regs);

public:

void iu_barrier(MacroAssembler* masm, Register dst, Register tmp);
Expand All @@ -74,6 +81,8 @@ class ShenandoahBarrierSetAssembler: public BarrierSetAssembler {

virtual void arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
Register src, Register dst, Register count, RegSet saved_regs);
virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop,
Register start, Register count, Register tmp, RegSet saved_regs);
virtual void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
Register dst, Address src, Register tmp1, Register tmp2);
virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved.
* Copyright (c) 2012, 2021 SAP SE. All rights reserved.
* Copyright (c) 2012, 2022 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -104,6 +104,8 @@ LIR_Opr ShenandoahBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess &access, LI

__ append(new LIR_OpShenandoahCompareAndSwap(addr, cmp_value.result(), new_value.result(), t1, t2, result));

post_barrier(access, access.resolved_addr(), new_value.result());

if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ membar_acquire();
} else {
Expand All @@ -114,7 +116,13 @@ LIR_Opr ShenandoahBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess &access, LI
}
}

return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);
LIR_Opr result = BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);

if (access.is_oop()) {
post_barrier(access, access.resolved_addr(), new_value.result());
}

return result;
}

LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess &access, LIRItem &value) {
Expand Down Expand Up @@ -150,6 +158,8 @@ LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess &access, LIRIt
if (ShenandoahSATBBarrier) {
pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr, result);
}

post_barrier(access, access.resolved_addr(), result);
}

if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved.
* Copyright (c) 2012, 2021 SAP SE. All rights reserved.
* Copyright (c) 2012, 2022 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -37,6 +37,7 @@
#include "gc/shenandoah/shenandoahRuntime.hpp"
#include "gc/shenandoah/shenandoahThreadLocalData.hpp"
#include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp"
#include "gc/shenandoah/mode/shenandoahMode.hpp"
#include "interpreter/interpreter.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/sharedRuntime.hpp"
Expand Down Expand Up @@ -90,8 +91,6 @@ void ShenandoahBarrierSetAssembler::load_reference_barrier(MacroAssembler *masm,
void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler *masm, DecoratorSet decorators, BasicType type,
Register src, Register dst, Register count,
Register preserve1, Register preserve2) {
__ block_comment("arraycopy_prologue (shenandoahgc) {");

Register R11_tmp = R11_scratch1;

assert_different_registers(src, dst, count, R11_tmp, noreg);
Expand All @@ -114,6 +113,7 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler *masm, Dec
return;
}

__ block_comment("arraycopy_prologue (shenandoahgc) {");
Label skip_prologue;

// Fast path: Array is of length zero.
Expand All @@ -130,7 +130,7 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler *masm, Dec
// for the garbage collector.
const int required_states = ShenandoahSATBBarrier && dest_uninitialized
? ShenandoahHeap::HAS_FORWARDED
: ShenandoahHeap::HAS_FORWARDED | ShenandoahHeap::MARKING;
: ShenandoahHeap::HAS_FORWARDED | ShenandoahHeap::YOUNG_MARKING | ShenandoahHeap::OLD_MARKING;

__ andi_(R11_tmp, R11_tmp, required_states);
__ beq(CCR0, skip_prologue);
Expand Down Expand Up @@ -187,6 +187,16 @@ void ShenandoahBarrierSetAssembler::arraycopy_prologue(MacroAssembler *masm, Dec
__ block_comment("} arraycopy_prologue (shenandoahgc)");
}

void ShenandoahBarrierSetAssembler::arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
Register dst, Register count,
Register preserve) {
if (is_reference_type(type)) {
__ block_comment("arraycopy_epilogue (shenandoahgc) {");
gen_write_ref_array_post_barrier(masm, decorators, dst, count, preserve);
__ block_comment("} arraycopy_epilogue (shenandoahgc)");
}
}

// The to-be-enqueued value can either be determined
// - dynamically by passing the reference's address information (load mode) or
// - statically by passing a register the value is stored in (preloaded mode)
Expand Down Expand Up @@ -220,7 +230,7 @@ void ShenandoahBarrierSetAssembler::satb_write_barrier_impl(MacroAssembler *masm
// Check whether marking is active.
__ lbz(tmp1, in_bytes(ShenandoahThreadLocalData::gc_state_offset()), R16_thread);

__ andi_(tmp1, tmp1, ShenandoahHeap::MARKING);
__ andi_(tmp1, tmp1, ShenandoahHeap::YOUNG_MARKING | ShenandoahHeap::OLD_MARKING);
__ beq(CCR0, skip_barrier);

/* ==== Determine the reference's previous value ==== */
Expand Down Expand Up @@ -586,6 +596,27 @@ void ShenandoahBarrierSetAssembler::load_at(
}
}

void ShenandoahBarrierSetAssembler::store_check(MacroAssembler* masm, Register base, RegisterOrConstant ind_or_offs, Register tmp) {
if (!ShenandoahHeap::heap()->mode()->is_generational()) {
return;
}

ShenandoahBarrierSet* ctbs = ShenandoahBarrierSet::barrier_set();
CardTable* ct = ctbs->card_table();
assert_different_registers(base, tmp, R0);

if (ind_or_offs.is_constant()) {
__ add_const_optimized(base, base, ind_or_offs.as_constant(), tmp);
} else {
__ add(base, ind_or_offs.as_register(), base);
}

__ load_const_optimized(tmp, (address)ct->byte_map_base(), R0);
__ srdi(base, base, CardTable::card_shift());
__ li(R0, CardTable::dirty_card_val());
__ stbx(R0, tmp, base);
}

// base: Base register of the reference's address.
// ind_or_offs: Index or offset of the reference's address.
// val: To-be-stored value/reference's new value.
Expand All @@ -608,6 +639,11 @@ void ShenandoahBarrierSetAssembler::store_at(MacroAssembler *masm, DecoratorSet
val,
tmp1, tmp2, tmp3,
preservation_level);

// No need for post barrier if storing NULL
if (is_reference_type(type) && val != noreg) {
store_check(masm, base, ind_or_offs, tmp1);
}
}

void ShenandoahBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler *masm,
Expand Down Expand Up @@ -757,6 +793,42 @@ void ShenandoahBarrierSetAssembler::cmpxchg_oop(MacroAssembler *masm, Register b
__ block_comment("} cmpxchg_oop (shenandoahgc)");
}

void ShenandoahBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
Register addr, Register count, Register preserve) {
if (!ShenandoahHeap::heap()->mode()->is_generational()) {
return;
}

ShenandoahBarrierSet* bs = ShenandoahBarrierSet::barrier_set();
CardTable* ct = bs->card_table();
assert_different_registers(addr, count, R0);

Label L_skip_loop, L_store_loop;

__ sldi_(count, count, LogBytesPerHeapOop);

// Zero length? Skip.
__ beq(CCR0, L_skip_loop);

__ addi(count, count, -BytesPerHeapOop);
__ add(count, addr, count);
// Use two shifts to clear out those low order two bits! (Cannot opt. into 1.)
__ srdi(addr, addr, CardTable::card_shift());
__ srdi(count, count, CardTable::card_shift());
__ subf(count, addr, count);
__ add_const_optimized(addr, addr, (address)ct->byte_map_base(), R0);
__ addi(count, count, 1);
__ li(R0, 0);
__ mtctr(count);

// Byte store loop
__ bind(L_store_loop);
__ stb(R0, 0, addr);
__ addi(addr, addr, 1);
__ bdnz(L_store_loop);
__ bind(L_skip_loop);
}

#undef __

#ifdef COMPILER1
Expand Down Expand Up @@ -892,7 +964,7 @@ void ShenandoahBarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAss
// another check is required as a safepoint might have been reached in the meantime (JDK-8140588).
__ lbz(R12_tmp2, in_bytes(ShenandoahThreadLocalData::gc_state_offset()), R16_thread);

__ andi_(R12_tmp2, R12_tmp2, ShenandoahHeap::MARKING);
__ andi_(R12_tmp2, R12_tmp2, ShenandoahHeap::YOUNG_MARKING | ShenandoahHeap::OLD_MARKING);
__ beq(CCR0, skip_barrier);

/* ==== Add previous value directly to thread-local SATB mark queue ==== */
Expand Down
Loading