[Patch] 8210853: C2 doesn't skip post barrier for new allocated objects

Kuai Wei kuaiwei.kw at alibaba-inc.com
Tue Sep 18 13:33:50 UTC 2018


Hi,

  I made a patch to https://bugs.openjdk.java.net/browse/JDK-8210853 . Could you help review my change?

Background:
  C2 could remove G1 post barrier if store to new allocated object. But the check of just_allocated_object will be prevent by a Region node which is created when inline initialize method of super class. The change is to check the pattern and skip the Region node.

src/hotspot/share/opto/graphKit.cpp

 // We use this to determine if an object is so "fresh" that
 // it does not require card marks.
 Node* GraphKit::just_allocated_object(Node* current_control) {
-  if (C->recent_alloc_ctl() == current_control)
+  Node * ctrl = current_control;
+  // Object::<init> is invoked after allocation, most of invoke nodes
+  // will be reduced, but a region node is kept in parse time, we check
+  // the pattern and skip the region node
+  if (ctrl != NULL && ctrl->is_Region() && ctrl->req() == 2) {
+    ctrl = ctrl->in(1);
+  }
+  if (C->recent_alloc_ctl() == ctrl)
     return C->recent_alloc_obj();
   return NULL;
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20180918/e07e1333/attachment.html>


More information about the hotspot-compiler-dev mailing list