[pypy-commit] pypy default: Fixes
Author: Armin Rigo Branch: Changeset: r87388:1057a7b1ad5f Date: 2016-09-26 09:21 +0200 http://bitbucket.org/pypy/pypy/changeset/1057a7b1ad5f/ Log:Fixes diff --git a/pypy/module/mmap/interp_mmap.py b/pypy/module/mmap/interp_mmap.py --- a/pypy/module/mmap/interp_mmap.py +++ b/pypy/module/mmap/interp_mmap.py @@ -328,7 +328,6 @@ else: # bogus 'e'? return OperationError(space.w_SystemError, space.wrap('%s' % e)) -mmap_error._dont_inline_ = True class MMapBuffer(Buffer): diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py --- a/pypy/objspace/std/formatting.py +++ b/pypy/objspace/std/formatting.py @@ -345,7 +345,7 @@ "unsupported format character '%s' (%s) at index %d", s, hex(ord(c)), self.fmtpos - 1) -@specialize.argtype(2) +@specialize.argtype(1) def std_wp(self, r): length = len(r) if do_unicode and isinstance(r, str): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: If libpypy-c.so is a symlink, look first around the non-deferred path to
Author: Armin Rigo Branch: Changeset: r87387:d1382b9d843b Date: 2016-09-26 09:01 +0200 http://bitbucket.org/pypy/pypy/changeset/d1382b9d843b/ Log:If libpypy-c.so is a symlink, look first around the non-deferred path to libpypy-c.so, and then look around where the symlink points to. Should fix virtualenv (e.g. seen in module.test_lib_pypy.cffi_tests.cffi0.test_zintegration) diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py --- a/pypy/module/sys/initpath.py +++ b/pypy/module/sys/initpath.py @@ -157,6 +157,22 @@ return space.wrap(resolvedirof(filename)) +def find_stdlib_link(state, executable): +path, prefix = find_stdlib(state, executable) +if path is None: +if os.path.islink(executable): +# If we can't find the stdlib from the given 'executable', +# which is usually the path of libpypy-c.so, then we try +# to look if this libpypy-c.so is a symlink and follow that. +try: +link = _readlink_maybe(executable) +except OSError: +pass +else: +return find_stdlib_link(state, link) +return path, prefix + + @unwrap_spec(executable='str0', dynamic=int) def pypy_find_stdlib(space, executable, dynamic=1): if dynamic and space.config.translation.shared: @@ -164,7 +180,7 @@ if dynamic_location: executable = rffi.charp2str(dynamic_location) pypy_init_free(dynamic_location) -path, prefix = find_stdlib(get_state(space), executable) +path, prefix = find_stdlib_link(get_state(space), executable) if path is None: return space.w_None w_prefix = space.wrap(prefix) @@ -229,11 +245,7 @@ dlerror()); return NULL; } -char *p = realpath(info.dli_fname, NULL); -if (p == NULL) { -p = strdup(info.dli_fname); -} -return p; +return strdup(info.dli_fname); } """ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: backout d1382b9d843b: doesn't work, dladdr() doesn't return the symlink's
Author: Armin Rigo Branch: Changeset: r87389:42797eb41b78 Date: 2016-09-26 10:05 +0200 http://bitbucket.org/pypy/pypy/changeset/42797eb41b78/ Log:backout d1382b9d843b: doesn't work, dladdr() doesn't return the symlink's path anyway diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py --- a/pypy/module/sys/initpath.py +++ b/pypy/module/sys/initpath.py @@ -157,22 +157,6 @@ return space.wrap(resolvedirof(filename)) -def find_stdlib_link(state, executable): -path, prefix = find_stdlib(state, executable) -if path is None: -if os.path.islink(executable): -# If we can't find the stdlib from the given 'executable', -# which is usually the path of libpypy-c.so, then we try -# to look if this libpypy-c.so is a symlink and follow that. -try: -link = _readlink_maybe(executable) -except OSError: -pass -else: -return find_stdlib_link(state, link) -return path, prefix - - @unwrap_spec(executable='str0', dynamic=int) def pypy_find_stdlib(space, executable, dynamic=1): if dynamic and space.config.translation.shared: @@ -180,7 +164,7 @@ if dynamic_location: executable = rffi.charp2str(dynamic_location) pypy_init_free(dynamic_location) -path, prefix = find_stdlib_link(get_state(space), executable) +path, prefix = find_stdlib(get_state(space), executable) if path is None: return space.w_None w_prefix = space.wrap(prefix) @@ -245,7 +229,11 @@ dlerror()); return NULL; } -return strdup(info.dli_fname); +char *p = realpath(info.dli_fname, NULL); +if (p == NULL) { +p = strdup(info.dli_fname); +} +return p; } """ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Aargh, missing header meant that the "char *" was truncated to 32 bits
Author: Armin Rigo Branch: Changeset: r87391:4e94cb209019 Date: 2016-09-26 10:24 +0100 http://bitbucket.org/pypy/pypy/changeset/4e94cb209019/ Log:Aargh, missing header meant that the "char *" was truncated to 32 bits (and *usually* it would fit in 32 bits, but of course, not always) diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py --- a/pypy/module/sys/initpath.py +++ b/pypy/module/sys/initpath.py @@ -241,7 +241,8 @@ } """ -_eci = ExternalCompilationInfo(separate_module_sources=[_source_code]) +_eci = ExternalCompilationInfo(separate_module_sources=[_source_code], +post_include_bits=['RPY_EXPORTED char *_pypy_init_home(void);']) pypy_init_home = rffi.llexternal("_pypy_init_home", [], rffi.CCHARP, _nowrapper=True, compilation_info=_eci) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Search first around the pypy executable (like previously),
Author: Armin Rigo Branch: Changeset: r87390:0e3b02bb98e5 Date: 2016-09-26 10:15 +0200 http://bitbucket.org/pypy/pypy/changeset/0e3b02bb98e5/ Log:Search first around the pypy executable (like previously), and only when not found search around the libpypy-c.so diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -93,12 +93,10 @@ home1 = rffi.charp2str(ll_home) home = os.path.join(home1, 'x') # <- so that 'll_home' can be # directly the root directory -dynamic = False else: home1 = "pypy's shared library location" -home = pypydir -dynamic = True -w_path = pypy_find_stdlib(space, home, dynamic) +home = '*' +w_path = pypy_find_stdlib(space, home) if space.is_none(w_path): if verbose: debug("pypy_setup_home: directories 'lib-python' and 'lib_pypy'" diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py --- a/pypy/module/sys/initpath.py +++ b/pypy/module/sys/initpath.py @@ -157,16 +157,20 @@ return space.wrap(resolvedirof(filename)) -@unwrap_spec(executable='str0', dynamic=int) -def pypy_find_stdlib(space, executable, dynamic=1): -if dynamic and space.config.translation.shared: -dynamic_location = pypy_init_home() -if dynamic_location: -executable = rffi.charp2str(dynamic_location) -pypy_init_free(dynamic_location) -path, prefix = find_stdlib(get_state(space), executable) +@unwrap_spec(executable='str0') +def pypy_find_stdlib(space, executable): +path, prefix = None, None +if executable != '*': +path, prefix = find_stdlib(get_state(space), executable) if path is None: -return space.w_None +if space.config.translation.shared: +dynamic_location = pypy_init_home() +if dynamic_location: +dyn_path = rffi.charp2str(dynamic_location) +pypy_init_free(dynamic_location) +path, prefix = find_stdlib(get_state(space), dyn_path) +if path is None: +return space.w_None w_prefix = space.wrap(prefix) space.setitem(space.sys.w_dict, space.wrap('prefix'), w_prefix) space.setitem(space.sys.w_dict, space.wrap('exec_prefix'), w_prefix) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Aaargh again. Borked the locking here. Shows up as a rare crash
Author: Armin Rigo Branch: Changeset: r87392:c540b2c9656a Date: 2016-09-26 10:53 +0100 http://bitbucket.org/pypy/pypy/changeset/c540b2c9656a/ Log:Aaargh again. Borked the locking here. Shows up as a rare crash in test_lib_pypy/cffi_tests/embedding/test_thread. diff --git a/rpython/translator/c/src/threadlocal.c b/rpython/translator/c/src/threadlocal.c --- a/rpython/translator/c/src/threadlocal.c +++ b/rpython/translator/c/src/threadlocal.c @@ -15,9 +15,10 @@ static int check_valid(void); void _RPython_ThreadLocals_Acquire(void) { -while (!pypy_lock_test_and_set(&pypy_threadlocal_lock, 1)) { -/* busy loop */ -} +long old_value; +do { +old_value = pypy_lock_test_and_set(&pypy_threadlocal_lock, 1); +} while (old_value != 0); /* busy loop */ assert(check_valid()); } void _RPython_ThreadLocals_Release(void) { ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: move compiler-workshop slides into scipyUS2016 dir
Author: Richard Plangger Branch: extradoc Changeset: r5714:3b81824d8ce8 Date: 2016-09-26 12:21 +0200 http://bitbucket.org/pypy/extradoc/changeset/3b81824d8ce8/ Log:move compiler-workshop slides into scipyUS2016 dir diff --git a/talk/compiler-workshop-2016/pypy.rst b/talk/scipyUS2016/compiler-workshop-2016/pypy.rst rename from talk/compiler-workshop-2016/pypy.rst rename to talk/scipyUS2016/compiler-workshop-2016/pypy.rst diff --git a/talk/compiler-workshop-2016/slides/CONTRIBUTING.md b/talk/scipyUS2016/compiler-workshop-2016/slides/CONTRIBUTING.md rename from talk/compiler-workshop-2016/slides/CONTRIBUTING.md rename to talk/scipyUS2016/compiler-workshop-2016/slides/CONTRIBUTING.md diff --git a/talk/compiler-workshop-2016/slides/Gruntfile.js b/talk/scipyUS2016/compiler-workshop-2016/slides/Gruntfile.js rename from talk/compiler-workshop-2016/slides/Gruntfile.js rename to talk/scipyUS2016/compiler-workshop-2016/slides/Gruntfile.js diff --git a/talk/compiler-workshop-2016/slides/LICENSE b/talk/scipyUS2016/compiler-workshop-2016/slides/LICENSE rename from talk/compiler-workshop-2016/slides/LICENSE rename to talk/scipyUS2016/compiler-workshop-2016/slides/LICENSE diff --git a/talk/compiler-workshop-2016/slides/README.md b/talk/scipyUS2016/compiler-workshop-2016/slides/README.md rename from talk/compiler-workshop-2016/slides/README.md rename to talk/scipyUS2016/compiler-workshop-2016/slides/README.md diff --git a/talk/compiler-workshop-2016/slides/bower.json b/talk/scipyUS2016/compiler-workshop-2016/slides/bower.json rename from talk/compiler-workshop-2016/slides/bower.json rename to talk/scipyUS2016/compiler-workshop-2016/slides/bower.json diff --git a/talk/compiler-workshop-2016/slides/css/print/paper.css b/talk/scipyUS2016/compiler-workshop-2016/slides/css/print/paper.css rename from talk/compiler-workshop-2016/slides/css/print/paper.css rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/print/paper.css diff --git a/talk/compiler-workshop-2016/slides/css/print/pdf.css b/talk/scipyUS2016/compiler-workshop-2016/slides/css/print/pdf.css rename from talk/compiler-workshop-2016/slides/css/print/pdf.css rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/print/pdf.css diff --git a/talk/compiler-workshop-2016/slides/css/reveal.css b/talk/scipyUS2016/compiler-workshop-2016/slides/css/reveal.css rename from talk/compiler-workshop-2016/slides/css/reveal.css rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/reveal.css diff --git a/talk/compiler-workshop-2016/slides/css/reveal.scss b/talk/scipyUS2016/compiler-workshop-2016/slides/css/reveal.scss rename from talk/compiler-workshop-2016/slides/css/reveal.scss rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/reveal.scss diff --git a/talk/compiler-workshop-2016/slides/css/theme/README.md b/talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/README.md rename from talk/compiler-workshop-2016/slides/css/theme/README.md rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/README.md diff --git a/talk/compiler-workshop-2016/slides/css/theme/beige.css b/talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/beige.css rename from talk/compiler-workshop-2016/slides/css/theme/beige.css rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/beige.css diff --git a/talk/compiler-workshop-2016/slides/css/theme/black.css b/talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/black.css rename from talk/compiler-workshop-2016/slides/css/theme/black.css rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/black.css diff --git a/talk/compiler-workshop-2016/slides/css/theme/blood.css b/talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/blood.css rename from talk/compiler-workshop-2016/slides/css/theme/blood.css rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/blood.css diff --git a/talk/compiler-workshop-2016/slides/css/theme/league.css b/talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/league.css rename from talk/compiler-workshop-2016/slides/css/theme/league.css rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/league.css diff --git a/talk/compiler-workshop-2016/slides/css/theme/moon.css b/talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/moon.css rename from talk/compiler-workshop-2016/slides/css/theme/moon.css rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/moon.css diff --git a/talk/compiler-workshop-2016/slides/css/theme/night.css b/talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/night.css rename from talk/compiler-workshop-2016/slides/css/theme/night.css rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/night.css diff --git a/talk/compiler-workshop-2016/slides/css/theme/serif.css b/talk/scipyUS2016/compiler-workshop-2016/slides/css/theme/serif.css rename from talk/compiler-workshop-2016/slides/css/theme/serif.css rename to talk/scipyUS2016/compiler-workshop-2016/slides/css/t
[pypy-commit] extradoc extradoc: create new empty slide deck for my presentation in pyconza, rmeove test files for reveal.js
Author: Richard Plangger Branch: extradoc Changeset: r5715:61d8bc530462 Date: 2016-09-26 12:41 +0200 http://bitbucket.org/pypy/extradoc/changeset/61d8bc530462/ Log:create new empty slide deck for my presentation in pyconza, rmeove test files for reveal.js diff too long, truncating to 2000 out of 20819 lines diff --git a/talk/pyconza2016/pypy/CONTRIBUTING.md b/talk/pyconza2016/pypy/CONTRIBUTING.md new file mode 100644 --- /dev/null +++ b/talk/pyconza2016/pypy/CONTRIBUTING.md @@ -0,0 +1,23 @@ +## Contributing + +Please keep the [issue tracker](http://github.com/hakimel/reveal.js/issues) limited to **bug reports**, **feature requests** and **pull requests**. + + +### Personal Support +If you have personal support or setup questions the best place to ask those are [StackOverflow](http://stackoverflow.com/questions/tagged/reveal.js). + + +### Bug Reports +When reporting a bug make sure to include information about which browser and operating system you are on as well as the necessary steps to reproduce the issue. If possible please include a link to a sample presentation where the bug can be tested. + + +### Pull Requests +- Should follow the coding style of the file you work in, most importantly: + - Tabs to indent + - Single-quoted strings +- Should be made towards the **dev branch** +- Should be submitted from a feature/topic branch (not your master) + + +### Plugins +Please do not submit plugins as pull requests. They should be maintained in their own separate repository. More information here: https://github.com/hakimel/reveal.js/wiki/Plugin-Guidelines diff --git a/talk/pyconza2016/pypy/Gruntfile.js b/talk/pyconza2016/pypy/Gruntfile.js new file mode 100644 --- /dev/null +++ b/talk/pyconza2016/pypy/Gruntfile.js @@ -0,0 +1,176 @@ +/* global module:false */ +module.exports = function(grunt) { + var port = grunt.option('port') || 8000; + var base = grunt.option('base') || '.'; + + // Project configuration + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + meta: { + banner: + '/*!\n' + + ' * reveal.js <%= pkg.version %> (<%= grunt.template.today("-mm-dd, HH:MM") %>)\n' + + ' * http://lab.hakim.se/reveal-js\n' + + ' * MIT licensed\n' + + ' *\n' + + ' * Copyright (C) 2016 Hakim El Hattab, http://hakim.se\n' + + ' */' + }, + + qunit: { + files: [ 'test/*.html' ] + }, + + uglify: { + options: { + banner: '<%= meta.banner %>\n' + }, + build: { + src: 'js/reveal.js', + dest: 'js/reveal.min.js' + } + }, + + sass: { + core: { + files: { + 'css/reveal.css': 'css/reveal.scss', + } + }, + themes: { + files: [ + { + expand: true, + cwd: 'css/theme/source', + src: ['*.scss'], + dest: 'css/theme', + ext: '.css' + } + ] + } + }, + + autoprefixer: { + dist: { + src: 'css/reveal.css' + } + }, + + cssmin: { + compress: { + files: { + 'css/reveal.min.css': [ 'css/reveal.css' ] + } + } + }, + + jshint: { + options: { + curly: false, + eqeqeq: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + sub: true, + undef: true, + eqnull: true, + browser: true, + expr: true, + globals: { + head: false, + module: false, +
[pypy-commit] extradoc extradoc: assign me a new task
Author: Richard Plangger Branch: extradoc Changeset: r5716:16a9983d1c9a Date: 2016-09-26 15:19 +0200 http://bitbucket.org/pypy/extradoc/changeset/16a9983d1c9a/ Log:assign me a new task diff --git a/planning/py3.5/milestone-1-progress.rst b/planning/py3.5/milestone-1-progress.rst --- a/planning/py3.5/milestone-1-progress.rst +++ b/planning/py3.5/milestone-1-progress.rst @@ -5,14 +5,7 @@ In-progress ("Lock" section) -* richard: Implement changes to memory view. e.g. hex(): https://bugs.python.org/issue9951 - Seems to work, but test suite hangs to verify the CPython tests. -* richard: tuple indexing for memory view, - Comments: Stronly tied to numpy. Hard to implement, because most of the basics are missing (dimensions/strides) - We should make a plan to impl. that on default with cpyext support and merge it back to py3.5. - Matti's opinion on that would be great! -* richard: extended slicing for memory view -* richard: bytes % args, bytearray % args: PEP 461 +* richard: bz2, lzma, ... changes (cpython issue 15955) * arigo: faulthandler module @@ -46,7 +39,6 @@ 'array' is typically an extension module; at least that's the case on Linux with default compilation settings). - Milestone 1 (Aug-Sep-Oct 2016) -- ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5-bz2-lzma: adding properties and new parameters in py3.5 (work in progress)
Author: Richard Plangger Branch: py3.5-bz2-lzma Changeset: r87393:3bc7c28ee3a9 Date: 2016-09-26 17:36 +0200 http://bitbucket.org/pypy/pypy/changeset/3bc7c28ee3a9/ Log:adding properties and new parameters in py3.5 (work in progress) diff --git a/pypy/module/bz2/interp_bz2.py b/pypy/module/bz2/interp_bz2.py --- a/pypy/module/bz2/interp_bz2.py +++ b/pypy/module/bz2/interp_bz2.py @@ -96,9 +96,11 @@ BZ_SEQUENCE_ERROR = cConfig.BZ_SEQUENCE_ERROR if BUFSIZ < 8192: -SMALLCHUNK = 8192 +INITIAL_BUFFER_SIZE = 8192 else: -SMALLCHUNK = BUFSIZ +INITIAL_BUFFER_SIZE = 8192 + +UINT_MAX = 2**32-1 if rffi.sizeof(rffi.INT) > 4: BIGCHUNK = 512 * 32 @@ -187,12 +189,21 @@ encapsulate the logic of setting up the fields of 'bzs' and allocating raw memory as needed. """ -def __init__(self, bzs, initial_size=SMALLCHUNK): +def __init__(self, bzs, initial_size=INITIAL_BUFFER_SIZE, max_length=-1): # when the constructor is called, allocate a piece of memory # of length 'piece_size' and make bzs ready to dump there. self.temp = [] self.bzs = bzs -self._allocate_chunk(initial_size) +self.max_length = max_length +if max_length < 0 or max_length >= initial_size: +size = initial_size +else: +size = max_length +self._allocate_chunk(size) +self.avail_in_real = 0 + +def get_data_size(self): +return 0 def _allocate_chunk(self, size): self.raw_buf, self.gc_buf, self.case_num = rffi.alloc_buffer(size) @@ -357,7 +368,6 @@ W_BZ2Decompressor.__init__(x, space) return space.wrap(x) - class W_BZ2Decompressor(W_Root): """BZ2Decompressor() -> decompressor object @@ -372,6 +382,8 @@ try: self.running = False self.unused_data = "" +self.needs_input = 1 +self.input_buffer = None self._init_bz2decomp() except: @@ -397,15 +409,47 @@ def descr_getstate(self): raise oefmt(self.space.w_TypeError, "cannot serialize '%T' object", self) +def needs_input_w(self, space): +""" True if more input is needed before more decompressed +data can be produced. """ +return space.wrap(self.needs_input) + def eof_w(self, space): if self.running: return space.w_False else: return space.w_True -@unwrap_spec(data='bufferstr') -def decompress(self, data): -"""decompress(data) -> string +def _decompress_buf(self, data, max_length): +in_bufsize = len(data) + +with rffi.scoped_nonmovingbuffer(data) as in_buf: +self.bzs.c_next_in = in_buf +rffi.setintfield(self.bzs, 'c_avail_in', in_bufsize) + +with OutBuffer(self.bzs, max_length=max_length) as out: +while True: +bzerror = BZ2_bzDecompress(self.bzs) +if bzerror == BZ_STREAM_END: +self.running = False +break +if bzerror != BZ_OK: +_catch_bz2_error(self.space, bzerror) + +if rffi.getintfield(self.bzs, 'c_avail_in') == 0: +break +elif rffi.getintfield(self.bzs, 'c_avail_out') == 0: +if out.get_data_size() == max_length: +break +out.prepare_next_chunk() +res = out.make_result_string() +# might be non zero if max_length has been specified +self.left_to_process = out.left +return self.space.newbytes(res) + +@unwrap_spec(data='bufferstr', max_length=int) +def decompress(self, data, max_length=-1): +"""decompress(data, max_length=-1) -> bytes Provide more data to the decompressor object. It will return chunks of decompressed data whenever possible. If you try to decompress data @@ -419,34 +463,27 @@ if data == '': return self.space.newbytes('') -in_bufsize = len(data) +bzs = self.bzs +if not self.input_buffer: +input_buffer_in_use = True +result = self._decompress_buf(self.input_buffer, max_length) +else: +input_buffer_in_use = False +result = self._decompress_buf(data, max_length) -with rffi.scoped_nonmovingbuffer(data) as in_buf: -self.bzs.c_next_in = in_buf -rffi.setintfield(self.bzs, 'c_avail_in', in_bufsize) +if self.left_to_process == 0: +self.input_buffer = None +self.need_input = 1 +else: +self.need_input = 0 +if not input_buffer_in_use: +datalen = len(data) +self.input_buffer = data[datalen-self.left_to_process-1:] -with OutBuffer(self.bzs) as out: -
[pypy-commit] pypy default: Fix what occurs near the limit MAX_STACK_DEPTH: I *think* it would
Author: Armin Rigo Branch: Changeset: r87394:a6e7414f79c7 Date: 2016-09-26 17:52 +0200 http://bitbucket.org/pypy/pypy/changeset/a6e7414f79c7/ Log:Fix what occurs near the limit MAX_STACK_DEPTH: I *think* it would appear to skip some frames then, in the JIT case diff --git a/rpython/rlib/rvmprof/src/vmprof_get_custom_offset.h b/rpython/rlib/rvmprof/src/vmprof_get_custom_offset.h --- a/rpython/rlib/rvmprof/src/vmprof_get_custom_offset.h +++ b/rpython/rlib/rvmprof/src/vmprof_get_custom_offset.h @@ -4,17 +4,18 @@ long *current_pos_addr); +#define MAX_INLINE_DEPTH 384 + + static long vmprof_write_header_for_jit_addr(intptr_t *result, long n, - intptr_t ip, int max_depth) + intptr_t addr, int max_depth) { #ifdef PYPY_JIT_CODEMAP void *codemap; long current_pos = 0; -intptr_t ident; +intptr_t ident, local_stack[MAX_INLINE_DEPTH]; +long m; long start_addr = 0; -intptr_t addr = (intptr_t)ip; -int start, k; -intptr_t tmp; codemap = pypy_find_codemap_at_addr(addr, &start_addr); if (codemap == NULL || n >= max_depth - 2) @@ -25,24 +26,29 @@ // in the middle result[n++] = VMPROF_ASSEMBLER_TAG; result[n++] = start_addr; -start = n; -while (n < max_depth) { + +// build the list of code idents corresponding to the current +// position inside this particular piece of assembler. If (very +// unlikely) we get more than MAX_INLINE_DEPTH recursion levels +// all inlined inside this single piece of assembler, then stop: +// there will be some missing frames then. Otherwise, we need to +// first collect 'local_stack' and then write it to 'result' in the +// opposite order, stopping at 'max_depth'. Previous versions of +// the code would write the oldest calls and then stop---whereas +// what we really need it to write the newest calls and then stop. +m = 0; +while (m < MAX_INLINE_DEPTH) { ident = pypy_yield_codemap_at_addr(codemap, addr, ¤t_pos); if (ident == -1) // finish break; if (ident == 0) continue; // not main codemap +local_stack[m++] = ident; +} +while (m > 0 && n < max_depth) { result[n++] = VMPROF_JITTED_TAG; -result[n++] = ident; -} -k = 1; - -while (k < (n - start) / 2) { -tmp = result[start + k]; -result[start + k] = result[n - k]; -result[n - k] = tmp; -k += 2; +result[n++] = local_stack[--m]; } #endif return n; ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: add comment
Author: Armin Rigo Branch: Changeset: r87395:9e9d4ae8cad2 Date: 2016-09-26 18:02 +0200 http://bitbucket.org/pypy/pypy/changeset/9e9d4ae8cad2/ Log:add comment diff --git a/rpython/jit/backend/x86/callbuilder.py b/rpython/jit/backend/x86/callbuilder.py --- a/rpython/jit/backend/x86/callbuilder.py +++ b/rpython/jit/backend/x86/callbuilder.py @@ -138,6 +138,7 @@ # shadowstack: change 'rpy_fastgil' to 0 (it should be # non-zero right now). self.change_extra_stack_depth = False +# ^^ note that set_extra_stack_depth() in this case is a no-op css_value = imm(0) else: from rpython.memory.gctransform import asmgcroot ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k-faulthandler: in-progress
Author: Armin Rigo Branch: py3k-faulthandler Changeset: r87396:80e8de7e078d Date: 2016-09-26 20:17 +0200 http://bitbucket.org/pypy/pypy/changeset/80e8de7e078d/ Log:in-progress 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 @@ -56,6 +56,11 @@ [rffi.INT], lltype.Void, compilation_info=eci, _nowrapper=True) +vmprof_get_traceback = rffi.llexternal("vmprof_get_traceback", + [PVMPROFSTACK, lltype.Signed, + rffi.SIGNEDP, lltype.Signed], + lltype.Signed, compilation_info=eci, + _nowrapper=True) return CInterface(locals()) @@ -156,7 +161,7 @@ vmprof_tl_stack.setraw(x) # -# rvmprof.traceback support +# traceback support def get_rvmprof_stack(): return vmprof_tl_stack.get_or_make_raw() diff --git a/rpython/rlib/rvmprof/src/rvmprof.h b/rpython/rlib/rvmprof/src/rvmprof.h --- a/rpython/rlib/rvmprof/src/rvmprof.h +++ b/rpython/rlib/rvmprof/src/rvmprof.h @@ -8,3 +8,6 @@ RPY_EXTERN int vmprof_stack_append(void*, long); RPY_EXTERN long vmprof_stack_pop(void*); RPY_EXTERN void vmprof_stack_free(void*); +RPY_EXTERN intptr_t vmprof_get_traceback(void *, intptr_t, intptr_t*, intptr_t); + +#define RVMPROF_TRACEBACK_ESTIMATE_N(num_entries) (2 * (num_entries) + 4) 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 @@ -128,3 +128,14 @@ return 0; } #endif + +RPY_EXTERN +intptr_t vmprof_get_traceback(void *stack, intptr_t pc, + intptr_t *result_p, intptr_t result_length) +{ +int n; +if (stack == NULL) +stack = get_vmprof_stack(); +n = get_stack_trace(stack, result_p, result_length - 2, pc); +return (intptr_t)n; +} diff --git a/rpython/rlib/rvmprof/test/test_traceback.py b/rpython/rlib/rvmprof/test/test_traceback.py --- a/rpython/rlib/rvmprof/test/test_traceback.py +++ b/rpython/rlib/rvmprof/test/test_traceback.py @@ -1,7 +1,8 @@ import re -from rpython.rlib import rvmprof -from rpython.rlib.rvmprof.traceback import traceback +from rpython.rlib import rvmprof, jit +from rpython.rlib.rvmprof import traceback from rpython.translator.interactive import Translation +from rpython.rtyper.lltypesystem import lltype def test_direct(): @@ -17,20 +18,21 @@ if level > 0: mainloop(code, level - 1) else: -traceback(MyCode, my_callback, 42) +p, length = traceback.traceback(20) +traceback.walk_traceback(MyCode, my_callback, 42, p, length) +lltype.free(p, flavor='raw') # seen = [] -def my_callback(depth, code, arg): -seen.append((depth, code, arg)) -return 0 +def my_callback(code, loc, arg): +seen.append((code, loc, arg)) # code1 = MyCode() rvmprof.register_code(code1, "foo") mainloop(code1, 2) # -assert seen == [(0, code1, 42), -(1, code1, 42), -(2, code1, 42)] +assert seen == [(code1, traceback.LOC_INTERPRETED, 42), +(code1, traceback.LOC_INTERPRETED, 42), +(code1, traceback.LOC_INTERPRETED, 42)] def test_compiled(): class MyCode: @@ -44,10 +46,12 @@ if level > 0: mainloop(code, level - 1) else: -traceback(MyCode, my_callback, 42) +p, length = traceback.traceback(20) +traceback.walk_traceback(MyCode, my_callback, 42, p, length) +lltype.free(p, flavor='raw') -def my_callback(depth, code, arg): -print depth, code, arg +def my_callback(code, loc, arg): +print code, loc, arg return 0 def f(argv): @@ -59,7 +63,49 @@ t = Translation(f, None, gc="boehm") t.compile_c() stdout = t.driver.cbuilder.cmdexec('') -r = re.compile("(\d+) [<]MyCode object at 0x([0-9a-f]+)[>] 42\n") +r = re.compile("[<]MyCode object at 0x([0-9a-f]+)[>] 0 42\n") +got = r.findall(stdout) +assert got == [got[0]] * 3 + +def test_jitted(): +class MyCode: +pass +def get_name(mycode): +raise NotImplementedError +rvmprof.register_code_object_class(MyCode, get_name) + +jitdriver = jit.JitDriver(greens=[], reds='auto') + +@rvmprof.vmprof_execute_code("mycode", lambda code, level, total_i: code) +def mainloop(code, level, total_i): +i = 20 +while i > 0: +jitdriver.jit_merge_point() +i -= 1 +if level > 0: +mainloop(code, level - 1, total_i + i) +if level == 0 and total_i == 0: +
[pypy-commit] pypy cpyext-null-slots: abandon making int(np.string_('abc')) raise a ValueError
Author: Matti Picus Branch: cpyext-null-slots Changeset: r87397:d37191c0da88 Date: 2016-09-26 21:57 +0300 http://bitbucket.org/pypy/pypy/changeset/d37191c0da88/ Log:abandon making int(np.string_('abc')) raise a ValueError diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py --- a/pypy/module/cpyext/typeobject.py +++ b/pypy/module/cpyext/typeobject.py @@ -479,10 +479,6 @@ if pto.c_tp_doc: self.w_doc = space.wrap(rffi.charp2str(pto.c_tp_doc)) -def lookup(self, name): -# do not traverse the mro, look only in self -return self.getdictvalue(self.space, name) - @bootstrap_function def init_typeobject(space): make_typedescr(space.w_type.layout.typedef, @@ -823,25 +819,17 @@ # inheriting tp_as_* slots base = py_type.c_tp_base if base: -remap_slots = False if not py_type.c_tp_as_number: py_type.c_tp_as_number = base.c_tp_as_number py_type.c_tp_flags |= base.c_tp_flags & Py_TPFLAGS_CHECKTYPES py_type.c_tp_flags |= base.c_tp_flags & Py_TPFLAGS_HAVE_INPLACEOPS -remap_slots = True if not py_type.c_tp_as_sequence: py_type.c_tp_as_sequence = base.c_tp_as_sequence py_type.c_tp_flags |= base.c_tp_flags & Py_TPFLAGS_HAVE_INPLACEOPS -remap_slots = True if not py_type.c_tp_as_mapping: py_type.c_tp_as_mapping = base.c_tp_as_mapping -remap_slots = True if not py_type.c_tp_as_buffer: py_type.c_tp_as_buffer = base.c_tp_as_buffer -remap_slots = True -if remap_slots: -add_operators(space, w_obj.dict_w, py_type) - return w_obj def finish_type_1(space, pto): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy closed-branches: Merge closed head faca61b444b4 on branch w-xor-x2
Author: Matti Picus Branch: closed-branches Changeset: r87398:fd181c80ace7 Date: 2016-09-26 22:02 +0300 http://bitbucket.org/pypy/pypy/changeset/fd181c80ace7/ Log:Merge closed head faca61b444b4 on branch w-xor-x2 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy closed-branches: Merge closed head d37191c0da88 on branch cpyext-null-slots
Author: Matti Picus Branch: closed-branches Changeset: r87400:3ded4861a366 Date: 2016-09-26 22:02 +0300 http://bitbucket.org/pypy/pypy/changeset/3ded4861a366/ Log:Merge closed head d37191c0da88 on branch cpyext-null-slots ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy closed-branches: re-close this branch
Author: Matti Picus Branch: closed-branches Changeset: r87401:3c1fdb654106 Date: 2016-09-26 22:02 +0300 http://bitbucket.org/pypy/pypy/changeset/3c1fdb654106/ Log:re-close this branch ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy buffer-interface2: merge default into branch
Author: Matti Picus Branch: buffer-interface2 Changeset: r87402:46f3011f6b83 Date: 2016-09-26 22:07 +0300 http://bitbucket.org/pypy/pypy/changeset/46f3011f6b83/ Log:merge default into branch diff too long, truncating to 2000 out of 2477 lines diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py --- a/lib-python/2.7/distutils/sysconfig_pypy.py +++ b/lib-python/2.7/distutils/sysconfig_pypy.py @@ -13,6 +13,7 @@ import sys import os import shlex +import imp from distutils.errors import DistutilsPlatformError @@ -62,8 +63,7 @@ """Initialize the module as appropriate for POSIX systems.""" g = {} g['EXE'] = "" -g['SO'] = ".so" -g['SOABI'] = g['SO'].rsplit('.')[0] +g['SO'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0] g['LIBDIR'] = os.path.join(sys.prefix, 'lib') g['CC'] = "gcc -pthread" # -pthread might not be valid on OS/X, check @@ -75,8 +75,7 @@ """Initialize the module as appropriate for NT""" g = {} g['EXE'] = ".exe" -g['SO'] = ".pyd" -g['SOABI'] = g['SO'].rsplit('.')[0] +g['SO'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0] global _config_vars _config_vars = g diff --git a/lib-python/2.7/sysconfig.py b/lib-python/2.7/sysconfig.py --- a/lib-python/2.7/sysconfig.py +++ b/lib-python/2.7/sysconfig.py @@ -529,7 +529,7 @@ for suffix, mode, type_ in imp.get_suffixes(): if type_ == imp.C_EXTENSION: _CONFIG_VARS['SOABI'] = suffix.split('.')[1] -break +break if args: vals = [] diff --git a/lib_pypy/_subprocess.py b/lib_pypy/_subprocess.py --- a/lib_pypy/_subprocess.py +++ b/lib_pypy/_subprocess.py @@ -22,7 +22,10 @@ code, message = _ffi.getwinerror() raise WindowsError(code, message) -_INVALID_HANDLE_VALUE = _ffi.cast("HANDLE", -1) +def _int2handle(val): +return _ffi.cast("HANDLE", val) + +_INVALID_HANDLE_VALUE = _int2handle(-1) class _handle(object): def __init__(self, c_handle): @@ -70,9 +73,9 @@ target = _ffi.new("HANDLE[1]") res = _kernel32.DuplicateHandle( -_ffi.cast("HANDLE", source_process), -_ffi.cast("HANDLE", source), -_ffi.cast("HANDLE", target_process), +_int2handle(source_process), +_int2handle(source), +_int2handle(target_process), target, access, inherit, options) if not res: @@ -119,12 +122,14 @@ if not res: raise _WinError() -return _handle(pi.hProcess), _handle(pi.hThread), pi.dwProcessId, pi.dwThreadId +return (_handle(pi.hProcess), +_handle(pi.hThread), +pi.dwProcessId, +pi.dwThreadId) def WaitForSingleObject(handle, milliseconds): # CPython: the first argument is expected to be an integer. -res = _kernel32.WaitForSingleObject(_ffi.cast("HANDLE", handle), -milliseconds) +res = _kernel32.WaitForSingleObject(_int2handle(handle), milliseconds) if res < 0: raise _WinError() @@ -134,7 +139,7 @@ # CPython: the first argument is expected to be an integer. code = _ffi.new("DWORD[1]") -res = _kernel32.GetExitCodeProcess(_ffi.cast("HANDLE", handle), code) +res = _kernel32.GetExitCodeProcess(_int2handle(handle), code) if not res: raise _WinError() @@ -144,7 +149,7 @@ def TerminateProcess(handle, exitcode): # CPython: the first argument is expected to be an integer. # The second argument is silently wrapped in a UINT. -res = _kernel32.TerminateProcess(_ffi.cast("HANDLE", handle), +res = _kernel32.TerminateProcess(_int2handle(handle), _ffi.cast("UINT", exitcode)) if not res: diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO --- a/lib_pypy/cffi.egg-info/PKG-INFO +++ b/lib_pypy/cffi.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: cffi -Version: 1.8.3 +Version: 1.8.4 Summary: Foreign Function Interface for Python calling C code. Home-page: http://cffi.readthedocs.org Author: Armin Rigo, Maciej Fijalkowski diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py --- a/lib_pypy/cffi/__init__.py +++ b/lib_pypy/cffi/__init__.py @@ -4,8 +4,8 @@ from .api import FFI, CDefError, FFIError from .ffiplatform import VerificationError, VerificationMissing -__version__ = "1.8.3" -__version_info__ = (1, 8, 3) +__version__ = "1.8.4" +__version_info__ = (1, 8, 4) # The verifier module file names are based on the CRC32 of a string that # contains the following version number. It may be older than __version__ diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h --- a/lib_pypy/cffi/_embedding.h +++ b/lib_pypy/cffi/_embedding.h @@ -233,7 +233,7 @@ f = PySys_GetObject((char *)"stderr"); if (f != NULL && f != Py_None) { P
[pypy-commit] pypy closed-branches: Merge closed head ba39bd805638 on branch zarch-simd-support
Author: Matti Picus Branch: closed-branches Changeset: r87399:c2e0070d0212 Date: 2016-09-26 22:02 +0300 http://bitbucket.org/pypy/pypy/changeset/c2e0070d0212/ Log:Merge closed head ba39bd805638 on branch zarch-simd-support ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-classes: Cleanup
Author: Spenser Bauman Branch: value-classes Changeset: r87403:e927b403b073 Date: 2016-09-26 13:05 -0400 http://bitbucket.org/pypy/pypy/changeset/e927b403b073/ Log:Cleanup diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py b/rpython/jit/metainterp/optimizeopt/virtualstate.py --- a/rpython/jit/metainterp/optimizeopt/virtualstate.py +++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py @@ -132,7 +132,6 @@ def debug_header(self, indent): raise NotImplementedError - class AbstractVirtualStructStateInfo(AbstractVirtualStateInfo): _attrs_ = ('typedescr', 'fielddescrs') @@ -141,6 +140,9 @@ self.fielddescrs = fielddescrs def _generate_guards(self, other, box, runtime_box, state): +if isinstance(other, NotVirtualStateInfo): +return self._generate_guards_non_virtual(other, box, runtime_box, state) + if not self._generalization_of_structpart(other): raise VirtualStatesCantMatch("different kinds of structs") @@ -178,7 +180,13 @@ fieldbox_runtime, state) def _generate_guards_non_virtual(self, other, box, runtime_box, state): -pass +""" +Generate guards for the case where a virtual object is expected, but +a non-virtual is given. When the underlying type is a value class, +the non-virtual may be virtualized by unpacking it and forwarding the +components elementwise. +""" +raise VirtualStatesCantMatch("different kinds of structs") def enum_forced_boxes(self, boxes, box, optimizer, force_boxes=False): box = optimizer.get_box_replacement(box) @@ -227,6 +235,7 @@ debug_print(indent + 'VStructStateInfo(%d):' % self.position) class VArrayStateInfo(AbstractVirtualStateInfo): +_attrs_ = ('arraydescr',) def __init__(self, arraydescr): self.arraydescr = arraydescr @@ -277,6 +286,8 @@ class VArrayStructStateInfo(AbstractVirtualStateInfo): +_attrs_ = ('arraydescr', 'fielddescrs', 'length') + def __init__(self, arraydescr, fielddescrs, length): self.arraydescr = arraydescr self.fielddescrs = fielddescrs @@ -355,10 +366,12 @@ return NotVirtualStateInfoInt(cpu, type, info) if type == 'r': return NotVirtualStateInfoPtr(cpu, type, info) +assert type == 'f' return NotVirtualStateInfo(cpu, type, info) class NotVirtualStateInfo(AbstractVirtualStateInfo): +_attrs_ = ('level', 'constbox', 'position_in_notvirtuals') level = LEVEL_UNKNOWN constbox = None @@ -458,6 +471,7 @@ debug_print(result) class NotVirtualStateInfoInt(NotVirtualStateInfo): +_attrs_ = ('intbound') intbound = None def __init__(self, cpu, type, info): @@ -492,6 +506,7 @@ class NotVirtualStateInfoPtr(NotVirtualStateInfo): +_attrs_ = ('lenbound', 'known_class') lenbound = None known_class = None diff --git a/rpython/jit/metainterp/test/test_virtual.py b/rpython/jit/metainterp/test/test_virtual.py --- a/rpython/jit/metainterp/test/test_virtual.py +++ b/rpython/jit/metainterp/test/test_virtual.py @@ -1048,12 +1048,7 @@ # virtual X object. The side exit in this case will contain a non-virtual # value class, which should be unpacked into the -# self.check_resops(jump=3, label=2, new_with_vtable=2) -# self.check_target_token_count(2) -# self.check_trace_count(3) - - -def test_conflated_virtual_states(self): +def test_aliased_virtual_states(self): # All cases are covered when forcing one component of the virtual state # also forces an as yet unseen component. # i.e. expect [NotVirtual, Virtual] and given a pair of aliasing virtual ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-classes: Kill dead rop function
Author: Spenser Bauman Branch: value-classes Changeset: r87405:da2ccb17ee1d Date: 2016-09-26 16:24 -0400 http://bitbucket.org/pypy/pypy/changeset/da2ccb17ee1d/ Log:Kill dead rop function diff --git a/rpython/jit/metainterp/resoperation.py b/rpython/jit/metainterp/resoperation.py --- a/rpython/jit/metainterp/resoperation.py +++ b/rpython/jit/metainterp/resoperation.py @@ -1265,14 +1265,6 @@ return rop.CALL_LOOPINVARIANT_N @staticmethod -def getfield_pure_for_descr(descr): -if descr.is_pointer_field(): -return rop.GETFIELD_GC_PURE_R -elif descr.is_float_field(): -return rop.GETFIELD_GC_PURE_F -return rop.GETFIELD_GC_PURE_I - -@staticmethod def getfield_for_descr(descr): if descr.is_pointer_field(): return rop.GETFIELD_GC_R ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-classes: Work on merging virtual and non-virtual states
Author: Spenser Bauman Branch: value-classes Changeset: r87404:460dc18502fe Date: 2016-09-26 16:14 -0400 http://bitbucket.org/pypy/pypy/changeset/460dc18502fe/ Log:Work on merging virtual and non-virtual states 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 @@ -33,8 +33,11 @@ class FakeDescr(object): def __init__(self, vtable): self.vtable = vtable +def is_value_class(self): +return False def get_vtable(self): return self.vtable + FakeDescr.value = FakeDescr(42) class BaseTestGenerateGuards(BaseTest): diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py b/rpython/jit/metainterp/optimizeopt/virtualstate.py --- a/rpython/jit/metainterp/optimizeopt/virtualstate.py +++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py @@ -179,15 +179,6 @@ fieldbox, fieldbox_runtime, state) -def _generate_guards_non_virtual(self, other, box, runtime_box, state): -""" -Generate guards for the case where a virtual object is expected, but -a non-virtual is given. When the underlying type is a value class, -the non-virtual may be virtualized by unpacking it and forwarding the -components elementwise. -""" -raise VirtualStatesCantMatch("different kinds of structs") - def enum_forced_boxes(self, boxes, box, optimizer, force_boxes=False): box = optimizer.get_box_replacement(box) info = optimizer.getptrinfo(box) @@ -222,6 +213,63 @@ return (isinstance(other, VirtualStateInfo) and self.typedescr is other.typedescr) +def _generate_guards_non_virtual(self, other, box, runtime_box, state): +""" +Generate guards for the case where a virtual object is expected, but +a non-virtual is given. When the underlying type is a value class, +the non-virtual may be virtualized by unpacking it and forwarding the +components elementwise. +""" +assert isinstance(other, NotVirtualStateInfoPtr) + +known_class = self.typedescr +if not known_class.is_value_class(): +raise VirtualStatesCantMatch("different kinds of structs") + +raise VirtualStatesCantMatch("different kinds of structs") + +# TODO: Probably should rename state.extra_guards to extra_ops +extra_guards = state.extra_guards +cpu = state.cpu + +# Emit any guards that are needed to validate the class of the supplied +# object, so that we know it is safe to unpack. +if other.level == LEVEL_UNKNOWN: +op = ResOperation(rop.GUARD_NONNULL_CLASS, [box, self.known_class]) +extra_guards.append(op) +elif other.level == LEVEL_NONULL: +op = ResOperation(rop.GUARD_CLASS, [box, self.known_class]) +extra_guards.append(op) +elif other.level == LEVEL_KNOWNCLASS: +if not self.known_class.same_constant(other.known_class): +raise VirtualStatesCantMatch("classes don't match") +else: +assert other.level == LEVEL_CONSTANT +known = self.known_class +const = other.constbox +if const.nonnull() and known.same_constant(cpu.ts.cls_of_box(const)): +pass +else: +raise VirtualStatesCantMatch("classes don't match") + +# Things to do... +# 1. Generate new_with_vtable operation to allocate the new virtual object +# 2. Generate getfield operations which populate the fields of the new virtual +# 3. Recursively generate guards for each portion of the virtual state +#(we don't have a VirtualStateInfo objects for the subfields of the +# non-virtual object which we are promoting to a virtual. How do we +# generate this new virtual state so we can operate recursively) + +# We need to build a virtual version which conforms with the expected +# virtual object. +# This will probably look a lot like +# AbstractVirtualStateInfo._generate_guards +fields = [None] * len(self.fielddescrs) +for i, descr in enumerate(self.fielddescrs): +opnum = rop.getfield_for_descr(descr) +fields[i] = getfield_op = ResOperation(opnum, [box], descr=descr) +extra_guards.append(getfield_op) + def debug_header(self, indent): debug_print(indent + 'VirtualStateInfo(%d):' % self.position) @@ -231,6 +279,9 @@ return (isinstance(other, VStructStateInfo) and self.typedescr is other.typedescr) +def _generate_guards_non_virtual(self, other, box, runt
[pypy-commit] pypy py3k-faulthandler: fix the test
Author: Armin Rigo Branch: py3k-faulthandler Changeset: r87406:986e0e2abaa1 Date: 2016-09-26 23:20 +0200 http://bitbucket.org/pypy/pypy/changeset/986e0e2abaa1/ Log:fix the test diff --git a/rpython/rlib/rvmprof/test/test_traceback.py b/rpython/rlib/rvmprof/test/test_traceback.py --- a/rpython/rlib/rvmprof/test/test_traceback.py +++ b/rpython/rlib/rvmprof/test/test_traceback.py @@ -74,13 +74,15 @@ raise NotImplementedError rvmprof.register_code_object_class(MyCode, get_name) -jitdriver = jit.JitDriver(greens=[], reds='auto') +jitdriver = jit.JitDriver(greens=['code'], reds='auto', + is_recursive=True, + get_unique_id=lambda code: rvmprof.get_unique_id(code)) @rvmprof.vmprof_execute_code("mycode", lambda code, level, total_i: code) def mainloop(code, level, total_i): i = 20 while i > 0: -jitdriver.jit_merge_point() +jitdriver.jit_merge_point(code=code) i -= 1 if level > 0: mainloop(code, level - 1, total_i + i) @@ -107,5 +109,5 @@ stdout = t.driver.cbuilder.cmdexec('') r = re.compile("[<]MyCode object at 0x([0-9a-f]+)[>] (\d) 42\n") got = r.findall(stdout) -addr = got[0][1] -assert got == XXX +addr = got[0][0] +assert got == [(addr, '1'), (addr, '1'), (addr, '0')] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Update int(x, base=10) behaviour for Python 3.4.
Author: Daniel Patrick Branch: py3.5 Changeset: r87407:1fc357671011 Date: 2016-09-26 21:00 +0100 http://bitbucket.org/pypy/pypy/changeset/1fc357671011/ Log:Update int(x, base=10) behaviour for Python 3.4. "Changed in version 3.4: If base is not an instance of int and the base object has a base.__index__ method, that method is called to obtain an integer for the base. Previous versions used base.__int__ instead of base.__index__." (from https://docs.python.org/3/library/functions.html#int) Note that in CPython an error is returned if base.__index__ does not exist on the non-int object, even if base.__int__ exists. Test amended to confirm this error is raised. diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py --- a/pypy/objspace/std/intobject.py +++ b/pypy/objspace/std/intobject.py @@ -892,7 +892,7 @@ return _string_to_int_or_long(space, w_inttype, w_value, buf) else: try: -base = space.int_w(w_base) +base = space.getindex_w(w_base, None) except OperationError as e: if not e.match(space, space.w_OverflowError): raise diff --git a/pypy/objspace/std/test/test_intobject.py b/pypy/objspace/std/test/test_intobject.py --- a/pypy/objspace/std/test/test_intobject.py +++ b/pypy/objspace/std/test/test_intobject.py @@ -525,12 +525,23 @@ class MyInt(object): def __init__(self, x): self.x = x -def __int__(self): +def __index__(self): return self.x base = MyInt(24) assert int('10', base) == 24 +class MyNonIndexable(object): +def __init__(self, x): +self.x = x +def __int__(self): +return self.x + +base = MyNonIndexable(24) +e = raises(TypeError, int, '10', base) +assert str(e.value) == ("'MyNonIndexable' object cannot be interpreted " +"as an integer") + def test_truediv(self): import operator x = 100 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-classes: Generate fieldboxes and faux virtual state
Author: Spenser Bauman Branch: value-classes Changeset: r87408:3d7fa60a7ac3 Date: 2016-09-26 23:19 -0400 http://bitbucket.org/pypy/pypy/changeset/3d7fa60a7ac3/ Log:Generate fieldboxes and faux virtual state diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py b/rpython/jit/metainterp/optimizeopt/virtualstate.py --- a/rpython/jit/metainterp/optimizeopt/virtualstate.py +++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py @@ -226,8 +226,11 @@ if not known_class.is_value_class(): raise VirtualStatesCantMatch("different kinds of structs") +# import pdb; pdb.set_trace() raise VirtualStatesCantMatch("different kinds of structs") +import pdb; pdb.set_trace() + # TODO: Probably should rename state.extra_guards to extra_ops extra_guards = state.extra_guards cpu = state.cpu @@ -260,15 +263,31 @@ # non-virtual object which we are promoting to a virtual. How do we # generate this new virtual state so we can operate recursively) +if runtime_box is not None: +opinfo = state.optimizer.getptrinfo(box) +assert opinfo is None or isinstance(opinfo, AbstractStructPtrInfo) +else: +opinfo = None + # We need to build a virtual version which conforms with the expected # virtual object. # This will probably look a lot like # AbstractVirtualStateInfo._generate_guards -fields = [None] * len(self.fielddescrs) +fields = [] for i, descr in enumerate(self.fielddescrs): -opnum = rop.getfield_for_descr(descr) -fields[i] = getfield_op = ResOperation(opnum, [box], descr=descr) -extra_guards.append(getfield_op) +if runtime_box is not None and opinfo is not None: +fieldbox = opinfo._fields[descr.get_index()] +fieldbox_runtime = state.get_runtime_field(runtime_box, descr) +else: +opnum = rop.getfield_for_descr(descr) +fieldbox = ResOperation(opnum, [box], descr=descr) +extra_guards.append(fieldbox) +fieldbox_runtime = None +fields.append(fieldbox) +faux_field_state = not_virtual(cpu, fieldbox.type, opinfo) +fieldstate = self.fieldstate[i] +fieldstate.generate_guards(faux_field_state, fieldbox, + fieldbox_runtime, state) def debug_header(self, indent): debug_print(indent + 'VirtualStateInfo(%d):' % self.position) @@ -542,6 +561,8 @@ other_intbound = other.intbound if self.intbound is None: return +if other.intbound is None: +return if self.intbound.contains_bound(other_intbound): return if (runtime_box is not None and ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy value-classes: Fix handling of intbounds in virtuastate
Author: Spenser Bauman Branch: value-classes Changeset: r87409:c5b9c438b580 Date: 2016-09-27 00:46 -0400 http://bitbucket.org/pypy/pypy/changeset/c5b9c438b580/ Log:Fix handling of intbounds in virtuastate diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py b/rpython/jit/metainterp/optimizeopt/virtualstate.py --- a/rpython/jit/metainterp/optimizeopt/virtualstate.py +++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py @@ -226,10 +226,8 @@ if not known_class.is_value_class(): raise VirtualStatesCantMatch("different kinds of structs") +raise VirtualStatesCantMatch("different kinds of structs") # import pdb; pdb.set_trace() -raise VirtualStatesCantMatch("different kinds of structs") - -import pdb; pdb.set_trace() # TODO: Probably should rename state.extra_guards to extra_ops extra_guards = state.extra_guards @@ -561,9 +559,8 @@ other_intbound = other.intbound if self.intbound is None: return -if other.intbound is None: -return -if self.intbound.contains_bound(other_intbound): +if (other_intbound is not None and +self.intbound.contains_bound(other_intbound)): return if (runtime_box is not None and self.intbound.contains(runtime_box.getint())): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit