[pypy-commit] pypy jit-short_from_state: hg merge default
hakanardo
noreply at buildbot.pypy.org
Sun Jul 3 08:45:01 CEST 2011
Author: Hakan Ardo <hakan at debian.org>
Branch: jit-short_from_state
Changeset: r45303:3091ae4843f5
Date: 2011-07-03 08:48 +0200
http://bitbucket.org/pypy/pypy/changeset/3091ae4843f5/
Log: hg merge default
diff --git a/pypy/jit/metainterp/optimizeopt/intbounds.py b/pypy/jit/metainterp/optimizeopt/intbounds.py
--- a/pypy/jit/metainterp/optimizeopt/intbounds.py
+++ b/pypy/jit/metainterp/optimizeopt/intbounds.py
@@ -382,6 +382,18 @@
v1.intbound.make_gt(IntBound(0, 0))
self.propagate_bounds_backward(op.getarg(0))
+ def propagate_bounds_INT_IS_ZERO(self, op):
+ r = self.getvalue(op.result)
+ if r.is_constant():
+ if r.box.same_constant(CONST_1):
+ v1 = self.getvalue(op.getarg(0))
+ # Clever hack, we can't use self.make_constant_int yet because
+ # the args aren't in the values dictionary yet so it runs into
+ # an assert, this is a clever way of expressing the same thing.
+ v1.intbound.make_ge(IntBound(0, 0))
+ v1.intbound.make_lt(IntBound(1, 1))
+ self.propagate_bounds_backward(op.getarg(0))
+
def propagate_bounds_INT_ADD(self, op):
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -439,6 +439,23 @@
"""
self.optimize_loop(ops, expected)
+ def test_int_is_zero_int_is_true(self):
+ ops = """
+ [i0]
+ i1 = int_is_zero(i0)
+ guard_true(i1) []
+ i2 = int_is_true(i0)
+ guard_false(i2) []
+ jump(i0)
+ """
+ expected = """
+ [i0]
+ i1 = int_is_zero(i0)
+ guard_true(i1) []
+ jump(0)
+ """
+ self.optimize_loop(ops, expected)
+
def test_ooisnull_oononnull_2(self):
ops = """
[p0]
diff --git a/pypy/jit/metainterp/test/test_ajit.py b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -1710,8 +1710,8 @@
return a1.val + b1.val
res = self.meta_interp(g, [6, 14])
assert res == g(6, 14)
- self.check_loop_count(9)
- self.check_loops(getarrayitem_gc=8, everywhere=True)
+ self.check_loop_count(8)
+ self.check_loops(getarrayitem_gc=7, everywhere=True)
py.test.skip("for the following, we need setarrayitem(varindex)")
def test_multiple_specialied_versions_bridge(self):
diff --git a/pypy/module/_io/interp_io.py b/pypy/module/_io/interp_io.py
--- a/pypy/module/_io/interp_io.py
+++ b/pypy/module/_io/interp_io.py
@@ -119,7 +119,7 @@
if buffering < 0:
buffering = DEFAULT_BUFFER_SIZE
- if "st_blksize" in STAT_FIELD_TYPES:
+ if space.config.translation.type_system == 'lltype' and 'st_blksize' in STAT_FIELD_TYPES:
fileno = space.int_w(space.call_method(w_raw, "fileno"))
try:
st = os.fstat(fileno)
diff --git a/pypy/module/pyexpat/__init__.py b/pypy/module/pyexpat/__init__.py
--- a/pypy/module/pyexpat/__init__.py
+++ b/pypy/module/pyexpat/__init__.py
@@ -2,6 +2,22 @@
from pypy.interpreter.mixedmodule import MixedModule
+class ErrorsModule(MixedModule):
+ "Definition of pyexpat.errors module."
+
+ appleveldefs = {
+ }
+
+ interpleveldefs = {
+ }
+
+ def setup_after_space_initialization(self):
+ from pypy.module.pyexpat import interp_pyexpat
+ for name in interp_pyexpat.xml_error_list:
+ self.space.setattr(self, self.space.wrap(name),
+ interp_pyexpat.ErrorString(self.space,
+ getattr(interp_pyexpat, name)))
+
class Module(MixedModule):
"Python wrapper for Expat parser."
@@ -21,6 +37,10 @@
'version_info': 'interp_pyexpat.get_expat_version_info(space)',
}
+ submodules = {
+ 'errors': ErrorsModule,
+ }
+
for name in ['XML_PARAM_ENTITY_PARSING_NEVER',
'XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE',
'XML_PARAM_ENTITY_PARSING_ALWAYS']:
diff --git a/pypy/module/pyexpat/interp_pyexpat.py b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -31,6 +31,48 @@
XML_Content_Ptr = lltype.Ptr(lltype.ForwardReference())
XML_Parser = rffi.COpaquePtr(typedef='XML_Parser')
+xml_error_list = [
+ "XML_ERROR_NO_MEMORY",
+ "XML_ERROR_SYNTAX",
+ "XML_ERROR_NO_ELEMENTS",
+ "XML_ERROR_INVALID_TOKEN",
+ "XML_ERROR_UNCLOSED_TOKEN",
+ "XML_ERROR_PARTIAL_CHAR",
+ "XML_ERROR_TAG_MISMATCH",
+ "XML_ERROR_DUPLICATE_ATTRIBUTE",
+ "XML_ERROR_JUNK_AFTER_DOC_ELEMENT",
+ "XML_ERROR_PARAM_ENTITY_REF",
+ "XML_ERROR_UNDEFINED_ENTITY",
+ "XML_ERROR_RECURSIVE_ENTITY_REF",
+ "XML_ERROR_ASYNC_ENTITY",
+ "XML_ERROR_BAD_CHAR_REF",
+ "XML_ERROR_BINARY_ENTITY_REF",
+ "XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF",
+ "XML_ERROR_MISPLACED_XML_PI",
+ "XML_ERROR_UNKNOWN_ENCODING",
+ "XML_ERROR_INCORRECT_ENCODING",
+ "XML_ERROR_UNCLOSED_CDATA_SECTION",
+ "XML_ERROR_EXTERNAL_ENTITY_HANDLING",
+ "XML_ERROR_NOT_STANDALONE",
+ "XML_ERROR_UNEXPECTED_STATE",
+ "XML_ERROR_ENTITY_DECLARED_IN_PE",
+ "XML_ERROR_FEATURE_REQUIRES_XML_DTD",
+ "XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING",
+ # Added in Expat 1.95.7.
+ "XML_ERROR_UNBOUND_PREFIX",
+ # Added in Expat 1.95.8.
+ "XML_ERROR_UNDECLARING_PREFIX",
+ "XML_ERROR_INCOMPLETE_PE",
+ "XML_ERROR_XML_DECL",
+ "XML_ERROR_TEXT_DECL",
+ "XML_ERROR_PUBLICID",
+ "XML_ERROR_SUSPENDED",
+ "XML_ERROR_NOT_SUSPENDED",
+ "XML_ERROR_ABORTED",
+ "XML_ERROR_FINISHED",
+ "XML_ERROR_SUSPEND_PE",
+ ]
+
class CConfigure:
_compilation_info_ = eci
XML_Content = rffi_platform.Struct('XML_Content', [
@@ -56,6 +98,9 @@
XML_FALSE = rffi_platform.ConstantInteger('XML_FALSE')
XML_TRUE = rffi_platform.ConstantInteger('XML_TRUE')
+ for name in xml_error_list:
+ locals()[name] = rffi_platform.ConstantInteger(name)
+
for k, v in rffi_platform.configure(CConfigure).items():
globals()[k] = v
@@ -298,7 +343,8 @@
XML_GetErrorCode = expat_external(
'XML_GetErrorCode', [XML_Parser], rffi.INT)
XML_ErrorString = expat_external(
- 'XML_ErrorString', [rffi.INT], rffi.CCHARP)
+ 'XML_ErrorString', [rffi.INT],
+ rffi.CCHARP)
XML_GetCurrentLineNumber = expat_external(
'XML_GetCurrentLineNumber', [XML_Parser], rffi.INT)
XML_GetErrorLineNumber = XML_GetCurrentLineNumber
diff --git a/pypy/module/pyexpat/test/test_parser.py b/pypy/module/pyexpat/test/test_parser.py
--- a/pypy/module/pyexpat/test/test_parser.py
+++ b/pypy/module/pyexpat/test/test_parser.py
@@ -38,7 +38,7 @@
parser = pyexpat.ParserCreate()
raises(pyexpat.ExpatError, "parser.Parse(xml, True)")
- def test_encoding(self):
+ def test_encoding_argument(self):
import pyexpat
for encoding_arg in (None, 'utf-8', 'iso-8859-1'):
for namespace_arg in (None, '{'):
@@ -68,7 +68,7 @@
assert p.buffer_size == 150
raises(TypeError, setattr, p, 'buffer_size', sys.maxint + 1)
- def test_encoding(self):
+ def test_encoding_xml(self):
# use one of the few encodings built-in in expat
xml = "<?xml version='1.0' encoding='iso-8859-1'?><s>caf\xe9</s>"
import pyexpat
@@ -120,3 +120,14 @@
return True
p.ExternalEntityRefHandler = handler
p.Parse(xml)
+
+ def test_errors(self):
+ import types
+ import pyexpat
+ assert isinstance(pyexpat.errors, types.ModuleType)
+ # check a few random errors
+ assert pyexpat.errors.XML_ERROR_SYNTAX == 'syntax error'
+ assert (pyexpat.errors.XML_ERROR_INCORRECT_ENCODING ==
+ 'encoding specified in XML declaration is incorrect')
+ assert (pyexpat.errors.XML_ERROR_XML_DECL ==
+ 'XML declaration not well-formed')
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -57,7 +57,8 @@
raise OperationError(space.w_ValueError,
space.wrap("recursion limit must be positive"))
space.sys.recursionlimit = new_limit
- _stack_set_length_fraction(new_limit * 0.001)
+ if space.config.translation.type_system == 'lltype':
+ _stack_set_length_fraction(new_limit * 0.001)
def getrecursionlimit(space):
"""Return the last value set by setrecursionlimit().
diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py
--- a/pypy/objspace/std/celldict.py
+++ b/pypy/objspace/std/celldict.py
@@ -139,12 +139,24 @@
for k, cell in iterator():
cell.invalidate()
+ def popitem(self, w_dict):
+ # This is O(n) if called repeatadly, you probably shouldn't be on a
+ # Module's dict though
+ for k, cell in self.unerase(w_dict.dstorage).iteritems():
+ if cell.w_value is not None:
+ w_value = cell.w_value
+ cell.invalidate()
+ return self.space.wrap(k), w_value
+ else:
+ raise KeyError
+
def switch_to_object_strategy(self, w_dict):
d = self.unerase(w_dict.dstorage)
strategy = self.space.fromcache(ObjectDictStrategy)
d_new = strategy.unerase(strategy.get_empty_storage())
for key, cell in d.iteritems():
- d_new[self.space.wrap(key)] = cell.w_value
+ if cell.w_value is not None:
+ d_new[self.space.wrap(key)] = cell.w_value
w_dict.strategy = strategy
w_dict.dstorage = strategy.erase(d_new)
diff --git a/pypy/objspace/std/test/test_celldict.py b/pypy/objspace/std/test/test_celldict.py
--- a/pypy/objspace/std/test/test_celldict.py
+++ b/pypy/objspace/std/test/test_celldict.py
@@ -38,3 +38,33 @@
assert d.getitem("a") is None
assert d.getcell("a", False) is acell
assert d.length() == 0
+
+class AppTestCellDict(object):
+ OPTIONS = {"objspace.std.withcelldict": True}
+
+ def setup_class(cls):
+ if option.runappdirect:
+ py.test.skip("__repr__ doesn't work on appdirect")
+ strategy = ModuleDictStrategy(cls.space)
+ storage = strategy.get_empty_storage()
+ cls.w_d = W_DictMultiObject(cls.space, strategy, storage)
+
+ def test_popitem(self):
+ import __pypy__
+
+ d = self.d
+ assert "ModuleDict" in __pypy__.internal_repr(d)
+ raises(KeyError, d.popitem)
+ d["a"] = 3
+ x = d.popitem()
+ assert x == ("a", 3)
+
+ def test_degenerate(self):
+ import __pypy__
+
+ d = self.d
+ assert "ModuleDict" in __pypy__.internal_repr(d)
+ d["a"] = 3
+ del d["a"]
+ d[object()] = 5
+ assert d.values() == [5]
\ No newline at end of file
diff --git a/pypy/rpython/ootypesystem/rclass.py b/pypy/rpython/ootypesystem/rclass.py
--- a/pypy/rpython/ootypesystem/rclass.py
+++ b/pypy/rpython/ootypesystem/rclass.py
@@ -264,7 +264,8 @@
for name, attrdef in selfattrs.iteritems():
if not attrdef.readonly and self.is_quasi_immutable(name):
- ootype.addFields(self.lowleveltype, {'mutable_'+name: OBJECT})
+ name = mangle('mutable_' + name, self.rtyper.getconfig())
+ ootype.addFields(self.lowleveltype, {name: OBJECT})
classattributes = {}
baseInstance = self.lowleveltype._superclass
diff --git a/pypy/translator/jvm/opcodes.py b/pypy/translator/jvm/opcodes.py
--- a/pypy/translator/jvm/opcodes.py
+++ b/pypy/translator/jvm/opcodes.py
@@ -98,6 +98,7 @@
'jit_marker': Ignore,
'jit_force_virtualizable': Ignore,
'jit_force_virtual': DoNothing,
+ 'jit_force_quasi_immutable': Ignore,
'debug_assert': [], # TODO: implement?
'debug_start_traceback': Ignore,
diff --git a/pypy/translator/jvm/src/pypy/PyPy.java b/pypy/translator/jvm/src/pypy/PyPy.java
--- a/pypy/translator/jvm/src/pypy/PyPy.java
+++ b/pypy/translator/jvm/src/pypy/PyPy.java
@@ -964,7 +964,7 @@
return a + File.separator + b;
}
- public String ll_strtod_formatd(String format, double d)
+ public String ll_strtod_formatd(double d, char code, int precision, int flags)
{
// XXX: this is really a quick hack to make things work.
// it should disappear, because this function is not
More information about the pypy-commit
mailing list