Skip to content

Instantly share code, notes, and snippets.

@nitsanw
Last active January 5, 2018 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitsanw/c25e6e3969ac1b1575da71a79802035a to your computer and use it in GitHub Desktop.
Save nitsanw/c25e6e3969ac1b1575da71a79802035a to your computer and use it in GitHub Desktop.
// CPP, OpenJDK C2 compiler style... this is from:
// http://hg.openjdk.java.net/jdk9/jdk9/hotspot/file/b756e7a2ec33/src/share/vm/opto/graphKit.cpp#l4285
void GraphKit::g1_write_barrier_post(Node* oop_store,
Node* obj,
Node* adr,
uint alias_idx,
Node* val,
BasicType bt,
bool use_precise) {
/// ... Loads of other crap here...
// if (xor_res == 0) same region so skip
__ if_then(xor_res, BoolTest::ne, zeroX); {
// No barrier if we are storing a NULL
__ if_then(val, BoolTest::ne, null(), unlikely); {
// Ok must mark the card if not already dirty
// load the original value of the card
Node* card_val = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw);
__ if_then(card_val, BoolTest::ne, young_card); {
sync_kit(ideal);
// Use Op_MemBarVolatile to achieve the effect of a StoreLoad barrier.
insert_mem_bar(Op_MemBarVolatile, oop_store); // !!!HELLO THERE!!!
__ sync_kit(this);
Node* card_val_reload = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw);
__ if_then(card_val_reload, BoolTest::ne, dirty_card); {
g1_mark_card(ideal, card_adr, oop_store, alias_idx, index, index_adr, buffer, tf);
} __ end_if();
} __ end_if();
} __ end_if();
} __ end_if();
// ... And some more crap later too...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment