8173196: [REDO] C2 does not optimize redundant memory operations with G1

Reviewed-by: thartmann, kvn
This commit is contained in:
Roland Westrelin 2019-05-21 15:46:09 +02:00
parent d222b01dee
commit 98b1d8c798
4 changed files with 15 additions and 2 deletions

View File

@ -472,7 +472,7 @@ void G1BarrierSetC2::post_barrier(GraphKit* kit,
__ if_then(card_val, BoolTest::ne, young_card); {
kit->sync_kit(ideal);
kit->insert_mem_bar(Op_MemBarVolatile, oop_store);
kit->insert_store_load_for_barrier();
__ sync_kit(kit);
Node* card_val_reload = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw);

View File

@ -105,7 +105,7 @@ void CardTableBarrierSetC2::post_barrier(GraphKit* kit,
if (UseCondCardMark) {
if (ct->scanned_concurrently()) {
kit->insert_mem_bar(Op_MemBarVolatile, oop_store);
kit->insert_store_load_for_barrier();
__ sync_kit(kit);
}
// The classic GC reference write barrier is typically implemented

View File

@ -3306,6 +3306,18 @@ Node* GraphKit::insert_mem_bar_volatile(int opcode, int alias_idx, Node* precede
return membar;
}
void GraphKit::insert_store_load_for_barrier() {
Node* mem = reset_memory();
MemBarNode* mb = MemBarNode::make(C, Op_MemBarVolatile, Compile::AliasIdxRaw);
mb->init_req(TypeFunc::Control, control());
mb->init_req(TypeFunc::Memory, mem);
Node* membar = _gvn.transform(mb);
set_control(_gvn.transform(new ProjNode(membar, TypeFunc::Control)));
Node* newmem = _gvn.transform(new ProjNode(membar, TypeFunc::Memory));
set_all_memory(mem);
set_memory(newmem, Compile::AliasIdxRaw);
}
//------------------------------shared_lock------------------------------------
// Emit locking code.
FastLockNode* GraphKit::shared_lock(Node* obj) {

View File

@ -811,6 +811,7 @@ class GraphKit : public Phase {
int next_monitor();
Node* insert_mem_bar(int opcode, Node* precedent = NULL);
Node* insert_mem_bar_volatile(int opcode, int alias_idx, Node* precedent = NULL);
void insert_store_load_for_barrier();
// Optional 'precedent' is appended as an extra edge, to force ordering.
FastLockNode* shared_lock(Node* obj);
void shared_unlock(Node* box, Node* obj);