[pypy-svn] r69635 - in pypy/branch/virtual-forcing/pypy/jit/backend: . llgraph
pedronis at codespeak.net
pedronis at codespeak.net
Wed Nov 25 14:49:30 CET 2009
Author: pedronis
Date: Wed Nov 25 14:49:29 2009
New Revision: 69635
Modified:
pypy/branch/virtual-forcing/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/virtual-forcing/pypy/jit/backend/llgraph/runner.py
pypy/branch/virtual-forcing/pypy/jit/backend/model.py
Log:
support passing test_force_operations with the llgraph backend, not completely pretty but not too bad
Modified: pypy/branch/virtual-forcing/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/virtual-forcing/pypy/jit/backend/llgraph/llimpl.py Wed Nov 25 14:49:29 2009
@@ -145,6 +145,9 @@
'unicodesetitem' : (('ref', 'int', 'int'), 'int'),
'cast_ptr_to_int' : (('ref',), 'int'),
'debug_merge_point': (('ref',), None),
+ 'force_token' : ((), 'int'),
+ 'call_may_force' : (('ref', 'varargs'), 'intorptr'),
+ 'guard_not_forced': ((), None)
#'getitem' : (('void', 'ref', 'int'), 'int'),
#'setitem' : (('void', 'ref', 'int', 'int'), None),
#'newlist' : (('void', 'varargs'), 'ref'),
@@ -384,6 +387,9 @@
def __init__(self, memocast):
self.verbose = False
self.memocast = memocast
+ self.opindex = 1
+ self._forced = False
+ self._may_force = -1
def getenv(self, v):
if isinstance(v, Constant):
@@ -391,6 +397,16 @@
else:
return self.env[v]
+ def _populate_fail_args(self, op):
+ fail_args = []
+ if op.fail_args:
+ for fail_arg in op.fail_args:
+ if fail_arg is None:
+ fail_args.append(None)
+ else:
+ fail_args.append(self.getenv(fail_arg))
+ self.fail_args = fail_args
+
def execute(self):
"""Execute all operations in a loop,
possibly following to other loops as well.
@@ -401,6 +417,7 @@
operations = self.loop.operations
opindex = 0
while True:
+ self.opindex = opindex
op = operations[opindex]
args = [self.getenv(v) for v in op.args]
if not op.is_final():
@@ -419,18 +436,11 @@
opindex = 0
continue
else:
- fail_args = []
- if op.fail_args:
- for fail_arg in op.fail_args:
- if fail_arg is None:
- fail_args.append(None)
- else:
- fail_args.append(self.getenv(fail_arg))
+ self._populate_fail_args(op)
# a non-patched guard
if self.verbose:
log.trace('failed: %s' % (
', '.join(map(str, fail_args)),))
- self.fail_args = fail_args
return op.fail_index
#verbose = self.verbose
assert (result is None) == (op.result is None)
@@ -776,6 +786,21 @@
def op_uint_xor(self, descr, arg1, arg2):
return arg1 ^ arg2
+ def op_force_token(self, descr):
+ opaque_frame = _to_opaque(self)
+ return llmemory.cast_ptr_to_adr(opaque_frame)
+
+ def op_call_may_force(self, calldescr, func, *args):
+ assert not self._forced
+ self._may_force = self.opindex
+ self.op_call(calldescr, func, *args)
+
+ def op_guard_not_forced(self, descr):
+ forced = self._forced
+ self._forced = False
+ if forced:
+ raise GuardFailed
+
class OOFrame(Frame):
@@ -1042,6 +1067,16 @@
return lltype.cast_opaque_ptr(llmemory.GCREF,
_get_error(ZeroDivisionError).args[1])
+def force(force_token):
+ opaque_frame = llmemory.cast_adr_to_ptr(force_token,
+ lltype.Ptr(_TO_OPAQUE[Frame]))
+ frame = _from_opaque(opaque_frame)
+ frame._forced = True
+ assert frame._may_force >= 0
+ guard_op = frame.loop.operations[frame._may_force+1]
+ frame._populate_fail_args(guard_op)
+ return opaque_frame
+
class MemoCast(object):
def __init__(self):
self.addresses = [llmemory.NULL]
@@ -1411,6 +1446,7 @@
setannotation(get_overflow_error_value, annmodel.SomePtr(llmemory.GCREF))
setannotation(get_zero_division_error, annmodel.SomeAddress())
setannotation(get_zero_division_error_value, annmodel.SomePtr(llmemory.GCREF))
+setannotation(force, s_Frame)
setannotation(new_memo_cast, s_MemoCast)
setannotation(cast_adr_to_int, annmodel.SomeInteger())
Modified: pypy/branch/virtual-forcing/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/virtual-forcing/pypy/jit/backend/llgraph/runner.py Wed Nov 25 14:49:29 2009
@@ -497,6 +497,9 @@
def do_cast_ptr_to_int(self, ptrbox):
return history.BoxInt(llimpl.cast_to_int(ptrbox.getref_base(),
self.memo_cast))
+ def force(self, force_token):
+ frame = llimpl.force(force_token)
+ self.latest_frame = frame
class OOtypeCPU(BaseCPU):
is_oo = True
Modified: pypy/branch/virtual-forcing/pypy/jit/backend/model.py
==============================================================================
--- pypy/branch/virtual-forcing/pypy/jit/backend/model.py (original)
+++ pypy/branch/virtual-forcing/pypy/jit/backend/model.py Wed Nov 25 14:49:29 2009
@@ -206,10 +206,13 @@
raise NotImplementedError
def do_force_token(self):
- raise NotImplementedError
+ raise NotImplementedError
def do_call_may_force(self, args, calldescr):
- raise NotImplementedError
+ raise NotImplementedError
+
+ def force(self, force_token):
+ raise NotImplementedError
# ootype specific operations
# --------------------------
More information about the Pypy-commit
mailing list