Author: Maciej Fijalkowski <[email protected]>
Branch: continulet-jit-3
Changeset: r58216:1b75cd6598b5
Date: 2012-10-18 16:14 +0200
http://bitbucket.org/pypy/pypy/changeset/1b75cd6598b5/
Log: (arigo, fijal) fix llgraph backend
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
@@ -142,6 +142,8 @@
supports_singlefloats = True
translate_support_code = False
+ JITFRAMEPTR = llmemory.GCREF
+
def __init__(self, rtyper, stats=None, *ignored_args, **ignored_kwds):
model.AbstractCPU.__init__(self)
self.rtyper = rtyper
@@ -241,6 +243,16 @@
else:
return lltype.nullptr(llmemory.GCREF.TO)
+ def force(self, frame):
+ assert not frame._forced
+ frame._forced = True
+ guard_op = frame.lltrace.operations[frame.current_index + 1]
+ call_op = frame.current_op
+ frame.latest_values = frame._getfailargs(guard_op, call_op.result)
+ descr = guard_op.getdescr()
+ frame.latest_descr = descr
+ return descr
+
def calldescrof(self, FUNC, ARGS, RESULT, effect_info):
key = ('call', getkind(RESULT),
tuple([getkind(A) for A in ARGS]),
@@ -518,8 +530,10 @@
def bh_read_timestamp(self):
return read_timestamp()
-
class LLFrame(object):
+ _TYPE = llmemory.GCREF
+ _forced = False
+
def __init__(self, cpu, argboxes, args):
self.env = {}
self.cpu = cpu
@@ -546,6 +560,7 @@
continue
args = [self.lookup(arg) for arg in op.getarglist()]
self.current_op = op # for label
+ self.current_index = i
try:
resval = getattr(self, 'execute_' +
op.getopname())(op.getdescr(),
*args)
@@ -582,11 +597,15 @@
assert resval is None
i += 1
- def _getfailargs(self):
+ def _getfailargs(self, op=None, skip=None):
+ if op is None:
+ op = self.current_op
r = []
- for arg in self.current_op.getfailargs():
+ for arg in op.getfailargs():
if arg is None:
r.append(None)
+ elif arg is skip:
+ r.append(_example_res[skip.type])
else:
r.append(self.env[arg])
return r
@@ -663,7 +682,8 @@
return support.cast_to_ptr(res)
def execute_guard_not_forced(self, descr):
- pass # XXX
+ if self._forced:
+ self.fail_guard(descr)
def execute_guard_not_invalidated(self, descr):
if self.lltrace.invalid:
@@ -800,9 +820,8 @@
descr = heaptracker.vtable2descr(self.cpu, vtable)
return self.cpu.bh_new_with_vtable(vtable, descr)
- def execute_force_token(self, _):
- import py; py.test.skip("XXX")
-
+ def execute_jit_frame(self, _):
+ return self
def _setup():
def _make_impl_from_blackhole_interp(opname):
diff --git a/pypy/jit/backend/llgraph/support.py
b/pypy/jit/backend/llgraph/support.py
--- a/pypy/jit/backend/llgraph/support.py
+++ b/pypy/jit/backend/llgraph/support.py
@@ -85,6 +85,8 @@
return lltype.cast_primitive(TYPE, x)
def cast_from_ptr(TYPE, x):
+ if lltype.typeOf(x) == TYPE:
+ return x
return lltype.cast_opaque_ptr(TYPE, x)
def cast_arg(TP, x):
diff --git a/pypy/jit/backend/test/runner_test.py
b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -2200,7 +2200,7 @@
def test_force_operations_returning_void(self):
values = []
def maybe_force(token, flag):
- assert lltype.typeOf(token) == JITFRAMEPTR
+ assert lltype.typeOf(token) == cpu.JITFRAMEPTR
if flag:
descr = self.cpu.force(token)
values.append(descr)
@@ -2208,7 +2208,7 @@
values.append(self.cpu.get_latest_value_int(token, 1))
values.append(token)
- FUNC = self.FuncType([JITFRAMEPTR, lltype.Signed], lltype.Void)
+ FUNC = self.FuncType([self.cpu.JITFRAMEPTR, lltype.Signed],
lltype.Void)
func_ptr = llhelper(lltype.Ptr(FUNC), maybe_force)
funcbox = self.get_funcbox(self.cpu, func_ptr).constbox()
calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
@@ -2249,7 +2249,8 @@
values.append(token)
return 42
- FUNC = self.FuncType([JITFRAMEPTR, lltype.Signed], lltype.Signed)
+ FUNC = self.FuncType([self.cpu.JITFRAMEPTR, lltype.Signed],
+ lltype.Signed)
func_ptr = llhelper(lltype.Ptr(FUNC), maybe_force)
funcbox = self.get_funcbox(self.cpu, func_ptr).constbox()
calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
@@ -2294,7 +2295,7 @@
values.append(token)
return 42.5
- FUNC = self.FuncType([JITFRAMEPTR, lltype.Signed], lltype.Float)
+ FUNC = self.FuncType([self.cpu.JITFRAMEPTR, lltype.Signed],
lltype.Float)
func_ptr = llhelper(lltype.Ptr(FUNC), maybe_force)
funcbox = self.get_funcbox(self.cpu, func_ptr).constbox()
calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
@@ -2731,7 +2732,7 @@
called.append(failindex)
return 4 + 9
- FUNCPTR = lltype.Ptr(lltype.FuncType([JITFRAMEPTR, llmemory.GCREF],
+ FUNCPTR = lltype.Ptr(lltype.FuncType([self.cpu.JITFRAMEPTR,
llmemory.GCREF],
lltype.Signed))
class FakeJitDriverSD:
index_of_virtualizable = -1
@@ -2807,7 +2808,7 @@
called.append(failindex)
return 13.5
- FUNCPTR = lltype.Ptr(lltype.FuncType([JITFRAMEPTR, llmemory.GCREF],
+ FUNCPTR = lltype.Ptr(lltype.FuncType([self.cpu.JITFRAMEPTR,
llmemory.GCREF],
lltype.Float))
class FakeJitDriverSD:
index_of_virtualizable = -1
@@ -2903,7 +2904,7 @@
called.append(failindex)
return 13.5
- FUNCPTR = lltype.Ptr(lltype.FuncType([JITFRAMEPTR, llmemory.GCREF],
+ FUNCPTR = lltype.Ptr(lltype.FuncType([self.cpu.JITFRAMEPTR,
llmemory.GCREF],
lltype.Float))
class FakeJitDriverSD:
index_of_virtualizable = -1
@@ -3669,7 +3670,7 @@
values.append(token)
return 42
- FUNC = self.FuncType([JITFRAMEPTR, lltype.Signed], lltype.Signed)
+ FUNC = self.FuncType([self.cpu.JITFRAMEPTR, lltype.Signed],
lltype.Signed)
func_ptr = llhelper(lltype.Ptr(FUNC), maybe_force)
funcbox = self.get_funcbox(self.cpu, func_ptr).constbox()
calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit