[pypy-commit] pypy stm: Random progress.

arigo noreply at buildbot.pypy.org
Fri Oct 28 18:30:55 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r48575:451f6144a150
Date: 2011-10-28 18:01 +0200
http://bitbucket.org/pypy/pypy/changeset/451f6144a150/

Log:	Random progress.

diff --git a/pypy/translator/c/funcgen.py b/pypy/translator/c/funcgen.py
--- a/pypy/translator/c/funcgen.py
+++ b/pypy/translator/c/funcgen.py
@@ -603,6 +603,7 @@
     OP_STM_BEGIN_INEVITABLE_TRANSACTION = _OP_STM
     OP_STM_TRANSACTION_BOUNDARY = _OP_STM
     OP_STM_DECLARE_VARIABLE = _OP_STM
+    OP_STM_TRY_INEVITABLE = _OP_STM
 
 
     def OP_PTR_NONZERO(self, op):
diff --git a/pypy/translator/stm/_rffi_stm.py b/pypy/translator/stm/_rffi_stm.py
--- a/pypy/translator/stm/_rffi_stm.py
+++ b/pypy/translator/stm/_rffi_stm.py
@@ -30,6 +30,7 @@
 begin_inevitable_transaction = llexternal('stm_begin_inevitable_transaction',
                                           [], lltype.Void)
 commit_transaction = llexternal('stm_commit_transaction', [], lltype.Signed)
+try_inevitable = llexternal('stm_try_inevitable', [], lltype.Void)
 
 stm_read_word = llexternal('stm_read_word', [SignedP], lltype.Signed)
 stm_write_word = llexternal('stm_write_word', [SignedP, lltype.Signed],
diff --git a/pypy/translator/stm/funcgen.py b/pypy/translator/stm/funcgen.py
--- a/pypy/translator/stm/funcgen.py
+++ b/pypy/translator/stm/funcgen.py
@@ -104,6 +104,9 @@
     assert funcgen.exception_policy == 'stm'
     return 'STM_TRANSACTION_BOUNDARY();'
 
+def stm_try_inevitable(funcgen, op):
+    return 'stm_try_inevitable();'
+
 
 def op_stm(funcgen, op):
     assert funcgen.db.translator.stm_transformation_applied
diff --git a/pypy/translator/stm/llstminterp.py b/pypy/translator/stm/llstminterp.py
--- a/pypy/translator/stm/llstminterp.py
+++ b/pypy/translator/stm/llstminterp.py
@@ -1,6 +1,7 @@
 from pypy.rpython.lltypesystem import lltype
 from pypy.rpython.llinterp import LLFrame, LLException
 from pypy.translator.stm import rstm
+from pypy.translator.stm.transform import op_in_set, ALWAYS_ALLOW_OPERATIONS
 
 
 class ForbiddenInstructionInSTMMode(Exception):
@@ -30,11 +31,6 @@
 
 class LLSTMFrame(LLFrame):
 
-    ALWAYS_ALLOW_OPERATIONS = set([
-        'int_*', 'same_as', 'cast_*',
-        'direct_call',
-        ])
-
     def eval(self):
         try:
             res = LLFrame.eval(self)
@@ -60,16 +56,8 @@
             setattr(self, 'opstm_' + opname, ophandler)
         return ophandler
 
-    def _op_in_set(self, opname, set):
-        if opname in set:
-            return True
-        for i in range(len(opname)-1, -1, -1):
-            if (opname[:i] + '*') in set:
-                return True
-        return False
-
     def _validate_stmoperation_handler(self, opname):
-        if self._op_in_set(opname, self.ALWAYS_ALLOW_OPERATIONS):
+        if op_in_set(opname, ALWAYS_ALLOW_OPERATIONS):
             return
         raise ForbiddenInstructionInSTMMode(opname, self.graph)
 
diff --git a/pypy/translator/stm/transform.py b/pypy/translator/stm/transform.py
--- a/pypy/translator/stm/transform.py
+++ b/pypy/translator/stm/transform.py
@@ -4,6 +4,23 @@
 from pypy.rpython.lltypesystem import lltype
 
 
+ALWAYS_ALLOW_OPERATIONS = set([
+    'int_*', 'same_as', 'cast_*',
+    'direct_call',
+    'debug_print',
+    ])
+
+def op_in_set(opname, set):
+    if opname in set:
+        return True
+    for i in range(len(opname)-1, -1, -1):
+        if (opname[:i] + '*') in set:
+            return True
+    return False
+
+# ____________________________________________________________
+
+
 class STMTransformer(object):
 
     def __init__(self, translator=None):
@@ -23,7 +40,15 @@
             return
         newoperations = []
         for op in block.operations:
-            meth = getattr(self, 'stt_' + op.opname, list.append)
+            try:
+                meth = getattr(self, 'stt_' + op.opname)
+            except AttributeError:
+                if op_in_set(op.opname, ALWAYS_ALLOW_OPERATIONS):
+                    meth = list.append
+                else:
+                    meth = turn_inevitable_and_proceed
+                setattr(self.__class__, 'stt_' + op.opname,
+                        staticmethod(meth))
             meth(newoperations, op)
         block.operations = newoperations
 
@@ -71,3 +96,9 @@
 def transform_graph(graph):
     # for tests: only transforms one graph
     STMTransformer().transform_graph(graph)
+
+
+def turn_inevitable_and_proceed(newoperations, op):
+    op1 = SpaceOperation('stm_try_inevitable', [], varoftype(lltype.Void))
+    newoperations.append(op1)
+    newoperations.append(op)


More information about the pypy-commit mailing list