[pypy-commit] pypy jit-simplify-backendintf: Add an extra assertion in the llgraph backend.
arigo
noreply at buildbot.pypy.org
Mon Dec 12 11:53:05 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: jit-simplify-backendintf
Changeset: r50418:cd85bd047d43
Date: 2011-12-12 11:15 +0100
http://bitbucket.org/pypy/pypy/changeset/cd85bd047d43/
Log: Add an extra assertion in the llgraph backend.
diff --git a/pypy/jit/backend/llgraph/llimpl.py b/pypy/jit/backend/llgraph/llimpl.py
--- a/pypy/jit/backend/llgraph/llimpl.py
+++ b/pypy/jit/backend/llgraph/llimpl.py
@@ -328,6 +328,10 @@
_variables.append(v)
return r
+def compile_started_vars(clt):
+ if not hasattr(clt, '_debug_argtypes'): # only when compiling the loop
+ clt._debug_argtypes = [v.concretetype for v in _variables]
+
def compile_add(loop, opnum):
loop = _from_opaque(loop)
loop.operations.append(Operation(opnum))
@@ -355,11 +359,13 @@
TARGET_TOKENS = weakref.WeakKeyDictionary()
-def compile_add_target_token(loop, descr):
+def compile_add_target_token(loop, descr, clt):
+ # here, 'clt' is the compiled_loop_token of the original loop that
+ # we are compiling
loop = _from_opaque(loop)
op = loop.operations[-1]
descrobj = _normalize(descr)
- TARGET_TOKENS[descrobj] = loop, len(loop.operations), op.args
+ TARGET_TOKENS[descrobj] = loop, len(loop.operations), op.args, clt
def compile_add_var(loop, intvar):
loop = _from_opaque(loop)
@@ -395,10 +401,13 @@
_variables.append(v)
return r
-def compile_add_jump_target(loop, targettoken):
+def compile_add_jump_target(loop, targettoken, source_clt):
loop = _from_opaque(loop)
descrobj = _normalize(targettoken)
- loop_target, target_opindex, target_inputargs = TARGET_TOKENS[descrobj]
+ (loop_target, target_opindex, target_inputargs, target_clt
+ ) = TARGET_TOKENS[descrobj]
+ #
+ assert source_clt._debug_argtypes == target_clt._debug_argtypes
#
op = loop.operations[-1]
op.jump_target = loop_target
@@ -406,6 +415,7 @@
op.jump_target_inputargs = target_inputargs
assert op.opnum == rop.JUMP
assert len(op.args) == len(target_inputargs)
+ #
if loop_target == loop:
log.info("compiling new loop")
else:
diff --git a/pypy/jit/backend/llgraph/runner.py b/pypy/jit/backend/llgraph/runner.py
--- a/pypy/jit/backend/llgraph/runner.py
+++ b/pypy/jit/backend/llgraph/runner.py
@@ -138,11 +138,12 @@
clt = original_loop_token.compiled_loop_token
clt.loop_and_bridges.append(c)
clt.compiling_a_bridge()
- self._compile_loop_or_bridge(c, inputargs, operations)
+ self._compile_loop_or_bridge(c, inputargs, operations, clt)
old, oldindex = faildescr._compiled_fail
llimpl.compile_redirect_fail(old, oldindex, c)
- def compile_loop(self, inputargs, operations, jitcell_token, log=True, name=''):
+ def compile_loop(self, inputargs, operations, jitcell_token,
+ log=True, name=''):
"""In a real assembler backend, this should assemble the given
list of operations. Here we just generate a similar CompiledLoop
instance. The code here is RPython, whereas the code in llimpl
@@ -153,14 +154,14 @@
clt.loop_and_bridges = [c]
clt.compiled_version = c
jitcell_token.compiled_loop_token = clt
- self._compile_loop_or_bridge(c, inputargs, operations)
+ self._compile_loop_or_bridge(c, inputargs, operations, clt)
def free_loop_and_bridges(self, compiled_loop_token):
for c in compiled_loop_token.loop_and_bridges:
llimpl.mark_as_free(c)
model.AbstractCPU.free_loop_and_bridges(self, compiled_loop_token)
- def _compile_loop_or_bridge(self, c, inputargs, operations):
+ def _compile_loop_or_bridge(self, c, inputargs, operations, clt):
var2index = {}
for box in inputargs:
if isinstance(box, history.BoxInt):
@@ -172,10 +173,11 @@
var2index[box] = llimpl.compile_start_float_var(c)
else:
raise Exception("box is: %r" % (box,))
- self._compile_operations(c, operations, var2index)
+ llimpl.compile_started_vars(clt)
+ self._compile_operations(c, operations, var2index, clt)
return c
- def _compile_operations(self, c, operations, var2index):
+ def _compile_operations(self, c, operations, var2index, clt):
for op in operations:
llimpl.compile_add(c, op.getopnum())
descr = op.getdescr()
@@ -187,7 +189,7 @@
assert op.getopnum() != rop.JUMP
llimpl.compile_add_loop_token(c, descr)
if isinstance(descr, history.TargetToken) and op.getopnum() == rop.LABEL:
- llimpl.compile_add_target_token(c, descr)
+ llimpl.compile_add_target_token(c, descr, clt)
if self.is_oo and isinstance(descr, (OODescr, MethDescr)):
# hack hack, not rpython
c._obj.externalobj.operations[-1].setdescr(descr)
@@ -241,7 +243,7 @@
assert op.is_final()
if op.getopnum() == rop.JUMP:
targettoken = op.getdescr()
- llimpl.compile_add_jump_target(c, targettoken)
+ llimpl.compile_add_jump_target(c, targettoken, clt)
elif op.getopnum() == rop.FINISH:
faildescr = op.getdescr()
index = self.get_fail_descr_number(faildescr)
More information about the pypy-commit
mailing list