[pypy-commit] pypy follow_symlinks: hg merge rposix-for-3

2016-03-25 Thread rlamy
Author: Ronan Lamy 
Branch: follow_symlinks
Changeset: r83385:b61310248d8f
Date: 2016-03-26 04:11 +
http://bitbucket.org/pypy/pypy/changeset/b61310248d8f/

Log:hg merge rposix-for-3

diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -1903,6 +1903,17 @@
 lltype.free(buf, flavor='raw')
 return result
 
+if HAVE_RENAMEAT:
+c_renameat = external(
+'renameat',
+[rffi.INT, rffi.CCHARP, rffi.INT, rffi.CCHARP], rffi.INT,
+save_err=rffi.RFFI_SAVE_ERRNO)
+
+def renameat(src, dst, src_dir_fd=AT_FDCWD, dst_dir_fd=AT_FDCWD):
+error = c_renameat(src_dir_fd, src, dst_dir_fd, dst)
+handle_posix_error('renameat', error)
+
+
 if HAVE_SYMLINKAT:
 c_symlinkat = external('symlinkat',
 [rffi.CCHARP, rffi.INT, rffi.CCHARP], rffi.INT,
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -545,3 +545,14 @@
 assert os.readlink(str(tmpdir.join('link'))) == 'file'
 finally:
 os.close(dirfd)
+
+
+def test_renameat(tmpdir):
+tmpdir.join('file').write('text')
+dirfd = os.open(str(tmpdir), os.O_RDONLY)
+try:
+rposix.renameat('file', 'file2', src_dir_fd=dirfd, dst_dir_fd=dirfd)
+finally:
+os.close(dirfd)
+assert tmpdir.join('file').check(exists=False)
+assert tmpdir.join('file2').check(exists=True)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy follow_symlinks: Support *_dir_fd arguments in rename() and replace()

2016-03-25 Thread rlamy
Author: Ronan Lamy 
Branch: follow_symlinks
Changeset: r83386:b7d85ab453c9
Date: 2016-03-26 04:14 +
http://bitbucket.org/pypy/pypy/changeset/b7d85ab453c9/

Log:Support *_dir_fd arguments in rename() and replace()

diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -849,8 +849,9 @@
 """
 _chmod_fd(space, fd, mode)
 
-@unwrap_spec(src_dir_fd=DirFD(available=False), 
dst_dir_fd=DirFD(available=False))
-def rename(space, w_old, w_new,
+@unwrap_spec(src_dir_fd=DirFD(rposix.HAVE_RENAMEAT),
+dst_dir_fd=DirFD(rposix.HAVE_RENAMEAT))
+def rename(space, w_src, w_dst,
 src_dir_fd=DEFAULT_DIR_FD, dst_dir_fd=DEFAULT_DIR_FD):
 """rename(src, dst, *, src_dir_fd=None, dst_dir_fd=None)
 
@@ -862,12 +863,18 @@
 src_dir_fd and dst_dir_fd, may not be implemented on your platform.
   If they are unavailable, using them will raise a NotImplementedError."""
 try:
-dispatch_filename_2(rposix.rename)(space, w_old, w_new)
+if (src_dir_fd != DEFAULT_DIR_FD or dst_dir_fd != DEFAULT_DIR_FD):
+src = space.fsencode_w(w_src)
+dst = space.fsencode_w(w_dst)
+rposix.renameat(src, dst, src_dir_fd, dst_dir_fd)
+else:
+dispatch_filename_2(rposix.rename)(space, w_src, w_dst)
 except OSError, e:
 raise wrap_oserror(space, e)
 
-@unwrap_spec(src_dir_fd=DirFD(available=False), 
dst_dir_fd=DirFD(available=False))
-def replace(space, w_old, w_new,
+@unwrap_spec(src_dir_fd=DirFD(rposix.HAVE_RENAMEAT),
+dst_dir_fd=DirFD(rposix.HAVE_RENAMEAT))
+def replace(space, w_src, w_dst,
 src_dir_fd=DEFAULT_DIR_FD, dst_dir_fd=DEFAULT_DIR_FD):
 """replace(src, dst, *, src_dir_fd=None, dst_dir_fd=None)
 
@@ -879,8 +886,13 @@
 src_dir_fd and dst_dir_fd, may not be implemented on your platform.
   If they are unavailable, using them will raise a NotImplementedError."""
 try:
-dispatch_filename_2(rposix.replace)(space, w_old, w_new)
-except OSError, e:
+if (src_dir_fd != DEFAULT_DIR_FD or dst_dir_fd != DEFAULT_DIR_FD):
+src = space.fsencode_w(w_src)
+dst = space.fsencode_w(w_dst)
+rposix.renameat(src, dst, src_dir_fd, dst_dir_fd)
+else:
+dispatch_filename_2(rposix.replace)(space, w_src, w_dst)
+except OSError as e:
 raise wrap_oserror(space, e)
 
 @unwrap_spec(mode=c_int, dir_fd=DirFD(rposix.HAVE_MKFIFOAT))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy rposix-for-3: Add renameat()

2016-03-25 Thread rlamy
Author: Ronan Lamy 
Branch: rposix-for-3
Changeset: r83384:57f52c369d21
Date: 2016-03-26 04:09 +
http://bitbucket.org/pypy/pypy/changeset/57f52c369d21/

Log:Add renameat()

diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -1903,6 +1903,17 @@
 lltype.free(buf, flavor='raw')
 return result
 
+if HAVE_RENAMEAT:
+c_renameat = external(
+'renameat',
+[rffi.INT, rffi.CCHARP, rffi.INT, rffi.CCHARP], rffi.INT,
+save_err=rffi.RFFI_SAVE_ERRNO)
+
+def renameat(src, dst, src_dir_fd=AT_FDCWD, dst_dir_fd=AT_FDCWD):
+error = c_renameat(src_dir_fd, src, dst_dir_fd, dst)
+handle_posix_error('renameat', error)
+
+
 if HAVE_SYMLINKAT:
 c_symlinkat = external('symlinkat',
 [rffi.CCHARP, rffi.INT, rffi.CCHARP], rffi.INT,
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -545,3 +545,14 @@
 assert os.readlink(str(tmpdir.join('link'))) == 'file'
 finally:
 os.close(dirfd)
+
+
+def test_renameat(tmpdir):
+tmpdir.join('file').write('text')
+dirfd = os.open(str(tmpdir), os.O_RDONLY)
+try:
+rposix.renameat('file', 'file2', src_dir_fd=dirfd, dst_dir_fd=dirfd)
+finally:
+os.close(dirfd)
+assert tmpdir.join('file').check(exists=False)
+assert tmpdir.join('file2').check(exists=True)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy follow_symlinks: Support *_dir_fd arguments in posix.link()

2016-03-25 Thread rlamy
Author: Ronan Lamy 
Branch: follow_symlinks
Changeset: r83383:3da1fa9db8d2
Date: 2016-03-26 03:29 +
http://bitbucket.org/pypy/pypy/changeset/3da1fa9db8d2/

Log:Support *_dir_fd arguments in posix.link()

diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -964,7 +964,7 @@
 
 @unwrap_spec(
 src='fsencode', dst='fsencode',
-src_dir_fd=DirFD(available=False), dst_dir_fd=DirFD(available=False),
+src_dir_fd=DirFD(rposix.HAVE_LINKAT), dst_dir_fd=DirFD(rposix.HAVE_LINKAT),
 follow_symlinks=kwonly(bool))
 def link(
 space, src, dst,
@@ -985,8 +985,12 @@
   platform.  If they are unavailable, using them will raise a
   NotImplementedError."""
 try:
-os.link(src, dst)
-except OSError, e:
+if (src_dir_fd != DEFAULT_DIR_FD or dst_dir_fd != DEFAULT_DIR_FD
+or not follow_symlinks):
+rposix.linkat(src, dst, src_dir_fd, dst_dir_fd, follow_symlinks)
+else:
+rposix.link(src, dst)
+except OSError as e:
 raise wrap_oserror(space, e)
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy follow_symlinks: workaround for missing errno.ENOTSUP (e.g. on the buildbot's PyPy)

2016-03-25 Thread rlamy
Author: Ronan Lamy 
Branch: follow_symlinks
Changeset: r83382:fb2b32a805d3
Date: 2016-03-26 03:05 +
http://bitbucket.org/pypy/pypy/changeset/fb2b32a805d3/

Log:workaround for missing errno.ENOTSUP (e.g. on the buildbot's PyPy)

diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1,7 +1,12 @@
 import os
 import sys
 from math import modf
-from errno import ENOTSUP, EOPNOTSUPP
+from errno import EOPNOTSUPP
+try:
+from errno import ENOTSUP
+except ImportError:
+# some Pythons don't have errno.ENOTSUP
+ENOTSUP = 0
 
 from rpython.rlib import rposix, rposix_stat
 from rpython.rlib import objectmodel, rurandom
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy follow_symlinks: Implement missing features in chown()

2016-03-25 Thread rlamy
Author: Ronan Lamy 
Branch: follow_symlinks
Changeset: r83381:10b3f4bf59cd
Date: 2016-03-26 02:43 +
http://bitbucket.org/pypy/pypy/changeset/10b3f4bf59cd/

Log:Implement missing features in chown()

diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1698,9 +1698,9 @@
 return space.wrap(res)
 
 @unwrap_spec(
-path='fsencode', uid=c_uid_t, gid=c_gid_t,
-dir_fd=DirFD(available=False), follow_symlinks=kwonly(bool))
-def chown(space, path, uid, gid, dir_fd=DEFAULT_DIR_FD, follow_symlinks=True):
+uid=c_uid_t, gid=c_gid_t,
+dir_fd=DirFD(rposix.HAVE_FCHOWNAT), follow_symlinks=kwonly(bool))
+def chown(space, w_path, uid, gid, dir_fd=DEFAULT_DIR_FD, 
follow_symlinks=True):
 """chown(path, uid, gid, *, dir_fd=None, follow_symlinks=True)
 
 Change the owner and group id of path to the numeric uid and gid.
@@ -1719,10 +1719,43 @@
   If they are unavailable, using them will raise a NotImplementedError."""
 check_uid_range(space, uid)
 check_uid_range(space, gid)
+if not (rposix.HAVE_LCHOWN or rposix.HAVE_FCHMODAT):
+if not follow_symlinks:
+raise argument_unavailable(space, 'chown', 'follow_symlinks')
 try:
-os.chown(path, uid, gid)
-except OSError, e:
-raise wrap_oserror(space, e, path)
+path = space.fsencode_w(w_path)
+except OperationError:
+if not space.isinstance_w(w_path, space.w_int):
+raise oefmt(space.w_TypeError,
+"argument should be string, bytes or integer, not %T", w_path)
+# File descriptor case
+fd = unwrap_fd(space, w_path)
+if dir_fd != DEFAULT_DIR_FD:
+raise oefmt(space.w_ValueError,
+"chown: can't specify both dir_fd and fd")
+if not follow_symlinks:
+raise oefmt(space.w_ValueError,
+"chown: cannnot use fd and follow_symlinks together")
+try:
+os.fchown(fd, uid, gid)
+except OSError as e:
+raise wrap_oserror(space, e)
+else:
+# String case
+try:
+if (rposix.HAVE_LCHOWN and
+dir_fd == DEFAULT_DIR_FD and not follow_symlinks):
+os.lchown(path, uid, gid)
+elif rposix.HAVE_FCHOWNAT and (
+not follow_symlinks or dir_fd != DEFAULT_DIR_FD):
+rposix.fchownat(path, uid, gid, dir_fd, follow_symlinks)
+else:
+assert follow_symlinks
+assert dir_fd == DEFAULT_DIR_FD
+os.chown(path, uid, gid)
+except OSError as e:
+raise wrap_oserror2(space, e, w_path)
+
 
 @unwrap_spec(path='fsencode', uid=c_uid_t, gid=c_gid_t)
 def lchown(space, path, uid, gid):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Only execute NEON instructions on CPUs supporting NEON

2016-03-25 Thread stefanor
Author: Stefano Rivera 
Branch: 
Changeset: r83380:fc95c9347679
Date: 2016-03-25 21:24 -0500
http://bitbucket.org/pypy/pypy/changeset/fc95c9347679/

Log:Only execute NEON instructions on CPUs supporting NEON

On Debian armhf, NEON is not mandated. In fact Debian's buildds
don't support it.

diff --git a/rpython/jit/backend/arm/detect.py 
b/rpython/jit/backend/arm/detect.py
--- a/rpython/jit/backend/arm/detect.py
+++ b/rpython/jit/backend/arm/detect.py
@@ -1,6 +1,7 @@
 import os
 
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
+from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rtyper.tool import rffi_platform
 from rpython.rlib.clibffi import FFI_DEFAULT_ABI, FFI_SYSV, FFI_VFP
 from rpython.translator.platform import CompilationError
@@ -15,6 +16,7 @@
 asm volatile("VMOV s0, s1");
 }
 """])
+getauxval = rffi.llexternal("getauxval", [lltype.Unsigned], lltype.Unsigned)
 
 def detect_hardfloat():
 return FFI_DEFAULT_ABI == FFI_VFP
@@ -63,3 +65,10 @@
 "falling back to", "ARMv%d" % n)
 debug_stop("jit-backend-arch")
 return n
+
+
+def detect_neon():
+AT_HWCAP = 16
+HWCAP_NEON = 1 << 12
+hwcap = getauxval(AT_HWCAP)
+return bool(hwcap & HWCAP_NEON)
diff --git a/rpython/jit/backend/arm/opassembler.py 
b/rpython/jit/backend/arm/opassembler.py
--- a/rpython/jit/backend/arm/opassembler.py
+++ b/rpython/jit/backend/arm/opassembler.py
@@ -1092,8 +1092,8 @@
 self.mc.VCVT_int_to_float(res.value, r.svfp_ip.value)
 return fcond
 
-# the following five instructions are only ARMv7;
-# regalloc.py won't call them at all on ARMv6
+# the following five instructions are only ARMv7 with NEON;
+# regalloc.py won't call them at all, in other cases
 emit_opx_llong_add = gen_emit_float_op('llong_add', 'VADD_i64')
 emit_opx_llong_sub = gen_emit_float_op('llong_sub', 'VSUB_i64')
 emit_opx_llong_and = gen_emit_float_op('llong_and', 'VAND_i64')
diff --git a/rpython/jit/backend/arm/regalloc.py 
b/rpython/jit/backend/arm/regalloc.py
--- a/rpython/jit/backend/arm/regalloc.py
+++ b/rpython/jit/backend/arm/regalloc.py
@@ -530,7 +530,7 @@
 EffectInfo.OS_LLONG_AND,
 EffectInfo.OS_LLONG_OR,
 EffectInfo.OS_LLONG_XOR):
-if self.cpu.cpuinfo.arch_version >= 7:
+if self.cpu.cpuinfo.neon:
 args = self._prepare_llong_binop_xx(op, fcond)
 self.perform_extra(op, args, fcond)
 return
diff --git a/rpython/jit/backend/arm/runner.py 
b/rpython/jit/backend/arm/runner.py
--- a/rpython/jit/backend/arm/runner.py
+++ b/rpython/jit/backend/arm/runner.py
@@ -7,13 +7,14 @@
 from rpython.rlib.jit_hooks import LOOP_RUN_CONTAINER
 from rpython.rtyper.lltypesystem import lltype, llmemory
 from rpython.jit.backend.arm.detect import detect_hardfloat
-from rpython.jit.backend.arm.detect import detect_arch_version
+from rpython.jit.backend.arm.detect import detect_arch_version, detect_neon
 
 jitframe.STATICSIZE = JITFRAME_FIXED_SIZE
 
 class CPUInfo(object):
 hf_abi = False
 arch_version = 6
+neon = False
 
 class AbstractARMCPU(AbstractLLCPU):
 
@@ -48,6 +49,7 @@
 def setup_once(self):
 self.cpuinfo.arch_version = detect_arch_version()
 self.cpuinfo.hf_abi = detect_hardfloat()
+self.cpuinfo.neon = detect_neon()
 #self.codemap.setup()
 self.assembler.setup_once()
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: oops, move the _annspecialcase_ to the new function

2016-03-25 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r83378:d5f8ea5bac55
Date: 2016-03-25 22:14 +0100
http://bitbucket.org/pypy/pypy/changeset/d5f8ea5bac55/

Log:oops, move the _annspecialcase_ to the new function

diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -334,7 +334,7 @@
 def _lookup(self, w_obj, name):
 w_type = self.type(w_obj)
 return w_type.lookup(name)
-lookup._annspecialcase_ = 'specialize:lookup'
+_lookup._annspecialcase_ = 'specialize:lookup'
 
 def lookup_in_type_where(self, w_type, name):
 return w_type.lookup_where(name)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: store more debug info on the Conditions, as it can be very hard to figure out

2016-03-25 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r83376:90e798a6ec1f
Date: 2016-03-25 14:37 +0100
http://bitbucket.org/pypy/pypy/changeset/90e798a6ec1f/

Log:store more debug info on the Conditions, as it can be very hard to
figure out where they come from

diff --git a/rpython/jit/metainterp/compatible.py 
b/rpython/jit/metainterp/compatible.py
--- a/rpython/jit/metainterp/compatible.py
+++ b/rpython/jit/metainterp/compatible.py
@@ -55,11 +55,11 @@
 copied_op = op.copy()
 copied_op.setarg(1, self.known_valid)
 if op.numargs() == 2:
-return copied_op, PureCallCondition(op, optimizer.metainterp_sd)
+return copied_op, PureCallCondition(op, optimizer)
 arg2 = copied_op.getarg(2)
 if arg2.is_constant():
 # already a constant, can just use PureCallCondition
-return copied_op, PureCallCondition(op, optimizer.metainterp_sd)
+return copied_op, PureCallCondition(op, optimizer)
 
 # really simple-minded pattern matching
 # the order of things is like this:
@@ -85,15 +85,25 @@
 copied_op.setarg(2, qmutdescr.constantfieldbox)
 self.last_quasi_immut_field_op = None
 return copied_op, QuasiimmutGetfieldAndPureCallCondition(
-op, qmutdescr, optimizer.metainterp_sd)
+op, qmutdescr, optimizer)
 
 def repr_of_conditions(self, argrepr="?"):
 return "\n".join([cond.repr(argrepr) for cond in self.conditions])
 
 
 class Condition(object):
-def __init__(self, metainterp_sd):
-self.metainterp_sd = metainterp_sd
+def __init__(self, optimizer):
+self.metainterp_sd = optimizer.metainterp_sd
+# XXX maybe too expensive
+op = optimizer._last_debug_merge_point
+if op:
+jd_sd = self.metainterp_sd.jitdrivers_sd[op.getarg(0).getint()]
+s = jd_sd.warmstate.get_location_str(op.getarglist()[3:])
+s = s.replace(',', '.') # we use comma for argument splitting
+else:
+s = ''
+self.debug_mp_str = s
+self.rpyfunc = None
 
 def check(self, cpu, ref):
 raise NotImplementedError
@@ -133,12 +143,13 @@
 return ""
 
 class PureCallCondition(Condition):
-def __init__(self, op, metainterp_sd):
-Condition.__init__(self, metainterp_sd)
+def __init__(self, op, optimizer):
+Condition.__init__(self, optimizer)
 args = op.getarglist()[:]
 args[1] = None
 self.args = args
 self.descr = op.getdescr()
+self.rpyfunc = op.rpyfunc
 
 def check(self, cpu, ref):
 from rpython.rlib.debug import debug_print, debug_start, debug_stop
@@ -186,17 +197,23 @@
 extra = ''
 else:
 extra = ', ' + ', '.join([self._repr_const(arg) for arg in 
self.args[2:]])
-return "compatible if %s == %s(%s%s)" % (result, funcname, argrepr, 
extra)
+res = "compatible if %s == %s(%s%s)" % (result, funcname, argrepr, 
extra)
+if self.rpyfunc:
+res = "%s: %s" % (self.rpyfunc, res)
+if self.debug_mp_str:
+res = self.debug_mp_str + "\n" + res
+return res
 
 
 class QuasiimmutGetfieldAndPureCallCondition(PureCallCondition):
-def __init__(self, op, qmutdescr, metainterp_sd):
-Condition.__init__(self, metainterp_sd)
+def __init__(self, op, qmutdescr, optimizer):
+Condition.__init__(self, optimizer)
 args = op.getarglist()[:]
 args[1] = None
 args[2] = None
 self.args = args
 self.descr = op.getdescr()
+self.rpyfunc = op.rpyfunc
 self.qmut = qmutdescr.qmut
 self.mutatefielddescr = qmutdescr.mutatefielddescr
 self.fielddescr = qmutdescr.fielddescr
@@ -266,5 +283,10 @@
 else:
 extra = ', ' + ', '.join([self._repr_const(arg) for arg in 
self.args[3:]])
 attrname = self.fielddescr.repr_of_descr()
-return "compatible if %s == %s(%s, %s.%s%s)" % (
+res = "compatible if %s == %s(%s, %s.%s%s)" % (
 result, funcname, argrepr, argrepr, attrname, extra)
+if self.rpyfunc:
+res = "%s: %s" % (self.rpyfunc, res)
+if self.debug_mp_str:
+res = self.debug_mp_str + "\n" + res
+return res
diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py 
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -264,6 +264,7 @@
 self.optunroll = None
 
 self._last_guard_op = None
+self._last_debug_merge_point = None
 
 self.set_optimizations(optimizations)
 self.setup()
@@ -886,6 +887,7 @@
 # FIXME: Is this still needed?
 
 def optimize_DEBUG_MERGE_POINT(self, op):
+self._last_debug_merge_point = op
 self.emit_operation(op)
 

[pypy-commit] pypy guard-compatible: merge default

2016-03-25 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r83375:ba422164355b
Date: 2016-03-25 09:25 +0100
http://bitbucket.org/pypy/pypy/changeset/ba422164355b/

Log:merge default

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -19,3 +19,4 @@
 850edf14b2c75573720f59e95767335fb1affe55 release-4.0.0
 5f8302b8bf9f53056e40426f10c72151564e5b19 release-4.0.1
 246c9cf22037b11dc0e8c29ce3f291d3b8c5935a release-5.0
+bbd45126bc691f669c4ebdfbd74456cd274c6b92 release-5.0.1
diff --git a/pypy/doc/config/translation.gc.txt 
b/pypy/doc/config/translation.gc.txt
--- a/pypy/doc/config/translation.gc.txt
+++ b/pypy/doc/config/translation.gc.txt
@@ -1,24 +1,26 @@
 Choose the Garbage Collector used by the translated program.
-The good performing collectors are "hybrid" and "minimark".
-The default is "minimark".
+The recommended default is "incminimark".
 
   - "ref": reference counting. Takes very long to translate and the result is
-slow.
+slow.  Used only for tests.  Don't use it for real RPython programs.
 
-  - "marksweep": naive mark & sweep.
+  - "none": no GC.  Leaks everything.  Don't use it for real RPython
+programs: the rate of leaking is immense.
 
   - "semispace": a copying semi-space GC.
 
   - "generation": a generational GC using the semi-space GC for the
 older generation.
 
-  - "boehm": use the Boehm conservative GC.
-
   - "hybrid": a hybrid collector of "generation" together with a
 mark-n-sweep old space
 
-  - "markcompact": a slow, but memory-efficient collector,
-influenced e.g. by Smalltalk systems.
+  - "boehm": use the Boehm conservative GC.
 
   - "minimark": a generational mark-n-sweep collector with good
 performance.  Includes page marking for large arrays.
+
+  - "incminimark": like minimark, but adds incremental major
+collections.  Seems to come with no performance drawback over
+"minimark", so it is the default.  A few recent features of PyPy
+(like cpyext) are only working with this GC.
diff --git a/pypy/doc/extradoc.rst b/pypy/doc/extradoc.rst
--- a/pypy/doc/extradoc.rst
+++ b/pypy/doc/extradoc.rst
@@ -80,7 +80,7 @@
 .. _How to *not* write Virtual Machines for Dynamic Languages: 
https://bitbucket.org/pypy/extradoc/raw/tip/talk/dyla2007/dyla.pdf
 .. _`Tracing the Meta-Level: PyPy's Tracing JIT Compiler`: 
https://bitbucket.org/pypy/extradoc/raw/tip/talk/icooolps2009/bolz-tracing-jit.pdf
 .. _`Faster than C#: Efficient Implementation of Dynamic Languages on .NET`: 
https://bitbucket.org/pypy/extradoc/raw/tip/talk/icooolps2009-dotnet/cli-jit.pdf
-.. _Automatic JIT Compiler Generation with Runtime Partial Evaluation: 
http://wwwold.cobra.cs.uni-duesseldorf.de/thesis/final-master.pdf
+.. _Automatic JIT Compiler Generation with Runtime Partial Evaluation: 
http://stups.hhu.de/mediawiki/images/b/b9/Master_bolz.pdf
 .. _`RPython: A Step towards Reconciling Dynamically and Statically Typed OO 
Languages`: 
http://www.disi.unige.it/person/AnconaD/papers/DynamicLanguages_abstracts.html#AACM-DLS07
 .. _EU Reports: index-report.html
 .. _Hardware Transactional Memory Support for Lightweight Dynamic Language 
Evolution: http://sabi.net/nriley/pubs/dls6-riley.pdf
diff --git a/pypy/doc/index-of-release-notes.rst 
b/pypy/doc/index-of-release-notes.rst
--- a/pypy/doc/index-of-release-notes.rst
+++ b/pypy/doc/index-of-release-notes.rst
@@ -6,6 +6,7 @@
 
 .. toctree::
 
+   release-5.0.1.rst
release-5.0.0.rst
release-4.0.1.rst
release-4.0.0.rst
diff --git a/pypy/doc/release-5.0.1.rst b/pypy/doc/release-5.0.1.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/release-5.0.1.rst
@@ -0,0 +1,40 @@
+==
+PyPy 5.0.1
+==
+
+We have released a bugfix for PyPy 5.0, after reports that the newly released
+`lxml 3.6.0`_, which now supports PyPy 5.0 +, can `crash on large files`_.
+Thanks to those who reported the crash. Please update, downloads are available
+at pypy.org/download.html
+
+.. _`lxml 3.6.0`: https://pypi.python.org/pypi/lxml/3.6.0
+.. _`crash on large files`: https://bitbucket.org/pypy/pypy/issues/2260
+
+The changes between PyPy 5.0 and 5.0.1 are only two bug fixes: one in
+cpyext, which fixes notably (but not only) lxml; and another for a
+corner case of the JIT.
+
+What is PyPy?
+=
+
+PyPy is a very compliant Python interpreter, almost a drop-in replacement for
+CPython 2.7. It's fast (`PyPy and CPython 2.7.x`_ performance comparison)
+due to its integrated tracing JIT compiler.
+
+We also welcome developers of other
+`dynamic languages`_ to see what RPython can do for them.
+
+This release supports **x86** machines on most common operating systems
+(Linux 32/64, Mac OS X 64, Windows 32, OpenBSD, FreeBSD),
+newer **ARM** hardware (ARMv6 or ARMv7, with VFPv3) running Linux, and the
+big- and little-endian variants of **PPC64** running Linux.
+
+.. _`PyPy and CPython 2.7.x`: http://speed.pypy.org
+.. _`dynamic languages`: http://pypyjs.org
+
+Please update, and continue to help us 

[pypy-commit] pypy guard-compatible: print a bit less

2016-03-25 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r83379:9c4f6b7c5e3e
Date: 2016-03-25 22:14 +0100
http://bitbucket.org/pypy/pypy/changeset/9c4f6b7c5e3e/

Log:print a bit less

diff --git a/rpython/jit/metainterp/compatible.py 
b/rpython/jit/metainterp/compatible.py
--- a/rpython/jit/metainterp/compatible.py
+++ b/rpython/jit/metainterp/compatible.py
@@ -36,6 +36,8 @@
 if oldcond.same_cond(cond, res):
 return
 cond.activate(res, optimizer)
+if self.conditions and self.conditions.debug_mp_str == 
cond.debug_mp_str:
+cond.debug_mp_str = ''
 self.conditions.append(cond)
 
 def register_quasi_immut_field(self, op):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: grumble

2016-03-25 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r83377:dd33eb1a6551
Date: 2016-03-25 16:39 +0100
http://bitbucket.org/pypy/pypy/changeset/dd33eb1a6551/

Log:grumble

diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -2218,7 +2218,7 @@
 
 
 def attach_debug_info(self, op):
-if (op is not None and self.framestack is not None):
+if (op is not None and self.framestack):
 if not we_are_translated():
 op.pc = self.framestack[-1].pc
 op.rpyfunc = self.framestack[-1].jitcode.name
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: do annspecialcase for lookup after the mapdict stuff

2016-03-25 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r83374:a5db7ce2b186
Date: 2016-03-25 09:23 +0100
http://bitbucket.org/pypy/pypy/changeset/a5db7ce2b186/

Log:do annspecialcase for lookup after the mapdict stuff

diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -1145,11 +1145,11 @@
 # 
 # various functions that replace objspace implementations
 
+@objectmodel.specialize.arg_or_var(2)
 def mapdict_lookup(space, w_obj, name):
 if we_are_jitted():
 map = w_obj._get_mapdict_map_no_promote()
 if map is not None:
 return map._type_lookup(name)
-w_type = space.type(w_obj)
-return w_type.lookup(name)
+return space._lookup(w_obj, name)
 
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -323,10 +323,15 @@
 jit.promote(w_obj.__class__)
 return w_obj.getclass(self)
 
+@specialize.arg_or_var(2)
 def lookup(self, w_obj, name):
 if self.config.objspace.std.withmapdict:
 from pypy.objspace.std.mapdict import mapdict_lookup
 return mapdict_lookup(self, w_obj, name)
+# an indirection for the benefit of mapdict
+return self._lookup(w_obj, name)
+
+def _lookup(self, w_obj, name):
 w_type = self.type(w_obj)
 return w_type.lookup(name)
 lookup._annspecialcase_ = 'specialize:lookup'
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy follow_symlinks: Make 'times' argument in os.utime() optional

2016-03-25 Thread rlamy
Author: Ronan Lamy 
Branch: follow_symlinks
Changeset: r83373:8c01214d65d7
Date: 2016-03-25 21:01 +
http://bitbucket.org/pypy/pypy/changeset/8c01214d65d7/

Log:Make 'times' argument in os.utime() optional

diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1193,7 +1193,7 @@
 return space.wrap(ret)
 
 
-@unwrap_spec(w_ns=kwonly(WrappedDefault(None)),
+@unwrap_spec(w_times=WrappedDefault(None), w_ns=kwonly(WrappedDefault(None)),
 dir_fd=DirFD(rposix.HAVE_UTIMENSAT), follow_symlinks=kwonly(bool))
 def utime(space, w_path, w_times, w_ns, dir_fd=DEFAULT_DIR_FD, 
follow_symlinks=True):
 """utime(path, times=None, *, ns=None, dir_fd=None, follow_symlinks=True)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: pass list of resops here

2016-03-25 Thread fijal
Author: fijal
Branch: 
Changeset: r83371:09249cf47b13
Date: 2016-03-25 22:42 +0200
http://bitbucket.org/pypy/pypy/changeset/09249cf47b13/

Log:pass list of resops here

diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -2256,7 +2256,7 @@
 jd_sd.warmstate.get_location_str(greenkey),
 self.staticdata.logger_ops._make_log_operations(
 self.box_names_memo),
-self.history.trace)
+self.history.trace.unpack()[1])
 if self.aborted_tracing_jitdriver is not None:
 jd_sd = self.aborted_tracing_jitdriver
 greenkey = self.aborted_tracing_greenkey
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy follow_symlinks: Implement missing features in chmod()

2016-03-25 Thread rlamy
Author: Ronan Lamy 
Branch: follow_symlinks
Changeset: r83372:d8c010696602
Date: 2016-03-25 20:42 +
http://bitbucket.org/pypy/pypy/changeset/d8c010696602/

Log:Implement missing features in chmod()

diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1,6 +1,7 @@
 import os
 import sys
 from math import modf
+from errno import ENOTSUP, EOPNOTSUPP
 
 from rpython.rlib import rposix, rposix_stat
 from rpython.rlib import objectmodel, rurandom
@@ -113,19 +114,22 @@
 DEFAULT_DIR_FD = -100
 DIR_FD_AVAILABLE = False
 
-def _unwrap_fd(space, w_value):
+def unwrap_fd(space, w_value):
+return space.c_int_w(w_value)
+
+def _unwrap_dirfd(space, w_value):
 if space.is_none(w_value):
 return DEFAULT_DIR_FD
 else:
-return space.c_int_w(w_value)
+return unwrap_fd(space, w_value)
 
 class _DirFD(Unwrapper):
 def unwrap(self, space, w_value):
-return _unwrap_fd(space, w_value)
+return _unwrap_dirfd(space, w_value)
 
 class _DirFD_Unavailable(Unwrapper):
 def unwrap(self, space, w_value):
