[trans-mem] add hashtable lock comments

Aldy Hernandez aldyh@redhat.com
Thu Jun 24 19:19:00 GMT 2010


I'm a bit stuck implementing dropReferences() in the runtime, and have
been getting better acquainted with how we cache memory in the runtime.
Here are some comments for the writeback code.

Richard okayed the comments.

Committing.

	* method-wbetl.cc (struct w_entry): Add comments.
	(trycommit): Same.
	(rollback): Same.

Index: method-wbetl.cc
===================================================================
--- method-wbetl.cc	(revision 161318)
+++ method-wbetl.cc	(working copy)
@@ -45,8 +45,15 @@ class wbetl_dispatch : public gtm_dispat
 
   struct w_entry
   {
+    /* There's a hashtable where the locks are held, so multiple
+       cachelines can hash to a given bucket.  This link points to the
+       possible next cacheline that also hashes to this bucket.  */
     struct w_entry *next;
+
+    /* Every entry in this bucket (accessed by NEXT) has the same LOCK
+       address below.  */
     gtm_stmlock *lock;
+
     gtm_cacheline *addr;
     gtm_cacheline *value;
     gtm_version version;
@@ -442,6 +449,9 @@ wbetl_dispatch::trycommit ()
       for (size_t i = 0; i < n; ++i)
 	{
 	  w_entry *w = &m_wset_entries[i];
+
+	  /* Every link along the chain has the same lock, but only
+	     bother dropping the lock once per bucket (at the end).  */
 	  if (w->next == NULL)
 	    *w->lock = gtm_stmlock_set_version (t);
 	}
@@ -459,6 +469,9 @@ wbetl_dispatch::rollback ()
   for (size_t i = 0; i < n; ++i)
     {
       w_entry *w = &m_wset_entries[i];
+
+      /* Every link along the chain has the same lock, but only
+	 bother dropping the lock once per bucket (at the end).  */
       if (w->next == NULL)
 	*w->lock = gtm_stmlock_set_version (w->version);
     }



More information about the Gcc-patches mailing list