[pypy-commit] pypy NonConstant: Simply use not_const() to annotate NonConstant
Author: Ronan Lamy Branch: NonConstant Changeset: r69041:d1fc613a6520 Date: 2014-02-01 17:27 + http://bitbucket.org/pypy/pypy/changeset/d1fc613a6520/ Log:Simply use not_const() to annotate NonConstant diff --git a/rpython/rlib/nonconst.py b/rpython/rlib/nonconst.py --- a/rpython/rlib/nonconst.py +++ b/rpython/rlib/nonconst.py @@ -4,6 +4,7 @@ from rpython.rtyper.extregistry import ExtRegistryEntry from rpython.flowspace.model import Constant +from rpython.annotator.model import not_const class NonConstant(object): def __init__(self, _constant): @@ -33,11 +34,8 @@ class EntryNonConstant(ExtRegistryEntry): _about_ = NonConstant -def compute_result_annotation(self, arg): -if hasattr(arg, 'const'): -return self.bookkeeper.immutablevalue(arg.const, False) -else: -return arg +def compute_result_annotation(self, s_arg): +return not_const(s_arg) def specialize_call(self, hop): hop.exception_cannot_occur() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: windows - prevent dreaded dialog box on failure tests
Author: Matti Picus Branch: Changeset: r69044:565d143e0975 Date: 2014-02-01 19:55 +0200 http://bitbucket.org/pypy/pypy/changeset/565d143e0975/ Log:windows - prevent dreaded dialog box on failure tests diff --git a/rpython/translator/c/test/test_standalone.py b/rpython/translator/c/test/test_standalone.py --- a/rpython/translator/c/test/test_standalone.py +++ b/rpython/translator/c/test/test_standalone.py @@ -16,6 +16,20 @@ from rpython.conftest import cdir from rpython.conftest import option +def setup_module(module): +if os.name == 'nt': +# Do not open dreaded dialog box on segfault +import ctypes +SEM_NOGPFAULTERRORBOX = 0x0002 # From MSDN +old_err_mode = ctypes.windll.kernel32.GetErrorMode() +new_err_mode = old_err_mode | SEM_NOGPFAULTERRORBOX +ctypes.windll.kernel32.SetErrorMode(new_err_mode) +module.old_err_mode = old_err_mode + +def teardown_module(module): +if os.name == 'nt': +import ctypes +ctypes.windll.kernel32.SetErrorMode(module.old_err_mode) class StandaloneTests(object): config = None ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy precompiled-headers: implement precompiled header use for windows
Author: Matti Picus Branch: precompiled-headers Changeset: r69043:d74d5f697984 Date: 2014-01-31 14:56 +0200 http://bitbucket.org/pypy/pypy/changeset/d74d5f697984/ Log:implement precompiled header use for windows diff --git a/rpython/translator/platform/test/test_makefile.py b/rpython/translator/platform/test/test_makefile.py --- a/rpython/translator/platform/test/test_makefile.py +++ b/rpython/translator/platform/test/test_makefile.py @@ -93,9 +93,10 @@ cfiles_precompiled_headers = [] for i in range(nprecompiled_headers): pch_name =tmpdir.join('pcheader%03d.h' % i) -txt = '' +txt = '#ifndef PCHEADER%03d_H\n#define PCHEADER%03d_H\n' %(i, i) for j in range(3000): txt += "int pcfunc%03d_%03d();\n" %(i, j) +txt += '#endif' pch_name.write(txt) cfiles_precompiled_headers.append(pch_name) # Create some cfiles with headers we want precompiled @@ -108,12 +109,22 @@ txt += "int func%03d(){ return %d;};\n" % (i, i) c_name.write(txt) cfiles.append(c_name) -mk = self.platform.gen_makefile(cfiles, eci, path=udir, - cfile_precompilation=cfiles_precompiled_headers) if sys.platform == 'win32': clean = ('clean', '', 'for %f in ( $(OBJECTS) $(TARGET) ) do @if exist %f del /f %f') else: clean = ('clean', '', 'rm -f $(OBJECTS) $(TARGET) ') +#write a non-precompiled header makefile +mk = self.platform.gen_makefile(cfiles, eci, path=tmpdir) +mk.rule(*clean) +mk.write() +t0 = time.clock() +self.platform.execute_makefile(mk) +t1 = time.clock() +t_normal = t1 - t0 +self.platform.execute_makefile(mk, extra_opts=['clean']) +# Write a super-duper makefile with precompiled headers +mk = self.platform.gen_makefile(cfiles, eci, path=tmpdir, + cfile_precompilation=cfiles_precompiled_headers,) mk.rule(*clean) mk.write() t0 = time.clock() @@ -122,15 +133,6 @@ t_precompiled = t1 - t0 res = self.platform.execute(mk.exe_name) self.check_res(res, '%d\n' %sum(range(ncfiles))) -self.platform.execute_makefile(mk, extra_opts=['clean']) -#Rewrite a non-precompiled header makefile -mk = self.platform.gen_makefile(cfiles, eci, path=udir) -mk.rule(*clean) -mk.write() -t0 = time.clock() -self.platform.execute_makefile(mk) -t1 = time.clock() -t_normal = t1 - t0 print "precompiled haeder 'make' time %.2f, non-precompiled header time %.2f" %(t_precompiled, t_normal) assert t_precompiled < t_normal * 0.5 diff --git a/rpython/translator/platform/windows.py b/rpython/translator/platform/windows.py --- a/rpython/translator/platform/windows.py +++ b/rpython/translator/platform/windows.py @@ -318,15 +318,38 @@ if self.x64: definitions.append(('_WIN64', '1')) +rules = [ +('.asm.obj', '', '$(MASM) /nologo /Fo$@ /c $< $(INCLUDEDIRS)'), +] + +if cfile_precompilation: +stdafx_h = path.join('stdafx.h') +txt = '#ifndef PYPY_STDAFX_H\n' +txt += '#define PYPY_STDAFX_H\n' +txt += '\n'.join(['#include "' + m.pathrel(c) + '"' for c in cfile_precompilation]) +txt += '\n#endif\n' +stdafx_h.write(txt) +stdafx_c = path.join('stdafx.c') +stdafx_c.write('#include "stdafx.h"\n') +definitions.append(('CREATE_PCH', '/Ycstdafx.h /Fpstdafx.pch /FIstdafx.h')) +definitions.append(('USE_PCH', '/Yustdafx.h /Fpstdafx.pch /FIstdafx.h')) +rules.append(('all', 'stdafx.pch $(DEFAULT_TARGET)', [])) +rules.append(('stdafx.pch', '', + '$(CC) stdafx.c /c /nologo $(CFLAGS) $(CFLAGSEXTRA) $(CREATE_PCH) $(INCLUDEDIRS)')) +rules.append(('.c.obj', '', +'$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) $(USE_PCH) /Fo$@ /c $< $(INCLUDEDIRS)')) + +target_deps = 'stdafx.obj $(OBJECTS)' +else: +rules.append(('all', '$(DEFAULT_TARGET)', [])) +rules.append(('.c.obj', '', + '$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) /Fo$@ /c $< $(INCLUDEDIRS)')) +target_deps = '$(OBJECTS)' + + for args in definitions: m.definition(*args) -rules = [ -('all', '$(DEFAULT_TARGET)', []), -('.c.obj', '', '$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) /Fo$@ /c $< $(INCLUDEDIRS)'), -('.asm.obj', '', '$(MASM) /nologo /Fo$@ /c $< $(INCLUDEDIRS)'), -] - for rule in rules: m.rule(*rule) @@ -343,12 +366,12 @@ rel_ofiles[-1])
[pypy-commit] pypy precompiled-headers: move Makefile tests
Author: Matti Picus Branch: precompiled-headers Changeset: r69042:0b9dc910cbd5 Date: 2014-01-29 23:39 +0200 http://bitbucket.org/pypy/pypy/changeset/0b9dc910cbd5/ Log:move Makefile tests diff --git a/rpython/translator/platform/test/test_makefile.py b/rpython/translator/platform/test/test_makefile.py --- a/rpython/translator/platform/test/test_makefile.py +++ b/rpython/translator/platform/test/test_makefile.py @@ -1,7 +1,10 @@ from rpython.translator.platform.posix import GnuMakefile as Makefile +from rpython.translator.platform import host +from rpython.tool.udir import udir +from rpython.translator.tool.cbuild import ExternalCompilationInfo from StringIO import StringIO -import re +import re, sys def test_simple_makefile(): m = Makefile() @@ -29,3 +32,106 @@ val = s.getvalue() assert not re.search('CC += +xxx', val, re.M) assert re.search('CC += +yyy', val, re.M) + +class TestMakefile(object): +platform = host +strict_on_stderr = True + +def check_res(self, res, expected='42\n'): +assert res.out == expected +if self.strict_on_stderr: +assert res.err == '' +assert res.returncode == 0 + +def test_900_files(self): +txt = '#include \n' +for i in range(900): +txt += 'int func%03d();\n' % i +txt += 'int main() {\nint j=0;' +for i in range(900): +txt += 'j += func%03d();\n' % i +txt += 'printf("%d\\n", j);\n' +txt += 'return 0;};\n' +cfile = udir.join('test_900_files.c') +cfile.write(txt) +cfiles = [cfile] +for i in range(900): +cfile2 = udir.join('implement%03d.c' %i) +cfile2.write(''' +int func%03d() +{ +return %d; +} +''' % (i, i)) +cfiles.append(cfile2) +mk = self.platform.gen_makefile(cfiles, ExternalCompilationInfo(), path=udir) +mk.write() +self.platform.execute_makefile(mk) +res = self.platform.execute(udir.join('test_900_files')) +self.check_res(res, '%d\n' %sum(range(900))) + +def test_precompiled_headers(self): +import time +tmpdir = udir.join('precompiled_headers').ensure(dir=1) +# Create an eci that should not use precompiled headers +eci = ExternalCompilationInfo(include_dirs=[tmpdir]) +main_c = tmpdir.join('main_no_pch.c') +eci.separate_module_files = [main_c] +ncfiles = 10 +nprecompiled_headers = 20 +txt = '' +for i in range(ncfiles): +txt += "int func%03d();\n" % i +txt += "\nint main(int argc, char * argv[])\n" +txt += "{\n int i=0;\n" +for i in range(ncfiles): +txt += " i += func%03d();\n" % i +txt += 'printf("%d\\n", i);\n' +txt += " return 0;\n};\n" +main_c.write(txt) +# Create some large headers with dummy functions to be precompiled +cfiles_precompiled_headers = [] +for i in range(nprecompiled_headers): +pch_name =tmpdir.join('pcheader%03d.h' % i) +txt = '' +for j in range(3000): +txt += "int pcfunc%03d_%03d();\n" %(i, j) +pch_name.write(txt) +cfiles_precompiled_headers.append(pch_name) +# Create some cfiles with headers we want precompiled +cfiles = [] +for i in range(ncfiles): +c_name =tmpdir.join('implement%03d.c' % i) +txt = '' +for pch_name in cfiles_precompiled_headers: +txt += '#include "%s"\n' % pch_name +txt += "int func%03d(){ return %d;};\n" % (i, i) +c_name.write(txt) +cfiles.append(c_name) +mk = self.platform.gen_makefile(cfiles, eci, path=udir, + cfile_precompilation=cfiles_precompiled_headers) +if sys.platform == 'win32': +clean = ('clean', '', 'for %f in ( $(OBJECTS) $(TARGET) ) do @if exist %f del /f %f') +else: +clean = ('clean', '', 'rm -f $(OBJECTS) $(TARGET) ') +mk.rule(*clean) +mk.write() +t0 = time.clock() +self.platform.execute_makefile(mk) +t1 = time.clock() +t_precompiled = t1 - t0 +res = self.platform.execute(mk.exe_name) +self.check_res(res, '%d\n' %sum(range(ncfiles))) +self.platform.execute_makefile(mk, extra_opts=['clean']) +#Rewrite a non-precompiled header makefile +mk = self.platform.gen_makefile(cfiles, eci, path=udir) +mk.rule(*clean) +mk.write() +t0 = time.clock() +self.platform.execute_makefile(mk) +t1 = time.clock() +t_normal = t1 - t0 +print "precompiled haeder 'make' time %.2f, non-precompiled header time %.2f" %(t_precompiled, t_normal) +assert t_precompiled < t_no
[pypy-commit] pypy default: unused import
Author: Philip Jenvey Branch: Changeset: r69045:186bbfd2aad0 Date: 2014-02-01 12:09 -0800 http://bitbucket.org/pypy/pypy/changeset/186bbfd2aad0/ Log:unused import diff --git a/rpython/rlib/rarithmetic.py b/rpython/rlib/rarithmetic.py --- a/rpython/rlib/rarithmetic.py +++ b/rpython/rlib/rarithmetic.py @@ -690,9 +690,8 @@ characters of 's'. Raises ParseStringError in case of error. Raises ParseStringOverflowError in case the result does not fit. """ -from rpython.rlib.rstring import NumberStringParser, \ -ParseStringOverflowError, \ -ParseStringError, strip_spaces +from rpython.rlib.rstring import ( +NumberStringParser, ParseStringOverflowError, strip_spaces) s = literal = strip_spaces(s) p = NumberStringParser(s, literal, base, 'int') base = p.base ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: remove unnecessary import
Author: Ronan Lamy Branch: Changeset: r69046:180ede03fc14 Date: 2014-02-01 20:32 + http://bitbucket.org/pypy/pypy/changeset/180ede03fc14/ Log:remove unnecessary import diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py --- a/rpython/annotator/annrpython.py +++ b/rpython/annotator/annrpython.py @@ -24,7 +24,6 @@ def __init__(self, translator=None, policy=None, bookkeeper=None): import rpython.rtyper.extfuncregistry # has side effects -import rpython.rlib.nonconst # has side effects if translator is None: # interface for tests ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit