1. Pypy
  2. Untitled project
  3. pypy

Commits

Armin Rigo  committed 55b6948

Translation fixes and a "bah": can't seem to get a doubly-linked list
implementation correct. (stm/test/test_ztranslated.test_targetdemo)

  • Participants
  • Parent commits 27210e4
  • Branches stm-gc-2

Comments (0)

Files changed (4)

File rpython/memory/gc/stmgc.py

View file
         llop.nop(lltype.Void, llhelper(self.stm_operations.DUPLICATE,
                                        self._stm_duplicate))
         #
+        self.ll_global_lock = rthread.null_ll_lock
         self.sharedarea.setup()
         #
         self.linked_list_stmtls = None
-        self.ll_global_lock = rthread.allocate_ll_lock()
         #
         self.stm_operations.descriptor_init()
         self.stm_operations.begin_inevitable_transaction()
         self.setup_thread()
+        #
+        # Now the gc is running, we can allocate this lock object
+        self.ll_global_lock = rthread.allocate_ll_lock()
 
     def setup_thread(self):
         """Build the StmGCTLS object and start a transaction at the level
         stmtls.delete()
 
     def acquire_global_lock(self):
-        rthread.acquire_NOAUTO(self.ll_global_lock, True)
+        if self.ll_global_lock:
+            rthread.acquire_NOAUTO(self.ll_global_lock, True)
 
     def release_global_lock(self):
-        rthread.release_NOAUTO(self.ll_global_lock)
+        if self.ll_global_lock:
+            rthread.release_NOAUTO(self.ll_global_lock)
 
     def add_in_linked_list(self, stmtls):
         self.acquire_global_lock()
+        stmnext = self.linked_list_stmtls
         stmtls.linked_list_prev = None
-        stmtls.linked_list_next = self.linked_list_stmtls
+        stmtls.linked_list_next = stmnext
+        if stmnext is not None:
+            ll_assert(stmnext.linked_list_prev is None,
+                      "add_in_linked_list: bad linked list")
+            stmnext.linked_list_prev = stmtls
         self.linked_list_stmtls = stmtls
         self.release_global_lock()
 
         c = 0
         stmprev = stmtls.linked_list_prev
         stmnext = stmtls.linked_list_next
-        if stmnext:
+        if stmnext is not None:
             stmnext.linked_list_prev = stmprev
-        if stmprev:
+        if stmprev is not None:
             stmprev.linked_list_next = stmnext
             c += 1
         if stmtls is self.linked_list_stmtls:

File rpython/memory/gc/stmshared.py

View file
         self.count_global_pages = 0
 
     def setup(self):
-        self.ll_global_lock = rthread.allocate_ll_lock()
-
-    def acquire_global_lock(self):
-        rthread.acquire_NOAUTO(self.ll_global_lock, True)
-
-    def release_global_lock(self):
-        rthread.release_NOAUTO(self.ll_global_lock)
+        pass
 
 
 # ------------------------------------------------------------
         them out.
         """
         stmshared = self.sharedarea
-        stmshared.acquire_global_lock()
+        stmshared.gc.acquire_global_lock()
         i = stmshared.length - 1
         while i >= 1:
             lpage = self.pages_for_size[i]
                 stmshared.full_pages[i] = lpage
             i -= 1
         stmshared.count_global_pages += self.count_pages
-        stmshared.release_global_lock()
+        stmshared.gc.release_global_lock()
 
     def delete(self):
         self.gift_all_pages_to_shared_area()

File rpython/rlib/rthread.py

View file
     res = c_thread_acquirelock_NOAUTO(ll_lock, flag)
     res = rffi.cast(lltype.Signed, res)
     return bool(res)
+acquire_NOAUTO._annenforceargs_ = (None, bool)
 
 def release_NOAUTO(ll_lock):
     if not we_are_translated():

File rpython/translator/c/genc.py

View file
 
     def cmdexec(self, args='', env=None, err=False, expect_crash=False):
         assert self._compiled
+        if env is None:
+            envrepr = ''
+        else:
+            envrepr = ' [env=%r]' % (env,)
+        log.cmdexec('%s %s%s' % (self.executable_name, args, envrepr))
         res = self.translator.platform.execute(self.executable_name, args,
                                                env=env)
         if res.returncode != 0: