8144993: Elide redundant memory barrier after AllocationNode

Elide memory barrier for AllocationNode when it doesn't escape in initializer and has an MemBarRelease node at exit of initializer method.

Reviewed-by: aph, mdoerr, goetz, kvn, asiebenborn
This commit is contained in:
Hui Shi 2015-12-27 05:15:14 -08:00
parent c4a81b327d
commit 3767315e75
4 changed files with 48 additions and 4 deletions

View file

@ -962,6 +962,14 @@ void Parse::do_exits() {
PPC64_ONLY(wrote_volatile() ||)
(AlwaysSafeConstructors && wrote_fields()))) {
_exits.insert_mem_bar(Op_MemBarRelease, alloc_with_final());
// If Memory barrier is created for final fields write
// and allocation node does not escape the initialize method,
// then barrier introduced by allocation node can be removed.
if (DoEscapeAnalysis && alloc_with_final()) {
AllocateNode *alloc = AllocateNode::Ideal_allocation(alloc_with_final(), &_gvn);
alloc->compute_MemBar_redundancy(method());
}
if (PrintOpto && (Verbose || WizardMode)) {
method()->print_name();
tty->print_cr(" writes finals and needs a memory barrier");