[pypy-commit] pypy numpy-multidim-shards: rename shards to strides

2011-11-23 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: numpy-multidim-shards
Changeset: r49681:0c2425c1ad39
Date: 2011-11-23 11:07 +0200
http://bitbucket.org/pypy/pypy/changeset/0c2425c1ad39/

Log:rename shards to strides

diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -163,11 +163,11 @@
 for i in range(shape_len - 1, -1, -1):
 if self.indices[i]  self.arr.shape[i] - 1:
 self.indices[i] += 1
-self.offset += self.arr.shards[i]
+self.offset += self.arr.strides[i]
 break
 else:
 self.indices[i] = 0
-self.offset -= self.arr.backshards[i]
+self.offset -= self.arr.backstrides[i]
 else:
 self._done = True
 
@@ -185,20 +185,20 @@
 def __init__(self, arr, res_shape):
 self.indices = [0] * len(res_shape)
 self.offset  = arr.start
-#shards are 0 where original shape==1
-self.shards = []
-self.backshards = []
+#strides are 0 where original shape==1
+self.strides = []
+self.backstrides = []
 for i in range(len(arr.shape)):
 if arr.shape[i]==1:
-self.shards.append(0)
-self.backshards.append(0)
+self.strides.append(0)
+self.backstrides.append(0)
 else:
-self.shards.append(arr.shards[i])
-self.backshards.append(arr.backshards[i])
+self.strides.append(arr.strides[i])
+self.backstrides.append(arr.backstrides[i])
 self.shape_len = len(res_shape)
 self.res_shape = res_shape
-self.shards = [0] * (len(res_shape) - len(arr.shape)) + self.shards
-self.backshards = [0] * (len(res_shape) - len(arr.shape)) + 
self.backshards
+self.strides = [0] * (len(res_shape) - len(arr.shape)) + self.strides
+self.backstrides = [0] * (len(res_shape) - len(arr.shape)) + 
self.backstrides
 self._done = False
 self.arr = arr
 
@@ -208,11 +208,11 @@
 for i in range(shape_len - 1, -1, -1):
 if self.indices[i]  self.res_shape[i] - 1:
 self.indices[i] += 1
-self.offset += self.shards[i]
+self.offset += self.strides[i]
 break
 else:
 self.indices[i] = 0
-self.offset -= self.backshards[i]
+self.offset -= self.backstrides[i]
 else:
 self._done = True
 
@@ -263,35 +263,35 @@
 return 0
 
 class BaseArray(Wrappable):
-_attrs_ = [invalidates, signature, shape, shards, backshards,
+_attrs_ = [invalidates, signature, shape, strides, backstrides,
start, 'order']
 
-_immutable_fields_ = ['shape[*]', shards[*], backshards[*], 'start',
+_immutable_fields_ = ['shape[*]', strides[*], backstrides[*], 'start',
   order]
 
-shards = None
+strides = None
 start = 0
 
 def __init__(self, shape, order):
 self.invalidates = []
 self.shape = shape
 self.order = order
-if self.shards is None:
-shards = []
-backshards = []
+if self.strides is None:
+strides = []
+backstrides = []
 s = 1
 shape_rev = shape[:]
 if order == 'C':
 shape_rev.reverse()
 for sh in shape_rev:
-shards.append(s)
-backshards.append(s * (sh - 1))
+strides.append(s)
+backstrides.append(s * (sh - 1))
 s *= sh
 if order == 'C':
-shards.reverse()
-backshards.reverse()
-self.shards = shards[:]
-self.backshards = backshards[:]
+strides.reverse()
+backstrides.reverse()
+self.strides = strides[:]
+self.backstrides = backstrides[:]
 
 def invalidated(self):
 if self.invalidates:
@@ -525,11 +525,11 @@
 else:
 builder.append(spacer)
 builder.append(dtype.str_format(self.getitem(item)))
-item += self.shards[0]
+item += self.strides[0]
 #Add a comma only if comma is False - this prevents adding two 
commas
 builder.append(spacer + '...' + ',' * (1 - comma))
 #Ugly, but can this be done with an iterator?
-item = self.start + self.backshards[0] - 2 * self.shards[0]
+item = self.start + self.backstrides[0] - 2 * self.strides[0]
 i = self.shape[0] - 3
 while i  self.shape[0]:
 if start:
@@ -537,7 

[pypy-commit] pypy numpy-multidim-shards: close merged branch

2011-11-23 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: numpy-multidim-shards
Changeset: r49683:d0d86e088b8b
Date: 2011-11-23 11:09 +0200
http://bitbucket.org/pypy/pypy/changeset/d0d86e088b8b/

Log:close merged branch

___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy numpy-multidim: fix test_zjit until test_slice

2011-11-23 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: numpy-multidim
Changeset: r49684:b56fd5dc80b5
Date: 2011-11-23 11:44 +0200
http://bitbucket.org/pypy/pypy/changeset/b56fd5dc80b5/

Log:fix test_zjit until test_slice

diff --git a/pypy/module/micronumpy/interp_numarray.py 
b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -7,6 +7,7 @@
 from pypy.rpython.lltypesystem import lltype
 from pypy.tool.sourcetools import func_with_new_name
 from pypy.rlib.rstring import StringBuilder
+from pypy.rlib.objectmodel import instantiate
 
 numpy_driver = jit.JitDriver(greens=['signature'],
  reds=['result_size', 'i', 'ri', 'self',
@@ -122,7 +123,7 @@
 for i in range(len(elems_w)):
 w_elem = elems_w[i]
 dtype.setitem_w(space, arr.storage, arr_iter.offset, w_elem)
-arr_iter.next()
+arr_iter = arr_iter.next()
 return arr
 
 class BaseIterator(object):
@@ -141,7 +142,10 @@
 self.size = size
 
 def next(self):
-self.offset += 1
+arr = instantiate(ArrayIterator)
+arr.size = self.size
+arr.offset = self.offset + 1
+return arr
 
 def done(self):
 return self.offset = self.size
@@ -170,6 +174,7 @@
 self.offset -= self.arr.backstrides[i]
 else:
 self._done = True
+return self
 
 def done(self):
 return self._done
@@ -215,6 +220,7 @@
 self.offset -= self.backstrides[i]
 else:
 self._done = True
+return self
 
 def done(self):
 return self._done
@@ -228,11 +234,12 @@
 self.right = right
 
 def next(self):
-self.left.next()
-self.right.next()
+return Call2Iterator(self.left.next(), self.right.next())
 
 def done(self):
-return self.left.done() or self.right.done()
+if isinstance(self.left, ConstantIterator):
+return self.right.done()
+return self.left.done()
 
 def get_offset(self):
 if isinstance(self.left, ConstantIterator):
@@ -244,7 +251,7 @@
 self.child = child
 
 def next(self):
-self.child.next()
+return Call1Iterator(self.child.next())
 
 def done(self):
 return self.child.done()
@@ -254,7 +261,7 @@
 
 class ConstantIterator(BaseIterator):
 def next(self):
-pass
+return self
 
 def done(self):
 return False
@@ -377,7 +384,7 @@
 if dtype.ne(new_best, cur_best):
 result = i.get_offset()
 cur_best = new_best
-i.next()
+i = i.next()
 return result
 def impl(self, space):
 size = self.find_size()
@@ -395,7 +402,7 @@
 all_driver.jit_merge_point(signature=self.signature, self=self, 
dtype=dtype, i=i)
 if not dtype.bool(self.eval(i)):
 return False
-i.next()
+i = i.next()
 return True
 def descr_all(self, space):
 return space.wrap(self._all())
@@ -408,7 +415,7 @@
dtype=dtype, i=i)
 if dtype.bool(self.eval(i)):
 return True
-i.next()
+i = i.next()
 return False
 def descr_any(self, space):
 return space.wrap(self._any())
@@ -787,8 +794,8 @@
  result_size=result_size, i=i, ri=ri,
  self=self, result=result)
 result.dtype.setitem(result.storage, ri.offset, self.eval(i))
-i.next()
-ri.next()
+i = i.next()
+ri = ri.next()
 return result
 
 def force_if_needed(self):
@@ -967,8 +974,8 @@
  source_iter=source_iter)
 self.setitem(res_iter.offset, source.eval(source_iter).convert_to(
 self.find_dtype()))
-source_iter.next()
-res_iter.next()
+source_iter = source_iter.next()
+res_iter = res_iter.next()
 
 def start_iter(self, res_shape=None):
 if res_shape is not None and res_shape != self.shape:
diff --git a/pypy/module/micronumpy/interp_ufuncs.py 
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -68,7 +68,7 @@
 raise operationerrfmt(space.w_ValueError, zero-size array to 
 %s.reduce without identity, self.name)
 value = obj.eval(start).convert_to(dtype)
-start.next()
+start = start.next()
 else:
 value = self.identity.convert_to(dtype)
 new_sig = signature.Signature.find_sig([
@@ -82,7 +82,7 @@
   value=value, obj=obj, i=i,

[pypy-commit] pypy default: Try to detect conflicting options with the gc.

2011-11-23 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r49685:b51d37b92694
Date: 2011-11-23 12:21 +0100
http://bitbucket.org/pypy/pypy/changeset/b51d37b92694/

Log:Try to detect conflicting options with the gc.

diff --git a/pypy/config/test/test_translationoption.py 
b/pypy/config/test/test_translationoption.py
new file mode 100644
--- /dev/null
+++ b/pypy/config/test/test_translationoption.py
@@ -0,0 +1,10 @@
+import py
+from pypy.config.translationoption import get_combined_translation_config
+from pypy.config.translationoption import set_opt_level
+from pypy.config.config import ConflictConfigError
+
+
+def test_no_gcrootfinder_with_boehm():
+config = get_combined_translation_config()
+config.translation.gcrootfinder = shadowstack
+py.test.raises(ConflictConfigError, set_opt_level, config, '0')
diff --git a/pypy/config/translationoption.py b/pypy/config/translationoption.py
--- a/pypy/config/translationoption.py
+++ b/pypy/config/translationoption.py
@@ -398,6 +398,10 @@
 # make_sure_not_resized often relies on it, so we always enable them
 config.translation.suggest(list_comprehension_operations=True)
 
+# finally, make the choice of the gc definitive.  This will fail
+# if we have specified strange inconsistent settings.
+config.translation.gc = config.translation.gc
+
 # 
 
 def set_platform(config):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy disable_merge_different_int_types: (arigo, bivab): fix

2011-11-23 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: disable_merge_different_int_types
Changeset: r49687:fe6b9886d517
Date: 2011-11-23 14:58 +0100
http://bitbucket.org/pypy/pypy/changeset/fe6b9886d517/

Log:(arigo, bivab): fix

diff --git a/pypy/rlib/rbigint.py b/pypy/rlib/rbigint.py
--- a/pypy/rlib/rbigint.py
+++ b/pypy/rlib/rbigint.py
@@ -1790,7 +1790,7 @@
 i = v.numdigits() - 1
 while i = 0:
 prev = x
-x = (x  SHIFT) + v.widedigit(i)
+x = (x  SHIFT) + r_ulonglong(v.widedigit(i))
 if (x  SHIFT) != prev:
 raise OverflowError(
 long int too large to convert to unsigned long long int)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy list-strategies: added more tests for so far uncovered code in listobject.setslice

2011-11-23 Thread l . diekmann
Author: Lukas Diekmann lukas.diekm...@uni-duesseldorf.de
Branch: list-strategies
Changeset: r49688:47318b7c592d
Date: 2011-11-23 15:19 +0100
http://bitbucket.org/pypy/pypy/changeset/47318b7c592d/

Log:added more tests for so far uncovered code in listobject.setslice

diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -774,7 +774,6 @@
 # self.unerase is valid for both of them
 other_items = self.unerase(w_other.lstorage)
 if other_items is items:
-XXX # untested paths
 if step  0:
 # Always copy starting from the right to avoid
 # having to make a shallow copy in the case where
diff --git a/pypy/objspace/std/test/test_listobject.py 
b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -779,6 +779,32 @@
 l[::3] = ('a', 'b')
 assert l == ['a', 1, 2, 'b', 4, 5]
 
+def test_setslice_with_self(self):
+l = [1,2,3,4]
+l[:] = l
+assert l == [1,2,3,4]
+
+l = [1,2,3,4]
+l[0:2] = l
+assert l == [1,2,3,4,3,4]
+
+l = [1,2,3,4]
+l[0:2] = l
+assert l == [1,2,3,4,3,4]
+
+l = [1,2,3,4,5,6,7,8,9,10]
+raises(ValueError, l[5::-1] = l)
+
+l = [1,2,3,4,5,6,7,8,9,10]
+raises(ValueError, l[::2] = l)
+
+l = [1,2,3,4,5,6,7,8,9,10]
+l[5:] = l
+assert l == [1,2,3,4,5,1,2,3,4,5,6,7,8,9,10]
+
+l = [1,2,3,4,5,6]
+l[::-1] = l
+assert l == [6,5,4,3,2,1]
 
 def test_recursive_repr(self):
 l = []
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64-stage1: Merge with default

2011-11-23 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64-stage1
Changeset: r49690:c70ae8696466
Date: 2011-11-23 16:06 +0100
http://bitbucket.org/pypy/pypy/changeset/c70ae8696466/

Log:Merge with default

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -231,6 +231,9 @@
 sqlite.sqlite3_result_text.argtypes = [c_void_p, c_char_p, c_int, c_void_p]
 sqlite.sqlite3_result_text.restype = None
 
+sqlite.sqlite3_enable_load_extension.argtypes = [c_void_p, c_int]
+sqlite.sqlite3_enable_load_extension.restype = c_int
+
 ##
 # END Wrapped SQLite C API and constants
 ##
@@ -705,6 +708,14 @@
 from sqlite3.dump import _iterdump
 return _iterdump(self)
 
+def enable_load_extension(self, enabled):
+self._check_thread()
+self._check_closed()
+
+rc = sqlite.sqlite3_enable_load_extension(self.db, int(enabled))
+if rc != SQLITE_OK:
+raise OperationalError(Error enabling load extension)
+
 DML, DQL, DDL = range(3)
 
 class Cursor(object):
diff --git a/pypy/config/test/test_translationoption.py 
b/pypy/config/test/test_translationoption.py
new file mode 100644
--- /dev/null
+++ b/pypy/config/test/test_translationoption.py
@@ -0,0 +1,10 @@
+import py
+from pypy.config.translationoption import get_combined_translation_config
+from pypy.config.translationoption import set_opt_level
+from pypy.config.config import ConflictConfigError
+
+
+def test_no_gcrootfinder_with_boehm():
+config = get_combined_translation_config()
+config.translation.gcrootfinder = shadowstack
+py.test.raises(ConflictConfigError, set_opt_level, config, '0')
diff --git a/pypy/config/translationoption.py b/pypy/config/translationoption.py
--- a/pypy/config/translationoption.py
+++ b/pypy/config/translationoption.py
@@ -398,6 +398,10 @@
 # make_sure_not_resized often relies on it, so we always enable them
 config.translation.suggest(list_comprehension_operations=True)
 
+# finally, make the choice of the gc definitive.  This will fail
+# if we have specified strange inconsistent settings.
+config.translation.gc = config.translation.gc
+
 # 
 
 def set_platform(config):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy disable_merge_different_int_types: raise UnionError

2011-11-23 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: disable_merge_different_int_types
Changeset: r49691:96f0a1fe89b1
Date: 2011-11-23 16:10 +0100
http://bitbucket.org/pypy/pypy/changeset/96f0a1fe89b1/

Log:raise UnionError

diff --git a/pypy/annotation/binaryop.py b/pypy/annotation/binaryop.py
--- a/pypy/annotation/binaryop.py
+++ b/pypy/annotation/binaryop.py
@@ -263,18 +263,18 @@
 knowntype = t1
 elif t2 is int:
 if not int2.is_constant():
-   raise Exception, Merging %s and a non-constant int is not 
allowed % t1
+   raise UnionError, Merging %s and a non-constant int is not 
allowed % t1
 knowntype = t1
 # ensure constant int2 is in range of t1
 t1(int2.const)
 elif t1 is int:
 if not int1.is_constant():
-   raise Exception, Merging %s and a non-constant int is not 
allowed % t2
+   raise UnionError, Merging %s and a non-constant int is not 
allowed % t2
 knowntype = t2
 # ensure constant int1 is in range of t2
 t2(int1.const)
 else:
-raise Exception, Merging these types (%s, %s) is not supported % 
(t1, t2)
+raise UnionError, Merging these types (%s, %s) is not supported 
% (t1, t2)
 return SomeInteger(nonneg=int1.nonneg and int2.nonneg,
knowntype=knowntype)
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64-stage1: added snakepit to predefined libdirs

2011-11-23 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64-stage1
Changeset: r49692:5e84431740d1
Date: 2011-11-23 16:52 +0100
http://bitbucket.org/pypy/pypy/changeset/5e84431740d1/

Log:added snakepit to predefined libdirs

diff --git a/pypy/rpython/tool/rffi_platform.py 
b/pypy/rpython/tool/rffi_platform.py
--- a/pypy/rpython/tool/rffi_platform.py
+++ b/pypy/rpython/tool/rffi_platform.py
@@ -704,9 +704,13 @@
 PYPY_EXTERNAL_DIR = py.path.local(pypydir).join('..', '..')
 # XXX make this configurable
 if sys.platform == 'win32':
-libdir = py.path.local('c:/buildslave/support') # on the bigboard buildbot
-if libdir.check():
-PYPY_EXTERNAL_DIR = libdir
+for libdir in [
+py.path.local('c:/buildslave/support'), # on the bigboard buildbot
+py.path.local('d:/myslave'), # on the snakepit buildbot
+]:
+if libdir.check():
+PYPY_EXTERNAL_DIR = libdir
+break
 
 def configure_external_library(name, eci, configurations,
symbol=None, _cache={}):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy disable_merge_different_int_types: (arigo, bivab): more fixes (not really tested)

2011-11-23 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: disable_merge_different_int_types
Changeset: r49693:2cba060a3f7a
Date: 2011-11-23 17:04 +0100
http://bitbucket.org/pypy/pypy/changeset/2cba060a3f7a/

Log:(arigo, bivab): more fixes (not really tested)

diff --git a/pypy/annotation/binaryop.py b/pypy/annotation/binaryop.py
--- a/pypy/annotation/binaryop.py
+++ b/pypy/annotation/binaryop.py
@@ -261,6 +261,9 @@
 
 if t1 is t2:
 knowntype = t1
+elif (t1 is int and t2 is rarithmetic.r_int) or (
+  t2 is int and t1 is rarithmetic.r_int):
+knowntype = rarithmetic.r_int
 elif t2 is int:
 if not int2.is_constant():
raise UnionError, Merging %s and a non-constant int is not 
allowed % t1
diff --git a/pypy/rlib/test/test_rarithmetic.py 
b/pypy/rlib/test/test_rarithmetic.py
--- a/pypy/rlib/test/test_rarithmetic.py
+++ b/pypy/rlib/test/test_rarithmetic.py
@@ -126,13 +126,18 @@
 cmp = f(r_uint(arg))
 assert res == cmp
 
-def binary_test(self, f, rargs = None):
+def binary_test(self, f, rargs = None, translated=False):
 mask = maxint_mask 
 if not rargs:
 rargs = (1, 3, 55)
+# when translated merging different int types is not allowed
+if translated:
+alltypes = [(r_uint, r_uint)]
+else:
+alltypes = [(int, r_uint), (r_uint, int), (r_uint, r_uint)]
 for larg in (0, 1, 2, 3, 1234):
 for rarg in rargs:
-for types in ((int, r_uint), (r_uint, int), (r_uint, r_uint)):
+for types in alltypes:
 res = f(larg, rarg)
 left, right = types
 cmp = f(left(larg), right(rarg))
diff --git a/pypy/translator/jvm/test/test_rarithmetic.py 
b/pypy/translator/jvm/test/test_rarithmetic.py
--- a/pypy/translator/jvm/test/test_rarithmetic.py
+++ b/pypy/translator/jvm/test/test_rarithmetic.py
@@ -32,7 +32,7 @@
 cache[types] = fun
 return cache[types](x, y)
 return f(x,y)
-super(BaseAdaptedTest,self).binary_test(new_func, rargs)
+super(BaseAdaptedTest,self).binary_test(new_func, rargs, 
translated=True)
 
 class Test_r_uint(BaseAdaptedTest, BaseTest_r_uint):
 RTYPE = ra.r_uint
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy disable_merge_different_int_types: (arigo, bivab): fix test

2011-11-23 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: disable_merge_different_int_types
Changeset: r49694:b1f7a47053f1
Date: 2011-11-23 17:14 +0100
http://bitbucket.org/pypy/pypy/changeset/b1f7a47053f1/

Log:(arigo, bivab): fix test

diff --git a/pypy/translator/c/test/test_typed.py 
b/pypy/translator/c/test/test_typed.py
--- a/pypy/translator/c/test/test_typed.py
+++ b/pypy/translator/c/test/test_typed.py
@@ -261,7 +261,7 @@
 f._annspecialcase_ = specialize:argtype(0)
 def g(n):
 if n  0:
-return f(r_longlong(0))
+return intmask(f(r_longlong(0)))
 else:
 return f(0)
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy disable_merge_different_int_types: (arigo, bivab) fix test

2011-11-23 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: disable_merge_different_int_types
Changeset: r49696:e1e61acee8d8
Date: 2011-11-23 17:20 +0100
http://bitbucket.org/pypy/pypy/changeset/e1e61acee8d8/

Log:(arigo, bivab) fix test

diff --git a/pypy/translator/c/test/test_lltyped.py 
b/pypy/translator/c/test/test_lltyped.py
--- a/pypy/translator/c/test/test_lltyped.py
+++ b/pypy/translator/c/test/test_lltyped.py
@@ -476,12 +476,13 @@
 def f(n):
 result = ()
 for cls in classes:
+nn = cls(n)
 for OP in operators:
 x = getmin(cls)
-res1 = OP(x, n)
+res1 = OP(x, nn)
 result = result + (res1,)
 x = getmax(cls)
-res1 = OP(x, n)
+res1 = OP(x, nn)
 result = result + (res1,)
 return result
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy disable_merge_different_int_types: (arigo, bivab): allow to merge different int types if they have both the same signedness. Generalizing to the larger type

2011-11-23 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: disable_merge_different_int_types
Changeset: r49697:b336e9e40643
Date: 2011-11-23 17:40 +0100
http://bitbucket.org/pypy/pypy/changeset/b336e9e40643/

Log:(arigo, bivab): allow to merge different int types if they have both
the same signedness. Generalizing to the larger type

diff --git a/pypy/annotation/binaryop.py b/pypy/annotation/binaryop.py
--- a/pypy/annotation/binaryop.py
+++ b/pypy/annotation/binaryop.py
@@ -252,32 +252,30 @@
 # unsignedness is considered a rare and contagious disease
 
 def union((int1, int2)):
-t1 = int1.knowntype
-if t1 is bool:
-t1 = int
-t2 = int2.knowntype
-if t2 is bool:
-t2 = int
+if int1.unsigned == int2.unsigned:
+knowntype = rarithmetic.compute_restype(int1.knowntype, 
int2.knowntype)
+else:
+t1 = int1.knowntype
+if t1 is bool:
+t1 = int
+t2 = int2.knowntype
+if t2 is bool:
+t2 = int
 
-if t1 is t2:
-knowntype = t1
-elif (t1 is int and t2 is rarithmetic.r_int) or (
-  t2 is int and t1 is rarithmetic.r_int):
-knowntype = rarithmetic.r_int
-elif t2 is int:
-if not int2.is_constant():
-   raise UnionError, Merging %s and a non-constant int is not 
allowed % t1
-knowntype = t1
-# ensure constant int2 is in range of t1
-t1(int2.const)
-elif t1 is int:
-if not int1.is_constant():
-   raise UnionError, Merging %s and a non-constant int is not 
allowed % t2
-knowntype = t2
-# ensure constant int1 is in range of t2
-t2(int1.const)
-else:
-raise UnionError, Merging these types (%s, %s) is not supported 
% (t1, t2)
+if t2 is int:
+if not int2.is_constant():
+   raise UnionError, Merging %s and a non-constant int is not 
allowed % t1
+knowntype = t1
+# ensure constant int2 is in range of t1
+t1(int2.const)
+elif t1 is int:
+if not int1.is_constant():
+   raise UnionError, Merging %s and a non-constant int is not 
allowed % t2
+knowntype = t2
+# ensure constant int1 is in range of t2
+t2(int1.const)
+else:
+raise UnionError, Merging these types (%s, %s) is not 
supported % (t1, t2)
 return SomeInteger(nonneg=int1.nonneg and int2.nonneg,
knowntype=knowntype)
 
diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -143,6 +143,8 @@
 return self_type
 if self_type in (bool, int, long):
 return other_type
+if self_type.SIGNED == other_type.SIGNED:
+return build_int(None, self_type.SIGNED, max(self_type.BITS, 
other_type.BITS))
 raise AssertionError, Merging these types (%s, %s) is not supported % 
(self_type, other_type)
 
 def signedtype(t):
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy disable_merge_different_int_types: (arigo, bivab): fix termios

2011-11-23 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: disable_merge_different_int_types
Changeset: r49698:c7028dade92d
Date: 2011-11-23 18:04 +0100
http://bitbucket.org/pypy/pypy/changeset/c7028dade92d/

Log:(arigo, bivab): fix termios

diff --git a/pypy/rpython/module/ll_termios.py 
b/pypy/rpython/module/ll_termios.py
--- a/pypy/rpython/module/ll_termios.py
+++ b/pypy/rpython/module/ll_termios.py
@@ -72,9 +72,14 @@
 
 def tcsetattr_llimpl(fd, when, attributes):
 c_struct = lltype.malloc(TERMIOSP.TO, flavor='raw')
-c_struct.c_c_iflag, c_struct.c_c_oflag, c_struct.c_c_cflag, \
-c_struct.c_c_lflag, ispeed, ospeed, cc = attributes
 try:
+c_struct.c_c_iflag = r_uint(attributes[0])
+c_struct.c_c_oflag = r_uint(attributes[1])
+c_struct.c_c_cflag = r_uint(attributes[2])
+c_struct.c_c_lflag = r_uint(attributes[3])
+ispeed = r_uint(attributes[4])
+ospeed = r_uint(attributes[5])
+cc = attributes[6]
 for i in range(NCCS):
 c_struct.c_c_cc[i] = rffi.r_uchar(ord(cc[i][0]))
 if c_cfsetispeed(c_struct, ispeed)  0:
@@ -87,8 +92,8 @@
 lltype.free(c_struct, flavor='raw')
 
 r_uint = rffi.r_uint
-register_external(rtermios.tcsetattr, [int, int, (r_uint, r_uint, r_uint,
-  r_uint, r_uint, r_uint, [str])], llimpl=tcsetattr_llimpl,
+register_external(rtermios.tcsetattr, [int, int, (int, int, int,
+  int, int, int, [str])], llimpl=tcsetattr_llimpl,
   export_name='termios.tcsetattr')
 
 # a bit C-c C-v code follows...
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy disable_merge_different_int_types: (arigo, bivab) fix rrandom and _random

2011-11-23 Thread bivab
Author: David Schneider david.schnei...@picle.org
Branch: disable_merge_different_int_types
Changeset: r49699:b52b9ae850fe
Date: 2011-11-23 18:16 +0100
http://bitbucket.org/pypy/pypy/changeset/b52b9ae850fe/

Log:(arigo, bivab) fix rrandom and _random

diff --git a/pypy/rlib/rrandom.py b/pypy/rlib/rrandom.py
--- a/pypy/rlib/rrandom.py
+++ b/pypy/rlib/rrandom.py
@@ -31,7 +31,7 @@
 mt[0]= s  MASK_32
 for mti in range(1, N):
 mt[mti] = (MAGIC_CONSTANT_A *
-   (mt[mti - 1] ^ (mt[mti - 1]  30)) + mti)
+   (mt[mti - 1] ^ (mt[mti - 1]  30)) + r_uint(mti))
 # See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier.
 # In the previous versions, MSBs of the seed affect
 # only MSBs of the array mt[].
@@ -52,7 +52,7 @@
 for k in range(max_k, 0, -1):
 mt[i] = ((mt[i] ^
  ((mt[i - 1] ^ (mt[i - 1]  30)) * MAGIC_CONSTANT_C))
- + init_key[j] + j) # non linear
+ + init_key[j] + r_uint(j)) # non linear
 mt[i] = MASK_32 # for WORDSIZE  32 machines
 i += 1
 j += 1
@@ -104,5 +104,5 @@
 j = n % i
 mt[i], mt[j] = mt[j], mt[i]
 for i in range(N):
-mt[i] += i + 1
+mt[i] += r_uint(i + 1)
 self.index = N
diff --git a/pypy/rlib/test/test_rrandom.py b/pypy/rlib/test/test_rrandom.py
--- a/pypy/rlib/test/test_rrandom.py
+++ b/pypy/rlib/test/test_rrandom.py
@@ -1,4 +1,5 @@
 from pypy.rlib.rrandom import Random, N, r_uint
+from pypy.rlib.rarithmetic import intmask
 import _random
 
 # the numbers were created by using CPython's _randommodule.c
@@ -24,13 +25,13 @@
 
 def test_init_by_array():
 rnd = Random()
-rnd.init_by_array([1, 2, 3, 4])
+rnd.init_by_array([r_uint(n) for n in [1, 2, 3, 4]])
 assert rnd.state[:14] == [2147483648, 1269538435, 699006892, 381364451,
 172015551, 3237099449, 3609464087, 2187366456, 654585064,
 2665903765, 3735624613, 1241943673, 2038528247, 3774211972]
 # try arrays of various sizes to test for corner cases
 for size in [N, N - 1, N + 1, N // 2, 2 * N]:
-rnd.init_by_array(range(N))
+rnd.init_by_array([r_uint(n) for n in range(N)])
 
 def test_jumpahead():
 rnd = Random()
@@ -47,8 +48,8 @@
 def f(x, y):
 rnd = Random(x)
 rnd.init_by_array([x, y])
-rnd.jumpahead(y)
+rnd.jumpahead(intmask(y))
 return rnd.genrand32(), rnd.random()
 t = Translation(f)
-fc = t.compile_c([int, int])
-assert fc(1, 2) == f(1, 2)
+fc = t.compile_c([r_uint, r_uint])
+assert fc(r_uint(1), r_uint(2)) == f(r_uint(1), r_uint(2))
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: fix test

2011-11-23 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r49700:556382e97898
Date: 2011-11-23 18:59 +0100
http://bitbucket.org/pypy/pypy/changeset/556382e97898/

Log:fix test

diff --git a/pypy/jit/metainterp/test/test_virtualstate.py 
b/pypy/jit/metainterp/test/test_virtualstate.py
--- a/pypy/jit/metainterp/test/test_virtualstate.py
+++ b/pypy/jit/metainterp/test/test_virtualstate.py
@@ -913,6 +913,9 @@
 pass
 def getvalue(*args):
 pass
+def emit_operation(*args):
+pass
+
 
 class TestShortBoxes:
 p1 = BoxPtr()
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: reenable autoconstruction of jump descr in oparser

2011-11-23 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r49701:175f0efa03c1
Date: 2011-11-23 19:18 +0100
http://bitbucket.org/pypy/pypy/changeset/175f0efa03c1/

Log:reenable autoconstruction of jump descr in oparser

diff --git a/pypy/jit/tool/oparser.py b/pypy/jit/tool/oparser.py
--- a/pypy/jit/tool/oparser.py
+++ b/pypy/jit/tool/oparser.py
@@ -70,7 +70,7 @@
 self.invent_fail_descr = invent_fail_descr
 self.nonstrict = nonstrict
 self.model = get_model(self.use_mock_model)
-self.celltoken = self.model.JitCellToken()
+self.original_jitcell_token = self.model.JitCellToken()
 
 def get_const(self, name, typ):
 if self._consts is None:
@@ -241,9 +241,10 @@
 if opnum == rop.FINISH:
 if descr is None and self.invent_fail_descr:
 descr = self.invent_fail_descr(self.model, fail_args)
-##elif opnum == rop.JUMP:
-##if descr is None and self.invent_fail_descr:
-##...
+elif opnum == rop.JUMP:
+if descr is None and self.invent_fail_descr:
+descr = self.original_jitcell_token
+
 return opnum, args, descr, fail_args
 
 def create_op(self, opnum, args, result, descr):
@@ -307,6 +308,7 @@
 raise ParseError(unexpected dedent at line: %s % newlines[num])
 loop = self.model.ExtendedTreeLoop(loop)
 loop.comment = first_comment
+loop.original_jitcell_token = self.original_jitcell_token
 loop.operations = ops
 loop.inputargs = inpargs
 loop.last_offset = last_offset
diff --git a/pypy/jit/tool/oparser_model.py b/pypy/jit/tool/oparser_model.py
--- a/pypy/jit/tool/oparser_model.py
+++ b/pypy/jit/tool/oparser_model.py
@@ -33,13 +33,13 @@
 return LoopModel
 
 def get_mock_model():
-class LoopModel(object):
+class MockLoopModel(object):
 
 class TreeLoop(object):
 def __init__(self, name):
 self.name = name
 
-class LoopToken(object):
+class JitCellToken(object):
 I_am_a_descr = True
 
 class BasicFailDescr(object):
@@ -107,9 +107,9 @@
 class llhelper(object):
 pass
 
-LoopModel.llhelper.BoxRef = LoopModel.BoxRef
+MockLoopModel.llhelper.BoxRef = MockLoopModel.BoxRef
 
-return LoopModel
+return MockLoopModel
 
 
 def get_model(use_mock):
diff --git a/pypy/jit/tool/test/test_oparser.py 
b/pypy/jit/tool/test/test_oparser.py
--- a/pypy/jit/tool/test/test_oparser.py
+++ b/pypy/jit/tool/test/test_oparser.py
@@ -119,7 +119,7 @@
 jump()
 '''
 loop = self.parse(x)
-assert loop.operations[0].getdescr() is loop.token
+assert loop.operations[0].getdescr() is loop.original_jitcell_token
 
 def test_jump_target_other(self):
 looptoken = JitCellToken()
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: fix test

2011-11-23 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r49702:c4496275b179
Date: 2011-11-23 19:27 +0100
http://bitbucket.org/pypy/pypy/changeset/c4496275b179/

Log:fix test

diff --git a/pypy/module/micronumpy/test/test_zjit.py 
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -53,7 +53,7 @@
 )
 self.check_resops({'setarrayitem_raw': 2, 'getfield_gc': 11,
'guard_class': 7, 'guard_true': 2,
-   'guard_isnull': 1, 'jump': 2, 'int_lt': 2,
+   'guard_isnull': 1, 'jump': 1, 'int_lt': 2,
'float_add': 2, 'int_add': 2, 'guard_value': 1,
'getarrayitem_raw': 4})
 assert result == 3 + 3
@@ -66,7 +66,7 @@
 assert result == 3 + 3
 self.check_resops({'setarrayitem_raw': 2, 'getfield_gc': 11,
'guard_class': 7, 'guard_true': 2,
-   'guard_isnull': 1, 'jump': 2, 'int_lt': 2,
+   'guard_isnull': 1, 'jump': 1, 'int_lt': 2,
'float_add': 2, 'int_add': 2, 'guard_value': 1,
'getarrayitem_raw': 2})
 
@@ -78,7 +78,7 @@
 )
 assert result == 2 * sum(range(30))
 self.check_resops({'guard_class': 7, 'getfield_gc': 11,
-   'guard_true': 2, 'jump': 2, 'getarrayitem_raw': 4,
+   'guard_true': 2, 'jump': 1, 'getarrayitem_raw': 4,
'guard_value': 2, 'guard_isnull': 1, 'int_lt': 2,
'float_add': 4, 'int_add': 2})
 
@@ -94,7 +94,7 @@
 assert result == expected
 self.check_resops({'int_lt': 2, 'getfield_gc': 11, 'guard_class': 7,
'float_mul': 2, 'guard_true': 2, 'guard_isnull': 1,
-   'jump': 2, 'getarrayitem_raw': 4, 'float_add': 2,
+   'jump': 1, 'getarrayitem_raw': 4, 'float_add': 2,
'int_add': 2, 'guard_value': 2})
 
 def test_max(self):
@@ -133,7 +133,7 @@
 assert result == 1
 self.check_resops({'int_lt': 2, 'getfield_gc': 9, 'guard_class': 7,
'guard_value': 1, 'int_add': 2, 'guard_true': 2,
-   'guard_isnull': 1, 'jump': 2, 'getarrayitem_raw': 4,
+   'guard_isnull': 1, 'jump': 1, 'getarrayitem_raw': 4,
'float_add': 2, 'guard_false': 2, 'float_ne': 2})
 
 def test_already_forced(self):
@@ -151,7 +151,7 @@
 self.check_resops({'setarrayitem_raw': 4, 'guard_nonnull': 1,
'getfield_gc': 23, 'guard_class': 14,
'guard_true': 4, 'float_mul': 2, 'guard_isnull': 2,
-   'jump': 4, 'int_lt': 4, 'float_add': 2,
+   'jump': 2, 'int_lt': 4, 'float_add': 2,
'int_add': 4, 'guard_value': 2,
'getarrayitem_raw': 4})
 
@@ -165,7 +165,7 @@
 assert result == -6
 self.check_resops({'setarrayitem_raw': 2, 'getfield_gc': 15,
'guard_class': 9, 'float_neg': 2, 'guard_true': 2,
-   'guard_isnull': 2, 'jump': 2, 'int_lt': 2,
+   'guard_isnull': 2, 'jump': 1, 'int_lt': 2,
'float_add': 2, 'int_add': 2, 'guard_value': 2,
'getarrayitem_raw': 4})
 
@@ -189,7 +189,7 @@
 d - 3
 )
 # This is 3, not 2 because there is a bridge for the exit.
-self.check_loop_count(3)
+self.check_trace_count(3)
 
 
 class TestNumpyOld(LLJitMixin):
@@ -213,7 +213,7 @@
 
 result = self.meta_interp(f, [5], listops=True, backendopt=True)
 self.check_resops({'setarrayitem_raw': 2, 'getfield_gc': 9,
-   'guard_true': 2, 'guard_isnull': 1, 'jump': 2,
+   'guard_true': 2, 'guard_isnull': 1, 'jump': 1,
'int_lt': 2, 'float_add': 2, 'int_mul': 2,
'int_add': 2, 'guard_value': 1,
'getarrayitem_raw': 4})
@@ -237,7 +237,7 @@
 
 result = self.meta_interp(f, [5], listops=True, backendopt=True)
 self.check_resops({'setarrayitem_raw': 2, 'getfield_gc': 11,
-   'guard_true': 2, 'guard_isnull': 1, 'jump': 2,
+   'guard_true': 2, 'guard_isnull': 1, 'jump': 1,
'int_lt': 2, 'float_add': 2, 'int_mul': 4,
'int_add': 2, 'guard_value': 1,
'getarrayitem_raw': 4})
@@ -260,7 +260,7 @@
 self.check_resops({'int_is_true': 1, 'setarrayitem_raw': 2,
'guard_nonnull': 1, 'getfield_gc': 

[pypy-commit] pypy default: copy this function from jitviewer

2011-11-23 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r49704:461ca1ae9f2a
Date: 2011-11-23 20:10 +0200
http://bitbucket.org/pypy/pypy/changeset/461ca1ae9f2a/

Log:copy this function from jitviewer

diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -386,3 +386,20 @@
  dump_start=start_ofs))
 loops.append(loop)
 return log, loops
+
+
+def parse_log_counts(input, loops):
+if not input:
+return
+lines = input[-1].splitlines()
+mapping = {}
+for loop in loops:
+com = loop.comment
+if 'Loop' in com:
+mapping['loop ' + re.search('Loop (\d+)', com).group(1)] = loop
+else:
+mapping['bridge ' + re.search('Guard (\d+)', com).group(1)] = loop
+for line in lines:
+if line:
+num, count = line.split(':', 2)
+mapping[num].count = int(count)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge

2011-11-23 Thread fijal
Author: Maciej Fijalkowski fij...@gmail.com
Branch: 
Changeset: r49705:0a31d8ef2f8a
Date: 2011-11-23 20:18 +0200
http://bitbucket.org/pypy/pypy/changeset/0a31d8ef2f8a/

Log:merge

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -231,6 +231,9 @@
 sqlite.sqlite3_result_text.argtypes = [c_void_p, c_char_p, c_int, c_void_p]
 sqlite.sqlite3_result_text.restype = None
 
+sqlite.sqlite3_enable_load_extension.argtypes = [c_void_p, c_int]
+sqlite.sqlite3_enable_load_extension.restype = c_int
+
 ##
 # END Wrapped SQLite C API and constants
 ##
@@ -705,6 +708,14 @@
 from sqlite3.dump import _iterdump
 return _iterdump(self)
 
+def enable_load_extension(self, enabled):
+self._check_thread()
+self._check_closed()
+
+rc = sqlite.sqlite3_enable_load_extension(self.db, int(enabled))
+if rc != SQLITE_OK:
+raise OperationalError(Error enabling load extension)
+
 DML, DQL, DDL = range(3)
 
 class Cursor(object):
diff --git a/pypy/config/test/test_translationoption.py 
b/pypy/config/test/test_translationoption.py
new file mode 100644
--- /dev/null
+++ b/pypy/config/test/test_translationoption.py
@@ -0,0 +1,10 @@
+import py
+from pypy.config.translationoption import get_combined_translation_config
+from pypy.config.translationoption import set_opt_level
+from pypy.config.config import ConflictConfigError
+
+
+def test_no_gcrootfinder_with_boehm():
+config = get_combined_translation_config()
+config.translation.gcrootfinder = shadowstack
+py.test.raises(ConflictConfigError, set_opt_level, config, '0')
diff --git a/pypy/config/translationoption.py b/pypy/config/translationoption.py
--- a/pypy/config/translationoption.py
+++ b/pypy/config/translationoption.py
@@ -398,6 +398,10 @@
 # make_sure_not_resized often relies on it, so we always enable them
 config.translation.suggest(list_comprehension_operations=True)
 
+# finally, make the choice of the gc definitive.  This will fail
+# if we have specified strange inconsistent settings.
+config.translation.gc = config.translation.gc
+
 # 
 
 def set_platform(config):
diff --git a/pypy/jit/metainterp/optimizeopt/optimizer.py 
b/pypy/jit/metainterp/optimizeopt/optimizer.py
--- a/pypy/jit/metainterp/optimizeopt/optimizer.py
+++ b/pypy/jit/metainterp/optimizeopt/optimizer.py
@@ -348,6 +348,7 @@
 self.opaque_pointers = {}
 self.replaces_guard = {}
 self._newoperations = []
+self.seen_results = {}
 self.optimizer = self
 self.optpure = None
 self.optearlyforce = None
@@ -542,6 +543,10 @@
 op = self.store_final_boxes_in_guard(op)
 elif op.can_raise():
 self.exception_might_have_happened = True
+if op.result:
+if op.result in self.seen_results:
+raise ValueError, invalid optimization
+self.seen_results[op.result] = None
 self._newoperations.append(op)
 
 def replace_op(self, old_op, new_op):
diff --git a/pypy/jit/metainterp/optimizeopt/virtualize.py 
b/pypy/jit/metainterp/optimizeopt/virtualize.py
--- a/pypy/jit/metainterp/optimizeopt/virtualize.py
+++ b/pypy/jit/metainterp/optimizeopt/virtualize.py
@@ -111,7 +111,7 @@
 if value.is_constant():
 pass# it is a constant value: ok
 elif (isinstance(value, AbstractVirtualStructValue)
-  and value.box is None):
+  and value.is_virtual()):
 # recursive check
 if not value._is_immutable_and_filled_with_constants(memo):
 return False
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: fix tests

2011-11-23 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r49706:71f16e839255
Date: 2011-11-23 20:00 +0100
http://bitbucket.org/pypy/pypy/changeset/71f16e839255/

Log:fix tests

diff --git a/pypy/jit/backend/x86/test/test_recompilation.py 
b/pypy/jit/backend/x86/test/test_recompilation.py
--- a/pypy/jit/backend/x86/test/test_recompilation.py
+++ b/pypy/jit/backend/x86/test/test_recompilation.py
@@ -5,10 +5,11 @@
 def test_compile_bridge_not_deeper(self):
 ops = '''
 [i0]
+label(i0, descr=targettoken)
 i1 = int_add(i0, 1)
 i2 = int_lt(i1, 20)
 guard_true(i2, descr=fdescr1) [i1]
-jump(i1)
+jump(i1, descr=targettoken)
 '''
 loop = self.interpret(ops, [0])
 assert self.getint(0) == 20
@@ -26,10 +27,11 @@
 def test_compile_bridge_deeper(self):
 ops = '''
 [i0]
+label(i0, descr=targettoken)
 i1 = int_add(i0, 1)
 i2 = int_lt(i1, 20)
 guard_true(i2, descr=fdescr1) [i1]
-jump(i1)
+jump(i1, descr=targettoken)
 '''
 loop = self.interpret(ops, [0])
 previous = loop.token._x86_frame_depth
@@ -47,7 +49,7 @@
 finish(i3, i4, i5, i6, i7, i8, i9, descr=fdescr2)
 '''
 bridge = self.attach_bridge(ops, loop, -2)
-descr = loop.operations[2].getdescr()
+descr = loop.operations[3].getdescr()
 new = descr._x86_bridge_frame_depth
 assert descr._x86_bridge_param_depth == 0
 # XXX: Maybe add enough ops to force stack on 64-bit as well?
@@ -64,21 +66,23 @@
 def test_bridge_jump_to_other_loop(self):
 loop = self.interpret('''
 [i0, i10, i11, i12, i13, i14, i15, i16]
+label(i0, i10, i11, i12, i13, i14, i15, i16, descr=targettoken)
 i1 = int_add(i0, 1)
 i2 = int_lt(i1, 20)
 guard_true(i2, descr=fdescr1) [i1]
-jump(i1, i10, i11, i12, i13, i14, i15, i16)
+jump(i1, i10, i11, i12, i13, i14, i15, i16, descr=targettoken)
 ''', [0])
 other_loop = self.interpret('''
 [i3]
+label(i3, descr=targettoken2)
 guard_false(i3, descr=fdescr2) [i3]
-jump(i3)
+jump(i3, descr=targettoken2)
 ''', [1])
 ops = '''
 [i3]
-jump(i3, 1, 2, 3, 4, 5, 6, 7, descr=looptoken)
+jump(i3, 1, 2, 3, 4, 5, 6, 7, descr=targettoken)
 '''
-bridge = self.attach_bridge(ops, other_loop, 0, looptoken=loop.token)
+bridge = self.attach_bridge(ops, other_loop, 1)
 self.cpu.set_future_value_int(0, 1)
 fail = self.run(other_loop)
 assert fail.identifier == 1
@@ -86,6 +90,7 @@
 def test_bridge_jumps_to_self_deeper(self):
 loop = self.interpret('''
 [i0, i1, i2, i31, i32, i33]
+label(i0, i1, i2, i31, i32, i33, descr=targettoken)
 i98 = same_as(0)
 i99 = same_as(1)
 i30 = int_add(i1, i2)
@@ -94,7 +99,7 @@
 guard_false(i4) [i98, i3]
 i5 = int_lt(i3, 20)
 guard_true(i5) [i99, i3]
-jump(i3, i30, 1, i30, i30, i30)
+jump(i3, i30, 1, i30, i30, i30, descr=targettoken)
 ''', [0])
 assert self.getint(0) == 0
 assert self.getint(1) == 1
@@ -106,10 +111,10 @@
 i7 = int_add(i3, i6)
 i12 = int_add(i7, i8)
 i11 = int_add(i12, i6)
-jump(i3, i12, i11, i10, i6, i7, descr=looptoken)
+jump(i3, i12, i11, i10, i6, i7, descr=targettoken)
 '''
-bridge = self.attach_bridge(ops, loop, 5, looptoken=loop.token)
-guard_op = loop.operations[5]
+bridge = self.attach_bridge(ops, loop, 6)
+guard_op = loop.operations[6]
 loop_frame_depth = loop.token._x86_frame_depth
 assert loop.token._x86_param_depth == 0
 # XXX: Maybe add enough ops to force stack on 64-bit as well?
@@ -126,6 +131,7 @@
 def test_bridge_jumps_to_self_shallower(self):
 loop = self.interpret('''
 [i0, i1, i2]
+label(i0, i1, i2, descr=targettoken)
 i98 = same_as(0)
 i99 = same_as(1)
 i3 = int_add(i0, 1)
@@ -133,15 +139,15 @@
 guard_false(i4) [i98, i3]
 i5 = int_lt(i3, 20)
 guard_true(i5) [i99, i3]
-jump(i3, i1, i2)
+jump(i3, i1, i2, descr=targettoken)
 ''', [0])
 assert self.getint(0) == 0
 assert self.getint(1) == 1
 ops = '''
 [i97, i3]
-jump(i3, 0, 1, descr=looptoken)
+jump(i3, 0, 1, descr=targettoken)
 '''
-bridge = self.attach_bridge(ops, loop, 4, looptoken=loop.token)
+bridge = self.attach_bridge(ops, loop, 5)
 self.cpu.set_future_value_int(0, 0)
 self.cpu.set_future_value_int(1, 0)
 self.cpu.set_future_value_int(2, 0)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-targets: fix test

2011-11-23 Thread hakanardo
Author: Hakan Ardo ha...@debian.org
Branch: jit-targets
Changeset: r49707:b768bf077b7e
Date: 2011-11-23 20:13 +0100
http://bitbucket.org/pypy/pypy/changeset/b768bf077b7e/

Log:fix test

diff --git a/pypy/jit/backend/x86/test/test_runner.py 
b/pypy/jit/backend/x86/test/test_runner.py
--- a/pypy/jit/backend/x86/test/test_runner.py
+++ b/pypy/jit/backend/x86/test/test_runner.py
@@ -528,19 +528,21 @@
 
 loop = 
 [i0]
+label(i0, descr=targettoken)
 debug_merge_point('xyz', 0)
 i1 = int_add(i0, 1)
 i2 = int_ge(i1, 10)
 guard_false(i2) []
-jump(i1)
+jump(i1, descr=targettoken)
 
-ops = parse(loop)
+ops = parse(loop, namespace={'targettoken': TargetToken()})
 debug._log = dlog = debug.DebugLog()
 try:
 self.cpu.assembler.set_debug(True)
-self.cpu.compile_loop(ops.inputargs, ops.operations, ops.token)
+looptoken = JitCellToken()
+self.cpu.compile_loop(ops.inputargs, ops.operations, looptoken)
 self.cpu.set_future_value_int(0, 0)
-self.cpu.execute_token(ops.token)
+self.cpu.execute_token(looptoken)
 # check debugging info
 struct = self.cpu.assembler.loop_run_counters[0]
 assert struct.i == 10
@@ -552,16 +554,18 @@
 def test_debugger_checksum(self):
 loop = 
 [i0]
+label(i0, descr=targettoken)
 debug_merge_point('xyz', 0)
 i1 = int_add(i0, 1)
 i2 = int_ge(i1, 10)
 guard_false(i2) []
-jump(i1)
+jump(i1, descr=targettoken)
 
-ops = parse(loop)
+ops = parse(loop, namespace={'targettoken': TargetToken()})
 self.cpu.assembler.set_debug(True)
-self.cpu.compile_loop(ops.inputargs, ops.operations, ops.token)
+looptoken = JitCellToken()
+self.cpu.compile_loop(ops.inputargs, ops.operations, looptoken)
 self.cpu.set_future_value_int(0, 0)
-self.cpu.execute_token(ops.token)
-assert ops.token._x86_debug_checksum == sum([op.getopnum()
+self.cpu.execute_token(looptoken)
+assert looptoken._x86_debug_checksum == sum([op.getopnum()
  for op in ops.operations])
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-jit-backend: asm_helper_adr is function descriptor on PPC64

2011-11-23 Thread edelsohn
Author: edelsohn
Branch: ppc-jit-backend
Changeset: r49709:4b6f56e2836f
Date: 2011-11-23 15:35 -0500
http://bitbucket.org/pypy/pypy/changeset/4b6f56e2836f/

Log:asm_helper_adr is function descriptor on PPC64

diff --git a/pypy/jit/backend/ppc/ppcgen/opassembler.py 
b/pypy/jit/backend/ppc/ppcgen/opassembler.py
--- a/pypy/jit/backend/ppc/ppcgen/opassembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/opassembler.py
@@ -893,7 +893,14 @@
 with saved_registers(self.mc, r.NONVOLATILES + [r.r3]):
 # resbox is already in r3
 self.mov_loc_loc(arglocs[1], r.r4)
-self.mc.bl_abs(asm_helper_adr)
+if IS_PPC_32:
+self.mc.bl_abs(asm_helper_adr)
+else:
+self.mc.load_from_addr(r.r0, asm_helper_adr)
+self.mc.load_from_addr(r.r2, asm_helper_adr + WORD)
+self.mc.load_from_addr(r.r11, asm_helper_adr + 2 * WORD)
+self.mc.mtctr(r.r0.value)
+self.mc.bctrl()
 if op.result:
 resloc = regalloc.after_call(op.result)
 if resloc.is_vfp_reg():
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-jit-backend: saved_registers must allocate and deallocate a full stack frame

2011-11-23 Thread edelsohn
Author: edelsohn
Branch: ppc-jit-backend
Changeset: r49710:45dba217d143
Date: 2011-11-23 16:21 -0500
http://bitbucket.org/pypy/pypy/changeset/45dba217d143/

Log:saved_registers must allocate and deallocate a full stack frame

diff --git a/pypy/jit/backend/ppc/ppcgen/helper/assembler.py 
b/pypy/jit/backend/ppc/ppcgen/helper/assembler.py
--- a/pypy/jit/backend/ppc/ppcgen/helper/assembler.py
+++ b/pypy/jit/backend/ppc/ppcgen/helper/assembler.py
@@ -1,6 +1,7 @@
 import pypy.jit.backend.ppc.ppcgen.condition as c
 from pypy.rlib.rarithmetic import r_uint, r_longlong, intmask
-from pypy.jit.backend.ppc.ppcgen.arch import MAX_REG_PARAMS, IS_PPC_32, WORD
+from pypy.jit.backend.ppc.ppcgen.arch import (MAX_REG_PARAMS, IS_PPC_32, WORD,
+  BACKCHAIN_SIZE)
 from pypy.jit.metainterp.history import FLOAT
 from pypy.rlib.unroll import unrolling_iterable
 import pypy.jit.backend.ppc.ppcgen.register as r
@@ -96,19 +97,28 @@
 
 def __enter__(self):
 if len(self.regs)  0:
-space = WORD * len(self.regs)
-self.mc.addi(r.SP.value, r.SP.value, -space)
+if IS_PPC_32:
+space = BACKCHAIN_SIZE + WORD * len(self.regs)
+self.mc.stwu(r.SP.value, r.SP.value, -space)
+else:
+space = (6 + MAX_REG_PARAMS + len(self.regs)) * WORD
+self.mc.stdu(r.SP.value, r.SP.value, -space)
 for i, reg in enumerate(self.regs):
 if IS_PPC_32:
-self.mc.stw(reg.value, r.SP.value, i * WORD)
+self.mc.stw(reg.value, r.SP.value, BACKCHAIN_SIZE + i * 
WORD)
 else:
-self.mc.std(reg.value, r.SP.value, i * WORD)
+self.mc.std(reg.value, r.SP.value, (14 + i) * WORD)
 
 def __exit__(self, *args):
 if len(self.regs)  0:
-space = WORD * len(self.regs)
 for i, reg in enumerate(self.regs):
 if IS_PPC_32:
-self.mc.lwz(reg.value, r.SP.value, i * WORD)
+self.mc.lwz(reg.value, r.SP.value, BACKCHAIN_SIZE + i * 
WORD)
 else:
-self.mc.ld(reg.value, r.SP.value, i * WORD)
+self.mc.ld(reg.value, r.SP.value, (14 + i) * WORD)
+if IS_PPC_32:
+space = BACKCHAIN_SIZE + WORD * len(self.regs)
+else:
+space = (6 + MAX_REG_PARAMS + len(self.regs)) * WORD
+self.mc.addi(r.SP.value, r.SP.value, space)
+
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64-stage1: enabled support won win64 standalone builds

2011-11-23 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64-stage1
Changeset: r49711:e399893be188
Date: 2011-11-23 17:46 +0100
http://bitbucket.org/pypy/pypy/changeset/e399893be188/

Log:enabled support won win64 standalone builds

diff --git a/pypy/translator/c/src/commondefs.h 
b/pypy/translator/c/src/commondefs.h
--- a/pypy/translator/c/src/commondefs.h
+++ b/pypy/translator/c/src/commondefs.h
@@ -69,16 +69,32 @@
 / 64-bit support /
 #else
 
-#  if LONG_MAX != 9223372036854775807L
-#error error in LONG_MAX (64-bit sources but a 32-bit compiler?)
+#  ifndef _WIN64
+#if LONG_MAX != 9223372036854775807L
+#  error error in LONG_MAX (64-bit sources but a 32-bit compiler?)
+#endif
+#if LONG_MIN != -9223372036854775807L-1L
+#  error unsupported value for LONG_MIN
+#endif
+
+#define SIZEOF_INT4
+#define SIZEOF_LONG   8
+#define SIZEOF_LONG_LONG  8
+
+/ Win-64 support /
+#  else
+#if LONG_MAX != 2147483647L
+#  error error in LONG_MAX (64-bit sources but incompatible compiler?)
+#endif
+#if LONG_MIN != -2147483647L-1L
+#  error unsupported value for LONG_MIN
+#endif
+
+#define SIZEOF_INT4
+#define SIZEOF_LONG   4
+#define SIZEOF_LONG_LONG  8
+
 #  endif
-#  if LONG_MIN != -9223372036854775807L-1L
-#error unsupported value for LONG_MIN
-#  endif
-
-#  define SIZEOF_INT4
-#  define SIZEOF_LONG   8
-#  define SIZEOF_LONG_LONG  8
 
 #endif
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64-stage1: a few more int/long unifications.

2011-11-23 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64-stage1
Changeset: r49713:53b5e001b4db
Date: 2011-11-23 23:17 +0100
http://bitbucket.org/pypy/pypy/changeset/53b5e001b4db/

Log:a few more int/long unifications. XXX I think this should be
replaced by a range checking function.

diff --git a/pypy/annotation/builtin.py b/pypy/annotation/builtin.py
--- a/pypy/annotation/builtin.py
+++ b/pypy/annotation/builtin.py
@@ -163,7 +163,7 @@
 r.const = False
 return r
 
-assert not issubclass(typ, (int, long)) or typ in (bool, int), (
+assert not issubclass(typ, (int, long)) or typ in (bool, int, 
long), (
 for integers only isinstance(.,int|r_uint) are supported)
  
 if s_obj.is_constant():
diff --git a/pypy/interpreter/test/test_compiler.py 
b/pypy/interpreter/test/test_compiler.py
--- a/pypy/interpreter/test/test_compiler.py
+++ b/pypy/interpreter/test/test_compiler.py
@@ -794,7 +794,7 @@
 def test_tuple_constants(self):
 ns = {}
 exec x = (1, 0); y = (1L, 0L) in ns
-assert isinstance(ns[x][0], int)
+assert isinstance(ns[x][0], (int, long))
 assert isinstance(ns[y][0], long)
 
 def test_division_folding(self):
diff --git a/pypy/rpython/test/test_rbuiltin.py 
b/pypy/rpython/test/test_rbuiltin.py
--- a/pypy/rpython/test/test_rbuiltin.py
+++ b/pypy/rpython/test/test_rbuiltin.py
@@ -542,7 +542,7 @@
 if r_longlong is not r_int:
 assert isinstance(res, r_longlong)
 else:
-assert isinstance(res, int)
+assert isinstance(res, (int, long))
 #
 def llfn(v):
 return rffi.cast(rffi.ULONGLONG, v)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy win64-stage1: added explicit _WIN32/_WIN64 defns for nmake

2011-11-23 Thread ctismer
Author: Christian Tismer tis...@stackless.com
Branch: win64-stage1
Changeset: r49714:7749a906e83a
Date: 2011-11-24 00:25 +0100
http://bitbucket.org/pypy/pypy/changeset/7749a906e83a/

Log:added explicit _WIN32/_WIN64 defns for nmake

diff --git a/pypy/translator/platform/windows.py 
b/pypy/translator/platform/windows.py
--- a/pypy/translator/platform/windows.py
+++ b/pypy/translator/platform/windows.py
@@ -91,8 +91,9 @@
 standalone_only = ()
 shared_only = ()
 environ = None
-
+
 def __init__(self, cc=None, x64=False):
+self.x64 = x64
 if x64:
 msvc_compiler_environ = msvc_compiler_environ64
 else:
@@ -302,7 +303,10 @@
 ('CC_LINK', self.link),
 ('LINKFILES', eci.link_files),
 ('MASM', self.masm),
+('_WIN32', '1'),
 ]
+if self.x64:
+definitions.append(('_WIN64', '1'))
 
 for args in definitions:
 m.definition(*args)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy list-strategies: Closing branch to be merged.

2011-11-23 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: list-strategies
Changeset: r49716:2449ac0ea4a1
Date: 2011-11-24 01:53 -0600
http://bitbucket.org/pypy/pypy/changeset/2449ac0ea4a1/

Log:Closing branch to be merged.

___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy list-strategies: merged default in

2011-11-23 Thread alex_gaynor
Author: Alex Gaynor alex.gay...@gmail.com
Branch: list-strategies
Changeset: r49715:8e6605b379dc
Date: 2011-11-24 01:53 -0600
http://bitbucket.org/pypy/pypy/changeset/8e6605b379dc/

Log:merged default in

diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -231,6 +231,9 @@
 sqlite.sqlite3_result_text.argtypes = [c_void_p, c_char_p, c_int, c_void_p]
 sqlite.sqlite3_result_text.restype = None
 
+sqlite.sqlite3_enable_load_extension.argtypes = [c_void_p, c_int]
+sqlite.sqlite3_enable_load_extension.restype = c_int
+
 ##
 # END Wrapped SQLite C API and constants
 ##
@@ -705,6 +708,14 @@
 from sqlite3.dump import _iterdump
 return _iterdump(self)
 
+def enable_load_extension(self, enabled):
+self._check_thread()
+self._check_closed()
+
+rc = sqlite.sqlite3_enable_load_extension(self.db, int(enabled))
+if rc != SQLITE_OK:
+raise OperationalError(Error enabling load extension)
+
 DML, DQL, DDL = range(3)
 
 class Cursor(object):
diff --git a/pypy/config/test/test_translationoption.py 
b/pypy/config/test/test_translationoption.py
new file mode 100644
--- /dev/null
+++ b/pypy/config/test/test_translationoption.py
@@ -0,0 +1,10 @@
+import py
+from pypy.config.translationoption import get_combined_translation_config
+from pypy.config.translationoption import set_opt_level
+from pypy.config.config import ConflictConfigError
+
+
+def test_no_gcrootfinder_with_boehm():
+config = get_combined_translation_config()
+config.translation.gcrootfinder = shadowstack
+py.test.raises(ConflictConfigError, set_opt_level, config, '0')
diff --git a/pypy/config/translationoption.py b/pypy/config/translationoption.py
--- a/pypy/config/translationoption.py
+++ b/pypy/config/translationoption.py
@@ -398,6 +398,10 @@
 # make_sure_not_resized often relies on it, so we always enable them
 config.translation.suggest(list_comprehension_operations=True)
 
+# finally, make the choice of the gc definitive.  This will fail
+# if we have specified strange inconsistent settings.
+config.translation.gc = config.translation.gc
+
 # 
 
 def set_platform(config):
diff --git a/pypy/doc/project-ideas.rst b/pypy/doc/project-ideas.rst
--- a/pypy/doc/project-ideas.rst
+++ b/pypy/doc/project-ideas.rst
@@ -23,6 +23,12 @@
 PyPy's implementation of the Python ``long`` type is slower than CPython's.
 Find out why and optimize them.
 
+Make bytearray type fast
+
+
+PyPy's bytearray type is very inefficient. It would be an interesting
+task to look into possible optimizations on this.
+
 Numpy improvements
 --
 
diff --git a/pypy/jit/metainterp/optimizeopt/optimizer.py 
b/pypy/jit/metainterp/optimizeopt/optimizer.py
--- a/pypy/jit/metainterp/optimizeopt/optimizer.py
+++ b/pypy/jit/metainterp/optimizeopt/optimizer.py
@@ -348,6 +348,7 @@
 self.opaque_pointers = {}
 self.replaces_guard = {}
 self._newoperations = []
+self.seen_results = {}
 self.optimizer = self
 self.optpure = None
 self.optearlyforce = None
@@ -542,6 +543,10 @@
 op = self.store_final_boxes_in_guard(op)
 elif op.can_raise():
 self.exception_might_have_happened = True
+if op.result:
+if op.result in self.seen_results:
+raise ValueError, invalid optimization
+self.seen_results[op.result] = None
 self._newoperations.append(op)
 
 def replace_op(self, old_op, new_op):
diff --git a/pypy/jit/metainterp/optimizeopt/virtualize.py 
b/pypy/jit/metainterp/optimizeopt/virtualize.py
--- a/pypy/jit/metainterp/optimizeopt/virtualize.py
+++ b/pypy/jit/metainterp/optimizeopt/virtualize.py
@@ -111,7 +111,7 @@
 if value.is_constant():
 pass# it is a constant value: ok
 elif (isinstance(value, AbstractVirtualStructValue)
-  and value.box is None):
+  and value.is_virtual()):
 # recursive check
 if not value._is_immutable_and_filled_with_constants(memo):
 return False
diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -386,3 +386,20 @@
  dump_start=start_ofs))
 loops.append(loop)
 return log, loops
+
+
+def parse_log_counts(input, loops):
+if not input:
+return
+lines = input[-1].splitlines()
+mapping = {}
+for loop in loops:
+com = loop.comment
+if 'Loop' in com:
+mapping['loop ' + re.search('Loop (\d+)', com).group(1)] = loop
+else:
+mapping['bridge ' +