[pypy-svn] r37352 - in pypy/dist/pypy/jit: codegen/llgraph timeshifter timeshifter/test
ac at codespeak.net
ac at codespeak.net
Thu Jan 25 19:31:52 CET 2007
Author: ac
Date: Thu Jan 25 19:31:52 2007
New Revision: 37352
Modified:
pypy/dist/pypy/jit/codegen/llgraph/llimpl.py
pypy/dist/pypy/jit/timeshifter/rcontainer.py
pypy/dist/pypy/jit/timeshifter/rtimeshift.py
pypy/dist/pypy/jit/timeshifter/test/test_virtualizable.py
Log:
(pedronis, arre) Intermediate checking with one more test in progress.
Modified: pypy/dist/pypy/jit/codegen/llgraph/llimpl.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llgraph/llimpl.py (original)
+++ pypy/dist/pypy/jit/codegen/llgraph/llimpl.py Thu Jan 25 19:31:52 2007
@@ -198,22 +198,25 @@
assert not isinstance(llvalue, str) and not isinstance(llvalue, lltype.LowLevelType)
return to_opaque_object(v)
-def revealconst(T, gv_value):
- c = from_opaque_object(gv_value)
- assert isinstance(c, flowmodel.Constant)
+def _generalcast(T, value):
if isinstance(T, lltype.Ptr):
- return lltype.cast_pointer(T, c.value)
+ return lltype.cast_pointer(T, value)
elif T == llmemory.Address:
- return llmemory.cast_ptr_to_adr(c.value)
+ return llmemory.cast_ptr_to_adr(value)
else:
- T1 = lltype.typeOf(c.value)
+ T1 = lltype.typeOf(value)
if T1 is llmemory.Address:
- value = llmemory.cast_adr_to_int(c.value)
+ value = llmemory.cast_adr_to_int(value)
elif isinstance(T1, lltype.Ptr):
- value = lltype.cast_ptr_to_int(c.value)
+ value = lltype.cast_ptr_to_int(value)
else:
- value = c.value
- return lltype.cast_primitive(T, value)
+ value = value
+ return lltype.cast_primitive(T, value)
+
+def revealconst(T, gv_value):
+ c = from_opaque_object(gv_value)
+ assert isinstance(c, flowmodel.Constant)
+ return _generalcast(T, c.value)
def isconst(gv_value):
c = from_opaque_object(gv_value)
@@ -587,34 +590,18 @@
else:
llframe = base.ptr
val = llframe.bindings[v]
- assert lltype.typeOf(val) == T
- return val
-
-
-class ReadFrameVarEntry(ExtRegistryEntry):
- "Annotation and specialization for calls to 'func'."
- _about_ = read_frame_var
+ return _generalcast(T, val)
- def compute_result_annotation(self, *args_s):
- T = args_s[0].const
- return annmodel.lltype_to_annotation(T)
-
- # specialize as direct_call
- def specialize_call(self, hop):
- FUNCTYPE = lltype.FuncType([r.lowleveltype for r in hop.args_r],
- hop.r_result.lowleveltype)
- args_v = hop.inputargs(*hop.args_r)
- funcptr = lltype.functionptr(FUNCTYPE, 'read_frame_var',
- _callable=read_frame_var)
- cfunc = hop.inputconst(lltype.Ptr(FUNCTYPE), funcptr)
- return hop.genop('direct_call', [cfunc] + args_v, hop.r_result)
+setannotation(read_frame_var, lambda s_T, s_base, s_info, s_index:
+ annmodel.lltype_to_annotation(s_T.const))
def write_frame_var(base, info, index, value):
vars = info._obj.info.args
v = vars[index]
assert isinstance(v, flowmodel.Variable)
llframe = base.ptr
- llframe.setvar(v, value)
+ value = _generalcast(v.concretetype, value)
+ llframe.bindings[v] = value
setannotation(write_frame_var, None)
Modified: pypy/dist/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rcontainer.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rcontainer.py Thu Jan 25 19:31:52 2007
@@ -704,7 +704,6 @@
vable_rti = rvirtualizable.VirtualizableRTI(rgenop, 0)
memo.containers[self] = vable_rti
- in_virtualizable_varboxes = memo.in_virtualizable_framevarboxes
varboxes = memo.framevarboxes
varboxes.append(outsidebox)
getset_rti = (memo.frameindex,
@@ -721,7 +720,9 @@
if box.genvar:
varindexes.append(memo.frameindex)
memo.frameindex += 1
- in_virtualizable_varboxes[box] = None
+ if box.genvar.is_const: # KILL KILL KILL
+ copymemo = rvalue.copy_memo()
+ box = boxes[i] = box.forcevar(jitstate, copymemo)
varboxes.append(box)
else:
varindexes.append(j)
Modified: pypy/dist/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtimeshift.py (original)
+++ pypy/dist/pypy/jit/timeshifter/rtimeshift.py Thu Jan 25 19:31:52 2007
@@ -903,7 +903,6 @@
memo = rvalue.make_vinfo_memo()
memo.bitcount = 0
memo.frameindex = 0
- memo.in_virtualizable_framevarboxes = {}
memo.framevarboxes = []
memo.vable_getset_rtis = []
vable_rtis = []
@@ -913,10 +912,6 @@
vable_rtis.append(content.make_rti(self, memo))
assert memo.bitcount < 32
gv_base = builder.genop_get_frame_base()
- for varbox in memo.in_virtualizable_framevarboxes:
- if varbox.genvar.is_const:
- gvar = builder.genop_same_as(varbox.kind, varbox.genvar)
- varbox.genvar = gvar
framevars_gv = []
for varbox in memo.framevarboxes:
framevars_gv.append(varbox.genvar)
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 Thu Jan 25 19:31:52 2007
@@ -854,3 +854,31 @@
assert res == 8
+ def test_aliased_box(self):
+ py.test.skip("WIP")
+ class S(object):
+ def __init__(self, x):
+ self.x = x
+
+ class V(object):
+ _virtualizable_ = True
+ def __init__(self, x):
+ self.x = x
+
+ def g(v):
+ v.x = 42
+
+ def f(x):
+ hint(None, global_merge_point=True)
+ s = S(x)
+ v = V(x)
+ g(v)
+ return v.x + s.x
+
+ def main(x):
+ s = S(19)
+ r = f(x)
+ return r
+
+ res = self.timeshift_from_portal(main, f, [0], policy=StopAtXPolicy(g))
+ assert res == 42
More information about the pypy-svn
mailing list