-dir_fd = _unwrap_fd(space, w_value)
+dir_fd = unwrap_fd(space, w_value)
 if dir_fd == DEFAULT_DIR_FD:
 return dir_fd
 else:
@@ -140,7 +144,7 @@
 def argument_unavailable(space, funcname, arg):
 return oefmt(
 space.w_NotImplementedError,
-"%s: %s unavailable on this platform" % (funcname, arg))
+"%s: %s unavailable on this platform", funcname, arg)
 
 @unwrap_spec(flags=c_int, mode=c_int, dir_fd=DirFD(rposix.HAVE_OPENAT))
 def open(space, w_path, flags, mode=0777, dir_fd=DEFAULT_DIR_FD):
@@ -477,9 +481,9 @@
   of R_OK, W_OK, and X_OK."""
 if not rposix.HAVE_FACCESSAT:
 if not follow_symlinks:
-raise argument_unavailable("access", "follow_symlinks")
+raise argument_unavailable(space, "access", "follow_symlinks")
 if effective_ids:
-raise argument_unavailable("access", "effective_ids")
+raise argument_unavailable(space, "access", "effective_ids")
 
 try:
 if dir_fd == DEFAULT_DIR_FD and follow_symlinks and not effective_ids:
@@ -773,7 +777,7 @@
 raise wrap_oserror(space, e)
 return space.newtuple([space.wrap(fd1), space.wrap(fd2)])
 
-@unwrap_spec(mode=c_int, dir_fd=DirFD(available=False), 
follow_symlinks=kwonly(bool))
+@unwrap_spec(mode=c_int, dir_fd=DirFD(rposix.HAVE_FCHMODAT), 
follow_symlinks=kwonly(bool))
 def chmod(space, w_path, mode, dir_fd=DEFAULT_DIR_FD, follow_symlinks=True):
 """chmod(path, mode, *, dir_fd=None, follow_symlinks=True)
 
@@ -791,21 +795,55 @@
   an open file descriptor.
 dir_fd and follow_symlinks may not be implemented on your platform.
   If they are unavailable, using them will raise a NotImplementedError."""
+if not rposix.HAVE_FCHMODAT:
+if not follow_symlinks:
+raise argument_unavailable(space, "chmod", "follow_symlinks")
+else:
+try:
+dispatch_filename(rposix.chmod)(space, w_path, mode)
+return
+except OSError as e:
+raise wrap_oserror2(space, e, w_path)
+
 try:
-dispatch_filename(rposix.chmod)(space, w_path, mode)
-except OSError, e:
-raise wrap_oserror2(space, e, w_path)
+path = space.fsencode_w(w_path)
+except OperationError as operr:
+if not space.isinstance_w(w_path, space.w_int):
+raise oefmt(space.w_TypeError,
+"argument should be string, bytes or integer, not %T", w_path)
+fd = unwrap_fd(space, w_path)
+_chmod_fd(space, fd, mode)
+else:
+try:
+_chmod_path(path, mode, dir_fd, follow_symlinks)
+except OSError as e:
+if not follow_symlinks and e.errno in (ENOTSUP, EOPNOTSUPP):
+# fchmodat() doesn't actually implement follow_symlinks=False
+# so raise NotImplementedError in this case
+raise argument_unavailable(space, "chmod", "follow_symlinks")
+else:
+raise wrap_oserror2(space, e, w_path)
 
-@unwrap_spec(mode=c_int)
-def fchmod(space, w_fd, mode):
-"""Change the access permissions of the file given by file
-descriptor fd."""
-fd = space.c_filedescriptor_w(w_fd)
+def _chmod_path(path, mode, dir_fd, follow_symlinks):
+if dir_fd != DEFAULT_DIR_FD or not follow_symlinks:
+rposix.fchmodat(path, mode, dir_fd, follow_symlinks)
+else:
+rposix.chmod(path, mode)
+
+def _chmod_fd(space, fd, mode):
 try:
 os.fchmod(fd, mode)
-except OSError, e:
+except OSError as e:
 raise wrap_oserror(space, e)
 
+
+@unwrap_spec(fd=c_int, mode=c_int)
+def fchmod(space, fd, mode):
+"""\
+Change the access permissions of the file given by file descriptor fd.
+"""
+

[pypy-commit] pypy default: fix

2016-03-25 Thread fijal
Author: fijal
Branch: 
Changeset: r83370:55bbf61581a3
Date: 2016-03-25 22:19 +0200
http://bitbucket.org/pypy/pypy/changeset/55bbf61581a3/

Log:fix

diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -34,9 +34,12 @@
 check_range = False
 # we can move SMALL ints here, if necessary
 
+def get_model(self):
+return _get_model(self.metainterp_sd)
+
 @specialize.memo()
-def get_model(self):
-return getattr(self.metainterp_sd, 'opencoder_model', Model)
+def _get_model(metainterp_sd):
+return getattr(metainterp_sd, 'opencoder_model', Model)
 
 SMALL_INT_STOP  = (2 ** (15 - TAGSHIFT)) - 1
 SMALL_INT_START = -SMALL_INT_STOP # we might want to distribute them uneven
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy faster-traceback: work work work

2016-03-25 Thread fijal
Author: fijal
Branch: faster-traceback
Changeset: r83369:13d1a1f6b325
Date: 2016-03-25 22:18 +0200
http://bitbucket.org/pypy/pypy/changeset/13d1a1f6b325/

Log:work work work

diff --git a/pypy/module/_vmprof/interp_vmprof.py 
b/pypy/module/_vmprof/interp_vmprof.py
--- a/pypy/module/_vmprof/interp_vmprof.py
+++ b/pypy/module/_vmprof/interp_vmprof.py
@@ -5,7 +5,7 @@
 from pypy.interpreter.baseobjspace import W_Root
 from rpython.rlib import rvmprof
 
-from rpython.rtyper.lltypesystem import lltype
+from rpython.rtyper.lltypesystem import lltype, rffi
 
 
 # 
@@ -91,8 +91,8 @@
 MAX_SIZE = 1000
 l = []
 
-with lltype.scoped_alloc(lltype.Signed, MAX_SIZE) as buf:
-n = rvmprof._get_vmprof().cintf.get_stack_trace_default(
+with lltype.scoped_alloc(rffi.CArray(lltype.Signed), MAX_SIZE) as buf:
+n = rvmprof._get_vmprof().cintf.vmprof_get_stack_trace_default(
 buf, MAX_SIZE)
 for i in range(n):
 l.append(buf[i])
diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -34,9 +34,12 @@
 check_range = False
 # we can move SMALL ints here, if necessary
 
+def get_model(self):
+return _get_model(self.metainterp_sd)
+
 @specialize.memo()
-def get_model(self):
-return getattr(self.metainterp_sd, 'opencoder_model', Model)
+def _get_model(metainterp_sd):
+return getattr(metainterp_sd, 'opencoder_model', Model)
 
 SMALL_INT_STOP  = (2 ** (15 - TAGSHIFT)) - 1
 SMALL_INT_START = -SMALL_INT_STOP # we might want to distribute them uneven
diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py
--- a/rpython/rlib/rvmprof/cintf.py
+++ b/rpython/rlib/rvmprof/cintf.py
@@ -58,7 +58,7 @@
 vmprof_get_stack_trace_default = rffi.llexternal(
 "vmprof_get_stack_trace_default",
 [rffi.CArrayPtr(lltype.Signed), rffi.INT],
-rffi.INT, compilation_info=eci, threadsafe=False)
+rffi.INT, compilation_info=eci, releasegil=False)
 return CInterface(locals())
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy faster-traceback: try to get a raw way of getting traceback quickly

2016-03-25 Thread fijal
Author: fijal
Branch: faster-traceback
Changeset: r83368:5c1292c4398f
Date: 2016-03-25 21:32 +0200
http://bitbucket.org/pypy/pypy/changeset/5c1292c4398f/

Log:try to get a raw way of getting traceback quickly

diff --git a/pypy/module/__pypy__/interp_traceback.py 
b/pypy/module/__pypy__/interp_traceback.py
new file mode 100644
diff --git a/pypy/module/_vmprof/__init__.py b/pypy/module/_vmprof/__init__.py
--- a/pypy/module/_vmprof/__init__.py
+++ b/pypy/module/_vmprof/__init__.py
@@ -13,6 +13,8 @@
 'disable': 'interp_vmprof.disable',
 'write_all_code_objects': 'interp_vmprof.write_all_code_objects',
 'VMProfError': 'space.fromcache(interp_vmprof.Cache).w_VMProfError',
+'get_fast_traceback' : 'interp_vmprof.get_fast_traceback',
+'code_get_unique_id' : 'interp_vmprof.code_get_unique_id',
 }
 
 
diff --git a/pypy/module/_vmprof/interp_vmprof.py 
b/pypy/module/_vmprof/interp_vmprof.py
--- a/pypy/module/_vmprof/interp_vmprof.py
+++ b/pypy/module/_vmprof/interp_vmprof.py
@@ -5,6 +5,9 @@
 from pypy.interpreter.baseobjspace import W_Root
 from rpython.rlib import rvmprof
 
+from rpython.rtyper.lltypesystem import lltype
+
+
 # 
 
 
@@ -82,3 +85,20 @@
 rvmprof.disable()
 except rvmprof.VMProfError, e:
 raise VMProfError(space, e)
+
+
+def get_fast_traceback(space):
+MAX_SIZE = 1000
+l = []
+
+with lltype.scoped_alloc(lltype.Signed, MAX_SIZE) as buf:
+n = rvmprof._get_vmprof().cintf.get_stack_trace_default(
+buf, MAX_SIZE)
+for i in range(n):
+l.append(buf[i])
+return space.newlist_int(l)
+
+@unwrap_spec(w_code=PyCode)
+def code_get_unique_id(space, w_code):
+return space.wrap(w_code._vmprof_unique_id)
+
diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py
--- a/rpython/rlib/rvmprof/cintf.py
+++ b/rpython/rlib/rvmprof/cintf.py
@@ -55,6 +55,10 @@
 [rffi.INT], lltype.Void,
 compilation_info=eci,
 _nowrapper=True)
+vmprof_get_stack_trace_default = rffi.llexternal(
+"vmprof_get_stack_trace_default",
+[rffi.CArrayPtr(lltype.Signed), rffi.INT],
+rffi.INT, compilation_info=eci, threadsafe=False)
 return CInterface(locals())
 
 
diff --git a/rpython/rlib/rvmprof/src/vmprof_common.h 
b/rpython/rlib/rvmprof/src/vmprof_common.h
--- a/rpython/rlib/rvmprof/src/vmprof_common.h
+++ b/rpython/rlib/rvmprof/src/vmprof_common.h
@@ -119,3 +119,8 @@
 return 0;
 }
 #endif
+
+static int get_stack_trace_default(intptr_t *result, int max_depth)
+{
+return get_stack_trace(get_vmprof_stack(), result, max_depth, 0);
+}
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: remerge jit-leaner-frontend

2016-03-25 Thread fijal
Author: fijal
Branch: 
Changeset: r83367:2094e6aab3b2
Date: 2016-03-25 21:09 +0200
http://bitbucket.org/pypy/pypy/changeset/2094e6aab3b2/

Log:remerge jit-leaner-frontend

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


[pypy-commit] pypy jit-leaner-frontend: close merged branch

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83366:5044de96586a
Date: 2016-03-25 21:08 +0200
http://bitbucket.org/pypy/pypy/changeset/5044de96586a/

Log:close merged branch

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


[pypy-commit] pypy default: fix whatsnew

2016-03-25 Thread fijal
Author: fijal
Branch: 
Changeset: r83365:857e78c019da
Date: 2016-03-25 20:55 +0200
http://bitbucket.org/pypy/pypy/changeset/857e78c019da/

Log:fix whatsnew

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -27,3 +27,8 @@
 .. branch: fix_transpose_for_list_v3
 
 Allow arguments to transpose to be sequences
+
+.. branch: jit-leaner-frontend
+
+Improve the tracing speed in the frontend as well as heapcache by using a more 
compact representation
+of traces
\ No newline at end of file
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: (fijal, arigo) Merge jit-leaner-frontend

2016-03-25 Thread fijal
Author: fijal
Branch: 
Changeset: r83364:913dd4cf97ff
Date: 2016-03-25 20:54 +0200
http://bitbucket.org/pypy/pypy/changeset/913dd4cf97ff/

Log:(fijal, arigo) Merge jit-leaner-frontend

This branch separates resoperations used in optimizer from the ones
used in the frontend, which now uses a more compact way to store
traces. Additionally the heapcache has been reworked to the new
model. The net effects are ~20% improvements in the speed of
tracing. There is potential for more work which would avoid
allocating ResOperations that are not emitted completely

diff too long, truncating to 2000 out of 8331 lines

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -46,7 +46,6 @@
 except detect_cpu.ProcessorAutodetectError:
 pass
 
-
 translation_modules = default_modules.copy()
 translation_modules.update([
 "fcntl", "time", "select", "signal", "_rawffi", "zlib", "struct", "_md5",
diff --git a/pypy/tool/gdb_pypy.py b/pypy/tool/gdb_pypy.py
--- a/pypy/tool/gdb_pypy.py
+++ b/pypy/tool/gdb_pypy.py
@@ -288,9 +288,11 @@
 RPyListPrinter.recursive = True
 try:
 itemlist = []
-for i in range(length):
+for i in range(min(length, MAX_DISPLAY_LENGTH)):
 item = items[i]
 itemlist.append(str(item))# may recurse here
+if length > MAX_DISPLAY_LENGTH:
+itemlist.append("...")
 str_items = ', '.join(itemlist)
 finally:
 RPyListPrinter.recursive = False
diff --git a/rpython/config/translationoption.py 
b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -126,6 +126,9 @@
 ChoiceOption("jit_profiler", "integrate profiler support into the JIT",
  ["off", "oprofile"],
  default="off"),
+ChoiceOption("jit_opencoder_model", "the model limits the maximal length"
+ " of traces. Use big if you want to go bigger than "
+ "the default", ["big", "normal"], default="normal"),
 BoolOption("check_str_without_nul",
"Forbid NUL chars in strings in some external function calls",
default=False, cmdline=None),
diff --git a/rpython/jit/backend/llgraph/runner.py 
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -455,7 +455,7 @@
 if box is not frame.current_op:
 value = frame.env[box]
 else:
-value = box.getvalue()# 0 or 0.0 or NULL
+value = 0 # box.getvalue()# 0 or 0.0 or NULL
 else:
 value = None
 values.append(value)
@@ -472,6 +472,13 @@
 
 # 
 
+def setup_descrs(self):
+all_descrs = []
+for k, v in self.descrs.iteritems():
+v.descr_index = len(all_descrs)
+all_descrs.append(v)
+return all_descrs
+
 def calldescrof(self, FUNC, ARGS, RESULT, effect_info):
 key = ('call', getkind(RESULT),
tuple([getkind(A) for A in ARGS]),
diff --git a/rpython/jit/backend/llsupport/assembler.py 
b/rpython/jit/backend/llsupport/assembler.py
--- a/rpython/jit/backend/llsupport/assembler.py
+++ b/rpython/jit/backend/llsupport/assembler.py
@@ -331,7 +331,7 @@
 counter = self._register_counter(tp, number, token)
 c_adr = ConstInt(rffi.cast(lltype.Signed, counter))
 operations.append(
-ResOperation(rop.INCREMENT_DEBUG_COUNTER, [c_adr], None))
+ResOperation(rop.INCREMENT_DEBUG_COUNTER, [c_adr]))
 
 def _register_counter(self, tp, number, token):
 # YYY very minor leak -- we need the counters to stay alive
diff --git a/rpython/jit/backend/llsupport/descr.py 
b/rpython/jit/backend/llsupport/descr.py
--- a/rpython/jit/backend/llsupport/descr.py
+++ b/rpython/jit/backend/llsupport/descr.py
@@ -21,6 +21,30 @@
 self._cache_call = {}
 self._cache_interiorfield = {}
 
+def setup_descrs(self):
+all_descrs = []
+for k, v in self._cache_size.iteritems():
+v.descr_index = len(all_descrs)
+all_descrs.append(v)
+for k, v in self._cache_field.iteritems():
+for k1, v1 in v.iteritems():
+v1.descr_index = len(all_descrs)
+all_descrs.append(v1)
+for k, v in self._cache_array.iteritems():
+v.descr_index = len(all_descrs)
+all_descrs.append(v)
+for k, v in self._cache_arraylen.iteritems():
+v.descr_index = len(all_descrs)
+all_descrs.append(v)
+for k, v in self._cache_call.iteritems():
+

[pypy-commit] pypy remove-frame-forcing-in-executioncontext: remove forcing of vref to see what happens

2016-03-25 Thread fijal
Author: fijal
Branch: remove-frame-forcing-in-executioncontext
Changeset: r83363:811209af057f
Date: 2016-03-25 17:50 +0200
http://bitbucket.org/pypy/pypy/changeset/811209af057f/

Log:remove forcing of vref to see what happens

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -278,17 +278,9 @@
 
 def get_traceback(self):
 """Calling this marks the PyTraceback as escaped, i.e. it becomes
-accessible and inspectable by app-level Python code.  For the JIT.
-Note that this has no effect if there are already several traceback
-frames recorded, because in this case they are already marked as
-escaping by executioncontext.leave() being called with
-got_exception=True.
+accessible and inspectable by app-level Python code.
 """
-from pypy.interpreter.pytraceback import PyTraceback
-tb = self._application_traceback
-if tb is not None and isinstance(tb, PyTraceback):
-tb.frame.mark_as_escaped()
-return tb
+return self._application_traceback
 
 def set_traceback(self, traceback):
 """Set the current traceback.  It should either be a traceback
diff --git a/pypy/interpreter/executioncontext.py 
b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -74,15 +74,6 @@
 finally:
 frame_vref = self.topframeref
 self.topframeref = frame.f_backref
-if frame.escaped or got_exception:
-# if this frame escaped to applevel, we must ensure that also
-# f_back does
-f_back = frame.f_backref()
-if f_back:
-f_back.mark_as_escaped()
-# force the frame (from the JIT point of view), so that it can
-# be accessed also later
-frame_vref()
 jit.virtual_ref_finish(frame_vref, frame)
 
 # 
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -65,7 +65,6 @@
 last_exception   = None
 f_backref= jit.vref_None
 
-escaped  = False  # see mark_as_escaped()
 debugdata= None
 
 pycode = None # code object executed by that frame
@@ -152,15 +151,6 @@
 assert isinstance(cell, Cell)
 return cell
 
-def mark_as_escaped(self):
-"""
-Must be called on frames that are exposed to applevel, e.g. by
-sys._getframe().  This ensures that the virtualref holding the frame
-is properly forced by ec.leave(), and thus the frame will be still
-accessible even after the corresponding C stack died.
-"""
-self.escaped = True
-
 def append_block(self, block):
 assert block.previous is self.lastblock
 self.lastblock = block
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
@@ -37,7 +37,6 @@
 raise OperationError(space.w_ValueError,
  space.wrap("call stack is not deep enough"))
 if depth == 0:
-f.mark_as_escaped()
 return space.wrap(f)
 depth -= 1
 f = ec.getnextframe_nohidden(f)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: reenable jit hooks

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83362:2e8ef5f3792a
Date: 2016-03-25 16:21 +0200
http://bitbucket.org/pypy/pypy/changeset/2e8ef5f3792a/

Log:reenable jit hooks

diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -336,7 +336,7 @@
 def jitpolicy(self, driver):
 from pypy.module.pypyjit.policy import PyPyJitPolicy
 from pypy.module.pypyjit.hooks import pypy_hooks
-return PyPyJitPolicy() #pypy_hooks)
+return PyPyJitPolicy(pypy_hooks)
 
 def get_entry_point(self, config):
 from pypy.tool.lib_pypy import import_from_lib_pypy
diff --git a/pypy/module/pypyjit/__init__.py b/pypy/module/pypyjit/__init__.py
--- a/pypy/module/pypyjit/__init__.py
+++ b/pypy/module/pypyjit/__init__.py
@@ -12,9 +12,9 @@
 'dont_trace_here': 'interp_jit.dont_trace_here',
 'trace_next_iteration': 'interp_jit.trace_next_iteration',
 'trace_next_iteration_hash': 'interp_jit.trace_next_iteration_hash',
-#'set_compile_hook': 'interp_resop.set_compile_hook',
-#'set_abort_hook': 'interp_resop.set_abort_hook',
-#'set_trace_too_long_hook': 'interp_resop.set_trace_too_long_hook',
+'set_compile_hook': 'interp_resop.set_compile_hook',
+'set_abort_hook': 'interp_resop.set_abort_hook',
+'set_trace_too_long_hook': 'interp_resop.set_trace_too_long_hook',
 'get_stats_snapshot': 'interp_resop.get_stats_snapshot',
 'get_stats_asmmemmgr': 'interp_resop.get_stats_asmmemmgr',
 # those things are disabled because they have bugs, but if
@@ -23,10 +23,10 @@
 # correct loop_runs if PYPYLOG is correct
 #'enable_debug': 'interp_resop.enable_debug',
 #'disable_debug': 'interp_resop.disable_debug',
-#'ResOperation': 'interp_resop.WrappedOp',
-#'GuardOp': 'interp_resop.GuardOp',
-#'DebugMergePoint': 'interp_resop.DebugMergePoint',
-#'JitLoopInfo': 'interp_resop.W_JitLoopInfo',
+'ResOperation': 'interp_resop.WrappedOp',
+'GuardOp': 'interp_resop.GuardOp',
+'DebugMergePoint': 'interp_resop.DebugMergePoint',
+'JitLoopInfo': 'interp_resop.W_JitLoopInfo',
 'PARAMETER_DOCS': 'space.wrap(rpython.rlib.jit.PARAMETER_DOCS)',
 }
 
diff --git a/pypy/module/pypyjit/interp_resop.py 
b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -249,7 +249,7 @@
 ofs = debug_info.asminfo.ops_offset
 else:
 ofs = {}
-_, ops = debug_info.trace.unpack()
+ops = debug_info.operations
 self.w_ops = space.newlist(wrap_oplist(space, logops, ops, ofs))
 else:
 self.w_ops = space.w_None
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: be a bit more specific about problems

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83361:dc43144bc017
Date: 2016-03-25 16:16 +0200
http://bitbucket.org/pypy/pypy/changeset/dc43144bc017/

Log:be a bit more specific about problems

diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -782,6 +782,12 @@
 """Reset one of the tunable JIT parameters to its default value."""
 _set_param(driver, name, None)
 
