Armin Rigo avatar Armin Rigo committed b3866af

fixes fixes

Comments (0)

Files changed (8)

pypy/annotation/builtin.py

 def llmemory_cast_adr_to_int(s, s_mode=None):
     return SomeInteger() # xxx
 
+def llmemory_cast_adr_to_uint_symbolic(s):
+    return SomeInteger(unsigned=True)
+
 def llmemory_cast_int_to_adr(s):
     return SomeAddress()
 
 BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_ptr_to_adr] = llmemory_cast_ptr_to_adr
 BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_adr_to_ptr] = llmemory_cast_adr_to_ptr
 BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_adr_to_int] = llmemory_cast_adr_to_int
+BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_adr_to_uint_symbolic] = llmemory_cast_adr_to_uint_symbolic
 BUILTIN_ANALYZERS[pypy.rpython.lltypesystem.llmemory.cast_int_to_adr] = llmemory_cast_int_to_adr
 
 BUILTIN_ANALYZERS[getattr(OSError.__init__, 'im_func', OSError.__init__)] = (

pypy/rpython/llinterp.py

         checkptr(ptr)
         return llmemory.cast_ptr_to_adr(ptr)
 
-    def op_cast_adr_to_int(self, adr, mode):
+    def op_cast_adr_to_int(self, RESTYPE, adr, mode):
         checkadr(adr)
-        return llmemory.cast_adr_to_int(adr, mode)
+        if RESTYPE is lltype.Signed:
+            return llmemory.cast_adr_to_int(adr, mode)
+        elif RESTYPE is lltype.Unsigned:
+            assert mode == "symbolic"
+            return llmemory.cast_adr_to_uint_symbolic(adr)
+        else:
+            raise TypeError('cast_adr_to_int -> %r' % (RESTYPE,))
+    op_cast_adr_to_int.need_result_type = True
 
     def op_convert_float_bytes_to_longlong(self, f):
         from pypy.rlib import longlong2float

pypy/rpython/memory/gc/stmgc.py

 #   - GCFLAG_LOCAL_COPY: see stmimpl.rst.  Used by C.
 #
 #   - GCFLAG_VISITED: used temporarily to mark local objects found to be
-#     surviving during a collection.
+#     surviving during a collection.  Between collections, it can remain
+#     set on the LOCAL COPY objects, but only on them.
 #
 #   - GCFLAG_HAS_SHADOW: set on nursery objects whose id() or identityhash()
 #     was taken.  Means that we already have a corresponding object allocated
         flags |= GCFLAG_GLOBAL
         self.init_gc_object(addr, typeid16, flags)
 
-    def obj_revision(obj):
+    def obj_revision(self, obj):
         return hdr_revision(self.header(obj))
 
-    def set_obj_revision(obj, nrevision):
+    def set_obj_revision(self, obj, nrevision):
         set_hdr_revision(self.header(obj), nrevision)
 
     def stm_duplicate(self, obj):
             # (It cannot be in the nursery of a different thread, because
             # such an object would not be visible to this thread at all.)
             #
-            ll_assert(hdr.tid & GCFLAG_WAS_COPIED == 0, "id: WAS_COPIED?")
+            ll_assert(hdr.tid & GCFLAG_LOCAL_COPY == 0, "id: LOCAL_COPY?")
             #
             if hdr.tid & GCFLAG_HAS_SHADOW == 0:
                 #
-                # We need to allocate a global object here.  We only allocate
-                # it for now; it is left completely uninitialized.
+                # We need to allocate a non-movable object here.  We only
+                # allocate it for now; it is left completely uninitialized.
                 size_gc_header = self.gcheaderbuilder.size_gc_header
                 size = self.get_size(obj)
                 totalsize = size_gc_header + size
             #
             obj = fixedobj
             #
-        elif hdr.tid & (GCFLAG_GLOBAL|GCFLAG_WAS_COPIED) == GCFLAG_WAS_COPIED:
+        elif hdr.tid & (GCFLAG_GLOBAL|GCFLAG_LOCAL_COPY) == GCFLAG_LOCAL_COPY:
             #
             # The object is the local copy of a LOCAL-GLOBAL pair.
-            obj = hdr.version
+            obj = hdr_revision(hdr)
         #
         i = llmemory.cast_adr_to_int(obj)
         if is_hash:

pypy/rpython/memory/gc/stmshared.py

     def add_regular(self, obj):
         """After malloc_object(), register the object in the internal chained
         list.  For objects whose 'version' field is not otherwise needed."""
-        hdr = self.gc.header(obj)
-        hdr.version = self.chained_list
+        self.gc.set_obj_revision(obj, self.chained_list)
         self.chained_list = obj
 
     def free_object(self, adr2):
         obj = self.chained_list
         self.chained_list = NULL
         while obj:
-            next = self.gc.header(obj).version
+            next = self.gc.obj_revision(obj)
             self.free_object(obj)
             obj = next
 

pypy/rpython/memory/gc/stmtls.py

 from pypy.rpython.memory.gc.stmgc import GCFLAG_GLOBAL, GCFLAG_VISITED
 from pypy.rpython.memory.gc.stmgc import GCFLAG_LOCAL_COPY, GCFLAG_HAS_SHADOW
 from pypy.rpython.memory.gc.stmgc import GCFLAG_POSSIBLY_OUTDATED
-from pypy.rpython.memory.gc.stmgc import hdr_revision
+from pypy.rpython.memory.gc.stmgc import GCFLAG_NOT_WRITTEN
+from pypy.rpython.memory.gc.stmgc import hdr_revision, set_hdr_revision
 
 
 class StmGCTLS(object):
         # Find the roots that are living in raw structures.
         self.collect_from_raw_structures()
         #
-        # Also find the roots that are the local copy of GCFLAG_WAS_COPIED
-        # objects.
+        # Also find the roots that are the local copy of global objects.
         self.collect_roots_from_tldict()
         #
         # Now repeatedly follow objects until 'pending' is empty.
         # don't have GCFLAG_VISITED.  As the newly allocated nursery
         # objects don't have it either, at the start of the next
         # collection, the only LOCAL objects that have it are the ones
-        # in the C tldict, together with GCFLAG_WAS_COPIED.
+        # in the C tldict, together with GCFLAG_LOCAL_COPY.
         #
         # All live nursery objects are out, and the rest dies.  Fill
         # the whole nursery with zero and reset the current nursery pointer.
         return localobj
 
     def fresh_new_weakref(self, obj):
-        XXX  # review
         self.local_weakrefs.append(obj)
 
     # ------------------------------------------------------------
         #
         while obj:
             hdr = self.gc.header(obj)
-            obj = hdr.version
+            obj = hdr_revision(hdr)
             ll_assert(hdr.tid & GCFLAG_GLOBAL == 0, "already GLOBAL [1]")
             ll_assert(hdr.tid & GCFLAG_VISITED == 0, "unexpected VISITED [1]")
             hdr.tid |= GCFLAG_GLOBAL | GCFLAG_NOT_WRITTEN
                 hdr.tid |= GCFLAG_VISITED
                 self.pending.append(obj)
             elif cat == 2:
-                root.address[0] = hdr.version
+                root.address[0] = hdr_revision(hdr)
             return
         #
         # If 'obj' was already forwarded, change it to its forwarding address.
         if hdr.tid & (GCFLAG_VISITED | GCFLAG_HAS_SHADOW):
             #
             if hdr.tid & GCFLAG_VISITED:
-                root.address[0] = hdr.version
+                root.address[0] = hdr_revision(hdr)
                 return
             #
             # Case of GCFLAG_HAS_SHADOW.  See comments below.
             size_gc_header = self.gc.gcheaderbuilder.size_gc_header
             totalsize = size_gc_header + size
             hdr.tid &= ~GCFLAG_HAS_SHADOW
-            newobj = hdr.version
+            newobj = hdr_revision(hdr)
             newhdr = self.gc.header(newobj)
             #
-            saved_version = newhdr.version
+            saved_version = hdr_revision(newhdr)
             llmemory.raw_memcopy(obj - size_gc_header,
                                  newobj - size_gc_header,
                                  totalsize)
-            newhdr.version = saved_version
+            set_hdr_revision(newhdr, saved_version)
             newhdr.tid = hdr.tid | GCFLAG_VISITED
             #
         else:
         # Set the YOUNG copy's GCFLAG_VISITED and set its version to
         # point to the OLD copy.
         hdr.tid |= GCFLAG_VISITED
-        hdr.version = newobj
+        set_hdr_revision(hdr, newobj)
         #
         # Change the original pointer to this object.
         root.address[0] = newobj
                   "in a root: unexpected GCFLAG_GLOBAL")
         ll_assert(localhdr.tid & GCFLAG_LOCAL_COPY != 0,
                   "in a root: missing GCFLAG_LOCAL_COPY")
