[pypy-svn] r36294 - in pypy/dist/pypy/jit/timeshifter: . test
pedronis at codespeak.net
pedronis at codespeak.net
Mon Jan 8 17:33:28 CET 2007
Author: pedronis
Date: Mon Jan 8 17:33:23 2007
New Revision: 36294
Modified:
pypy/dist/pypy/jit/timeshifter/hrtyper.py
pypy/dist/pypy/jit/timeshifter/rcontainer.py
pypy/dist/pypy/jit/timeshifter/test/test_portal.py
pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py
Log:
(arre, pedronis)
start using a special subclass of VirtualStruct - VirtualizableStruct - for virtualizable structs.
Make sure that the original virtualizable struct from the non-jit world is carried around.
Modified: pypy/dist/pypy/jit/timeshifter/hrtyper.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/hrtyper.py (original)
+++ pypy/dist/pypy/jit/timeshifter/hrtyper.py Mon Jan 8 17:33:23 2007
@@ -1503,7 +1503,7 @@
names = unrolling_iterable([name for name in T._names if name != 'access'])
def collect_residual_args(v):
- t = ()
+ t = (v,)
for name in names:
t = t + (getattr(v, name),) # xxx need to use access ?
return t
@@ -1521,13 +1521,16 @@
content = box.content
assert isinstance(content, rcontainer.VirtualStruct)
content_boxes = content.content_boxes
+ gv_outside = inputargs_gv[i]
+ i += 1
for name in names:
content_boxes[j].genvar = inputargs_gv[i]
j = j + 1
i += 1
+ content_boxes[j].genvar = gv_outside
return box
self.make_arg_redbox = make_arg_redbox
- make_arg_redbox.consumes = len(T._names)-1
+ make_arg_redbox.consumes = len(T._names)
def gettypedesc(self):
if self.typedesc is None:
@@ -1544,17 +1547,16 @@
return hop.llops.as_redbox(v_ptrbox)
def residual_argtypes(self):
+ argtypes = [self.original_concretetype]
T = self.original_concretetype.TO
if T._hints.get('virtualizable', False):
- argtypes = []
getredrepr = self.hrtyper.getredrepr
for name in T._names:
if name == 'access':
continue
FIELDTYPE = getattr(T, name)
argtypes += getredrepr(FIELDTYPE).residual_argtypes()
- return argtypes
- return [self.original_concretetype]
+ return argtypes
##class VoidRedRepr(Repr):
## def __init__(self, hrtyper):
Modified: pypy/dist/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rcontainer.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rcontainer.py Mon Jan 8 17:33:23 2007
@@ -82,6 +82,9 @@
self.immutable = TYPE._hints.get('immutable', False)
self.noidentity = TYPE._hints.get('noidentity', False)
+ if TYPE._hints.get('virtualizable', False):
+ self.__class__ = VirtualizableStructTypeDesc
+
if self.immutable and self.noidentity:
descs = unrolling_iterable(fielddescs)
def materialize(rgenop, boxes):
@@ -117,6 +120,20 @@
def compact_repr(self): # goes in ll helper names
return "Desc_%s" % (self.TYPE._short_name(),)
+class VirtualizableStructTypeDesc(StructTypeDesc):
+
+ def factory(self):
+ vstruct = VirtualizableStruct(self)
+ vstruct.content_boxes = [desc.redboxcls(desc.kind, desc.gv_default)
+ for desc in self.fielddescs]
+ outsidebox = rvalue.PtrRedBox(self.innermostdesc.ptrkind)
+ # xxx set outsidebox.genvar
+ vstruct.content_boxes.append(outsidebox)
+ box = rvalue.PtrRedBox(self.innermostdesc.ptrkind)
+ box.content = vstruct
+ vstruct.ownbox = box
+ return box
+
# XXX basic field descs for now
class FieldDesc(object):
__metaclass__ = cachedtype
@@ -306,6 +323,12 @@
def op_getsubstruct(self, jitstate, fielddesc):
return self.ownbox
+class VirtualizableStruct(VirtualStruct):
+
+ def force_runtime_container(self, builder):
+ assert 0, "not implemented for now"
+
+
# ____________________________________________________________
class FrozenPartialDataStruct(AbstractContainer):
Modified: pypy/dist/pypy/jit/timeshifter/test/test_portal.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_portal.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_portal.py Mon Jan 8 17:33:23 2007
@@ -88,8 +88,7 @@
res = llinterp.eval_graph(self.maingraph, main_args)
return res
- def check_insns(self, expected=None, **counts):
- # XXX only works if the portal is the same as the main
+ def get_residual_graph(self):
llinterp = LLInterpreter(self.rtyper)
if self.main_is_portal:
residual_graph = llinterp.eval_graph(self.readportalgraph,
@@ -98,7 +97,11 @@
residual_graphs = llinterp.eval_graph(self.readallportalsgraph, [])
assert residual_graphs.ll_length() == 1
residual_graph = residual_graphs.ll_getitem_fast(0)._obj.graph
+ return residual_graph
+ def check_insns(self, expected=None, **counts):
+ # XXX only works if the portal is the same as the main
+ residual_graph = self.get_residual_graph()
self.insns = summary(residual_graph)
if expected is not None:
assert self.insns == expected
Modified: pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py Mon Jan 8 17:33:23 2007
@@ -47,4 +47,8 @@
res = self.timeshift_from_portal(main, f, [20, 22], policy=P_NOVIRTUAL)
assert res == 42
- self.check_insns(getfield=0) # maybe?
+ self.check_insns(getfield=0)
+ residual_graph = self.get_residual_graph()
+ assert len(residual_graph.startblock.inputargs) == 3
+ assert ([v.concretetype for v in residual_graph.startblock.inputargs] ==
+ [lltype.Ptr(XY), lltype.Signed, lltype.Signed])
More information about the Pypy-commit
mailing list