[pypy-svn] r76175 - in pypy/branch/reflex-support/pypy/jit: codewriter codewriter/test metainterp
arigo at codespeak.net
arigo at codespeak.net
Tue Jul 13 12:16:40 CEST 2010
Author: arigo
Date: Tue Jul 13 12:16:38 2010
New Revision: 76175
Modified:
pypy/branch/reflex-support/pypy/jit/codewriter/effectinfo.py
pypy/branch/reflex-support/pypy/jit/codewriter/test/test_effectinfo.py
pypy/branch/reflex-support/pypy/jit/metainterp/optimizeopt.py
pypy/branch/reflex-support/pypy/jit/metainterp/pyjitpl.py
Log:
Extend the EffectInfo to distinguish between the cases EF_PURE etc.,
even for cases of general escaping where we don't have any list of
fields.
Modified: pypy/branch/reflex-support/pypy/jit/codewriter/effectinfo.py
==============================================================================
--- pypy/branch/reflex-support/pypy/jit/codewriter/effectinfo.py (original)
+++ pypy/branch/reflex-support/pypy/jit/codewriter/effectinfo.py Tue Jul 13 12:16:38 2010
@@ -18,14 +18,14 @@
def __new__(cls, readonly_descrs_fields,
write_descrs_fields, write_descrs_arrays,
extraeffect=EF_CAN_RAISE):
- key = (frozenset(readonly_descrs_fields),
- frozenset(write_descrs_fields),
- frozenset(write_descrs_arrays),
+ key = (_frozenset_or_none(readonly_descrs_fields),
+ _frozenset_or_none(write_descrs_fields),
+ _frozenset_or_none(write_descrs_arrays),
extraeffect)
if key in cls._cache:
return cls._cache[key]
result = object.__new__(cls)
- result.readonly_descrs_fields = readonly_descrs_fields
+ result.readonly_descrs_fields = readonly_descrs_fields # or None
result.write_descrs_fields = write_descrs_fields
result.write_descrs_arrays = write_descrs_arrays
result.extraeffect = extraeffect
@@ -35,11 +35,16 @@
def check_forces_virtual_or_virtualizable(self):
return self.extraeffect >= self.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE
+def _frozenset_or_none(x):
+ if x is None: return None
+ return frozenset(x)
+
+
def effectinfo_from_writeanalyze(effects, cpu,
extraeffect=EffectInfo.EF_CAN_RAISE):
from pypy.translator.backendopt.writeanalyze import top_set
if effects is top_set:
- return None
+ return EffectInfo(None, None, None, extraeffect)
readonly_descrs_fields = []
# readonly_descrs_arrays = [] --- not enabled for now
write_descrs_fields = []
Modified: pypy/branch/reflex-support/pypy/jit/codewriter/test/test_effectinfo.py
==============================================================================
--- pypy/branch/reflex-support/pypy/jit/codewriter/test/test_effectinfo.py (original)
+++ pypy/branch/reflex-support/pypy/jit/codewriter/test/test_effectinfo.py Tue Jul 13 12:16:38 2010
@@ -2,6 +2,8 @@
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.ootypesystem import ootype
from pypy.jit.codewriter.effectinfo import effectinfo_from_writeanalyze
+from pypy.jit.codewriter.effectinfo import EffectInfo
+from pypy.translator.backendopt.writeanalyze import top_set
class FakeCPU:
def fielddescrof(self, T, fieldname):
@@ -77,3 +79,19 @@
assert not effectinfo.readonly_descrs_fields
assert not effectinfo.write_descrs_fields
assert not effectinfo.write_descrs_arrays
+
+def test_no_effectinfo():
+ effectinfo = effectinfo_from_writeanalyze(top_set, None,
+ EffectInfo.EF_CANNOT_RAISE)
+ assert effectinfo.readonly_descrs_fields is None
+ assert effectinfo.write_descrs_fields is None
+ assert effectinfo.write_descrs_arrays is None
+ assert effectinfo.extraeffect == EffectInfo.EF_CANNOT_RAISE
+ #
+ effectinfo2 = effectinfo_from_writeanalyze(top_set, None,
+ EffectInfo.EF_CANNOT_RAISE)
+ assert effectinfo2 is effectinfo
+ #
+ effectinfo3 = effectinfo_from_writeanalyze(top_set, None,
+ EffectInfo.EF_PURE)
+ assert effectinfo3.extraeffect == EffectInfo.EF_PURE
Modified: pypy/branch/reflex-support/pypy/jit/metainterp/optimizeopt.py
==============================================================================
--- pypy/branch/reflex-support/pypy/jit/metainterp/optimizeopt.py (original)
+++ pypy/branch/reflex-support/pypy/jit/metainterp/optimizeopt.py Tue Jul 13 12:16:38 2010
@@ -1098,14 +1098,10 @@
opnum == rop.DEBUG_MERGE_POINT):
return
assert opnum != rop.CALL_PURE
- if (opnum == rop.CALL or
- opnum == rop.CALL_MAY_FORCE or
- opnum == rop.CALL_ASSEMBLER):
- if opnum == rop.CALL_ASSEMBLER:
- effectinfo = None
- else:
- effectinfo = op.descr.get_extra_info()
- if effectinfo is not None:
+ if opnum == rop.CALL or opnum == rop.CALL_MAY_FORCE:
+ effectinfo = op.descr.get_extra_info()
+ if (effectinfo is not None and
+ effectinfo.readonly_descrs_fields is not None):
# XXX we can get the wrong complexity here, if the lists
# XXX stored on effectinfo are large
for fielddescr in effectinfo.readonly_descrs_fields:
@@ -1128,8 +1124,9 @@
# of virtualref_info and virtualizable_info are not gcptrs.
return
self.force_all_lazy_setfields()
- elif op.is_final() or (not we_are_translated() and
- op.opnum < 0): # escape() operations
+ elif (opnum == rop.CALL_ASSEMBLER or
+ op.is_final() or
+ (not we_are_translated() and op.opnum < 0)): # escape() ops
self.force_all_lazy_setfields()
self.clean_caches()
Modified: pypy/branch/reflex-support/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/reflex-support/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/reflex-support/pypy/jit/metainterp/pyjitpl.py Tue Jul 13 12:16:38 2010
@@ -1063,10 +1063,13 @@
assert i == len(allboxes)
#
effectinfo = descr.get_extra_info()
- if (effectinfo is None or
- effectinfo.extraeffect ==
- effectinfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE or
- assembler_call_token is not None):
+ if effectinfo is None:
+ effect = -1
+ else:
+ effect = effectinfo.extraeffect
+ if (assembler_call_token is not None or
+ effectinfo is None or
+ effect == effectinfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE):
# residual calls require attention to keep virtualizables in-sync
self.metainterp.clear_exception()
self.metainterp.vable_and_vrefs_before_residual_call()
@@ -1083,7 +1086,6 @@
self.metainterp.handle_possible_exception()
return resbox
else:
- effect = effectinfo.extraeffect
if effect == effectinfo.EF_CANNOT_RAISE:
return self.execute_varargs(rop.CALL, allboxes, descr, False)
elif effect == effectinfo.EF_PURE:
More information about the Pypy-commit
mailing list