-        ll_assert(localhdr.tid & GCFLAG_VISITED == 0,
-                  "in a root: unexpected GCFLAG_VISITED")
+        # localhdr.tid & GCFLAG_VISITED may be set or not so far, with no
+        # particular consequence, but we force it to be set from now on (below)
         globalhdr = self.gc.header(globalobj)
         ll_assert(globalhdr.tid & GCFLAG_GLOBAL != 0,
                   "in a root: GLOBAL: missing GCFLAG_GLOBAL")
         while old.non_empty():
             obj = old.pop()
             hdr = self.gc.header(obj)
-            ll_assert(hdr.tid & (GCFLAG_GLOBAL|GCFLAG_WAS_COPIED) == 0,
+            ll_assert(hdr.tid & (GCFLAG_GLOBAL|GCFLAG_LOCAL_COPY) == 0,
                       "local weakref: bad flags")
             if hdr.tid & GCFLAG_VISITED == 0:
                 continue # weakref itself dies
             #
             if self.is_in_nursery(obj):
-                obj = hdr.version
+                obj = hdr_revision(hdr)
                 #hdr = self.gc.header(obj) --- not needed any more
             offset = self.gc.weakpointer_offset(self.gc.get_type_id(obj))
             pointing_to = (obj + offset).address[0]
                 # the weakref points to an object that stays alive
                 if cat == 2:      # update the pointer if needed
                     pointing_hdr = self.gc.header(pointing_to)
-                    (obj + offset).address[0] = pointing_hdr.version
+                    (obj + offset).address[0] = hdr_revision(pointing_hdr)
                 new.append(obj)   # re-register in the new local_weakrefs list
         #
         self.local_weakrefs = new
         previous_sharedarea_tls.delete()
         while obj != NULL:
             hdr = self.gc.header(obj)
-            next = hdr.version
+            next = hdr_revision(hdr)
             if hdr.tid & GCFLAG_VISITED:
                 # survives: relink in the new sharedarea_tls
                 hdr.tid -= GCFLAG_VISITED
         hdr = self.gc.header(obj)
         ll_assert(hdr.tid & GCFLAG_GLOBAL != 0,
                   "debug_check: missing GLOBAL")
-        #ll_assert(hdr.tid & GCFLAG_WAS_COPIED == 0,
-        #          "debug_check: unexpected WAS_COPIED")
+        ll_assert(hdr.tid & GCFLAG_LOCAL_COPY == 0,
+                  "debug_check: unexpected LOCAL_COPY")
         ll_assert(hdr.tid & GCFLAG_VISITED == 0,
                   "debug_check: unexpected VISITED")
         ll_assert(hdr.tid & GCFLAG_HAS_SHADOW == 0,

pypy/rpython/memory/gc/test/test_stmgc.py

         hdr = self.gc.header(obj)
         assert (hdr.tid & GCFLAG_GLOBAL != 0) == must_have_global
         if must_have_was_copied != '?':
-            assert (hdr.tid & GCFLAG_WAS_COPIED != 0) == must_have_was_copied
+            assert (hdr.tid & GCFLAG_LOCAL_COPY != 0) == must_have_was_copied
         if must_have_version != '?':
             assert hdr.version == must_have_version
 

pypy/rpython/memory/gctransform/stmframework.py

 from pypy.rlib.objectmodel import specialize
 
 
-END_MARKER = -8      # keep in sync with src_stm/core.c
+END_MARKER = -8      # keep in sync with src_stm/rpyintf.c
 
 
 class StmFrameworkGCTransformer(FrameworkGCTransformer):
 
-    def transform_graph(self, graph):
-        self.vars_local_not_needed = set()
-        super(StmFrameworkGCTransformer, self).transform_graph(graph)
-        self.vars_local_not_needed = None
-
     def _declare_functions(self, GCClass, getfn, s_gc, *args):
         super(StmFrameworkGCTransformer, self)._declare_functions(
             GCClass, getfn, s_gc, *args)
         self.stm_stop_ptr = getfn(
             self.gcdata.gc.stop_transaction.im_func,
             [s_gc], annmodel.s_None)
-        self.stm_writebarrier_ptr = getfn(
-            self.gcdata.gc.stm_writebarrier,
-            [annmodel.SomeAddress()], annmodel.SomeAddress())
-        self.stm_normalize_global_ptr = getfn(
-            self.gcdata.gc.stm_normalize_global,
-            [annmodel.SomeAddress()], annmodel.SomeAddress())
-        self.write_barrier_failing_case_ptr = getfn(
-            self.gcdata.gc._stm_write_barrier_global,
-            [annmodel.SomeAddress()], annmodel.SomeAddress())
+##        self.stm_writebarrier_ptr = getfn(
+##            self.gcdata.gc.stm_writebarrier,
+##            [annmodel.SomeAddress()], annmodel.SomeAddress())
+##        self.stm_normalize_global_ptr = getfn(
+##            self.gcdata.gc.stm_normalize_global,
+##            [annmodel.SomeAddress()], annmodel.SomeAddress())
+##        self.write_barrier_failing_case_ptr = getfn(
+##            self.gcdata.gc._stm_write_barrier_global,
+##            [annmodel.SomeAddress()], annmodel.SomeAddress())
 
     def build_root_walker(self):
         return StmShadowStackRootWalker(self)
                                  resulttype=llmemory.Address)
         hop.genop('adr_add', [v_gcdata_adr, c_ofs], resultvar=op.result)
 
-    def gct_stm_writebarrier(self, hop):
-        op = hop.spaceop
-        v_adr = hop.genop('cast_ptr_to_adr',
-                          [op.args[0]], resulttype=llmemory.Address)
-        v_localadr = hop.genop("direct_call",
-                               [self.stm_writebarrier_ptr, v_adr],
-                               resulttype=llmemory.Address)
-        hop.genop('cast_adr_to_ptr', [v_localadr], resultvar=op.result)
+##    def gct_stm_writebarrier(self, hop):
+##        op = hop.spaceop
+##        v_adr = hop.genop('cast_ptr_to_adr',
+##                          [op.args[0]], resulttype=llmemory.Address)
+##        v_localadr = hop.genop("direct_call",
+##                               [self.stm_writebarrier_ptr, v_adr],
+##                               resulttype=llmemory.Address)
+##        hop.genop('cast_adr_to_ptr', [v_localadr], resultvar=op.result)
 
-    def gct_stm_normalize_global(self, hop):
-        op = hop.spaceop
-        v_adr = hop.genop('cast_ptr_to_adr',
-                          [op.args[0]], resulttype=llmemory.Address)
-        v_globaladr = hop.genop("direct_call",
-                                [self.stm_normalize_global_ptr, v_adr],
-                                resulttype=llmemory.Address)
-        hop.genop('cast_adr_to_ptr', [v_globaladr], resultvar=op.result)
+##    def gct_stm_normalize_global(self, hop):
+##        op = hop.spaceop
+##        v_adr = hop.genop('cast_ptr_to_adr',
+##                          [op.args[0]], resulttype=llmemory.Address)
+##        v_globaladr = hop.genop("direct_call",
+##                                [self.stm_normalize_global_ptr, v_adr],
+##                                resulttype=llmemory.Address)
+##        hop.genop('cast_adr_to_ptr', [v_globaladr], resultvar=op.result)
 
     def gct_stm_start_transaction(self, hop):
         livevars = self.push_roots(hop)
         hop.genop("direct_call", [self.stm_stop_ptr, self.c_const_gc])
         self.pop_roots(hop, livevars)
 
-    def gct_stm_local_not_needed(self, hop):
-        # XXX make use of this info :-)
-        # for now, 'stm_local_not_needed' is not generated
-        # (INSERT_STM_LOCAL_NOT_NEEDED=False in translator/stm/transform)
-        self.vars_local_not_needed.update(hop.spaceop.args)
-
-    def gct_gc_store(self, hop):
-        hop.rename('stm_gc_store')
+##    def gct_gc_store(self, hop):
+##        hop.rename('stm_gc_store')
 
 
 class StmShadowStackRootWalker(BaseRootWalker):

pypy/rpython/rbuiltin.py

                      [adr, hop.inputconst(lltype.Void, mode)],
                      resulttype = lltype.Signed)
 
+def rtype_cast_adr_to_uint_symb(hop):
+    assert isinstance(hop.args_r[0], raddress.AddressRepr)
+    adr = hop.inputarg(hop.args_r[0], arg=0)
+    mode = "symbolic"
+    hop.exception_cannot_occur()
+    return hop.genop('cast_adr_to_int',
+                     [adr, hop.inputconst(lltype.Void, mode)],
+                     resulttype = lltype.Unsigned)
+
 def rtype_cast_int_to_adr(hop):
     v_input, = hop.inputargs(lltype.Signed)
     hop.exception_cannot_occur()
 BUILTIN_TYPER[llmemory.cast_ptr_to_adr] = rtype_cast_ptr_to_adr
 BUILTIN_TYPER[llmemory.cast_adr_to_ptr] = rtype_cast_adr_to_ptr
 BUILTIN_TYPER[llmemory.cast_adr_to_int] = rtype_cast_adr_to_int
+BUILTIN_TYPER[llmemory.cast_adr_to_uint_symbolic] = rtype_cast_adr_to_uint_symb
 BUILTIN_TYPER[llmemory.cast_int_to_adr] = rtype_cast_int_to_adr
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.