Commits

Armin Rigo committed d32ed00

Rewrite the 'jit_conditional_call' operation to 'conditional_call' and
always allow it to occur, even if not jitted. Avoids the mess of '*args'
and playing around with 'if we_are_jitted()'.

  • Participants
  • Parent commits dc207f7
  • Branches array-overallocation-in-nursery

Comments (0)

Files changed (5)

File rpython/jit/codewriter/jtransform.py

             return []
         return getattr(self, 'handle_jit_marker__%s' % key)(op, jitdriver)
 
-    def rewrite_op_jit_conditional_call(self, op):
+    def rewrite_op_conditional_call(self, op):
         have_floats = False
         for arg in op.args:
             if getkind(arg.concretetype) == 'float':

File rpython/rlib/jit.py

         return hop.genop('jit_record_known_class', [v_inst, v_cls],
                          resulttype=lltype.Void)
 
-def _jit_conditional_call(condition, function, *args):
-    pass
-
-@specialize.call_location()
 def conditional_call(condition, function, *args):
-    if we_are_jitted():
-        _jit_conditional_call(condition, function, *args)
-    else:
-        if condition:
-            function(*args)
-conditional_call._always_inline_ = True
+    "NOT_RPYTHON"
+    if condition:
+        function(*args)
 
 class ConditionalCallEntry(ExtRegistryEntry):
-    _about_ = _jit_conditional_call
+    _about_ = conditional_call
 
     def compute_result_annotation(self, *args_s):
         self.bookkeeper.emulate_pbc_call(self.bookkeeper.position_key,
         args_v[1] = hop.args_r[1].get_concrete_llfn(hop.args_s[1],
                                                     hop.args_s[2:], hop.spaceop)
         hop.exception_is_here()
-        return hop.genop('jit_conditional_call', args_v)
+        return hop.genop('conditional_call', args_v)
 
 class Counters(object):
     counters="""

File rpython/rtyper/llinterp.py

     def op_jit_record_known_class(self, *args):
         pass
 
-    def op_jit_conditional_call(self, *args):
-        raise NotImplementedError("should not be called while not jitted")
+    def op_conditional_call(self, condition, function, *args):
+        assert isinstance(condition, bool)
+        if condition:
+            res = self.op_direct_call(function, *args)
+            assert res is None
 
     def op_get_exception_addr(self, *args):
         raise NotImplementedError

File rpython/rtyper/lltypesystem/lloperation.py

     'jit_force_quasi_immutable': LLOp(canrun=True),
     'jit_record_known_class'  : LLOp(canrun=True),
     'jit_ffi_save_result':  LLOp(canrun=True),
-    'jit_conditional_call': LLOp(),
+    'conditional_call':     LLOp(),
     'get_exception_addr':   LLOp(),
     'get_exc_value_addr':   LLOp(),
     'do_malloc_fixedsize_clear':LLOp(canmallocgc=True),

File rpython/translator/c/funcgen.py

                     break
         return line
 
-    def OP_DIRECT_CALL(self, op):
-        fn = op.args[0]
+    def _op_direct_call(self, fn, args_v, result):
         try:
             targets = [fn.value._obj.graph]
         except AttributeError:
             targets = None
         return self.generic_call(fn.concretetype, self.expr(fn),
-                                 op.args[1:], op.result, targets)
+                                 args_v, result, targets)
+
+    def OP_DIRECT_CALL(self, op):
+        return self._op_direct_call(op.args[0], op.args[1:], op.result)
 
     def OP_INDIRECT_CALL(self, op):
         fn = 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_CONDITIONAL_CALL(self, op):
-        return 'abort();  /* jit_conditional_call */'
+    def OP_CONDITIONAL_CALL(self, op):
+        condition = self.expr(op.args[0])
+        assert op.result.concretetype is Void
+        call = self._op_direct_call(op.args[1], op.args[2:], op.result)
+        return 'if (%s) { /* conditional_call */\n\t%s\n}' % (
+            condition, call.replace('\n', '\n\t'))
 
     # low-level operations
     def generic_get(self, op, sourceexpr):