[pypy-commit] pypy stm-thread-2: fixes fixes
arigo
noreply at buildbot.pypy.org
Fri Sep 7 10:43:39 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread-2
Changeset: r57206:b3866afc618b
Date: 2012-09-07 10:42 +0200
http://bitbucket.org/pypy/pypy/changeset/b3866afc618b/
Log: fixes fixes
diff --git a/pypy/annotation/builtin.py b/pypy/annotation/builtin.py
--- a/pypy/annotation/builtin.py
+++ b/pypy/annotation/builtin.py
@@ -358,6 +358,9 @@
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()
@@ -387,6 +390,7 @@
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__)] = (
diff --git a/pypy/rpython/llinterp.py b/pypy/rpython/llinterp.py
--- a/pypy/rpython/llinterp.py
+++ b/pypy/rpython/llinterp.py
@@ -781,9 +781,16 @@
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
diff --git a/pypy/rpython/memory/gc/stmgc.py b/pypy/rpython/memory/gc/stmgc.py
--- a/pypy/rpython/memory/gc/stmgc.py
+++ b/pypy/rpython/memory/gc/stmgc.py
@@ -59,7 +59,8 @@
# - 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
@@ -306,10 +307,10 @@
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):
@@ -349,12 +350,12 @@
# (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
@@ -372,10 +373,10 @@
#
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:
diff --git a/pypy/rpython/memory/gc/stmshared.py b/pypy/rpython/memory/gc/stmshared.py
--- a/pypy/rpython/memory/gc/stmshared.py
+++ b/pypy/rpython/memory/gc/stmshared.py
@@ -36,8 +36,7 @@
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):
@@ -48,7 +47,7 @@
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
diff --git a/pypy/rpython/memory/gc/stmtls.py b/pypy/rpython/memory/gc/stmtls.py
--- a/pypy/rpython/memory/gc/stmtls.py
+++ b/pypy/rpython/memory/gc/stmtls.py
@@ -12,7 +12,8 @@
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):
@@ -184,8 +185,7 @@
# 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.
@@ -204,7 +204,7 @@
# 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.
@@ -255,7 +255,6 @@
return localobj
def fresh_new_weakref(self, obj):
- XXX # review
self.local_weakrefs.append(obj)
# ------------------------------------------------------------
@@ -270,7 +269,7 @@
#
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
@@ -402,7 +401,7 @@
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.
@@ -412,21 +411,21 @@
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:
@@ -452,7 +451,7 @@
# 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
@@ -490,8 +489,8 @@
"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")
@@ -522,13 +521,13 @@
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]
@@ -541,7 +540,7 @@
# 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
@@ -552,7 +551,7 @@
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
@@ -581,8 +580,8 @@
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,
diff --git a/pypy/rpython/memory/gc/test/test_stmgc.py b/pypy/rpython/memory/gc/test/test_stmgc.py
--- a/pypy/rpython/memory/gc/test/test_stmgc.py
+++ b/pypy/rpython/memory/gc/test/test_stmgc.py
@@ -190,7 +190,7 @@
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
diff --git a/pypy/rpython/memory/gctransform/stmframework.py b/pypy/rpython/memory/gctransform/stmframework.py
--- a/pypy/rpython/memory/gctransform/stmframework.py
+++ b/pypy/rpython/memory/gctransform/stmframework.py
@@ -9,16 +9,11 @@
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)
@@ -28,15 +23,15 @@
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)
@@ -52,23 +47,23 @@
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)
@@ -80,14 +75,8 @@
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):
diff --git a/pypy/rpython/rbuiltin.py b/pypy/rpython/rbuiltin.py
--- a/pypy/rpython/rbuiltin.py
+++ b/pypy/rpython/rbuiltin.py
@@ -675,6 +675,15 @@
[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()
@@ -685,5 +694,5 @@
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
-
More information about the pypy-commit
mailing list