===================================================================
@@ -57,4 +57,15 @@ _ITM_free (void *ptr)
gtm_tx()->forget_allocation (ptr, free);
}
+/* Forget any internal references to PTR. */
+
+__attribute__((transaction_pure))
+void ITM_REGPARM
+_ITM_dropReferences (const void *ptr, size_t len)
+{
+ gtm_transaction *tx = gtm_tx();
+ tx->drop_references_local (ptr, len);
+ tx->drop_references_allocations (ptr);
+}
+
} // extern "C"
===================================================================
@@ -167,6 +167,7 @@ LIBITM_1.0 {
_ITM_malloc;
_ITM_calloc;
_ITM_free;
+ _ITM_dropReferences;
_ZGTtnwm;
_ZGTtnam;
===================================================================
@@ -152,6 +152,7 @@ extern void _ITM_addUserUndoAction(_ITM_
extern int _ITM_getThreadnum(void) ITM_REGPARM;
+__attribute__((transaction_pure))
extern void _ITM_dropReferences (const void *, size_t) ITM_REGPARM;
===================================================================
@@ -0,0 +1,11 @@
+#include <libitm.h>
+
+char *pp;
+
+int main()
+{
+ __transaction {
+ _ITM_dropReferences (pp, 555);
+ }
+ return 0;
+}
===================================================================
@@ -0,0 +1,11 @@
+#include <libitm.h>
+
+char *pp;
+
+int main()
+{
+ __transaction {
+ _ITM_dropReferences (pp, 555);
+ }
+ return 0;
+}
===================================================================
@@ -226,6 +226,10 @@ struct gtm_transaction
void commit_allocations (bool);
void record_allocation (void *, void (*)(void *));
void forget_allocation (void *, void (*)(void *));
+ void drop_references_allocations (const void *ptr)
+ {
+ this->alloc_actions.erase((uintptr_t) ptr);
+ }
// In beginend.cc
void rollback ();
@@ -247,6 +251,7 @@ struct gtm_transaction
// In local.cc
void commit_local (void);
void rollback_local (void);
+ void drop_references_local (const void *, size_t);
// In retry.cc
void decide_retry_strategy (gtm_restart_reason);
===================================================================
@@ -65,13 +65,38 @@ gtm_transaction::rollback_local (void)
for (i = n; i-- > 0; )
{
gtm_local_undo *u = local_undo[i];
- memcpy (u->addr, u->saved, u->len);
- free (u);
+ if (u)
+ {
+ memcpy (u->addr, u->saved, u->len);
+ free (u);
+ }
}
this->n_local_undo = 0;
}
}
+/* Forget any references to PTR in the local log. */
+
+void
+gtm_transaction::drop_references_local (const void *ptr, size_t len)
+{
+ gtm_local_undo **local_undo = this->local_undo;
+ size_t i, n = this->n_local_undo;
+
+ if (n > 0)
+ {
+ for (i = n; i > 0; i--)
+ {
+ gtm_local_undo *u = local_undo[i];
+ /* ?? Do we need such granularity, or can we get away with
+ just comparing PTR and LEN. ?? */
+ if ((const char *)u->addr >= (const char *)ptr
+ && ((const char *)u->addr + u->len <= (const char *)ptr + len))
+ this->local_undo = NULL;
+ }
+ }
+}
+
void ITM_REGPARM
GTM_LB (const void *ptr, size_t len)
{