Commits

Armin Rigo committed bfadfd7

Fixes.

  • Participants
  • Parent commits 6e55716
  • Branches stm-thread

Comments (0)

Files changed (3)

File pypy/rlib/rstm.py

     ll_assert(arg is None or isinstance(arg, argcls),
               "perform_transaction: wrong class")
     before_external_call()
+    # Passing around the GC object 'arg' is a bit delicate.  At this point
+    # it has been saved as a global, but 'arg' likely points to the object
+    # with an offset 2, which is the flag used for "used to be a local".
+    # We have to revert this flag here...
     llarg = cast_instance_to_base_ptr(arg)
+    llarg = rffi.cast(lltype.Signed, llarg)
+    llarg &= ~2
     llarg = rffi.cast(rffi.VOIDP, llarg)
+    #
     adr_of_top = llop.gc_adr_of_root_stack_top(llmemory.Address)
-    #
     callback = _get_stm_callback(func, argcls)
     llcallback = llhelper(stmgcintf.StmOperations.CALLBACK_TX, callback)
     stmgcintf.StmOperations.perform_transaction(llcallback, llarg, adr_of_top)

File pypy/rpython/memory/gc/stmtls.py

                                   run_finalizers=False)
         self._promote_locals_to_globals()
         self._disable_mallocs()
+        if self.gc.DEBUG:
+            self.check_all_global_objects()
 
     def local_nursery_is_empty(self):
         ll_assert(bool(self.nursery_free),
         x = llmemory.cast_adr_to_int(root.address[0])
         if x & 2:
             root.address[0] -= 2
+        old_tid = self.gc.header(root.address[0]).tid
+        #
         self._trace_drag_out1(root)
-        obj = root.address[0]
-        if self.gc.header(obj).tid & GCFLAG_GLOBAL == 0:
+        #
+        # if root.address[0] used to point to a local object, then flag
+        # this by adding the bit of value 2.
+        if old_tid & GCFLAG_GLOBAL == 0:
+            obj = root.address[0]
             x = llmemory.cast_adr_to_int(obj)
             ll_assert(x & 3 == 0, "flag_local: misaligned obj")
             obj = llarena.getfakearenaaddress(obj)

File pypy/translator/stm/test/test_ztranslated.py

 
     def test_targetdemo(self):
         t, cbuilder = self.compile(targetdemo2.entry_point)
-        data, dataerr = cbuilder.cmdexec('4 5000', err=True)
+        data, dataerr = cbuilder.cmdexec('4 5000', err=True,
+                                         env={'PYPY_GC_DEBUG': '1'})
         assert 'check ok!' in data
 
     def test_bug1(self):