[pypy-commit] pypy exctrans: Do sandboxing of register_external() stuff at the rtyper level

2016-01-17 Thread rlamy
Author: Ronan Lamy 
Branch: exctrans
Changeset: r81826:7a2c1c67667b
Date: 2016-01-17 15:44 +
http://bitbucket.org/pypy/pypy/changeset/7a2c1c67667b/

Log:Do sandboxing of register_external() stuff at the rtyper level

diff --git a/rpython/rtyper/extfunc.py b/rpython/rtyper/extfunc.py
--- a/rpython/rtyper/extfunc.py
+++ b/rpython/rtyper/extfunc.py
@@ -46,6 +46,12 @@
 impl = getattr(self, 'lltypeimpl', None)
 fakeimpl = getattr(self, 'lltypefakeimpl', self.instance)
 if impl:
+if (rtyper.annotator.translator.config.translation.sandbox
+and not self.safe_not_sandboxed):
+from rpython.translator.sandbox.rsandbox import (
+make_sandbox_trampoline)
+impl = make_sandbox_trampoline(
+self.name, signature_args, s_result)
 if hasattr(self, 'lltypefakeimpl'):
 # If we have both an llimpl and an llfakeimpl,
 # we need a wrapper that selects the proper one and calls it
@@ -74,15 +80,10 @@
 return original_impl(%s)
 """ % (args, args, args)) in d
 impl = func_with_new_name(d['ll_wrapper'], name + '_wrapper')
-if rtyper.annotator.translator.config.translation.sandbox:
-impl._dont_inline_ = True
 # store some attributes to the 'impl' function, where
 # the eventual call to rtyper.getcallable() will find them
 # and transfer them to the final lltype.functionptr().
-impl._llfnobjattrs_ = {
-'_name': self.name,
-'_safe_not_sandboxed': self.safe_not_sandboxed,
-}
+impl._llfnobjattrs_ = {'_name': self.name}
 obj = rtyper.getannmixlevel().delayedfunction(
 impl, signature_args, hop.s_result)
 else:
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -29,7 +29,7 @@
 from rpython.rtyper.rclass import RootClassRepr
 from rpython.tool.pairtype import pair
 from rpython.translator.unsimplify import insert_empty_block
-from rpython.translator.sandbox.rsandbox import make_sandbox_trampoline, 
_annotate
+from rpython.translator.sandbox.rsandbox import make_sandbox_trampoline
 
 
 class RPythonTyper(object):
diff --git a/rpython/translator/c/node.py b/rpython/translator/c/node.py
--- a/rpython/translator/c/node.py
+++ b/rpython/translator/c/node.py
@@ -905,13 +905,7 @@
 def new_funcnode(db, T, obj, forcename=None):
 sandbox = db.sandbox and need_sandboxing(obj)
 if sandbox:
-if hasattr(obj, 'graph') and sandbox != 'if_external':
-graph = rsandbox.get_external_function_sandbox_graph(
-obj, db.translator.rtyper)
-obj.__dict__['graph'] = graph
-obj.__dict__.pop('_safe_not_sandboxed', None)
-obj.__dict__.pop('external', None)
-elif getattr(obj, 'external', None) is not None:
+if getattr(obj, 'external', None) is not None:
 obj.__dict__['graph'] = rsandbox.get_sandbox_stub(
 obj, db.translator.rtyper)
 obj.__dict__.pop('_safe_not_sandboxed', None)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Missing .c and .h files

2016-01-17 Thread stefanor
Author: Stefano Rivera 
Branch: 
Changeset: r2606:5d2a59af1b06
Date: 2016-01-17 07:46 -0800
http://bitbucket.org/cffi/cffi/changeset/5d2a59af1b06/

Log:Missing .c and .h files

Required for the new embedding test suite.

diff --git a/MANIFEST.in b/MANIFEST.in
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,6 +1,6 @@
 recursive-include cffi *.py *.h
 recursive-include c *.c *.h *.asm *.py win64.obj
-recursive-include testing *.py
+recursive-include testing *.py *.c *.h
 recursive-include doc *.py *.rst Makefile *.bat
-recursive-include demo py.cleanup *.py manual.c
+recursive-include demo py.cleanup *.py embedding_test.c manual.c
 include AUTHORS LICENSE setup.py setup_base.py
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Don't blow away PYTHONPATH

2016-01-17 Thread stefanor
Author: Stefano Rivera 
Branch: 
Changeset: r2607:b1196289cab3
Date: 2016-01-17 07:47 -0800
http://bitbucket.org/cffi/cffi/changeset/b1196289cab3/

Log:Don't blow away PYTHONPATH

Rather parse it, and prefix our base directory, if necessary.

diff --git a/testing/embedding/test_basic.py b/testing/embedding/test_basic.py
--- a/testing/embedding/test_basic.py
+++ b/testing/embedding/test_basic.py
@@ -29,6 +29,14 @@
 py.test.skip(str(_link_error))
 
 
+def prefix_pythonpath():
+cffi_base = os.path.dirname(os.path.dirname(local_dir))
+pythonpath = os.environ.get('PYTHONPATH', '').split(':')
+if cffi_base not in pythonpath:
+pythonpath.insert(0, cffi_base)
+return ':'.join(pythonpath)
+
+
 class EmbeddingTests:
 _compiled_modules = {}
 
@@ -69,8 +77,7 @@
 # find a solution to that: we could hack sys.path inside the
 # script run here, but we can't hack it in the same way in
 # execute().
-env_extra = {'PYTHONPATH':
- os.path.dirname(os.path.dirname(local_dir))}
+env_extra = {'PYTHONPATH': prefix_pythonpath()}
 output = self._run([sys.executable, os.path.join(local_dir, 
filename)],
env_extra=env_extra)
 match = re.compile(r"\bFILENAME: (.+)").search(output)
@@ -114,8 +121,7 @@
 
 def execute(self, name):
 path = self.get_path()
-env_extra = {}
-env_extra['PYTHONPATH'] = os.path.dirname(os.path.dirname(local_dir))
+env_extra = {'PYTHONPATH': prefix_pythonpath()}
 libpath = os.environ.get('LD_LIBRARY_PATH')
 if libpath:
 libpath = path + ':' + libpath
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Use os.pathsep instead of directly ':'

2016-01-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2608:5e4c30fb3a24
Date: 2016-01-17 17:00 +0100
http://bitbucket.org/cffi/cffi/changeset/5e4c30fb3a24/

Log:Use os.pathsep instead of directly ':'

diff --git a/testing/embedding/test_basic.py b/testing/embedding/test_basic.py
--- a/testing/embedding/test_basic.py
+++ b/testing/embedding/test_basic.py
@@ -31,10 +31,10 @@
 
 def prefix_pythonpath():
 cffi_base = os.path.dirname(os.path.dirname(local_dir))
-pythonpath = os.environ.get('PYTHONPATH', '').split(':')
+pythonpath = os.environ.get('PYTHONPATH', '').split(os.pathsep)
 if cffi_base not in pythonpath:
 pythonpath.insert(0, cffi_base)
-return ':'.join(pythonpath)
+return os.pathsep.join(pythonpath)
 
 
 class EmbeddingTests:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Allow testing against installed package (which has egg_info already)

2016-01-17 Thread stefanor
Author: Stefano Rivera 
Branch: 
Changeset: r2609:2eb9c68c1515
Date: 2016-01-17 10:42 -0800
http://bitbucket.org/cffi/cffi/changeset/2eb9c68c1515/

Log:Allow testing against installed package (which has egg_info already)

diff --git a/testing/cffi1/test_zdist.py b/testing/cffi1/test_zdist.py
--- a/testing/cffi1/test_zdist.py
+++ b/testing/cffi1/test_zdist.py
@@ -48,7 +48,8 @@
 import setuptools
 except ImportError:
 py.test.skip("setuptools not found")
-self.run(['setup.py', 'egg_info'], cwd=self.rootdir)
+if os.path.exists(os.path.join(self.rootdir, 'setup.py')):
+self.run(['setup.py', 'egg_info'], cwd=self.rootdir)
 TestDist._setuptools_ready = True
 
 def check_produced_files(self, content, curdir=None):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Support extensions for pydebug cpythons

2016-01-17 Thread stefanor
Author: Stefano Rivera 
Branch: 
Changeset: r2610:b848a2fed6c7
Date: 2016-01-17 12:16 -0800
http://bitbucket.org/cffi/cffi/changeset/b848a2fed6c7/

Log:Support extensions for pydebug cpythons

diff --git a/cffi/api.py b/cffi/api.py
--- a/cffi/api.py
+++ b/cffi/api.py
@@ -565,6 +565,8 @@
 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
 if hasattr(sys, 'abiflags'):
 pythonlib += sys.abiflags
+elif hasattr(sys, 'gettotalrefcount'):
+pythonlib += '_d'
 ensure('libraries', pythonlib)
 if sys.platform == "win32":
 ensure('extra_link_args', '/MANIFEST')
diff --git a/testing/embedding/test_basic.py b/testing/embedding/test_basic.py
--- a/testing/embedding/test_basic.py
+++ b/testing/embedding/test_basic.py
@@ -4,10 +4,6 @@
 from testing.udir import udir
 import cffi
 
-if hasattr(sys, 'gettotalrefcount'):
-py.test.skip("tried hard and failed to have these tests run "
- "in a debug-mode python")
-
 
 local_dir = os.path.dirname(os.path.abspath(__file__))
 _link_error = '?'
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Don't hardcode _d. If that is the extension, it'll be in sysconfig

2016-01-17 Thread stefanor
Author: Stefano Rivera 
Branch: 
Changeset: r2611:a3f2aad89ff0
Date: 2016-01-17 12:52 -0800
http://bitbucket.org/cffi/cffi/changeset/a3f2aad89ff0/

Log:Don't hardcode _d. If that is the extension, it'll be in sysconfig

diff --git a/cffi/api.py b/cffi/api.py
--- a/cffi/api.py
+++ b/cffi/api.py
@@ -1,4 +1,4 @@
-import sys, types
+import sys, sysconfig, types
 from .lock import allocate_lock
 
 try:
@@ -557,16 +557,14 @@
 else:
 if sys.platform == "win32":
 template = "python%d%d"
-if sys.flags.debug:
-template = template + '_d'
 else:
 template = "python%d.%d"
 pythonlib = (template %
 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
 if hasattr(sys, 'abiflags'):
 pythonlib += sys.abiflags
-elif hasattr(sys, 'gettotalrefcount'):
-pythonlib += '_d'
+elif sysconfig.get_config_var('DEBUG_EXT'):
+pythonlib += sysconfig.get_config_var('DEBUG_EXT')
 ensure('libraries', pythonlib)
 if sys.platform == "win32":
 ensure('extra_link_args', '/MANIFEST')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Windows uses '_d' even though I'm pretty sure DEBUG_EXT is a Debian-only

2016-01-17 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2612:ab31f1f18faf
Date: 2016-01-17 22:01 +0100
http://bitbucket.org/cffi/cffi/changeset/ab31f1f18faf/

Log:Windows uses '_d' even though I'm pretty sure DEBUG_EXT is a Debian-
only extension

diff --git a/cffi/api.py b/cffi/api.py
--- a/cffi/api.py
+++ b/cffi/api.py
@@ -557,14 +557,16 @@
 else:
 if sys.platform == "win32":
 template = "python%d%d"
+if hasattr(sys, 'gettotalrefcount'):
+template += '_d'
 else:
 template = "python%d.%d"
+if sysconfig.get_config_var('DEBUG_EXT'):
+template += sysconfig.get_config_var('DEBUG_EXT')
 pythonlib = (template %
 (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
 if hasattr(sys, 'abiflags'):
 pythonlib += sys.abiflags
-elif sysconfig.get_config_var('DEBUG_EXT'):
-pythonlib += sysconfig.get_config_var('DEBUG_EXT')
 ensure('libraries', pythonlib)
 if sys.platform == "win32":
 ensure('extra_link_args', '/MANIFEST')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy remove-getfield-pure: Test case for a large number of immutable field references

2016-01-17 Thread sbauman
Author: Spenser Bauman 
Branch: remove-getfield-pure
Changeset: r81827:5efe5243ae95
Date: 2016-01-18 02:16 -0500
http://bitbucket.org/pypy/pypy/changeset/5efe5243ae95/

Log:Test case for a large number of immutable field references

diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py 
b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -9266,6 +9266,123 @@
 a = lltype.malloc(lltype.GcArray(lltype.Ptr(self.NODE3)), 5, zero=True)
 self.optimize_loop(ops, expected, jump_values=[a])
 
+def test_large_number_of_immutable_references(self):
+ops = """
+[p0]
+i0  = getfield_gc_i(p0, descr=bigadescr)
+i1  = getfield_gc_i(p0, descr=bigbdescr)
+i2  = getfield_gc_i(p0, descr=bigcdescr)
+i3  = getfield_gc_i(p0, descr=bigddescr)
+i4  = getfield_gc_i(p0, descr=bigedescr)
+i5  = getfield_gc_i(p0, descr=bigfdescr)
+i6  = getfield_gc_i(p0, descr=biggdescr)
+i7  = getfield_gc_i(p0, descr=bighdescr)
+i8  = getfield_gc_i(p0, descr=bigidescr)
+i9  = getfield_gc_i(p0, descr=bigjdescr)
+i10 = getfield_gc_i(p0, descr=bigkdescr)
+i11 = getfield_gc_i(p0, descr=bigldescr)
+i12 = getfield_gc_i(p0, descr=bigmdescr)
+i13 = getfield_gc_i(p0, descr=bigndescr)
+i14 = getfield_gc_i(p0, descr=bigodescr)
+i15 = getfield_gc_i(p0, descr=bigpdescr)
+i16 = getfield_gc_i(p0, descr=bigqdescr)
+i17 = getfield_gc_i(p0, descr=bigrdescr)
+i18 = getfield_gc_i(p0, descr=bigsdescr)
+i19 = getfield_gc_i(p0, descr=bigtdescr)
+i20 = getfield_gc_i(p0, descr=bigudescr)
+i21 = getfield_gc_i(p0, descr=bigvdescr)
+i22 = getfield_gc_i(p0, descr=bigwdescr)
+i23 = getfield_gc_i(p0, descr=bigxdescr)
+i24 = getfield_gc_i(p0, descr=bigydescr)
+i25 = getfield_gc_i(p0, descr=bigzdescr)
+i27 = getfield_gc_i(p0, descr=bigbdescr)
+i28 = getfield_gc_i(p0, descr=bigcdescr)
+i29 = getfield_gc_i(p0, descr=bigddescr)
+i30 = getfield_gc_i(p0, descr=bigedescr)
+i31 = getfield_gc_i(p0, descr=bigfdescr)
+i32 = getfield_gc_i(p0, descr=biggdescr)
+i33 = getfield_gc_i(p0, descr=bighdescr)
+i34 = getfield_gc_i(p0, descr=bigidescr)
+i35 = getfield_gc_i(p0, descr=bigjdescr)
+i36 = getfield_gc_i(p0, descr=bigkdescr)
+i37 = getfield_gc_i(p0, descr=bigldescr)
+i38 = getfield_gc_i(p0, descr=bigmdescr)
+i39 = getfield_gc_i(p0, descr=bigndescr)
+i40 = getfield_gc_i(p0, descr=bigodescr)
+i41 = getfield_gc_i(p0, descr=bigpdescr)
+i42 = getfield_gc_i(p0, descr=bigqdescr)
+i43 = getfield_gc_i(p0, descr=bigrdescr)
+i44 = getfield_gc_i(p0, descr=bigsdescr)
+i45 = getfield_gc_i(p0, descr=bigtdescr)
+i46 = getfield_gc_i(p0, descr=bigudescr)
+i47 = getfield_gc_i(p0, descr=bigvdescr)
+i48 = getfield_gc_i(p0, descr=bigwdescr)
+i49 = getfield_gc_i(p0, descr=bigxdescr)
+i50 = getfield_gc_i(p0, descr=bigydescr)
+i51 = getfield_gc_i(p0, descr=bigzdescr)
+i26 = getfield_gc_i(p0, descr=bigadescr)
+i99 = int_add(i26, i51)
+escape_i(i27)
+escape_i(i28)
+escape_i(i29)
+escape_i(i30)
+escape_i(i31)
+escape_i(i32)
+escape_i(i33)
+escape_i(i34)
+escape_i(i35)
+escape_i(i36)
+escape_i(i37)
+escape_i(i38)
+escape_i(i39)
+escape_i(i40)
+escape_i(i41)
+escape_i(i42)
+escape_i(i43)
+escape_i(i44)
+escape_i(i45)
+escape_i(i46)
+escape_i(i47)
+escape_i(i48)
+escape_i(i49)
+escape_i(i50)
+escape_i(i51)
+escape_i(i26)
+escape_i(i99)
+jump(p0)
+"""
+expected = """
+
[p0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16,i17,i18,i19,i20,i21,i22,i23,i24,i25,i0,i99]
+escape_i(i1)
+escape_i(i2)
+escape_i(i3)
+escape_i(i4)
+escape_i(i5)
+escape_i(i6)
+escape_i(i7)
+escape_i(i8)
+escape_i(i9)
+escape_i(i10)
+escape_i(i11)
+escape_i(i12)
+escape_i(i13)
+escape_i(i14)
+escape_i(i15)
+escape_i(i16)
+escape_i(i17)
+escape_i(i18)
+escape_i(i19)
+escape_i(i20)
+escape_i(i21)
+escape_i(i22)
+escape_i(i23)
+escape_i(i24)
+escape_i(i25)
+escape_i(i0)
+escape_i(i99)
+
jump(p0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16,i17,i18,i19,i20,i21,i22,i23,i24,i25,i0,i99)
+"""
+self.optimize_loop(ops, expected)
 
 class TestLLtype(OptimizeOp

[pypy-commit] pypy s390x-backend: fixed syntax error

2016-01-17 Thread plan_rich
Author: Richard Plangger 
Branch: s390x-backend
Changeset: r81828:12cb71eb84d2
Date: 2016-01-18 08:50 +0100
http://bitbucket.org/pypy/pypy/changeset/12cb71eb84d2/

Log:fixed syntax error

diff --git a/rpython/jit/backend/test/zll_stress.py 
b/rpython/jit/backend/test/zll_stress.py
--- a/rpython/jit/backend/test/zll_stress.py
+++ b/rpython/jit/backend/test/zll_stress.py
@@ -19,4 +19,5 @@
 r = Random()
 r.jumpahead(piece*)
 for i in range(piece*per_piece, (piece+1)*per_piece):
+print "i = %d; r.setstate(%s)" % (i, r.getstate())
 check_random_function(cpu, LLtypeOperationBuilder, r, i, 
total_iterations)
diff --git a/rpython/jit/backend/zarch/callbuilder.py 
b/rpython/jit/backend/zarch/callbuilder.py
--- a/rpython/jit/backend/zarch/callbuilder.py
+++ b/rpython/jit/backend/zarch/callbuilder.py
@@ -24,7 +24,7 @@
 type = INT
 size = WORD
 self.ressign = True
-if calldescr is not None and isinstance(calldescr, CallDescr)
+if calldescr is not None and isinstance(calldescr, CallDescr):
 type = calldescr.get_result_type()
 size = calldescr.get_result_size()
 self.ressign = calldescr.is_result_signed()
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit