[pypy-svn] r28190 - in pypy/dist/pypy/translator/stackless: . test
mwh at codespeak.net
mwh at codespeak.net
Sat Jun 3 19:22:49 CEST 2006
Author: mwh
Date: Sat Jun 3 19:22:47 2006
New Revision: 28190
Modified:
pypy/dist/pypy/translator/stackless/code.py
pypy/dist/pypy/translator/stackless/test/test_resume_point.py
pypy/dist/pypy/translator/stackless/transform.py
Log:
(mwh, pedronis)
make the last test work for better reasons, and convince ourselves that we only
need to write len(STORAGE_TYPES) versions of resume_after_... and not
len(STORAGE_TYPES)**2. see the big comment for more.
Modified: pypy/dist/pypy/translator/stackless/code.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/code.py (original)
+++ pypy/dist/pypy/translator/stackless/code.py Sat Jun 3 19:22:47 2006
@@ -209,8 +209,6 @@
resume_bottom.f_back = mystate.f_back
global_state.top = targetstate
raise UnwindException()
- else:
- return 0
resume_after_void.stackless_explicit = True
INDEX_RESUME_AFTER_VOID = frame.RestartInfo.add_prebuilt(resume_after_void,
Modified: pypy/dist/pypy/translator/stackless/test/test_resume_point.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/test/test_resume_point.py (original)
+++ pypy/dist/pypy/translator/stackless/test/test_resume_point.py Sat Jun 3 19:22:47 2006
@@ -138,5 +138,5 @@
c.x = 4*one()
s1 = rstack.resume_state_create(None, "rp1", c)
return v1*100 + rstack.resume_state_invoke(C, s1).x
- res = run_stackless_function(example)
+ res = llinterp_stackless_function(example)
assert res == 204
Modified: pypy/dist/pypy/translator/stackless/transform.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/transform.py (original)
+++ pypy/dist/pypy/translator/stackless/transform.py Sat Jun 3 19:22:47 2006
@@ -236,7 +236,7 @@
self.resume_after_void_ptr = mixlevelannotator.constfunc(
code.resume_after_void, [annmodel.SomePtr(lltype.Ptr(STATE_HEADER)),
annmodel.s_None],
- annmodel.SomeInteger())
+ annmodel.s_None)
mixlevelannotator.finish()
@@ -515,11 +515,21 @@
def handle_resume_state_invoke(self, block):
op = block.operations[-1]
assert op.opname == 'resume_state_invoke'
- rettype = storage_type(op.result.concretetype)
- if op.result.concretetype != rettype:
- retvar = varoftype(rettype)
- else:
- retvar = op.result
+ # some commentary.
+ #
+ # we don't want to write 155 or so different versions of
+ # resume_after_foo that appear to the annotator to return
+ # different types. we take advantage of the fact that this
+ # function always raises UnwindException and have it (appear
+ # to) return Void. then to placate all the other machinery,
+ # we pass a constant zero-of-the-appropriate-type along the
+ # non-exceptional link (which we know will never be taken).
+ # Nota Bene: only mutate a COPY of the non-exceptional link
+ # because the non-exceptional link has been stored in
+ # self.resume_points and we don't want a constant "zero" in
+ # there.
+ retvar = varoftype(lltype.Void)
+ realrettype = op.result.concretetype
v_returns = op.args[1]
if v_returns.concretetype == lltype.Signed:
raise NotImplementedError
@@ -529,13 +539,11 @@
block.operations[-1] = newop
else:
raise NotImplementedError
- if retvar is not op.result:
- noexclink = block.exits[0]
- for i, a in enumerate(noexclink.args):
- if a is op.result:
- noexclink.args[i] = retvar
- self.insert_return_conversion(
- noexclink, op.result.concretetype, retvar)
+ noexclink = block.exits[0].copy()
+ for i, a in enumerate(noexclink.args):
+ if a is op.result:
+ noexclink.args[i] = model.Constant(realrettype._defl(), realrettype)
+ block.recloseblock(*((noexclink,) + block.exits[1:]))
def transform_block(self, block):
i = 0
@@ -627,10 +635,6 @@
# block, and that it is called even if the return
# value is not again used.
- if op.opname == 'resume_state_invoke':
- self.handle_resume_state_invoke(block)
- op = block.operations[-1]
-
args = vars_to_save(block)
save_block, frame_state_type, fieldnames = \
@@ -650,6 +654,9 @@
block.recloseblock(*newexits)
self.translator.rtyper._convert_link(block, newlink)
+ if op.opname == 'resume_state_invoke':
+ self.handle_resume_state_invoke(block)
+
block = link.target
i = 0
else:
More information about the Pypy-commit
mailing list