+class TraceLimitTooHigh(Exception):
+""" This is raised when the trace limit is too high for the chosen
+opencoder model, recompile your interpreter with 'big' as
+jit_opencoder_model
+"""
+
 def set_user_param(driver, text):
 """Set the tunable JIT parameters from a user-supplied string
 following the format 'param=value,param=value', or 'off' to
@@ -809,6 +815,8 @@
 for name1, _ in unroll_parameters:
 if name1 == name and name1 != 'enable_opts':
 try:
+if name1 == 'trace_limit' and int(value) > 2**14:
+raise TraceLimitTooHigh
 set_param(driver, name1, int(value))
 except ValueError:
 raise
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: try to make an option for having two different models in case one wants to have really long traces

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83360:f364f082cc14
Date: 2016-03-25 16:05 +0200
http://bitbucket.org/pypy/pypy/changeset/f364f082cc14/

Log:try to make an option for having two different models in case one
wants to have really long traces

diff --git a/rpython/config/translationoption.py 
b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -126,6 +126,9 @@
 ChoiceOption("jit_profiler", "integrate profiler support into the JIT",
  ["off", "oprofile"],
  default="off"),
+ChoiceOption("jit_opencoder_model", "the model limits the maximal length"
+ " of traces. Use big if you want to go bigger than "
+ "the default", ["big", "normal"], default="normal"),
 BoolOption("check_str_without_nul",
"Forbid NUL chars in strings in some external function calls",
default=False, cmdline=None),
diff --git a/rpython/jit/metainterp/history.py 
b/rpython/jit/metainterp/history.py
--- a/rpython/jit/metainterp/history.py
+++ b/rpython/jit/metainterp/history.py
@@ -4,6 +4,7 @@
 from rpython.rlib.objectmodel import compute_unique_id, specialize
 from rpython.rlib.rarithmetic import r_int64, is_valid_int
 from rpython.rlib.rarithmetic import LONG_BIT, intmask, r_uint
+from rpython.rlib.jit import Counters
 
 from rpython.conftest import option
 
@@ -12,6 +13,7 @@
 opclasses
 from rpython.jit.codewriter import heaptracker, longlong
 import weakref
+from rpython.jit.metainterp import jitexc
 
 # 
 
@@ -25,6 +27,15 @@
 
 FAILARGS_LIMIT = 1000
 
+class SwitchToBlackhole(jitexc.JitException):
+def __init__(self, reason, raising_exception=False):
+self.reason = reason
+self.raising_exception = raising_exception
+# ^^^ must be set to True if the SwitchToBlackhole is raised at a
+# point where the exception on metainterp.last_exc_value
+# is supposed to be raised.  The default False means that it
+# should just be copied into the blackhole interp, but not raised.
+
 def getkind(TYPE, supports_floats=True,
   supports_longlong=True,
   supports_singlefloats=True):
@@ -712,12 +723,23 @@
 assert lltype.typeOf(value) == llmemory.GCREF
 op.setref_base(value)
 
+def _record_op(self, opnum, argboxes, descr=None):
+from rpython.jit.metainterp.opencoder import FrontendTagOverflow
+
+try:
+return self.trace.record_op(opnum, argboxes, descr)
+except FrontendTagOverflow:
+# note that with the default settings this one should not
+# happen - however if we hit that case, we don't get
+# anything disabled
+raise SwitchToBlackhole(Counters.ABORT_TOO_LONG)
+
 @specialize.argtype(3)
 def record(self, opnum, argboxes, value, descr=None):
 if self.trace is None:
 pos = 2**14 - 1
 else:
-pos = self.trace.record_op(opnum, argboxes, descr)
+pos = self._record_op(opnum, argboxes, descr)
 if value is None:
 op = FrontendOp(pos)
 elif isinstance(value, bool):
@@ -735,7 +757,7 @@
 
 def record_nospec(self, opnum, argboxes, descr=None):
 tp = opclasses[opnum].type
-pos = self.trace.record_op(opnum, argboxes, descr)
+pos = self._record_op(opnum, argboxes, descr)
 if tp == 'v':
 return FrontendOp(pos)
 elif tp == 'i':
diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -19,21 +19,32 @@
 TAGMASK = 0x3
 TAGSHIFT = 2
 
-STORAGE_TP = rffi.USHORT
-MAX_SIZE = 2**16-1
+class Model:
+STORAGE_TP = rffi.USHORT
+# this is the initial size of the trace - note that we probably
+# want something that would fit the inital "max_trace_length"
+INIT_SIZE = 3
+MIN_SHORT = 0
+MAX_SHORT = 2**16 - 1
+check_range = True
+
+class BigModel:
+INIT_SIZE = 3
+STORAGE_TP = lltype.Signed
+check_range = False
+# we can move SMALL ints here, if necessary
+
+@specialize.memo()
+def get_model(self):
+return getattr(self.metainterp_sd, 'opencoder_model', Model)
+
 SMALL_INT_STOP  = (2 ** (15 - TAGSHIFT)) - 1
 SMALL_INT_START = -SMALL_INT_STOP # we might want to distribute them uneven
-MIN_SHORT = 0
-MAX_SHORT = 2**16 - 1
 
 def expand_sizes_to_signed():
 """ This function will make sure we can use sizes all the
 way up to lltype.Signed for indexes everywhere
 """
-globals()['STORAGE_TP'] = lltype.Signed
-globals()['MAX_SIZE'] = 2**31-1
-globals()['MIN_SHORT'] = -2**31
-globals()['MAX_SHORT'] = 2**31 - 1
 
 class FrontendTagOverflow(Exception):
 pass
@@ -252,7 +263,8 @@
 

[pypy-commit] pypy jit-leaner-frontend: fix test_random

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83359:0b0fac585895
Date: 2016-03-25 15:27 +0200
http://bitbucket.org/pypy/pypy/changeset/0b0fac585895/

Log:fix test_random

diff --git a/rpython/jit/backend/test/test_random.py 
b/rpython/jit/backend/test/test_random.py
--- a/rpython/jit/backend/test/test_random.py
+++ b/rpython/jit/backend/test/test_random.py
@@ -718,7 +718,7 @@
 assert not hasattr(loop, '_targettoken')
 for i in range(position):
 op = loop.operations[i]
-if (not op.has_no_side_effect()
+if (not rop.has_no_side_effect(op.opnum)
 or op.type not in (INT, FLOAT)):
 position = i
 break   # cannot move the LABEL later
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: whack until tests pass

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83358:b29b22264d8f
Date: 2016-03-25 15:25 +0200
http://bitbucket.org/pypy/pypy/changeset/b29b22264d8f/

Log:whack until tests pass

diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -30,6 +30,10 @@
 """ This function will make sure we can use sizes all the
 way up to lltype.Signed for indexes everywhere
 """
+globals()['STORAGE_TP'] = lltype.Signed
+globals()['MAX_SIZE'] = 2**31-1
+globals()['MIN_SHORT'] = -2**31
+globals()['MAX_SHORT'] = 2**31 - 1
 
 class FrontendTagOverflow(Exception):
 pass
diff --git a/rpython/jit/metainterp/test/test_compile.py 
b/rpython/jit/metainterp/test/test_compile.py
--- a/rpython/jit/metainterp/test/test_compile.py
+++ b/rpython/jit/metainterp/test/test_compile.py
@@ -54,7 +54,7 @@
 loopnumbering = 0
 
 class FakeMetaInterpStaticData(object):
-
+all_descrs = []
 logger_noopt = FakeLogger()
 logger_ops = FakeLogger()
 config = get_combined_translation_config(translating=True)
diff --git a/rpython/jit/metainterp/test/test_opencoder.py 
b/rpython/jit/metainterp/test/test_opencoder.py
--- a/rpython/jit/metainterp/test/test_opencoder.py
+++ b/rpython/jit/metainterp/test/test_opencoder.py
@@ -54,7 +54,7 @@
 
 class TestOpencoder(object):
 def unpack(self, t):
-iter = t.get_iter(metainterp_sd)
+iter = t.get_iter()
 l = []
 while not iter.done():
 op = iter.next()
@@ -65,7 +65,7 @@
 
 def test_simple_iterator(self):
 i0, i1 = IntFrontendOp(0), IntFrontendOp(0)
-t = Trace([i0, i1])
+t = Trace([i0, i1], metainterp_sd)
 add = FakeOp(t.record_op(rop.INT_ADD, [i0, i1]))
 t.record_op(rop.INT_ADD, [add, ConstInt(1)])
 (i0, i1), l, _ = self.unpack(t)
@@ -79,7 +79,7 @@
 
 def test_rd_snapshot(self):
 i0, i1 = IntFrontendOp(0), IntFrontendOp(0)
-t = Trace([i0, i1])
+t = Trace([i0, i1], metainterp_sd)
 add = FakeOp(t.record_op(rop.INT_ADD, [i0, i1]))
 t.record_op(rop.GUARD_FALSE, [add])
 # now we write rd_snapshot and friends
@@ -103,7 +103,7 @@
 
 def test_read_snapshot_interface(self):
 i0, i1, i2 = IntFrontendOp(0), IntFrontendOp(0), IntFrontendOp(0)
-t = Trace([i0, i1, i2])
+t = Trace([i0, i1, i2], metainterp_sd)
 t.record_op(rop.GUARD_TRUE, [i1])
 frame0 = FakeFrame(1, JitCode(2), [i0, i1])
 frame1 = FakeFrame(3, JitCode(4), [i2, i2])
@@ -138,7 +138,7 @@
 @given(lists_of_operations())
 def xxx_test_random_snapshot(self, lst):
 inputargs, ops = lst
-t = Trace(inputargs)
+t = Trace(inputargs, metainterp_sd)
 for op in ops:
 newop = FakeOp(t.record_op(op.getopnum(), op.getarglist()))
 newop.orig_op = op
@@ -157,7 +157,7 @@
 
 def test_cut_trace_from(self):
 i0, i1, i2 = IntFrontendOp(0), IntFrontendOp(0), IntFrontendOp(0)
-t = Trace([i0, i1, i2])
+t = Trace([i0, i1, i2], metainterp_sd)
 add1 = FakeOp(t.record_op(rop.INT_ADD, [i0, i1]))
 cut_point = t.cut_point()
 add2 = FakeOp(t.record_op(rop.INT_ADD, [add1, i1]))
@@ -172,7 +172,7 @@
 
 def test_virtualizable_virtualref(self):
 i0, i1, i2 = IntFrontendOp(0), IntFrontendOp(0), IntFrontendOp(0)
-t = Trace([i0, i1, i2])
+t = Trace([i0, i1, i2], metainterp_sd)
 p0 = FakeOp(t.record_op(rop.NEW_WITH_VTABLE, [], descr=SomeDescr()))
 t.record_op(rop.GUARD_TRUE, [i0])
 resume.capture_resumedata([], [i1, i2, p0], [p0, i1], t)
@@ -183,15 +183,15 @@
 
 def test_liveranges(self):
 i0, i1, i2 = IntFrontendOp(0), IntFrontendOp(0), IntFrontendOp(0)
-t = Trace([i0, i1, i2])
+t = Trace([i0, i1, i2], metainterp_sd)
 p0 = FakeOp(t.record_op(rop.NEW_WITH_VTABLE, [], descr=SomeDescr()))
 t.record_op(rop.GUARD_TRUE, [i0])
 resume.capture_resumedata([], [i1, i2, p0], [p0, i1], t)
-assert t.get_live_ranges(metainterp_sd) == [4, 4, 4, 4]
+assert t.get_live_ranges() == [4, 4, 4, 4]
 
 def test_deadranges(self):
 i0, i1, i2 = IntFrontendOp(0), IntFrontendOp(0), IntFrontendOp(0)
-t = Trace([i0, i1, i2])
+t = Trace([i0, i1, i2], metainterp_sd)
 p0 = FakeOp(t.record_op(rop.NEW_WITH_VTABLE, [], descr=SomeDescr()))
 t.record_op(rop.GUARD_TRUE, [i0])
 resume.capture_resumedata([], [i1, i2, p0], [p0, i1], t)
@@ -203,4 +203,4 @@
 t.record_op(rop.ESCAPE_N, [ConstInt(3)])
 t.record_op(rop.ESCAPE_N, [ConstInt(3)])
 t.record_op(rop.FINISH, [i4])
-assert t.get_dead_ranges(metainterp_sd) == [0, 0, 0, 0, 0, 3, 4, 5]
+assert t.get_dead_ranges() == [0, 0, 0, 0, 0, 3, 4, 5]
diff --git a/rpython/jit/metainterp/test/test_pyjitpl.py 

[pypy-commit] pypy jit-leaner-frontend: one more thing

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83357:03de28875dfc
Date: 2016-03-25 14:51 +0200
http://bitbucket.org/pypy/pypy/changeset/03de28875dfc/

Log:one more thing

diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -2543,7 +2543,7 @@
 op2 = self.history.record(rop.SAVE_EXCEPTION, [], exception)
 self.history._cache = self.history._cache[i:] + 
self.history._cache[:i]
 self.history.record(rop.RESTORE_EXCEPTION, [op1, op2], None)
-self.history.set_inputargs(inputargs)
+self.history.set_inputargs(inputargs, self.staticdata)
 if exception_obj:
 self.execute_ll_raised(exception_obj)
 else:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: too eager :-)

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83356:acd5207f951c
Date: 2016-03-25 14:44 +0200
http://bitbucket.org/pypy/pypy/changeset/acd5207f951c/

Log:too eager :-)

diff --git a/rpython/jit/metainterp/optimizeopt/vector.py 
b/rpython/jit/metainterp/optimizeopt/vector.py
--- a/rpython/jit/metainterp/optimizeopt/vector.py
+++ b/rpython/jit/metainterp/optimizeopt/vector.py
@@ -185,7 +185,7 @@
 
 resop_count += 1
 
-if rop.is_primitive_array_access(op.opnum):
+if op.is_primitive_array_access():
 at_least_one_array_access = True
 
 if warmstate.vec_ratio > 0.0:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: fix some untested vectorization

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83355:1c9965d436b0
Date: 2016-03-25 14:38 +0200
http://bitbucket.org/pypy/pypy/changeset/1c9965d436b0/

Log:fix some untested vectorization

diff --git a/rpython/jit/metainterp/optimizeopt/vector.py 
b/rpython/jit/metainterp/optimizeopt/vector.py
--- a/rpython/jit/metainterp/optimizeopt/vector.py
+++ b/rpython/jit/metainterp/optimizeopt/vector.py
@@ -177,23 +177,23 @@
 guard_count = 0
 at_least_one_array_access = True
 for i,op in enumerate(loop.operations):
-if rop.is_jit_debug(op):
+if rop.is_jit_debug(op.opnum):
 continue
 
-if op.vector >= 0 and not op.is_guard():
+if op.vector >= 0 and not rop.is_guard(op.opnum):
 vector_instr += 1
 
 resop_count += 1
 
-if op.is_primitive_array_access():
+if rop.is_primitive_array_access(op.opnum):
 at_least_one_array_access = True
 
 if warmstate.vec_ratio > 0.0:
 # blacklist
-if rop.is_call(op) or rop.is_call_assembler(op):
+if rop.is_call(op.opnum) or rop.is_call_assembler(op.opnum):
 return True
 
-if op.is_guard():
+if rop.is_guard(op.opnum):
 guard_count += 1
 
 if not at_least_one_array_access:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: one more cast

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83354:93c65e378da3
Date: 2016-03-25 14:31 +0200
http://bitbucket.org/pypy/pypy/changeset/93c65e378da3/

Log:one more cast

diff --git a/rpython/jit/metainterp/resume.py b/rpython/jit/metainterp/resume.py
--- a/rpython/jit/metainterp/resume.py
+++ b/rpython/jit/metainterp/resume.py
@@ -232,7 +232,7 @@
 v = state.v
 liveboxes = state.liveboxes
 for item in arr:
-box = iter.get(item)
+box = iter.get(rffi.cast(lltype.Signed, item))
 box = optimizer.get_box_replacement(box)
 
 if isinstance(box, Const):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: specialize untag

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83353:cd2f966ad0ed
Date: 2016-03-25 14:24 +0200
http://bitbucket.org/pypy/pypy/changeset/cd2f966ad0ed/

Log:specialize untag

diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -11,7 +11,7 @@
 ResOperation, oparity, rop, opwithdescr, GuardResOp, IntOp, FloatOp, 
RefOp,\
 opclasses
 from rpython.rlib.rarithmetic import intmask, r_uint
-from rpython.rlib.objectmodel import we_are_translated
+from rpython.rlib.objectmodel import we_are_translated, specialize
 from rpython.rtyper.lltypesystem import rffi, lltype, llmemory
 from rpython.jit.metainterp.typesystem import llhelper
 
@@ -474,5 +474,6 @@
 #raise some error
 return (pos << TAGSHIFT) | kind
 
+@specialize.ll()
 def untag(tagged):
 return intmask(tagged) & TAGMASK, intmask(tagged) >> TAGSHIFT
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: more casting fun

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83352:bd8cbbe9d553
Date: 2016-03-25 14:04 +0200
http://bitbucket.org/pypy/pypy/changeset/bd8cbbe9d553/

Log:more casting fun

diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -385,7 +385,7 @@
 def _list_of_boxes(self, boxes):
 array = [rffi.cast(STORAGE_TP, 0)] * len(boxes)
 for i in range(len(boxes)):
-array[i] = self._encode(boxes[i])
+array[i] = self._encode_cast(boxes[i])
 return array
 
 def new_array(self, lgt):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: more fight

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83351:8f6875e3ff4a
Date: 2016-03-25 13:55 +0200
http://bitbucket.org/pypy/pypy/changeset/8f6875e3ff4a/

Log:more fight

diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -391,9 +391,12 @@
 def new_array(self, lgt):
 return [rffi.cast(STORAGE_TP, 0)] * lgt
 
+def _encode_cast(self, i):
+return rffi.cast(STORAGE_TP, self._encode(i))
+
 def create_top_snapshot(self, jitcode, pc, frame, flag, vable_boxes, 
vref_boxes):
 self._total_snapshots += 1
-array = frame.get_list_of_active_boxes(flag, self.new_array, 
self._encode)
+array = frame.get_list_of_active_boxes(flag, self.new_array, 
self._encode_cast)
 vable_array = self._list_of_boxes(vable_boxes)
 vref_array = self._list_of_boxes(vref_boxes)
 s = TopSnapshot(combine_uint(jitcode.index, pc), array, vable_array,
@@ -418,7 +421,7 @@
 
 def create_snapshot(self, jitcode, pc, frame, flag):
 self._total_snapshots += 1
-array = frame.get_list_of_active_boxes(flag, self.new_array, 
self._encode)
+array = frame.get_list_of_active_boxes(flag, self.new_array, 
self._encode_cast)
 return Snapshot(combine_uint(jitcode.index, pc), array)
 
 def get_iter(self):
@@ -469,7 +472,7 @@
 def tag(kind, pos):
 #if not SMALL_INT_START <= pos < SMALL_INT_STOP:
 #raise some error
-return rffi.cast(STORAGE_TP, (pos << TAGSHIFT) | kind)
+return (pos << TAGSHIFT) | kind
 
 def untag(tagged):
 return intmask(tagged) & TAGMASK, intmask(tagged) >> TAGSHIFT
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: merge

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83350:3de6e9371d12
Date: 2016-03-25 13:47 +0200
http://bitbucket.org/pypy/pypy/changeset/3de6e9371d12/

Log:merge

diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -295,7 +295,6 @@
 return None
 
 if ((warmstate.vec and jitdriver_sd.vec) or warmstate.vec_all):
-assert False
 from rpython.jit.metainterp.optimizeopt.vector import optimize_vector
 loop_info, loop_ops = optimize_vector(trace, metainterp_sd,
   jitdriver_sd, warmstate,
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py 
b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
@@ -828,7 +828,7 @@
 if hasattr(self, 'callinfocollection'):
 metainterp_sd.callinfocollection = self.callinfocollection
 #
-trace = oparser.convert_loop_to_trace(bridge)
+trace = oparser.convert_loop_to_trace(bridge, metainterp_sd)
 
 runtime_boxes = self.convert_values(bridge.operations[-1].getarglist(),
 values)
diff --git a/rpython/jit/metainterp/optimizeopt/vector.py 
b/rpython/jit/metainterp/optimizeopt/vector.py
--- a/rpython/jit/metainterp/optimizeopt/vector.py
+++ b/rpython/jit/metainterp/optimizeopt/vector.py
@@ -177,7 +177,7 @@
 guard_count = 0
 at_least_one_array_access = True
 for i,op in enumerate(loop.operations):
-if op.is_jit_debug():
+if rop.is_jit_debug(op):
 continue
 
 if op.vector >= 0 and not op.is_guard():
@@ -190,7 +190,7 @@
 
 if warmstate.vec_ratio > 0.0:
 # blacklist
-if op.is_call() or rop.is_call_assembler(op):
+if rop.is_call(op) or rop.is_call_assembler(op):
 return True
 
 if op.is_guard():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: improve casts

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83349:3fe35633374e
Date: 2016-03-25 13:47 +0200
http://bitbucket.org/pypy/pypy/changeset/3fe35633374e/

Log:improve casts

diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -26,6 +26,11 @@
 MIN_SHORT = 0
 MAX_SHORT = 2**16 - 1
 
+def expand_sizes_to_signed():
+""" This function will make sure we can use sizes all the
+way up to lltype.Signed for indexes everywhere
+"""
+
 class FrontendTagOverflow(Exception):
 pass
 
@@ -464,7 +469,7 @@
 def tag(kind, pos):
 #if not SMALL_INT_START <= pos < SMALL_INT_STOP:
 #raise some error
-return (pos << TAGSHIFT) | kind
+return rffi.cast(STORAGE_TP, (pos << TAGSHIFT) | kind)
 
 def untag(tagged):
 return intmask(tagged) & TAGMASK, intmask(tagged) >> TAGSHIFT
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: test_vector passing again. mostly issues with methods moved to rop from ResOperation

2016-03-25 Thread plan_rich
Author: Richard Plangger 
Branch: jit-leaner-frontend
Changeset: r83348:472192cef9c7
Date: 2016-03-25 12:38 +0100
http://bitbucket.org/pypy/pypy/changeset/472192cef9c7/

Log:test_vector passing again. mostly issues with methods moved to rop
from ResOperation

diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -295,7 +295,6 @@
 return None
 
 if ((warmstate.vec and jitdriver_sd.vec) or warmstate.vec_all):
-assert False
 from rpython.jit.metainterp.optimizeopt.vector import optimize_vector
 loop_info, loop_ops = optimize_vector(trace, metainterp_sd,
   jitdriver_sd, warmstate,
diff --git a/rpython/jit/metainterp/optimizeopt/vector.py 
b/rpython/jit/metainterp/optimizeopt/vector.py
--- a/rpython/jit/metainterp/optimizeopt/vector.py
+++ b/rpython/jit/metainterp/optimizeopt/vector.py
@@ -177,7 +177,7 @@
 guard_count = 0
 at_least_one_array_access = True
 for i,op in enumerate(loop.operations):
-if op.is_jit_debug():
+if rop.is_jit_debug(op):
 continue
 
 if op.vector >= 0 and not op.is_guard():
@@ -190,7 +190,7 @@
 
 if warmstate.vec_ratio > 0.0:
 # blacklist
-if op.is_call() or rop.is_call_assembler(op):
+if rop.is_call(op) or rop.is_call_assembler(op):
 return True
 
 if op.is_guard():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: missing argument, now optimizeopt tests all pass

2016-03-25 Thread plan_rich
Author: Richard Plangger 
Branch: jit-leaner-frontend
Changeset: r83347:c8d47f78736b
Date: 2016-03-25 12:21 +0100
http://bitbucket.org/pypy/pypy/changeset/c8d47f78736b/

Log:missing argument, now optimizeopt tests all pass

diff --git a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py 
b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
@@ -828,7 +828,7 @@
 if hasattr(self, 'callinfocollection'):
 metainterp_sd.callinfocollection = self.callinfocollection
 #
-trace = oparser.convert_loop_to_trace(bridge)
+trace = oparser.convert_loop_to_trace(bridge, metainterp_sd)
 
 runtime_boxes = self.convert_values(bridge.operations[-1].getarglist(),
 values)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: fix more tests

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83345:40b5c0262fc4
Date: 2016-03-25 13:12 +0200
http://bitbucket.org/pypy/pypy/changeset/40b5c0262fc4/

Log:fix more tests

diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py 
b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -29,7 +29,7 @@
 exp = parse(optops, namespace=self.namespace.copy())
 expected = convert_old_style_to_targets(exp, jump=True)
 call_pure_results = self._convert_call_pure_results(call_pure_results)
-trace = convert_loop_to_trace(loop)
+trace = convert_loop_to_trace(loop, FakeMetaInterpStaticData(self.cpu))
 compile_data = compile.SimpleCompileData(trace,
  call_pure_results)
 info, ops = self._do_optimize_loop(compile_data)
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebridge.py 
b/rpython/jit/metainterp/optimizeopt/test/test_optimizebridge.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebridge.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebridge.py
@@ -1,6 +1,6 @@
 
 from rpython.jit.metainterp.optimizeopt.test.test_util import BaseTest,\
- LLtypeMixin, convert_old_style_to_targets
+ LLtypeMixin, convert_old_style_to_targets, FakeMetaInterpStaticData
 from rpython.jit.metainterp import compile
 from rpython.jit.tool import oparser
 from rpython.jit.metainterp.resoperation import ResOperation, rop
@@ -28,7 +28,7 @@
 bridge = self.parse(bridge_ops)
 bridge.operations[-1].setdescr(jitcell_token)
 self.add_guard_future_condition(bridge)
-trace = oparser.convert_loop_to_trace(bridge)
+trace = oparser.convert_loop_to_trace(bridge, 
FakeMetaInterpStaticData(self.cpu))
 data = compile.BridgeCompileData(trace, 
self.convert_values(bridge.operations[-1].getarglist(), bridge_values),
  enable_opts=self.enable_opts,
 inline_short_preamble=inline_short_preamble)
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_unroll.py 
b/rpython/jit/metainterp/optimizeopt/test/test_unroll.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_unroll.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_unroll.py
@@ -5,7 +5,7 @@
 import py
 
 from rpython.jit.metainterp.optimizeopt.test.test_util import BaseTest,\
- LLtypeMixin
+ LLtypeMixin, FakeMetaInterpStaticData
 from rpython.jit.metainterp.optimizeopt.util import equaloplists
 from rpython.jit.metainterp.history import (TreeLoop, ConstInt,
 JitCellToken, TargetToken)
@@ -53,9 +53,7 @@
 preamble = TreeLoop('preamble')
 
 token = JitCellToken()
-start_label = ResOperation(rop.LABEL, inputargs, 
descr=TargetToken(token))
-stop_label = ResOperation(rop.LABEL, jump_args, descr=token)
-trace = oparser.convert_loop_to_trace(loop)
+trace = oparser.convert_loop_to_trace(loop, 
FakeMetaInterpStaticData(self.cpu))
 compile_data = LoopCompileData(trace, inputargs)
 start_state, newops = self._do_optimize_loop(compile_data)
 preamble.operations = newops
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py 
b/rpython/jit/metainterp/optimizeopt/test/test_util.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_util.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py
@@ -441,6 +441,7 @@
 vec = False
 
 class FakeMetaInterpStaticData(object):
+all_descrs = []
 
 def __init__(self, cpu):
 self.cpu = cpu
@@ -574,7 +575,7 @@
 #   descr=jump_op.getdescr())
 #end_label = jump_op.copy_and_change(opnum=rop.LABEL)
 call_pure_results = self._convert_call_pure_results(call_pure_results)
-t = convert_loop_to_trace(loop)
+t = convert_loop_to_trace(loop, FakeMetaInterpStaticData(self.cpu))
 preamble_data = compile.LoopCompileData(t, runtime_boxes,
 call_pure_results)
 start_state, preamble_ops = self._do_optimize_loop(preamble_data)
diff --git a/rpython/jit/metainterp/test/test_compile.py 
b/rpython/jit/metainterp/test/test_compile.py
--- a/rpython/jit/metainterp/test/test_compile.py
+++ b/rpython/jit/metainterp/test/test_compile.py
@@ -94,7 +94,7 @@
 metainterp.staticdata = staticdata
 metainterp.cpu = cpu
 metainterp.history = History()
-t = convert_loop_to_trace(loop)
+t = convert_loop_to_trace(loop, staticdata)
 metainterp.history.inputargs = t.inputargs
 metainterp.history.trace = t
 #
diff --git a/rpython/jit/tool/oparser.py b/rpython/jit/tool/oparser.py
--- a/rpython/jit/tool/oparser.py
+++ b/rpython/jit/tool/oparser.py
@@ -424,7 +424,7 @@
 

[pypy-commit] pypy jit-leaner-frontend: merge

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83346:1c4479dff8cd
Date: 2016-03-25 13:15 +0200
http://bitbucket.org/pypy/pypy/changeset/1c4479dff8cd/

Log:merge

diff --git a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py 
b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
@@ -14,9 +14,10 @@
 from rpython.jit.metainterp.optimizeopt.vector import (VectorizingOptimizer,
 MemoryRef, isomorphic, Pair, NotAVectorizeableLoop, VectorLoop,
 NotAProfitableLoop, GuardStrengthenOpt, CostModel, X86_CostModel,
-PackSet)
+PackSet, optimize_vector)
 from rpython.jit.metainterp.optimizeopt.schedule import (Scheduler,
 SchedulerState, VecScheduleState, Pack)
+from rpython.jit.metainterp.optimizeopt.optimizer import BasicLoopInfo
 from rpython.jit.metainterp.optimize import InvalidLoop
 from rpython.jit.metainterp import compile
 from rpython.jit.metainterp.resoperation import rop, ResOperation
@@ -74,6 +75,12 @@
 
 ARCH_VEC_REG_SIZE = 16
 
+class FakeWarmState(object):
+vec_all = False
+vec_cost = 0
+
+
+
 class VecTestHelper(DependencyBaseTest):
 
 enable_opts = "intbounds:rewrite:virtualize:string:earlyforce:pure:heap"
@@ -81,11 +88,17 @@
 jitdriver_sd = FakeJitDriverStaticData()
 
 def assert_vectorize(self, loop, expected_loop, call_pure_results=None):
-trace = convert_loop_to_trace(loop)
-compile_data = compile.LoopCompileData(trace, loop.jump.getarglist())
-state = self._do_optimize_loop(compile_data)
-loop.label = state[0].label_op
-loop.opererations = state[1]
+jump = ResOperation(rop.JUMP, loop.jump.getarglist(), 
loop.jump.getdescr())
+metainterp_sd = FakeMetaInterpStaticData(self.cpu)
+warmstate = FakeWarmState()
+loop.operations += [loop.jump]
+loop_info = BasicLoopInfo(loop.jump.getarglist(), None, jump)
+loop_info.label_op = ResOperation(rop.LABEL, loop.jump.getarglist(), 
loop.jump.getdescr())
+optimize_vector(None, metainterp_sd, self.jitdriver_sd, warmstate,
+loop_info, loop.operations)
+loop.operations = loop.operations[:-1]
+#loop.label = state[0].label_op
+#loop.operations = state[1]
 self.assert_equal(loop, expected_loop)
 
 def vectoroptimizer(self, loop):
diff --git a/rpython/jit/metainterp/optimizeopt/vector.py 
b/rpython/jit/metainterp/optimizeopt/vector.py
--- a/rpython/jit/metainterp/optimizeopt/vector.py
+++ b/rpython/jit/metainterp/optimizeopt/vector.py
@@ -117,7 +117,7 @@
 user_code = not jitdriver_sd.vec and warmstate.vec_all
 e = len(loop_ops)-1
 assert e > 0
-assert loop_ops[e].is_final()
+assert rop.is_final(loop_ops[e].getopnum())
 loop = VectorLoop(loop_info.label_op, loop_ops[:e], loop_ops[-1])
 if user_code and user_loop_bail_fast_path(loop, warmstate):
 return loop_info, loop_ops
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: remove descr after parse_loop in assert_vectorize, this is need to successfully convert the loop to a trace obj

2016-03-25 Thread plan_rich
Author: Richard Plangger 
Branch: jit-leaner-frontend
Changeset: r83343:2bbf906956f4
Date: 2016-03-25 11:08 +0100
http://bitbucket.org/pypy/pypy/changeset/2bbf906956f4/

Log:remove descr after parse_loop in assert_vectorize, this is need to
successfully convert the loop to a trace obj

diff --git a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py 
b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
@@ -82,12 +82,17 @@
 
 def assert_vectorize(self, loop, expected_loop, call_pure_results=None):
 jump = ResOperation(rop.LABEL, loop.jump.getarglist(), 
loop.jump.getdescr())
-trace = Trace(loop.label, jump, loop.operations)
-trace = self.convert_loop_to_packed(loop)
+# convert_loop_to_trace assumes that there are no descriptors
+# but because this optimization pass is after the normal optimization 
pass
+# parse_loop already set artificial resume descr!
+for op in loop.operations:
+if op.is_guard():
+op.setdescr(None)
+trace = convert_loop_to_trace(loop)
 compile_data = compile.LoopCompileData(trace, loop.jump.getarglist())
 state = self._do_optimize_loop(compile_data)
 loop.label = state[0].label_op
-loop.opererations = state[1]
+loop.operations = state[1]
 self.assert_equal(loop, expected_loop)
 
 def vectoroptimizer(self, loop):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: adapting the test interface for test_vecopt

2016-03-25 Thread plan_rich
Author: Richard Plangger 
Branch: jit-leaner-frontend
Changeset: r83342:5e609847041f
Date: 2016-03-22 17:09 +0100
http://bitbucket.org/pypy/pypy/changeset/5e609847041f/

Log:adapting the test interface for test_vecopt

diff --git a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py 
b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
@@ -81,7 +81,9 @@
 jitdriver_sd = FakeJitDriverStaticData()
 
 def assert_vectorize(self, loop, expected_loop, call_pure_results=None):
-trace = convert_loop_to_trace(loop)
+jump = ResOperation(rop.LABEL, loop.jump.getarglist(), 
loop.jump.getdescr())
+trace = Trace(loop.label, jump, loop.operations)
+trace = self.convert_loop_to_packed(loop)
 compile_data = compile.LoopCompileData(trace, loop.jump.getarglist())
 state = self._do_optimize_loop(compile_data)
 loop.label = state[0].label_op
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: instead of invoking _do_optimize_loop, optimize_vector is called instead, the additional other optimizations are not necessary

2016-03-25 Thread plan_rich
Author: Richard Plangger 
Branch: jit-leaner-frontend
Changeset: r83344:e5c868861aa2
Date: 2016-03-25 12:09 +0100
http://bitbucket.org/pypy/pypy/changeset/e5c868861aa2/

Log:instead of invoking _do_optimize_loop, optimize_vector is called
instead, the additional other optimizations are not necessary

diff --git a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py 
b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
@@ -14,9 +14,10 @@
 from rpython.jit.metainterp.optimizeopt.vector import (VectorizingOptimizer,
 MemoryRef, isomorphic, Pair, NotAVectorizeableLoop, VectorLoop,
 NotAProfitableLoop, GuardStrengthenOpt, CostModel, X86_CostModel,
-PackSet)
+PackSet, optimize_vector)
 from rpython.jit.metainterp.optimizeopt.schedule import (Scheduler,
 SchedulerState, VecScheduleState, Pack)
+from rpython.jit.metainterp.optimizeopt.optimizer import BasicLoopInfo
 from rpython.jit.metainterp.optimize import InvalidLoop
 from rpython.jit.metainterp import compile
 from rpython.jit.metainterp.resoperation import rop, ResOperation
@@ -74,6 +75,12 @@
 
 ARCH_VEC_REG_SIZE = 16
 
+class FakeWarmState(object):
+vec_all = False
+vec_cost = 0
+
+
+
 class VecTestHelper(DependencyBaseTest):
 
 enable_opts = "intbounds:rewrite:virtualize:string:earlyforce:pure:heap"
@@ -81,18 +88,17 @@
 jitdriver_sd = FakeJitDriverStaticData()
 
 def assert_vectorize(self, loop, expected_loop, call_pure_results=None):
-jump = ResOperation(rop.LABEL, loop.jump.getarglist(), 
loop.jump.getdescr())
-# convert_loop_to_trace assumes that there are no descriptors
-# but because this optimization pass is after the normal optimization 
pass
-# parse_loop already set artificial resume descr!
-for op in loop.operations:
-if op.is_guard():
-op.setdescr(None)
-trace = convert_loop_to_trace(loop)
-compile_data = compile.LoopCompileData(trace, loop.jump.getarglist())
-state = self._do_optimize_loop(compile_data)
-loop.label = state[0].label_op
-loop.operations = state[1]
+jump = ResOperation(rop.JUMP, loop.jump.getarglist(), 
loop.jump.getdescr())
+metainterp_sd = FakeMetaInterpStaticData(self.cpu)
+warmstate = FakeWarmState()
+loop.operations += [loop.jump]
+loop_info = BasicLoopInfo(loop.jump.getarglist(), None, jump)
+loop_info.label_op = ResOperation(rop.LABEL, loop.jump.getarglist(), 
loop.jump.getdescr())
+optimize_vector(None, metainterp_sd, self.jitdriver_sd, warmstate,
+loop_info, loop.operations)
+loop.operations = loop.operations[:-1]
+#loop.label = state[0].label_op
+#loop.operations = state[1]
 self.assert_equal(loop, expected_loop)
 
 def vectoroptimizer(self, loop):
diff --git a/rpython/jit/metainterp/optimizeopt/vector.py 
b/rpython/jit/metainterp/optimizeopt/vector.py
--- a/rpython/jit/metainterp/optimizeopt/vector.py
+++ b/rpython/jit/metainterp/optimizeopt/vector.py
@@ -117,7 +117,7 @@
 user_code = not jitdriver_sd.vec and warmstate.vec_all
 e = len(loop_ops)-1
 assert e > 0
-assert loop_ops[e].is_final()
+assert rop.is_final(loop_ops[e].getopnum())
 loop = VectorLoop(loop_info.label_op, loop_ops[:e], loop_ops[-1])
 if user_code and user_loop_bail_fast_path(loop, warmstate):
 return loop_info, loop_ops
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: whack a bit where we store metainterp_sd. Additionally use USHORT as opposed to SHORT

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83341:3136716f1017
Date: 2016-03-25 13:08 +0200
http://bitbucket.org/pypy/pypy/changeset/3136716f1017/

Log:whack a bit where we store metainterp_sd. Additionally use USHORT as
opposed to SHORT

diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -76,7 +76,7 @@
 
 #assert not unroll
 opt = Optimizer(metainterp_sd, jitdriver_sd, optimizations)
-return opt.propagate_all_forward(self.trace.get_iter(metainterp_sd),
+return opt.propagate_all_forward(self.trace.get_iter(),
 self.call_pure_results)
 
 class BridgeCompileData(CompileData):
diff --git a/rpython/jit/metainterp/history.py 
b/rpython/jit/metainterp/history.py
--- a/rpython/jit/metainterp/history.py
+++ b/rpython/jit/metainterp/history.py
@@ -674,10 +674,10 @@
 self.consts = []
 self._cache = []
 
-def set_inputargs(self, inpargs):
+def set_inputargs(self, inpargs, metainterp_sd):
 from rpython.jit.metainterp.opencoder import Trace
 
-self.trace = Trace(inpargs)
+self.trace = Trace(inpargs, metainterp_sd)
 self.inputargs = inpargs
 if self._cache:
 # hack to record the ops *after* we know our inputargs
@@ -860,7 +860,7 @@
 
 def check_history(self, expected=None, **check):
 insns = {}
-t = self.history.trace.get_iter(self.metainterp_sd)
+t = self.history.trace.get_iter()
 while not t.done():
 op = t.next()
 opname = op.getopname()
diff --git a/rpython/jit/metainterp/logger.py b/rpython/jit/metainterp/logger.py
--- a/rpython/jit/metainterp/logger.py
+++ b/rpython/jit/metainterp/logger.py
@@ -20,7 +20,7 @@
 
 def _unpack_trace(self, trace):
 ops = []
-i = trace.get_iter(self.metainterp_sd)
+i = trace.get_iter()
 while not i.done():
 ops.append(i.next())
 return i.inputargs, ops
diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -18,10 +18,13 @@
 TAGINT, TAGCONSTPTR, TAGCONSTOTHER, TAGBOX = range(4)
 TAGMASK = 0x3
 TAGSHIFT = 2
-SMALL_INT_STOP  = 2 ** (15 - TAGSHIFT)
-SMALL_INT_START = -SMALL_INT_STOP
-MIN_SHORT = -2**15 + 1
-MAX_SHORT = 2**15 - 1
+
+STORAGE_TP = rffi.USHORT
+MAX_SIZE = 2**16-1
+SMALL_INT_STOP  = (2 ** (15 - TAGSHIFT)) - 1
+SMALL_INT_START = -SMALL_INT_STOP # we might want to distribute them uneven
+MIN_SHORT = 0
+MAX_SHORT = 2**16 - 1
 
 class FrontendTagOverflow(Exception):
 pass
@@ -78,6 +81,7 @@
  metainterp_sd=None):
 self.trace = trace
 self.metainterp_sd = metainterp_sd
+self.all_descr_len = len(metainterp_sd.all_descrs)
 self._cache = [None] * trace._index
 if force_inputargs is not None:
 # the trace here is cut and we're working from
@@ -98,8 +102,8 @@
 self.start_index = start
 self.end = end
 
-def get_dead_ranges(self, metainterp_sd=None):
-return self.trace.get_dead_ranges(self.metainterp_sd)
+def get_dead_ranges(self):
+return self.trace.get_dead_ranges()
 
 def kill_cache_at(self, pos):
 if pos:
@@ -123,7 +127,7 @@
 if tag == TAGBOX:
 return self._get(v)
 elif tag == TAGINT:
-return ConstInt(v)
+return ConstInt(v + SMALL_INT_START)
 elif tag == TAGCONSTPTR:
 return ConstPtr(self.trace._refs[v])
 elif tag == TAGCONSTOTHER:
@@ -174,10 +178,10 @@
 if descr_index == 0 or rop.is_guard(opnum):
 descr = None
 else:
-if descr_index < 0:
-descr = self.metainterp_sd.all_descrs[-descr_index-1]
+if descr_index < self.all_descr_len + 1:
+descr = self.metainterp_sd.all_descrs[descr_index - 1]
 else:
-descr = self.trace._descrs[descr_index]
+descr = self.trace._descrs[descr_index - 
self.all_descr_len - 1]
 else:
 descr = None
 res = ResOperation(opnum, args, descr=descr)
@@ -202,9 +206,10 @@
 assert cut[1] > self.count
 self.trace.cut_at(cut)
 
-def get_iter(self, metainterp_sd=None):
+def get_iter(self):
 iter = TraceIterator(self.trace, self.start, self.trace._pos,
- self.inputargs, metainterp_sd=metainterp_sd)
+ self.inputargs,
+ metainterp_sd=self.trace.metainterp_sd)
 iter._count = self.count
 iter.start_index = self.index
 iter._index = self.index
@@ -237,8 +242,8 @@
 class Trace(BaseTrace):
 _deadranges = (-1, None)
 
-def __init__(self, inputargs):
-

[pypy-commit] pypy cpyext-ext: size -> length in unicode for cpython compatibility

2016-03-25 Thread mattip
Author: mattip 
Branch: cpyext-ext
Changeset: r83340:2af4fbd6f8e1
Date: 2016-03-25 13:56 +0300
http://bitbucket.org/pypy/pypy/changeset/2af4fbd6f8e1/

Log:size -> length in unicode for cpython compatibility

diff --git a/pypy/module/cpyext/include/unicodeobject.h 
b/pypy/module/cpyext/include/unicodeobject.h
--- a/pypy/module/cpyext/include/unicodeobject.h
+++ b/pypy/module/cpyext/include/unicodeobject.h
@@ -21,7 +21,7 @@
 typedef struct {
 PyObject_HEAD
 Py_UNICODE *str;
-Py_ssize_t size;
+Py_ssize_t length;
 long hash;  /* Hash value; -1 if not set */
 PyObject *defenc;   /* (Default) Encoded version as Python
string, or NULL; this is used for
diff --git a/pypy/module/cpyext/test/test_unicodeobject.py 
b/pypy/module/cpyext/test/test_unicodeobject.py
--- a/pypy/module/cpyext/test/test_unicodeobject.py
+++ b/pypy/module/cpyext/test/test_unicodeobject.py
@@ -190,14 +190,14 @@
 ar[0] = rffi.cast(PyObject, py_uni)
 api.PyUnicode_Resize(ar, 3)
 py_uni = rffi.cast(PyUnicodeObject, ar[0])
-assert py_uni.c_size == 3
+assert py_uni.c_length == 3
 assert py_uni.c_str[1] == u'b'
 assert py_uni.c_str[3] == u'\x00'
 # the same for growing
 ar[0] = rffi.cast(PyObject, py_uni)
 api.PyUnicode_Resize(ar, 10)
 py_uni = rffi.cast(PyUnicodeObject, ar[0])
-assert py_uni.c_size == 10
+assert py_uni.c_length == 10
 assert py_uni.c_str[1] == 'b'
 assert py_uni.c_str[10] == '\x00'
 Py_DecRef(space, ar[0])
diff --git a/pypy/module/cpyext/unicodeobject.py 
b/pypy/module/cpyext/unicodeobject.py
--- a/pypy/module/cpyext/unicodeobject.py
+++ b/pypy/module/cpyext/unicodeobject.py
@@ -22,7 +22,7 @@
 PyUnicodeObjectStruct = lltype.ForwardReference()
 PyUnicodeObject = lltype.Ptr(PyUnicodeObjectStruct)
 PyUnicodeObjectFields = (PyObjectFields +
-(("str", rffi.CWCHARP), ("size", Py_ssize_t),
+(("str", rffi.CWCHARP), ("length", Py_ssize_t),
  ("hash", rffi.LONG), ("defenc", PyObject)))
 cpython_struct("PyUnicodeObject", PyUnicodeObjectFields, PyUnicodeObjectStruct)
 
@@ -54,7 +54,7 @@
 py_uni = rffi.cast(PyUnicodeObject, py_obj)
 
 buflen = length + 1
-py_uni.c_size = length
+py_uni.c_length = length
 py_uni.c_str = lltype.malloc(rffi.CWCHARP.TO, buflen,
  flavor='raw', zero=True,
  add_memory_pressure=True)
@@ -65,7 +65,7 @@
 def unicode_attach(space, py_obj, w_obj):
 "Fills a newly allocated PyUnicodeObject with a unicode string"
 py_unicode = rffi.cast(PyUnicodeObject, py_obj)
-py_unicode.c_size = len(space.unicode_w(w_obj))
+py_unicode.c_length = len(space.unicode_w(w_obj))
 py_unicode.c_str = lltype.nullptr(rffi.CWCHARP.TO)
 py_unicode.c_hash = space.hash_w(w_obj)
 py_unicode.c_defenc = lltype.nullptr(PyObject.TO)
@@ -76,7 +76,7 @@
 be modified after this call.
 """
 py_uni = rffi.cast(PyUnicodeObject, py_obj)
