< prev index next >

src/hotspot/share/opto/valuetypenode.cpp

Print this page
rev 59083 : DRAFT 8236522: NonTearable marker interface for inline classes to enforce atomicity

@@ -397,10 +397,11 @@
     Node* alloc_oop  = kit->new_instance(klass_node, NULL, NULL, /* deoptimize_on_exception */ true, this);
     store(kit, alloc_oop, alloc_oop, vk, 0);
 
     // Do not let stores that initialize this buffer be reordered with a subsequent
     // store that would make this buffer accessible by other threads.
+    // FIXME: coordinate with ready_to_publish(kit, alloc_oop)
     AllocateNode* alloc = AllocateNode::Ideal_allocation(alloc_oop, &kit->gvn());
     assert(alloc != NULL, "must have an allocation node");
     kit->insert_mem_bar(Op_MemBarStoreStore, alloc->proj_out_or_null(AllocateNode::RawAddress));
 
     region->init_req(2, kit->control());

@@ -625,10 +626,11 @@
   Node* obj = get_oop();
   Node* mark_addr = kit->basic_plus_adr(obj, oopDesc::mark_offset_in_bytes());
   Node* mark = kit->make_load(NULL, mark_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered);
   mark = kit->gvn().transform(new AndXNode(mark, kit->MakeConX(~markWord::larval_mask_in_place)));
   kit->store_to_memory(kit->control(), mark_addr, mark, TypeX_X->basic_type(), kit->gvn().type(mark_addr)->is_ptr(), MemNode::unordered);
+  ready_to_publish(kit, obj);
 
   // Do not let stores that initialize this buffer be reordered with a subsequent
   // store that would make this buffer accessible by other threads.
   AllocateNode* alloc = AllocateNode::Ideal_allocation(obj, &kit->gvn());
   assert(alloc != NULL, "must have an allocation node");

@@ -639,10 +641,21 @@
   res->set_type(TypeValueType::make(vk, false));
   res = kit->gvn().transform(res)->as_ValueType();
   return res;
 }
 
+void ValueTypeBaseNode::ready_to_publish(GraphKit* kit, Node* base) const {
+  // Do not let stores that initialize this buffer be reordered with
+  // a subsequent store that would make it accessible by other threads.
+  // Required for correct non-flat array element publication.
+  // (See jtreg test ValueTearing.java.)
+  Node* raw_address_proj = NULL;  //FIXME
+  kit->insert_mem_bar(Op_MemBarStoreStore, raw_address_proj);
+  // Fails to prevent array element tearing:
+  //kit->insert_mem_bar_volatile(Op_MemBarStoreStore, Compile::AliasIdxRaw, raw_address_proj);
+}
+
 Node* ValueTypeNode::is_loaded(PhaseGVN* phase, ciValueKlass* vk, Node* base, int holder_offset) {
   if (vk == NULL) {
     vk = value_klass();
   }
   if (field_count() == 0) {
< prev index next >