[pypy-commit] pypy array-overallocation-in-nursery: Rewrite the 'jit_conditional_call' operation to 'conditional_call' and
arigo
noreply at buildbot.pypy.org
Mon Nov 4 21:26:51 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: array-overallocation-in-nursery
Changeset: r67835:d32ed008256d
Date: 2013-11-04 20:51 +0100
http://bitbucket.org/pypy/pypy/changeset/d32ed008256d/
Log: 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()'.
diff --git a/rpython/jit/codewriter/jtransform.py b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -1350,7 +1350,7 @@
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':
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -999,20 +999,13 @@
return hop.genop('jit_record_known_class', [v_inst, v_cls],
resulttype=lltype.Void)
-def _jit_conditional_call(condition, function, *args):
- pass
-
- at 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,
@@ -1025,7 +1018,7 @@
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="""
diff --git a/rpython/rtyper/llinterp.py b/rpython/rtyper/llinterp.py
--- a/rpython/rtyper/llinterp.py
+++ b/rpython/rtyper/llinterp.py
@@ -529,8 +529,11 @@
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
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
@@ -450,7 +450,7 @@
'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),
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
@@ -431,14 +431,16 @@
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]
@@ -454,8 +456,12 @@
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):
More information about the pypy-commit
mailing list