-s = rffi.wcharpsize2unicode(py_uni.c_str, py_uni.c_size)
+s = rffi.wcharpsize2unicode(py_uni.c_str, py_uni.c_length)
 w_obj = space.wrap(s)
 py_uni.c_hash = space.hash_w(w_obj)
 track_reference(space, py_obj, w_obj)
@@ -235,7 +235,7 @@
 def PyUnicode_GetSize(space, ref):
 if from_ref(space, rffi.cast(PyObject, ref.c_ob_type)) is space.w_unicode:
 ref = rffi.cast(PyUnicodeObject, ref)
-return ref.c_size
+return ref.c_length
 else:
 w_obj = from_ref(space, ref)
 return space.len_w(w_obj)
@@ -250,11 +250,11 @@
 to make sure that the wchar_t string is 0-terminated in case this is
 required by the application."""
 c_str = PyUnicode_AS_UNICODE(space, rffi.cast(PyObject, ref))
-c_size = ref.c_size
+c_length = ref.c_length
 
 # If possible, try to copy the 0-termination as well
-if size > c_size:
-size = c_size + 1
+if size > c_length:
+size = c_length + 1
 
 
 i = 0
@@ -262,8 +262,8 @@
 buf[i] = c_str[i]
 i += 1
 
-if size > c_size:
-return c_size
+if size > c_length:
+return c_length
 else:
 return size
 
@@ -469,7 +469,7 @@
 ref[0] = lltype.nullptr(PyObject.TO)
 raise
 to_cp = newsize
-oldsize = py_uni.c_size
+oldsize = py_uni.c_length
 if oldsize < newsize:
 to_cp = oldsize
 for i in range(to_cp):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: fix test_compile

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83338:b9528bcd43d0
Date: 2016-03-25 12:15 +0200
http://bitbucket.org/pypy/pypy/changeset/b9528bcd43d0/

Log:fix test_compile

diff --git a/rpython/jit/metainterp/test/test_compile.py 
b/rpython/jit/metainterp/test/test_compile.py
--- a/rpython/jit/metainterp/test/test_compile.py
+++ b/rpython/jit/metainterp/test/test_compile.py
@@ -99,7 +99,7 @@
 metainterp.history.trace = t
 #
 greenkey = 'faked'
-target_token = compile_loop(metainterp, greenkey, (0, 0),
+target_token = compile_loop(metainterp, greenkey, (0, 0, 0),
 t.inputargs,
 [t._mapping[x] for x in 
loop.operations[-1].getarglist()],
 None)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: use a much more lightweight approach (We don't care about the order of iterations of snapshots here)

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83337:2e1402dc3f14
Date: 2016-03-25 12:14 +0200
http://bitbucket.org/pypy/pypy/changeset/2e1402dc3f14/

Log:use a much more lightweight approach (We don't care about the order
of iterations of snapshots here)

diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -50,20 +50,6 @@
 def get(self, index):
 return self.main_iter._untag(index)
 
-def _update_liverange(self, item, index, liveranges):
-tag, v = untag(item)
-if tag == TAGBOX:
-liveranges[v] = index
-
-def update_liveranges(self, index, liveranges):
-for item in self.vable_array:
-self._update_liverange(item, index, liveranges)
-for item in self.vref_array:
-self._update_liverange(item, index, liveranges)
-for frame in self.framestack:
-for item in frame.box_array:
-self._update_liverange(item, index, liveranges)
-
 def unpack_jitcode_pc(self, snapshot):
 return unpack_uint(snapshot.packed_jitcode_pc)
 
@@ -71,6 +57,22 @@
 # NOT_RPYTHON
 return [self.get(i) for i in arr]
 
+def _update_liverange(item, index, liveranges):
+tag, v = untag(item)
+if tag == TAGBOX:
+liveranges[v] = index
+
+def update_liveranges(snapshot, index, liveranges):
+assert isinstance(snapshot, TopSnapshot)
+for item in snapshot.vable_array:
+_update_liverange(item, index, liveranges)
+for item in snapshot.vref_array:
+_update_liverange(item, index, liveranges)
+while snapshot:
+for item in snapshot.box_array:
+_update_liverange(item, index, liveranges)
+snapshot = snapshot.prev
+
 class TraceIterator(BaseTrace):
 def __init__(self, trace, start, end, force_inputargs=None,
  metainterp_sd=None):
@@ -151,8 +153,8 @@
 if opwithdescr[opnum]:
 descr_index = self._next()
 if rop.is_guard(opnum):
-self.get_snapshot_iter(descr_index).update_liveranges(
-index, liveranges)
+update_liveranges(self.trace._snapshots[descr_index], index, 
+  liveranges)
 if opclasses[opnum].type != 'v':
 return index + 1
 return index
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: make sure we have two different names for two different exceptions

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83336:a544bbe29381
Date: 2016-03-25 11:44 +0200
http://bitbucket.org/pypy/pypy/changeset/a544bbe29381/

Log:make sure we have two different names for two different exceptions

diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -23,7 +23,7 @@
 MIN_SHORT = -2**15 + 1
 MAX_SHORT = 2**15 - 1
 
-class TagOverflow(Exception):
+class FrontendTagOverflow(Exception):
 pass
 
 class BaseTrace(object):
@@ -263,7 +263,7 @@
 # grow by 2X
 self._ops = self._ops + [rffi.cast(rffi.SHORT, -15)] * 
len(self._ops)
 if not MIN_SHORT < v < MAX_SHORT:
-raise TagOverflow
+raise FrontendTagOverflow
 self._ops[self._pos] = rffi.cast(rffi.SHORT, v)
 self._pos += 1
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: grrr rpython

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83335:bb8c353b9254
Date: 2016-03-25 11:41 +0200
http://bitbucket.org/pypy/pypy/changeset/bb8c353b9254/

Log:grrr rpython

diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -1915,7 +1915,7 @@
 self.last_exc_value = lltype.nullptr(rclass.OBJECT)
 self.forced_virtualizable = None
 self.partial_trace = None
-self.retracing_from = (-1, -1)
+self.retracing_from = (-1, -1, -1)
 self.call_pure_results = args_dict()
 self.heapcache = HeapCache()
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: one more

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83334:dfe36bc75fec
Date: 2016-03-25 11:36 +0200
http://bitbucket.org/pypy/pypy/changeset/dfe36bc75fec/

Log:one more

diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -261,7 +261,7 @@
 jitcell_token = make_jitcell_token(jitdriver_sd)
 cut_at = history.get_trace_position()
 history.record(rop.JUMP, jumpargs, None, descr=jitcell_token)
-if start != (0, 0):
+if start != (0, 0, 0):
 trace = trace.cut_trace_from(start, inputargs)
 if 'unroll' not in enable_opts or not 
metainterp.cpu.supports_guard_gc_type:
 return compile_simple_loop(metainterp, greenkey, trace, jumpargs,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: fix rpython

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r8:1becdcc6a2b2
Date: 2016-03-25 11:29 +0200
http://bitbucket.org/pypy/pypy/changeset/1becdcc6a2b2/

Log:fix rpython

diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -2328,7 +2328,7 @@
 
 def _compile_and_run_once(self, original_boxes):
 self.initialize_state_from_start(original_boxes)
-self.current_merge_points = [(original_boxes, (0, 0))]
+self.current_merge_points = [(original_boxes, (0, 0, 0))]
 num_green_args = self.jitdriver_sd.num_green_args
 original_greenkey = original_boxes[:num_green_args]
 self.resumekey = compile.ResumeFromInterpDescr(original_greenkey)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy jit-leaner-frontend: try to shorten the ranges and numbers

2016-03-25 Thread fijal
Author: fijal
Branch: jit-leaner-frontend
Changeset: r83332:e625c46190c9
Date: 2016-03-25 11:23 +0200
http://bitbucket.org/pypy/pypy/changeset/e625c46190c9/

Log:try to shorten the ranges and numbers

diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -76,7 +76,7 @@
  metainterp_sd=None):
 self.trace = trace
 self.metainterp_sd = metainterp_sd
-self._cache = [None] * trace._count
+self._cache = [None] * trace._index
 if force_inputargs is not None:
 # the trace here is cut and we're working from
 # inputargs that are in the middle, shuffle stuff around a bit
@@ -92,6 +92,7 @@
 self.start = start
 self.pos = start
 self._count = start
+self._index = start
 self.start_index = start
 self.end = end
 
@@ -152,7 +153,9 @@
 if rop.is_guard(opnum):
 self.get_snapshot_iter(descr_index).update_liveranges(
 index, liveranges)
-return index + 1
+if opclasses[opnum].type != 'v':
+return index + 1
+return index
 
 def next(self):
 opnum = self._next()
@@ -180,16 +183,18 @@
 assert isinstance(res, GuardResOp)
 res.rd_resume_position = descr_index
 if res.type != 'v':
-self._cache[self._count] = res
+self._cache[self._index] = res
+self._index += 1
 self._count += 1
 return res
 
 class CutTrace(BaseTrace):
-def __init__(self, trace, start, count, inputargs):
+def __init__(self, trace, start, count, index, inputargs):
 self.trace = trace
 self.start = start
 self.inputargs = inputargs
 self.count = count
+self.index = index
 
 def cut_at(self, cut):
 assert cut[1] > self.count
@@ -199,7 +204,8 @@
 iter = TraceIterator(self.trace, self.start, self.trace._pos,
  self.inputargs, metainterp_sd=metainterp_sd)
 iter._count = self.count
-iter.start_index = self.count
+iter.start_index = self.index
+iter._index = self.index
 return iter
 
 def combine_uint(index1, index2):
@@ -246,7 +252,8 @@
 self._snapshots = []
 for i, inparg in enumerate(inputargs):
 inparg.set_position(i)
-self._count = len(inputargs)
+self._count = len(inputargs) # total count
+self._index = len(inputargs) # "position" of resulting resops
 self._start = len(inputargs)
 self._pos = self._start
 self.inputargs = inputargs
@@ -281,14 +288,15 @@
 return self._pos
 
 def cut_point(self):
-return self._pos, self._count
+return self._pos, self._count, self._index
 
 def cut_at(self, end):
 self._pos = end[0]
 self._count = end[1]
+self._index = end[2]
 
-def cut_trace_from(self, (start, count), inputargs):
-return CutTrace(self, start, count, inputargs)
+def cut_trace_from(self, (start, count, index), inputargs):
+return CutTrace(self, start, count, index, inputargs)
 
 def _encode(self, box):
 if isinstance(box, Const):
@@ -334,7 +342,7 @@
 assert False, "unreachable code"
 
 def record_op(self, opnum, argboxes, descr=None):
-pos = self._count
+pos = self._index
 self.append(opnum)
 expected_arity = oparity[opnum]
 if expected_arity == -1:
@@ -351,6 +359,8 @@
 else:
 self.append(self._encode_descr(descr))
 self._count += 1
+if opclasses[opnum].type != 'v':
+self._index += 1
 return pos
 
 def _encode_descr(self, descr):
@@ -404,7 +414,7 @@
 
 def get_live_ranges(self, metainterp_sd):
 t = self.get_iter(metainterp_sd)
-liveranges = [0] * self._count
+liveranges = [0] * self._index
 index = t._count
 while not t.done():
 index = t.next_element_update_live_range(index, liveranges)
@@ -427,7 +437,8 @@
 if self._deadranges[0] == self._count:
 return self._deadranges[1]
 liveranges = self.get_live_ranges(metainterp_sd)
-deadranges = [0] * (self._count + 1)
+deadranges = [0] * (self._index + 2)
+assert len(deadranges) == len(liveranges) + 2
 for i in range(self._start, len(liveranges)):
 elem = liveranges[i]
 if elem:
diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py 
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -520,7 +520,8 @@
 break
 self.first_optimization.propagate_forward(op)
 

[pypy-commit] pypy new-jit-log: test to generate a jitlog

2016-03-25 Thread plan_rich
Author: Richard Plangger 
Branch: new-jit-log
Changeset: r83331:a3cbc9a1c5d6
Date: 2016-03-24 17:53 +0100
http://bitbucket.org/pypy/pypy/changeset/a3cbc9a1c5d6/

Log:test to generate a jitlog

diff --git a/rpython/jit/backend/x86/test/test_jitlog.py 
b/rpython/jit/backend/x86/test/test_jitlog.py
new file mode 100644
--- /dev/null
+++ b/rpython/jit/backend/x86/test/test_jitlog.py
@@ -0,0 +1,37 @@
+import re
+from rpython.rlib import debug
+from rpython.jit.tool.oparser import pure_parse
+from rpython.jit.metainterp import logger
+from rpython.jit.metainterp.typesystem import llhelper
+from StringIO import StringIO
+from rpython.jit.metainterp.optimizeopt.util import equaloplists
+from rpython.jit.metainterp.history import AbstractDescr, JitCellToken, 
BasicFailDescr, BasicFinalDescr
+from rpython.jit.backend.model import AbstractCPU
+from rpython.rlib.jit import JitDriver
+from rpython.jit.metainterp.test.support import LLJitMixin
+from rpython.jit.backend.x86.test.test_basic import Jit386Mixin
+from rpython.rlib.rvmprof import rvmprof
+import tempfile
+
+class TestLogger(Jit386Mixin):
+
+def test_log_loop(self):
+myjitdriver = JitDriver(greens = [], reds = ['x', 'y', 'res'])
+vmprof = rvmprof.VMProf()
+fileno, name = tempfile.mkstemp()
+def f(x, y):
+res = 0
+vmprof.enable(fileno, 0.1)
+while y > 0:
+myjitdriver.can_enter_jit(x=x, y=y, res=res)
+myjitdriver.jit_merge_point(x=x, y=y, res=res)
+res += x
+if res > 40:
+res += 1
+res -= 2
+res += 1
+y -= 1
+return res
+res = self.meta_interp(f, [6, 20])
+self.check_trace_count(2)
+print(name)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: go via the space to benefit from the annspecialcase

2016-03-25 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: 
Changeset: r83329:336e2da610d5
Date: 2016-03-25 09:03 +0100
http://bitbucket.org/pypy/pypy/changeset/336e2da610d5/

Log:go via the space to benefit from the annspecialcase

diff --git a/pypy/objspace/std/objectobject.py 
b/pypy/objspace/std/objectobject.py
--- a/pypy/objspace/std/objectobject.py
+++ b/pypy/objspace/std/objectobject.py
@@ -110,7 +110,7 @@
 def descr__init__(space, w_obj, __args__):
 # don't allow arguments unless __new__ is overridden
 w_type = space.type(w_obj)
-w_parent_new, _ = w_type.lookup_where('__new__')
+w_parent_new, _ = space.lookup_in_type_where(w_type, '__new__')
 if w_parent_new is space.w_object:
 try:
 __args__.fixedunpack(0)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit