Author: Armin Rigo <[email protected]>
Branch: stm-gc
Changeset: r54821:6ed85ab7e802
Date: 2012-04-30 11:36 +0200
http://bitbucket.org/pypy/pypy/changeset/6ed85ab7e802/

Log:    Fixes

diff --git a/pypy/rpython/llinterp.py b/pypy/rpython/llinterp.py
--- a/pypy/rpython/llinterp.py
+++ b/pypy/rpython/llinterp.py
@@ -946,6 +946,14 @@
     def op_stack_current(self):
         return 0
 
+    def _stm_not_implemented(self, *args):
+        raise NotImplementedError
+    op_stm_writebarrier = _stm_not_implemented
+    op_stm_normalize_global = _stm_not_implemented
+    op_stm_become_inevitable = _stm_not_implemented
+    op_stm_thread_starting = _stm_not_implemented
+    op_stm_thread_stopping = _stm_not_implemented
+
     # operations on pyobjects!
     for opname in lloperation.opimpls.keys():
         exec py.code.Source("""
diff --git a/pypy/rpython/lltypesystem/rffi.py 
b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -716,10 +716,8 @@
         string is already nonmovable.  Must be followed by a
         free_nonmovingbuffer call.
         """
-        # XXX --- custom version for STM ---
-        # disabled the "else" part
-        ##if rgc.can_move(data):
-        if 1:
+        from pypy.rpython.lltypesystem.lloperation import llop
+        if llop.stm_is_enabled(lltype.Bool) or rgc.can_move(data):
             count = len(data)
             buf = lltype.malloc(TYPEP.TO, count, flavor='raw')
             for i in range(count):
@@ -743,14 +741,15 @@
         # if 'buf' points inside 'data'.  This is only possible if we
         # followed the 2nd case in get_nonmovingbuffer(); in the first case,
         # 'buf' points to its own raw-malloced memory.
-
-        # XXX --- custom version for STM ---
-##        data = llstrtype(data)
-##        data_start = cast_ptr_to_adr(data) + \
-##            offsetof(STRTYPE, 'chars') + itemoffsetof(STRTYPE.chars, 0)
-##        followed_2nd_path = (buf == cast(TYPEP, data_start))
-##        keepalive_until_here(data)
-        followed_2nd_path = False
+        from pypy.rpython.lltypesystem.lloperation import llop
+        if llop.stm_is_enabled(lltype.Bool):
+            followed_2nd_path = False
+        else:
+            data = llstrtype(data)
+            data_start = cast_ptr_to_adr(data) + \
+                offsetof(STRTYPE, 'chars') + itemoffsetof(STRTYPE.chars, 0)
+            followed_2nd_path = (buf == cast(TYPEP, data_start))
+            keepalive_until_here(data)
         if not followed_2nd_path:
             lltype.free(buf, flavor='raw')
     free_nonmovingbuffer._annenforceargs_ = [strtype, None]
diff --git a/pypy/rpython/lltypesystem/rstr.py 
b/pypy/rpython/lltypesystem/rstr.py
--- a/pypy/rpython/lltypesystem/rstr.py
+++ b/pypy/rpython/lltypesystem/rstr.py
@@ -73,17 +73,22 @@
         assert srcstart >= 0
         assert dststart >= 0
         assert length >= 0
-        # XXX --- custom version for STM ---
-        # the old version first:
-##        src = llmemory.cast_ptr_to_adr(src) + _str_ofs(srcstart)
-##        dst = llmemory.cast_ptr_to_adr(dst) + _str_ofs(dststart)
-##        llmemory.raw_memcopy(src, dst, llmemory.sizeof(CHAR_TP) * length)
-##        keepalive_until_here(src)
-##        keepalive_until_here(dst)
-        i = 0
-        while i < length:
-            dst.chars[dststart + i] = src.chars[srcstart + i]
-            i += 1
+        #
+        # STM requires the slow character-by-character version,
+        # which at least works without forcing the transaction
+        # to become inevitable
+        if llop.stm_is_enabled(Bool):
+            i = 0
+            while i < length:
+                dst.chars[dststart + i] = src.chars[srcstart + i]
+                i += 1
+            return
+        #
+        src = llmemory.cast_ptr_to_adr(src) + _str_ofs(srcstart)
+        dst = llmemory.cast_ptr_to_adr(dst) + _str_ofs(dststart)
+        llmemory.raw_memcopy(src, dst, llmemory.sizeof(CHAR_TP) * length)
+        keepalive_until_here(src)
+        keepalive_until_here(dst)
     copy_string_contents._always_inline_ = True
     return func_with_new_name(copy_string_contents, 'copy_%s_contents' % name)
 
diff --git a/pypy/rpython/memory/gctransform/framework.py 
b/pypy/rpython/memory/gctransform/framework.py
--- a/pypy/rpython/memory/gctransform/framework.py
+++ b/pypy/rpython/memory/gctransform/framework.py
@@ -136,7 +136,6 @@
 
     def __init__(self, translator):
         from pypy.rpython.memory.gc.base import choose_gc_from_config
-        from pypy.rpython.memory.gc.base import ARRAY_TYPEID_MAP
 
         super(FrameworkGCTransformer, self).__init__(translator, inline=True)
         if hasattr(self, 'GC_PARAMS'):
@@ -343,6 +342,7 @@
                 annmodel.s_None)
 
         if hasattr(GCClass, 'heap_stats'):
+            from pypy.rpython.memory.gc.base import ARRAY_TYPEID_MAP
             self.heap_stats_ptr = getfn(GCClass.heap_stats.im_func,
                     [s_gc], annmodel.SomePtr(lltype.Ptr(ARRAY_TYPEID_MAP)),
                     minimal_transform=False)
diff --git a/pypy/rpython/memory/gctransform/shadowstack.py 
b/pypy/rpython/memory/gctransform/shadowstack.py
--- a/pypy/rpython/memory/gctransform/shadowstack.py
+++ b/pypy/rpython/memory/gctransform/shadowstack.py
@@ -28,7 +28,7 @@
         self.decr_stack = decr_stack
 
         root_iterator = get_root_iterator(gctransformer)
-        def walk_stack_root(callback, arg, start, end):
+        def walk_stack_root(callback, start, end):
             root_iterator.setcontext(NonConstant(llmemory.NULL))
             gc = self.gc
             addr = end
@@ -36,7 +36,7 @@
                 addr = root_iterator.nextleft(gc, start, addr)
                 if addr == llmemory.NULL:
                     return
-                callback(arg, addr)
+                callback(gc, addr)
         self.rootstackhook = walk_stack_root
 
         self.shadow_stack_pool = ShadowStackPool(gcdata)
@@ -56,9 +56,9 @@
         self.shadow_stack_pool.initial_setup()
         BaseRootWalker.setup_root_walker(self)
 
-    def walk_stack_roots(self, collect_stack_root, arg):
+    def walk_stack_roots(self, collect_stack_root):
         gcdata = self.gcdata
-        self.rootstackhook(collect_stack_root, arg,
+        self.rootstackhook(collect_stack_root,
                            gcdata.root_stack_base, gcdata.root_stack_top)
 
     def need_thread_support(self, gctransformer, getfn):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to