[pypy-svn] r53280 - in pypy/branch/jit-hotpath/pypy: jit/rainbow/test rpython/lltypesystem rpython/ootypesystem translator/backendopt
antocuni at codespeak.net
antocuni at codespeak.net
Thu Apr 3 15:09:03 CEST 2008
Author: antocuni
Date: Thu Apr 3 15:09:01 2008
New Revision: 53280
Modified:
pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py
pypy/branch/jit-hotpath/pypy/rpython/lltypesystem/lltype.py
pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/ootype.py
pypy/branch/jit-hotpath/pypy/translator/backendopt/graphanalyze.py
Log:
- teach ImpurityAnalizer how to check if calls to external methods are pure
- mark all methods of ootype.String and ootype.Unicode as pure
- rewrite test_plus_minus to use an RPython string instead of a
lowlevel string, so that it can work also with ootype
- after all of this, test_plus_minus passes :-)
Modified: pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py (original)
+++ pypy/branch/jit-hotpath/pypy/jit/rainbow/test/test_interpreter.py Thu Apr 3 15:09:01 2008
@@ -13,7 +13,6 @@
from pypy.rpython.lltypesystem import lltype, rstr
from pypy.rpython.ootypesystem import ootype
from pypy.rpython.llinterp import LLInterpreter, LLException
-from pypy.rpython.module.support import LLSupport
from pypy.annotation import model as annmodel
from pypy.annotation.policy import AnnotatorPolicy
from pypy.objspace.flow.model import summary, Variable
@@ -818,7 +817,9 @@
assert res.x == 123
def test_plus_minus(self):
- def ll_plus_minus(s, x, y):
+ PROGRAMS = ["+-+"]
+ def ll_plus_minus(i, x, y):
+ s = PROGRAMS[i] # to prevent constant-folding
acc = x
n = len(s)
pc = 0
@@ -831,10 +832,9 @@
acc -= y
pc += 1
return acc
- ll_plus_minus.convert_arguments = [LLSupport.to_rstr, int, int]
- res = self.interpret(ll_plus_minus, ["+-+", 0, 2], [0])
- assert res == ll_plus_minus("+-+", 0, 2)
- self.check_insns({'int_add': 2, 'int_sub': 1})
+ res = self.interpret(ll_plus_minus, [0, 0, 2], [0])
+ assert res == ll_plus_minus(0, 0, 2)
+ self.check_insns({'int_add': 2, 'int_sub': 1, 'direct_call': 1})
def test_red_virtual_container(self):
# this checks that red boxes are able to be virtualized dynamically by
@@ -2181,7 +2181,6 @@
def _skip(self):
py.test.skip('in progress')
- test_plus_minus = _skip
test_red_array = _skip
test_red_struct_array = _skip
test_red_varsized_struct = _skip
@@ -2217,7 +2216,3 @@
test_void_args = _skip
test_ptrequality = _skip
test_green_ptrequality = _skip
-
-
-
-
Modified: pypy/branch/jit-hotpath/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/rpython/lltypesystem/lltype.py (original)
+++ pypy/branch/jit-hotpath/pypy/rpython/lltypesystem/lltype.py Thu Apr 3 15:09:01 2008
@@ -697,7 +697,7 @@
def cast_primitive(TGT, value):
ORIG = typeOf(value)
if not isinstance(TGT, Primitive) or not isinstance(ORIG, Primitive):
- raise TypeError, "can only primitive to primitive"
+ raise TypeError, "can cast only primitive to primitive"
if ORIG == TGT:
return value
if ORIG == Char or ORIG == UniChar:
Modified: pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/ootype.py (original)
+++ pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/ootype.py Thu Apr 3 15:09:01 2008
@@ -329,7 +329,7 @@
immutable = False # conservative
- def _setup_methods(self, generic_types, can_raise=[]):
+ def _setup_methods(self, generic_types, can_raise=[], pure_meth=[]):
methods = {}
for name, meth in self._GENERIC_METHODS.iteritems():
args = [self._specialize_type(arg, generic_types) for arg in meth.ARGS]
@@ -339,6 +339,10 @@
methods[name] = METH
self._METHODS = frozendict(methods)
self._can_raise = tuple(can_raise)
+ if pure_meth == 'ALL':
+ self._pure_meth = tuple(methods.keys())
+ else:
+ self._pure_meth = tuple(pure_meth)
def _lookup(self, meth_name):
METH = self._METHODS.get(meth_name)
@@ -346,7 +350,10 @@
if METH is not None:
cls = self._get_interp_class()
can_raise = meth_name in self._can_raise
- meth = _meth(METH, _name=meth_name, _callable=getattr(cls, meth_name), _can_raise=can_raise)
+ pure_meth = meth_name in self._pure_meth
+ meth = _meth(METH, _name=meth_name,
+ _callable=getattr(cls, meth_name),
+ _can_raise=can_raise, _pure_meth=pure_meth)
meth._virtual = False
return self, meth
@@ -384,7 +391,7 @@
"ll_contains": Meth([self.CHAR], Bool),
"ll_replace_chr_chr": Meth([self.CHAR, self.CHAR], self.SELFTYPE_T),
})
- self._setup_methods(generic_types)
+ self._setup_methods(generic_types, pure_meth='ALL')
def _example(self):
return self._defl()
Modified: pypy/branch/jit-hotpath/pypy/translator/backendopt/graphanalyze.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/translator/backendopt/graphanalyze.py (original)
+++ pypy/branch/jit-hotpath/pypy/translator/backendopt/graphanalyze.py Thu Apr 3 15:09:01 2008
@@ -148,3 +148,9 @@
except AttributeError:
pass
return GraphAnalyzer.analyze_direct_call(self, graph, seen)
+
+ def analyze_external_method(self, op, TYPE, meth):
+ if getattr(meth, "_pure_meth", False):
+ return False
+ else:
+ return GraphAnalyzer.analyze_external_method(self, op, TYPE, meth)
More information about the Pypy-commit
mailing list