Author: Armin Rigo <[email protected]>
Branch: stmgc-c4
Changeset: r66870:ff868bef7ee0
Date: 2013-09-09 19:09 +0200
http://bitbucket.org/pypy/pypy/changeset/ff868bef7ee0/

Log:    The indirect_call() going to assembler code forces the transaction
        to become inevitable. The only way I can think of to avoid this is
        to add a new operation.

diff --git a/rpython/jit/backend/llsupport/llmodel.py 
b/rpython/jit/backend/llsupport/llmodel.py
--- a/rpython/jit/backend/llsupport/llmodel.py
+++ b/rpython/jit/backend/llsupport/llmodel.py
@@ -252,7 +252,13 @@
                     else:
                         assert kind == history.REF
                         self.set_ref_value(ll_frame, num, arg)
-                ll_frame = func(ll_frame)
+                # This is the line that calls the assembler code.
+                # 'func(ll_frame)' would work here too, producing an
+                # indirect_call(func, ll_frame, None).  The main difference
+                # is that 'jit_assembler_call' is a hint to STM to not
+                # force the transaction to become inevitable.
+                ll_frame = llop.jit_assembler_call(llmemory.GCREF, func,
+                                                   ll_frame)
             finally:
                 if not self.translate_support_code:
                     LLInterpreter.current_interpreter = prev_interpreter
diff --git a/rpython/rtyper/lltypesystem/lloperation.py 
b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -507,6 +507,7 @@
     'get_write_barrier_from_array_failing_case': LLOp(sideeffects=False),
     'gc_get_type_info_group': LLOp(sideeffects=False),
     'll_read_timestamp': LLOp(canrun=True),
+    'jit_assembler_call': LLOp(canrun=True),   # similar to an 'indirect_call'
 
     # __________ GC operations __________
 
diff --git a/rpython/rtyper/lltypesystem/opimpl.py 
b/rpython/rtyper/lltypesystem/opimpl.py
--- a/rpython/rtyper/lltypesystem/opimpl.py
+++ b/rpython/rtyper/lltypesystem/opimpl.py
@@ -698,6 +698,9 @@
     return p[0]
 op_raw_load.need_result_type = True
 
+def op_jit_assembler_call(funcptr, *args):
+    return funcptr(*args)
+
 # ____________________________________________________________
 
 def get_op_impl(opname):
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -445,14 +445,10 @@
         return self.generic_call(fn.concretetype, self.expr(fn),
                                  op.args[1:-1], op.result, op.args[-1].value)
 
-    def OP_ADR_CALL(self, op):
-        ARGTYPES = [v.concretetype for v in op.args[1:]]
-        RESTYPE = op.result.concretetype
-        FUNC = Ptr(FuncType(ARGTYPES, RESTYPE))
-        typename = self.db.gettype(FUNC)
-        fnaddr = op.args[0]
-        fnexpr = '((%s)%s)' % (cdecl(typename, ''), self.expr(fnaddr))
-        return self.generic_call(FUNC, fnexpr, op.args[1:], op.result)
+    def OP_JIT_ASSEMBLER_CALL(self, op):
+        fn = op.args[0]
+        return self.generic_call(fn.concretetype, self.expr(fn),
+                                 op.args[1:], op.result)
 
     def OP_JIT_CONDITIONAL_CALL(self, op):
         return 'abort();  /* jit_conditional_call */'
diff --git a/rpython/translator/stm/inevitable.py 
b/rpython/translator/stm/inevitable.py
--- a/rpython/translator/stm/inevitable.py
+++ b/rpython/translator/stm/inevitable.py
@@ -18,6 +18,7 @@
     'weakref_create', 'weakref_deref',
     'stm_threadlocalref_get', 'stm_threadlocalref_set',
     'stm_threadlocalref_count', 'stm_threadlocalref_addr',
+    'jit_assembler_call',
     ])
 ALWAYS_ALLOW_OPERATIONS |= set(lloperation.enum_tryfold_ops())
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to