< prev index next >

src/hotspot/share/opto/parse3.cpp

Print this page

        

@@ -164,10 +164,22 @@
   bool is_vol = field->is_volatile();
 
   // Compute address and memory type.
   int offset = field->offset_in_bytes();
   const TypePtr* adr_type = C->alias_type(field)->adr_type();
+
+#if INCLUDE_SHENANDOAHGC
+  // Insert read barrier for Shenandoah.
+  if ((ShenandoahOptimizeStaticFinals   && field->is_static()  && field->is_final()) ||
+      (ShenandoahOptimizeInstanceFinals && !field->is_static() && field->is_final()) ||
+      (ShenandoahOptimizeStableFinals   && field->is_stable())) {
+    // Skip the barrier for special fields
+  } else {
+    obj = access_resolve_for_read(obj);
+  }
+#endif
+
   Node *adr = basic_plus_adr(obj, obj, offset);
 
   // Build the resultant type of the load
   const Type *type;
 

@@ -200,10 +212,23 @@
     type = Type::get_const_basic_type(bt);
   }
 
   Node* ld = access_load_at(obj, adr, adr_type, type, bt, decorators);
 
+#if INCLUDE_SHENANDOAHGC
+  // Only enabled for Shenandoah. Can this be useful in general?
+  if (UseShenandoahGC && ShenandoahOptimizeStableFinals && UseImplicitStableValues) {
+    if (field->holder()->name() == ciSymbol::java_lang_String() &&
+        field->offset() == java_lang_String::value_offset_in_bytes()) {
+      const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull,
+                                                      TypeAry::make(TypeInt::BYTE, TypeInt::POS),
+                                                      ciTypeArrayKlass::make(T_BYTE), true, 0);
+      ld = cast_array_to_stable(ld, value_type);
+    }
+  }
+#endif
+
   // Adjust Java stack
   if (type2size[bt] == 1)
     push(ld);
   else
     push_pair(ld);

@@ -234,10 +259,13 @@
 }
 
 void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
   bool is_vol = field->is_volatile();
 
+  // Insert write barrier for Shenandoah.
+  obj = access_resolve_for_write(obj);
+
   // Compute address and memory type.
   int offset = field->offset_in_bytes();
   const TypePtr* adr_type = C->alias_type(field)->adr_type();
   Node* adr = basic_plus_adr(obj, obj, offset);
   BasicType bt = field->layout_type();
< prev index next >