Commits

Remi Meier committed 65a5bbd

hack-in clearing of exception on abort (untested)

Comments (0)

Files changed (9)

pypy/module/thread/stm.py

 
 def initialize_execution_context(ec):
     """Called from ExecutionContext.__init__()."""
+    rstm.clear_exception_data_on_abort()
     ec._thread_local_dicts = rweakref.RWeakKeyDictionary(STMLocal, W_Root)
     if ec.space.config.objspace.std.withmethodcache:
         from pypy.objspace.std.typeobject import MethodCache

rpython/rlib/rstm.py

     return rffi.cast(lltype.Signed, addr)
 
 @dont_look_inside
+def clear_exception_data_on_abort():
+    # XXX: provisional API just to be safe
+    # called by pypy/module/thread/stm:initialize_execution_context
+    llop.stm_clear_exception_data_on_abort(lltype.Void)
+
+@dont_look_inside
 def become_inevitable():
     llop.stm_become_inevitable(lltype.Void)
 

rpython/rtyper/lltypesystem/lloperation.py

 
     'stm_get_adr_of_private_rev_num':LLOp(),
     'stm_get_adr_of_read_barrier_cache':LLOp(),
+
+    'stm_clear_exception_data_on_abort':LLOp(),
     
     # __________ address operations __________
 

rpython/translator/c/funcgen.py

     OP_STM_INSPECT_ABORT_INFO           = _OP_STM
     OP_STM_MAJOR_COLLECT                = _OP_STM
     OP_STM_MINOR_COLLECT                = _OP_STM
+    OP_STM_CLEAR_EXCEPTION_DATA_ON_ABORT= _OP_STM
 
 
     def OP_PTR_NONZERO(self, op):

rpython/translator/stm/funcgen.py

 def stm_major_collect(funcgen, op):
     return 'stm_major_collect();'
 
+def stm_clear_exception_data_on_abort(funcgen, op):
+    return """
+    stm_clear_on_abort(&pypy_g_ExcData.ed_exc_type,
+                       sizeof(struct pypy_object0 *));
+    """
+
+    
 
 def op_stm(funcgen, op):
     func = globals()[op.opname]

rpython/translator/stm/src_stm/et.c

   /* release the lock */
   spinlock_release(d->public_descriptor->collection_lock);
 
+  /* clear memory registered by stm_clear_on_abort */
+  if (stm_to_clear_on_abort)
+    memset(stm_to_clear_on_abort, 0, stm_bytes_to_clear_on_abort);
+
   dprintf(("\n"
           "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
           "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"

rpython/translator/stm/src_stm/extra.c

     dprintf(("copy_to_old_id_copy(%p -> %p)\n", obj, id));
 }
 
+
+__thread void *stm_to_clear_on_abort = NULL;
+__thread size_t stm_bytes_to_clear_on_abort;
+
+void stm_clear_on_abort(void *start, size_t bytes)
+{
+    stm_to_clear_on_abort = start;
+    stm_bytes_to_clear_on_abort = bytes;
+}
+
 /************************************************************/
 /* Each object has a h_original pointer to an old copy of 
    the same object (e.g. an old revision), the "original". 

rpython/translator/stm/src_stm/revision

-0ebfd6dd4f46
+12cf412eb2d7

rpython/translator/stm/src_stm/stmgc.h

 /****************  END OF PUBLIC INTERFACE  *****************/
 /************************************************************/
 
+/* Clear some memory when aborting a transaction in the current
+   thread. This is a provisional API. The information is stored
+   thread-locally and belongs to the current thread. */
+void stm_clear_on_abort(void *start, size_t bytes);
+extern __thread void *stm_to_clear_on_abort;
+extern __thread size_t stm_bytes_to_clear_on_abort;
+
 
 /* macro functionality */