[pypy-commit] pypy default: Fix bug with regard to multiple loops at the same assembler piece. Make parsing
Author: Maciej Fijalkowski Branch: Changeset: r45668:402d04acdc09 Date: 2011-07-16 16:29 +0200 http://bitbucket.org/pypy/pypy/changeset/402d04acdc09/ Log:Fix bug with regard to multiple loops at the same assembler piece. Make parsing assembler lazy (a bit ugly) diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py --- a/pypy/tool/jitlogparser/parser.py +++ b/pypy/tool/jitlogparser/parser.py @@ -343,18 +343,20 @@ addr = int(m.group(1), 16) entry = entry.lower() m = re.search('guard \d+', entry) -addrs[addr] = m.group(0) +name = m.group(0) else: name = entry[:entry.find('(') - 1].lower() -addrs[int(m.group(1), 16)] = name +addr = int(m.group(1), 16) +addrs.setdefault(addr, []).append(name) dumps = {} for entry in extract_category(log, 'jit-backend-dump'): backend, _, dump, _ = entry.split("\n") _, addr, _, data = re.split(" +", dump) backend_name = backend.split(" ")[1] addr = int(addr[1:], 16) -if addr in addrs: -dumps[addrs[addr]] = (backend_name, addr, data) +if addr in addrs and addrs[addr]: +name = addrs[addr].pop(0) # they should come in order +dumps[name] = (backend_name, addr, data) loops = [] for entry in extract_category(log, 'jit-log-opt'): parser = ParserCls(entry, None, {}, 'lltype', None, @@ -369,7 +371,10 @@ name = comm[2:comm.find(':')-1] if name in dumps: bname, start_ofs, dump = dumps[name] -parser.postprocess(loop, backend_tp=bname, backend_dump=dump, - dump_start=start_ofs) +loop.force_asm = (lambda dump=dump, start_ofs=start_ofs, + bname=bname, loop=loop: + parser.postprocess(loop, backend_tp=bname, + backend_dump=dump, + dump_start=start_ofs)) loops.append(loop) return log, loops diff --git a/pypy/tool/jitlogparser/test/logtest2.log b/pypy/tool/jitlogparser/test/logtest2.log --- a/pypy/tool/jitlogparser/test/logtest2.log +++ b/pypy/tool/jitlogparser/test/logtest2.log @@ -259,7 +259,7 @@ [1f600873506] {jit-backend-dump BACKEND x86_64 SYS_EXECUTABLE python -CODE_DUMP @7f8907a0b9e5 +0 C800 +CODE_DUMP @7f8907a0b3d5 +0 C800 [1f600874b44] jit-backend-dump} [1f6008754d4] {jit-backend-dump BACKEND x86_64 diff --git a/pypy/tool/jitlogparser/test/test_parser.py b/pypy/tool/jitlogparser/test/test_parser.py --- a/pypy/tool/jitlogparser/test/test_parser.py +++ b/pypy/tool/jitlogparser/test/test_parser.py @@ -213,11 +213,15 @@ def test_import_log(): _, loops = import_log(str(py.path.local(__file__).join('..', 'logtest.log'))) +for loop in loops: +loop.force_asm() assert 'jge' in loops[0].operations[3].asm def test_import_log_2(): _, loops = import_log(str(py.path.local(__file__).join('..', 'logtest2.log'))) +for loop in loops: +loop.force_asm() assert 'cmp' in loops[1].operations[1].asm # bridge assert 'jo' in loops[3].operations[3].asm ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] jitviewer default: use the lazy loading of loops
Author: Maciej Fijalkowski Branch: Changeset: r145:6159d4330dce Date: 2011-07-16 16:39 +0200 http://bitbucket.org/pypy/jitviewer/changeset/6159d4330dce/ Log:use the lazy loading of loops diff --git a/bin/jitviewer.py b/bin/jitviewer.py --- a/bin/jitviewer.py +++ b/bin/jitviewer.py @@ -96,6 +96,8 @@ def loop(self): no = int(flask.request.args.get('no', '0')) orig_loop = self.storage.loops[no] +if hasattr(orig_loop, 'force_asm'): +orig_loop.force_asm() ops = adjust_bridges(orig_loop, flask.request.args) loop = FunctionHtml.from_operations(ops, self.storage, inputargs=orig_loop.inputargs) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy arm-backend-2: fix
Author: David Schneider Branch: arm-backend-2 Changeset: r45669:05def4b63047 Date: 2011-07-15 15:00 +0200 http://bitbucket.org/pypy/pypy/changeset/05def4b63047/ Log:fix diff --git a/pypy/jit/backend/arm/assembler.py b/pypy/jit/backend/arm/assembler.py --- a/pypy/jit/backend/arm/assembler.py +++ b/pypy/jit/backend/arm/assembler.py @@ -117,7 +117,7 @@ ll_new_unicode) if gc_ll_descr.get_malloc_slowpath_addr is not None: self._build_malloc_slowpath() -if gc_ll_descr.gcrootmap and gc_ll_descr.is_shadow_stack: +if gc_ll_descr.gcrootmap and gc_ll_descr.gcrootmap.is_shadow_stack: self._build_release_gil(gc_ll_descr.gcrootmap) self.memcpy_addr = self.cpu.cast_ptr_to_int(memcpy_fn) self._exit_code_addr = self._gen_exit_path() ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy arm-backend-2: add a check for the size of the value stored in size
Author: David Schneider Branch: arm-backend-2 Changeset: r45671:5690763bfdba Date: 2011-07-16 17:11 +0200 http://bitbucket.org/pypy/pypy/changeset/5690763bfdba/ Log:add a check for the size of the value stored in size diff --git a/pypy/jit/backend/arm/assembler.py b/pypy/jit/backend/arm/assembler.py --- a/pypy/jit/backend/arm/assembler.py +++ b/pypy/jit/backend/arm/assembler.py @@ -988,9 +988,13 @@ self.mc.gen_load_int(r.r0.value, nursery_free_adr) self.mc.LDR_ri(r.r0.value, r.r0.value) -self.mc.ADD_ri(r.r1.value, r.r0.value, size) +if _check_imm_arg(ConstInt(size)): +self.mc.ADD_ri(r.r1.value, r.r0.value, size) +else: +self.mc.gen_load_int(r.r1.value, size) +self.mc.ADD_rr(r.r1.value, r.r0.value, r.r1.value) -# XXX maybe use an offset from the valeu nursery_free_addr +# XXX maybe use an offset from the value nursery_free_addr self.mc.gen_load_int(r.ip.value, nursery_top_adr) self.mc.LDR_ri(r.ip.value, r.ip.value) diff --git a/pypy/jit/backend/arm/helper/regalloc.py b/pypy/jit/backend/arm/helper/regalloc.py --- a/pypy/jit/backend/arm/helper/regalloc.py +++ b/pypy/jit/backend/arm/helper/regalloc.py @@ -4,6 +4,7 @@ from pypy.jit.metainterp.history import ConstInt, BoxInt, Box from pypy.jit.metainterp.history import ConstInt +# XXX create a version that does not need a ConstInt def _check_imm_arg(arg, size=0xFF, allow_zero=True): if isinstance(arg, ConstInt): i = arg.getint() ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] benchmarks default: remove name errors
Author: Maciej Fijalkowski Branch: Changeset: r124:1beaa1484ca2 Date: 2011-07-16 17:14 +0200 http://bitbucket.org/pypy/benchmarks/changeset/1beaa1484ca2/ Log:remove name errors diff --git a/own/chaos.py b/own/chaos.py --- a/own/chaos.py +++ b/own/chaos.py @@ -29,7 +29,7 @@ def __add__(self, other): if not isinstance(other, GVector): -raise exceptions.ValueError, \ +raise ValueError, \ "Can't add GVector to " + str(type(other)) v = GVector(self.x + other.x, self.y + other.y, self.z + other.z) return v @@ -71,13 +71,13 @@ self.knots = GetKnots(points, degree) else: if len(points) > len(knots) - degree + 1: -raise exceptions.ValueError, "too many control points" +raise ValueError, "too many control points" elif len(points) < len(knots) - degree + 1: -raise exceptions.ValueError, "not enough control points" +raise ValueError, "not enough control points" last = knots[0] for cur in knots[1:]: if cur < last: -raise exceptions.ValueError, \ +raise ValueError, \ "knots not strictly increasing" last = cur self.knots = knots @@ -93,7 +93,7 @@ """Calculates a point of the B-Spline using de Boors Algorithm""" dom = self.GetDomain() if u < dom[0] or u > dom[1]: -raise exceptions.ValueError, "Function value not in domain" +raise ValueError, "Function value not in domain" if u == dom[0]: return self.points[0] if u == dom[1]: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] benchmarks default: improve uploading so we can benchmark pypy against pypy no jit
Author: Maciej Fijalkowski Branch: Changeset: r125:a8836ad0cec7 Date: 2011-07-16 17:15 +0200 http://bitbucket.org/pypy/benchmarks/changeset/a8836ad0cec7/ Log:improve uploading so we can benchmark pypy against pypy no jit diff --git a/runner.py b/runner.py --- a/runner.py +++ b/runner.py @@ -2,12 +2,30 @@ """ Usage: runner.py """ -import os import json import sys from unladen_swallow import perf import benchmarks import socket + +def perform_upload(pypy_c_path, args, force_host, options, res, revision, + changed=True): +from saveresults import save +project = 'PyPy' +if "--jit" in args: +name = "pypy-c" +else: +name = "pypy-c-jit" +if "psyco.sh" in pypy_c_path: +name = "cpython psyco-profile" +revision = 100 +project = 'cpython' +if force_host is not None: +host = force_host +else: +host = socket.gethostname() +print save(project, revision, res, options, name, host, changed=changed) + def run_and_store(benchmark_set, result_filename, pypy_c_path, revision=0, options='', branch='trunk', args='', upload=False, @@ -36,21 +54,15 @@ })) f.close() if upload: -from saveresults import save -project = 'PyPy' -if "--jit threshold" in args: -name = "pypy-c" +if ',' in args: +argsbase, argschanged = args.split(',') else: -name = "pypy-c-jit" -if "psyco.sh" in pypy_c_path: -name = "cpython psyco-profile" -revision = 100 -project = 'cpython' -if force_host is not None: -host = force_host -else: -host = socket.gethostname() -save(project, revision, res, options, name, host) +argsbase, argschanged = args, args +if 'pypy' in baseline: +perform_upload(pypy_c_path, argsbase, force_host, options, res, + revision, changed=False) +perform_upload(pypy_c_path, argschanged, force_host, options, res, + revision, changed=True) BENCHMARK_SET = ['richards', 'slowspitfire', 'django', 'spambayes', 'rietveld', 'html5lib', 'ai'] diff --git a/saveresults.py b/saveresults.py --- a/saveresults.py +++ b/saveresults.py @@ -8,7 +8,8 @@ SPEEDURL = "http://speed.pypy.org/"; -def save(project, revision, results, options, interpreter, host, testing=False): +def save(project, revision, results, options, interpreter, host, testing=True, + changed=True): testparams = [] #Parse data data = {} @@ -20,9 +21,15 @@ results = b[2] value = 0 if res_type == "SimpleComparisonResult": -value = results['changed_time'] +if changed: +value = results['changed_time'] +else: +value = results['base_time'] elif res_type == "ComparisonResult": -value = results['avg_changed'] +if changed: +value = results['avg_changed'] +else: +value = results['avg_base'] else: print("ERROR: result type unknown " + b[1]) return 1 @@ -35,7 +42,10 @@ 'result_value': value, } if res_type == "ComparisonResult": -data['std_dev'] = results['std_changed'] +if changed: +data['std_dev'] = results['std_changed'] +else: +data['std_dev'] = results['std_base'] if testing: testparams.append(data) else: error |= send(data) if error: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] buildbot default: clean up - now we dont benchmark cpython nightly twice
Author: Maciej Fijalkowski Branch: Changeset: r528:6717b3a4b6a8 Date: 2011-07-16 17:22 +0200 http://bitbucket.org/pypy/buildbot/changeset/6717b3a4b6a8/ Log:clean up - now we dont benchmark cpython nightly twice diff --git a/bot2/pypybuildbot/builds.py b/bot2/pypybuildbot/builds.py --- a/bot2/pypybuildbot/builds.py +++ b/bot2/pypybuildbot/builds.py @@ -288,9 +288,11 @@ self.addStep(Translate(['-Ojit'], [])) pypy_c_rel = "../build/pypy/translator/goal/pypy-c" self.addStep(ShellCmd( -description="run benchmarks on top of pypy-c-jit", +description="run benchmarks on top of pypy-c", command=["python", "runner.py", '--output-filename', 'result.json', '--pypy-c', pypy_c_rel, + '--baseline', pypy_c_rel, + '--args', ',--jit off' '--upload', #'--force-host', 'bigdog', '--revision', WithProperties('%(got_revision)s'), '--branch', WithProperties('%(branch)s')], @@ -301,20 +303,6 @@ self.addStep(transfer.FileUpload(slavesrc="benchmarks/result.json", masterdest=WithProperties(resfile), workdir=".")) -self.addStep(ShellCmd( -description="run benchmarks on top of pypy-c no jit", -command=["python", "runner.py", '--output-filename', 'result.json', -'--pypy-c', '../build/pypy/translator/goal/pypy-c', - '--revision', WithProperties('%(got_revision)s'), - '--upload', #'--force-host', 'bigdog', - '--branch', WithProperties('%(branch)s'), - '--args', ',--jit off'], -workdir='./benchmarks', -haltOnFailure=True)) -resfile = os.path.expanduser("~/bench_results_nojit/%(got_revision)s.json") -self.addStep(transfer.FileUpload(slavesrc="benchmarks/result.json", - masterdest=WithProperties(resfile), - workdir=".")) ##self.addStep(ShellCmd( ##description="run on top of python with psyco", ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] buildbot default: grrr, missing coma
Author: Maciej Fijalkowski Branch: Changeset: r529:f1174e9107a5 Date: 2011-07-16 18:22 +0200 http://bitbucket.org/pypy/buildbot/changeset/f1174e9107a5/ Log:grrr, missing coma diff --git a/bot2/pypybuildbot/builds.py b/bot2/pypybuildbot/builds.py --- a/bot2/pypybuildbot/builds.py +++ b/bot2/pypybuildbot/builds.py @@ -292,7 +292,7 @@ command=["python", "runner.py", '--output-filename', 'result.json', '--pypy-c', pypy_c_rel, '--baseline', pypy_c_rel, - '--args', ',--jit off' + '--args', ',--jit off', '--upload', #'--force-host', 'bigdog', '--revision', WithProperties('%(got_revision)s'), '--branch', WithProperties('%(branch)s')], ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-singledim: Added simple repr and str for ViewArrays
Author: Justin Peel Branch: numpy-singledim Changeset: r45673:29e15adb6915 Date: 2011-07-15 18:10 -0600 http://bitbucket.org/pypy/pypy/changeset/29e15adb6915/ Log:Added simple repr and str for ViewArrays diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -341,10 +341,10 @@ return space.wrap(self.find_ndim()) def descr_repr(self, space): -return self.get_concrete().descr_repr(space) +return self.get_concrete()._repr(space) def descr_str(self, space): -return self.get_concrete().descr_str(space) +return self.get_concrete()._str(space) def descr_getitem(self, space, w_idx): # TODO: indexing by tuples and lists @@ -548,6 +548,26 @@ def calc_index(self, item): raise NotImplementedError +def _getnums(self, comma): +if self.find_size() > 1000: +nums = [str(self.getitem(index)) for index \ +in range(3)] +nums.append("..." + "," * comma) +nums.extend([str(self.getitem(index)) for index \ +in range(self.find_size() - 3, self.find_size())]) +else: +nums = [str(self.getitem(index)) for index \ +in range(self.find_size())] +return nums + +def _repr(self, space): +# Simple implementation so that we can see the array. Needs work. +return space.wrap("array([" + ", ".join(self._getnums(False)) + "])") + +def _str(self,space): +# Simple implementation so that we can see the array. Needs work. +return space.wrap("[" + " ".join(self._getnums(True)) + "]") + class SingleDimSlice(ViewArray): _immutable_fields_ = ["start", "stop", "step", "size"] static_signature = Signature() @@ -624,11 +644,11 @@ in range(self.find_size())] return nums -def descr_repr(self, space): +def _repr(self, space): # Simple implementation so that we can see the array. Needs work. return space.wrap("array([" + ", ".join(self._getnums(False)) + "])") -def descr_str(self,space): +def _str(self,space): # Simple implementation so that we can see the array. Needs work. return space.wrap("[" + " ".join(self._getnums(True)) + "]") diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -50,6 +50,15 @@ a = zeros(1001) assert repr(a) == "array([0.0, 0.0, 0.0, ..., 0.0, 0.0, 0.0])" +def test_repr_slice(self): +from numpy import array, zeros +a = array(range(5)) +b = a[1::2] +assert repr(b) == "array([1.0, 3.0])" +a = zeros(2002) +b = a[::2] +assert repr(b) == "array([0.0, 0.0, 0.0, ..., 0.0, 0.0, 0.0])" + def test_str(self): from numpy import array, zeros a = array(range(5)) @@ -57,6 +66,15 @@ a = zeros(1001) assert str(a) == "[0.0 0.0 0.0 ..., 0.0 0.0 0.0]" +def test_str_slice(self): +from numpy import array, zeros +a = array(range(5)) +b = a[1::2] +assert str(b) == "[1.0 3.0]" +a = zeros(2002) +b = a[::2] +assert str(b) == "[0.0 0.0 0.0 ..., 0.0 0.0 0.0]" + def test_getitem(self): from numpy import array a = array(range(5)) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-ndim-size: numpy: added ndim and size attributes. This includes work by Timo.
Author: Justin Peel Branch: numpy-ndim-size Changeset: r45674:db28a9352aa2 Date: 2011-07-16 10:38 -0600 http://bitbucket.org/pypy/pypy/changeset/db28a9352aa2/ Log:numpy: added ndim and size attributes. This includes work by Timo. diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -244,6 +244,12 @@ def descr_len(self, space): return self.get_concrete().descr_len(space) +def descr_get_size(self, space): +return space.wrap(self.find_size()) + +def descr_get_ndim(self, space): +return space.wrap(self.find_ndim()) + def descr_getitem(self, space, w_idx): # TODO: indexing by tuples start, stop, step, slice_length = space.decode_index4(w_idx, self.find_size()) @@ -287,6 +293,9 @@ def find_size(self): raise ValueError +def find_ndim(self): +raise ValueError + def eval(self, i): return self.float_value @@ -336,6 +345,12 @@ return self.forced_result.find_size() return self._find_size() +def find_ndim(self): +if self.forced_result is not None: +# The result has been computed and sources may be unavailable +return self.forced_result.find_ndim() +return self._find_ndim() + class Call1(VirtualArray): _immutable_fields_ = ["function", "values"] @@ -351,6 +366,9 @@ def _find_size(self): return self.values.find_size() +def _find_ndim(self): +return self.values.find_ndim() + def _eval(self, i): return self.function(self.values.eval(i)) @@ -377,6 +395,13 @@ pass return self.right.find_size() +def _find_ndim(self): +try: +return self.left.find_ndim() +except ValueError: +pass +return self.right.find_ndim() + def _eval(self, i): lhs, rhs = self.left.eval(i), self.right.eval(i) return self.function(lhs, rhs) @@ -426,10 +451,14 @@ self.stop = stop self.step = step self.size = slice_length +self.ndim = 1 def find_size(self): return self.size +def find_ndim(self): +return self.ndim + def calc_index(self, item): return (self.start + item * self.step) @@ -440,6 +469,7 @@ def __init__(self, size): BaseArray.__init__(self) self.size = size +self.ndim = 1 self.storage = lltype.malloc(TP, size, zero=True, flavor='raw', track_allocation=False) # XXX find out why test_zjit explodes with trackign of allocations @@ -450,6 +480,9 @@ def find_size(self): return self.size +def find_ndim(self): +return self.ndim + def eval(self, i): return self.storage[i] @@ -507,6 +540,8 @@ __new__ = interp2app(descr_new_numarray), shape = GetSetProperty(BaseArray.descr_get_shape), +size = GetSetProperty(BaseArray.descr_get_size), +ndim = GetSetProperty(BaseArray.descr_get_ndim), __len__ = interp2app(BaseArray.descr_len), __getitem__ = interp2app(BaseArray.descr_getitem), diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -66,6 +66,20 @@ assert len(a) == 5 assert len(a + a) == 5 +def test_ndim(self): +from numpy import array +a = array(range(4)) +assert a.ndim == 1 +assert (a + a).ndim == 1 +assert a[:3].ndim == 1 + +def test_size(self): +from numpy import array +a = array(range(4)) +assert a.size == 4 +assert (a + a).size == 4 +assert a[:3].size == 3 + def test_shape(self): from numpy import array a = array(range(5)) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-repr-str: numpy: simple implementations of repr and str. includes work by Timo.
Author: Justin Peel Branch: numpy-repr-str Changeset: r45675:9e83042f6f27 Date: 2011-07-16 10:53 -0600 http://bitbucket.org/pypy/pypy/changeset/9e83042f6f27/ Log:numpy: simple implementations of repr and str. includes work by Timo. diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -244,6 +244,12 @@ def descr_len(self, space): return self.get_concrete().descr_len(space) +def descr_repr(self, space): +return self.get_concrete()._repr(space) + +def descr_str(self, space): +return self.get_concrete()._str(space) + def descr_getitem(self, space, w_idx): # TODO: indexing by tuples start, stop, step, slice_length = space.decode_index4(w_idx, self.find_size()) @@ -433,6 +439,26 @@ def calc_index(self, item): return (self.start + item * self.step) +def _getnums(self, comma): +if self.find_size() > 1000: +nums = [str(self.getitem(index)) for index \ +in range(3)] +nums.append("..." + "," * comma) +nums.extend([str(self.getitem(index)) for index \ +in range(self.find_size() - 3, self.find_size())]) +else: +nums = [str(self.getitem(index)) for index \ +in range(self.find_size())] +return nums + +def _repr(self, space): +# Simple implementation so that we can see the array. Needs work. +return space.wrap("array([" + ", ".join(self._getnums(False)) + "])") + +def _str(self,space): +# Simple implementation so that we can see the array. Needs work. +return space.wrap("[" + " ".join(self._getnums(True)) + "]") + class SingleDimArray(BaseArray): signature = Signature() @@ -470,6 +496,26 @@ def getitem(self, item): return self.storage[item] +def _getnums(self, comma): +if self.find_size() > 1000: +nums = [str(self.getitem(index)) for index \ +in range(3)] +nums.append("..." + "," * comma) +nums.extend([str(self.getitem(index)) for index \ +in range(self.find_size() - 3, self.find_size())]) +else: +nums = [str(self.getitem(index)) for index \ +in range(self.find_size())] +return nums + +def _repr(self, space): +# Simple implementation so that we can see the array. Needs work. +return space.wrap("array([" + ", ".join(self._getnums(False)) + "])") + +def _str(self,space): +# Simple implementation so that we can see the array. Needs work. +return space.wrap("[" + " ".join(self._getnums(True)) + "]") + @unwrap_spec(item=int, value=float) def descr_setitem(self, space, item, value): item = self.getindex(space, item) @@ -527,6 +573,8 @@ __rdiv__ = interp2app(BaseArray.descr_rdiv), __rpow__ = interp2app(BaseArray.descr_rpow), __rmod__ = interp2app(BaseArray.descr_rmod), +__repr__ = interp2app(BaseArray.descr_repr), +__str__ = interp2app(BaseArray.descr_str), mean = interp2app(BaseArray.descr_mean), sum = interp2app(BaseArray.descr_sum), diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -43,6 +43,38 @@ a = array(range(5)) assert a[3] == 3 +def test_repr(self): +from numpy import array, zeros +a = array(range(5)) +assert repr(a) == "array([0.0, 1.0, 2.0, 3.0, 4.0])" +a = zeros(1001) +assert repr(a) == "array([0.0, 0.0, 0.0, ..., 0.0, 0.0, 0.0])" + +def test_repr_slice(self): +from numpy import array, zeros +a = array(range(5)) +b = a[1::2] +assert repr(b) == "array([1.0, 3.0])" +a = zeros(2002) +b = a[::2] +assert repr(b) == "array([0.0, 0.0, 0.0, ..., 0.0, 0.0, 0.0])" + +def test_str(self): +from numpy import array, zeros +a = array(range(5)) +assert str(a) == "[0.0 1.0 2.0 3.0 4.0]" +a = zeros(1001) +assert str(a) == "[0.0 0.0 0.0 ..., 0.0 0.0 0.0]" + +def test_str_slice(self): +from numpy import array, zeros +a = array(range(5)) +b = a[1::2] +assert str(b) == "[1.0 3.0]" +a = zeros(2002) +b = a[::2] +assert str(b) == "[0.0 0.0 0.0 ..., 0.0 0.0 0.0]" + def test_getitem(self): from numpy import array a = array(range(5)) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: bug in lazy setarrayitem. test and fix
Author: Carl Friedrich Bolz Branch: Changeset: r45676:e5d0029d562d Date: 2011-07-16 19:44 +0200 http://bitbucket.org/pypy/pypy/changeset/e5d0029d562d/ Log:bug in lazy setarrayitem. test and fix diff --git a/pypy/jit/metainterp/optimizeopt/heap.py b/pypy/jit/metainterp/optimizeopt/heap.py --- a/pypy/jit/metainterp/optimizeopt/heap.py +++ b/pypy/jit/metainterp/optimizeopt/heap.py @@ -73,7 +73,7 @@ assert self._lazy_setfield is None self._cached_fields[structvalue] = fieldvalue -def force_lazy_setfield(self, optheap): +def force_lazy_setfield(self, optheap, can_cache=True): op = self._lazy_setfield if op is not None: # This is the way _lazy_setfield is usually reset to None. @@ -83,6 +83,8 @@ self._cached_fields.clear() self._lazy_setfield = None optheap.next_optimization.propagate_forward(op) +if not can_cache: +return # Once it is done, we can put at least one piece of information # back in the cache: the value of this particular structure's # field. @@ -245,13 +247,13 @@ return cf.force_lazy_setfield(self) -def force_lazy_setarrayitem(self, arraydescr): +def force_lazy_setarrayitem(self, arraydescr, can_cache=True): try: submap = self.cached_arrayitems[arraydescr] except KeyError: return for cf in submap.values(): -cf.force_lazy_setfield(self) +cf.force_lazy_setfield(self, can_cache) def fixup_guard_situation(self): # hackish: reverse the order of the last two operations if it makes @@ -387,7 +389,7 @@ cf.do_setfield(self, op) else: # variable index, so make sure the lazy setarrayitems are done -self.force_lazy_setarrayitem(op.getdescr()) +self.force_lazy_setarrayitem(op.getdescr(), can_cache=False) # and then emit the operation self.emit_operation(op) diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -1755,6 +1755,27 @@ """ self.optimize_loop(ops, expected) +def test_duplicate_getarrayitem_after_setarrayitem_bug(self): +ops = """ +[p0, i0, i1] +setarrayitem_gc(p0, 0, i0, descr=arraydescr) +i6 = int_add(i0, 1) +setarrayitem_gc(p0, i1, i6, descr=arraydescr) +i10 = getarrayitem_gc(p0, 0, descr=arraydescr) +i11 = int_add(i10, i0) +jump(p0, i11, i1) +""" +expected = """ +[p0, i0, i1] +i6 = int_add(i0, 1) +setarrayitem_gc(p0, 0, i0, descr=arraydescr) +setarrayitem_gc(p0, i1, i6, descr=arraydescr) +i10 = getarrayitem_gc(p0, 0, descr=arraydescr) +i11 = int_add(i10, i0) +jump(p0, i11, i1) +""" +self.optimize_loop(ops, expected) + def test_bug_1(self): ops = """ [i0, p1] ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: broken test (armin will try to fix it)
Author: Carl Friedrich Bolz Branch: Changeset: r45677:8327f6fea2b2 Date: 2011-07-16 20:03 +0200 http://bitbucket.org/pypy/pypy/changeset/8327f6fea2b2/ Log:broken test (armin will try to fix it) diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -1776,6 +1776,27 @@ """ self.optimize_loop(ops, expected) +def test_duplicate_getarrayitem_after_setarrayitem_bug2(self): +ops = """ +[p0, i0, i1] +i2 = getarrayitem_gc(p0, 0, descr=arraydescr) +i6 = int_add(i0, 1) +setarrayitem_gc(p0, i1, i6, descr=arraydescr) +i10 = getarrayitem_gc(p0, 0, descr=arraydescr) +i11 = int_add(i10, i2) +jump(p0, i11, i1) +""" +expected = """ +[p0, i0, i1] +i2 = getarrayitem_gc(p0, 0, descr=arraydescr) +i6 = int_add(i0, 1) +setarrayitem_gc(p0, i1, i6, descr=arraydescr) +i10 = getarrayitem_gc(p0, 0, descr=arraydescr) +i11 = int_add(i10, i2) +jump(p0, i11, i1) +""" +self.optimize_loop(ops, expected) + def test_bug_1(self): ops = """ [i0, p1] ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix the test by always clear()ing _cache_fields if can_cache=False.
Author: Armin Rigo Branch: Changeset: r45678:e911b2205846 Date: 2011-07-16 20:07 +0200 http://bitbucket.org/pypy/pypy/changeset/e911b2205846/ Log:Fix the test by always clear()ing _cache_fields if can_cache=False. Rewrote some redundant try:except KeyError: code by using the new can_cache=False flag. diff --git a/pypy/jit/metainterp/optimizeopt/heap.py b/pypy/jit/metainterp/optimizeopt/heap.py --- a/pypy/jit/metainterp/optimizeopt/heap.py +++ b/pypy/jit/metainterp/optimizeopt/heap.py @@ -91,6 +91,8 @@ structvalue = optheap.getvalue(op.getarg(0)) fieldvalue = optheap.getvalue(op.getarglist()[-1]) self.remember_field_value(structvalue, fieldvalue) +elif not can_cache: +self._cached_fields.clear() def get_reconstructed(self, optimizer, valuemap): assert self._lazy_setfield is None @@ -204,20 +206,9 @@ for arraydescr in effectinfo.readonly_descrs_arrays: self.force_lazy_setarrayitem(arraydescr) for fielddescr in effectinfo.write_descrs_fields: -self.force_lazy_setfield(fielddescr) -try: -cf = self.cached_fields[fielddescr] -cf._cached_fields.clear() -except KeyError: -pass +self.force_lazy_setfield(fielddescr, can_cache=False) for arraydescr in effectinfo.write_descrs_arrays: -self.force_lazy_setarrayitem(arraydescr) -try: -submap = self.cached_arrayitems[arraydescr] -for cf in submap.itervalues(): -cf._cached_fields.clear() -except KeyError: -pass +self.force_lazy_setarrayitem(arraydescr, can_cache=False) if effectinfo.check_forces_virtual_or_virtualizable(): vrefinfo = self.optimizer.metainterp_sd.virtualref_info self.force_lazy_setfield(vrefinfo.descr_forced) @@ -240,12 +231,12 @@ if value in cf._cached_fields: cf._cached_fields[newvalue] = cf._cached_fields[value] -def force_lazy_setfield(self, descr): +def force_lazy_setfield(self, descr, can_cache=True): try: cf = self.cached_fields[descr] except KeyError: return -cf.force_lazy_setfield(self) +cf.force_lazy_setfield(self, can_cache) def force_lazy_setarrayitem(self, arraydescr, can_cache=True): try: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy heap-caching-during-tracing: setarrayitem does not influence the heap cache
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45679:afd433b6fc94 Date: 2011-07-16 18:37 +0200 http://bitbucket.org/pypy/pypy/changeset/afd433b6fc94/ Log:setarrayitem does not influence the heap cache diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -1648,7 +1648,8 @@ # record the operation profiler = self.staticdata.profiler profiler.count_ops(opnum, RECORDED_OPS) -if opnum != rop.SETFIELD_GC and self.heap_cache: +if (self.heap_cache and opnum != rop.SETFIELD_GC and +opnum != rop.SETARRAYITEM_GC): if not (rop._NOSIDEEFFECT_FIRST <= opnum <= rop._NOSIDEEFFECT_LAST): self.heap_cache = {} op = self.history.record(opnum, argboxes, resbox, descr) diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py --- a/pypy/jit/metainterp/test/test_tracingopts.py +++ b/pypy/jit/metainterp/test/test_tracingopts.py @@ -113,6 +113,7 @@ @jit.dont_look_inside def f(a): a.x = 5 +l = [1] def fn(n): if n > 0: a = a1 @@ -121,9 +122,11 @@ a.x = n x1 = a.x f(a) -return a.x + x1 +x2 = a.x +l[0] = x2 +return a.x + x1 + x2 res = self.interp_operations(fn, [7]) -assert res == 5 + 7 +assert res == 5 * 2 + 7 self.check_operations_history(getfield_gc=1) def test_heap_caching_dont_store_same(self): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy heap-caching-during-tracing: intermediate checkin: starting an array cache. stopped by a bug on trunk.
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45680:aacbf098fe2c Date: 2011-07-16 19:49 +0200 http://bitbucket.org/pypy/pypy/changeset/aacbf098fe2c/ Log:intermediate checkin: starting an array cache. stopped by a bug on trunk. diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -390,8 +390,17 @@ @arguments("box", "descr", "box") def _opimpl_getarrayitem_gc_any(self, arraybox, arraydescr, indexbox): -return self.execute_with_descr(rop.GETARRAYITEM_GC, - arraydescr, arraybox, indexbox) +cache = self.metainterp.heap_array_cache.get(arraydescr, None) +index = -1 +if cache and isinstance(indexbox, ConstInt): +index = indexbox.getint() +frombox, tobox = cache.get(index, (None, None)) +if frombox is arraybox: +return tobox +resbox = self.execute_with_descr(rop.GETARRAYITEM_GC, + arraydescr, arraybox, indexbox) +return resbox + opimpl_getarrayitem_gc_i = _opimpl_getarrayitem_gc_any opimpl_getarrayitem_gc_r = _opimpl_getarrayitem_gc_any @@ -419,6 +428,13 @@ indexbox, itembox): self.execute_with_descr(rop.SETARRAYITEM_GC, arraydescr, arraybox, indexbox, itembox) +if isinstance(indexbox, ConstInt): +cache = self.metainterp.heap_array_cache.setdefault(arraydescr, {}) +cache[indexbox.getint()] = arraybox, itembox +else: +cache = self.metainterp.heap_array_cache.get(arraydescr, None) +if cache: +cache.clear() opimpl_setarrayitem_gc_i = _opimpl_setarrayitem_gc_any opimpl_setarrayitem_gc_r = _opimpl_setarrayitem_gc_any @@ -1473,6 +1489,9 @@ # heap cache # maps descrs to (from_box, to_box) tuples self.heap_cache = {} +# heap array cache +# maps descrs to {index: (from_box, to_box)} dicts +self.heap_array_cache = {} def perform_call(self, jitcode, boxes, greenkey=None): # causes the metainterp to enter the given subfunction @@ -1820,6 +1839,7 @@ self.known_class_boxes = {} self.nonstandard_virtualizables = {} # XXX maybe not needed? self.heap_cache = {} +self.heap_array_cache = {} duplicates = {} self.remove_consts_and_duplicates(redboxes, len(redboxes), diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py --- a/pypy/jit/metainterp/test/test_tracingopts.py +++ b/pypy/jit/metainterp/test/test_tracingopts.py @@ -148,3 +148,39 @@ res = self.interp_operations(fn, [-7]) assert res == -7 self.check_operations_history(getfield_gc=0) + +def test_array_caching(self): +a1 = [0, 0] +a2 = [0, 0] +def fn(n): +if n > 0: +a = a1 +else: +a = a2 +a[0] = n +x1 = a[0] +a[n - n] = n + 1 +return a[0] + x1 +res = self.interp_operations(fn, [7]) +assert res == 7 + 7 + 1 +self.check_operations_history(getarrayitem_gc=1) +res = self.interp_operations(fn, [-7]) +assert res == -7 - 7 + 1 +self.check_operations_history(getarrayitem_gc=1) + +def fn(n, ca, cb): +a1[0] = n +a2[0] = n +a = a1 +if ca: +a = a2 +b = a1 +if cb: +b = a +return a[0] + b[0] +res = self.interp_operations(fn, [7, 0, 1]) +assert res == 7 * 2 +self.check_operations_history(getarrayitem_gc=1) +res = self.interp_operations(fn, [-7, 1, 1]) +assert res == -7 * 2 +self.check_operations_history(getarrayitem_gc=1) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy heap-caching-during-tracing: merge default
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45681:b60a9b13da69 Date: 2011-07-16 19:50 +0200 http://bitbucket.org/pypy/pypy/changeset/b60a9b13da69/ Log:merge default diff --git a/pypy/jit/metainterp/optimizeopt/heap.py b/pypy/jit/metainterp/optimizeopt/heap.py --- a/pypy/jit/metainterp/optimizeopt/heap.py +++ b/pypy/jit/metainterp/optimizeopt/heap.py @@ -73,7 +73,7 @@ assert self._lazy_setfield is None self._cached_fields[structvalue] = fieldvalue -def force_lazy_setfield(self, optheap): +def force_lazy_setfield(self, optheap, can_cache=True): op = self._lazy_setfield if op is not None: # This is the way _lazy_setfield is usually reset to None. @@ -83,6 +83,8 @@ self._cached_fields.clear() self._lazy_setfield = None optheap.next_optimization.propagate_forward(op) +if not can_cache: +return # Once it is done, we can put at least one piece of information # back in the cache: the value of this particular structure's # field. @@ -245,13 +247,13 @@ return cf.force_lazy_setfield(self) -def force_lazy_setarrayitem(self, arraydescr): +def force_lazy_setarrayitem(self, arraydescr, can_cache=True): try: submap = self.cached_arrayitems[arraydescr] except KeyError: return for cf in submap.values(): -cf.force_lazy_setfield(self) +cf.force_lazy_setfield(self, can_cache) def fixup_guard_situation(self): # hackish: reverse the order of the last two operations if it makes @@ -387,7 +389,7 @@ cf.do_setfield(self, op) else: # variable index, so make sure the lazy setarrayitems are done -self.force_lazy_setarrayitem(op.getdescr()) +self.force_lazy_setarrayitem(op.getdescr(), can_cache=False) # and then emit the operation self.emit_operation(op) diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -1755,6 +1755,27 @@ """ self.optimize_loop(ops, expected) +def test_duplicate_getarrayitem_after_setarrayitem_bug(self): +ops = """ +[p0, i0, i1] +setarrayitem_gc(p0, 0, i0, descr=arraydescr) +i6 = int_add(i0, 1) +setarrayitem_gc(p0, i1, i6, descr=arraydescr) +i10 = getarrayitem_gc(p0, 0, descr=arraydescr) +i11 = int_add(i10, i0) +jump(p0, i11, i1) +""" +expected = """ +[p0, i0, i1] +i6 = int_add(i0, 1) +setarrayitem_gc(p0, 0, i0, descr=arraydescr) +setarrayitem_gc(p0, i1, i6, descr=arraydescr) +i10 = getarrayitem_gc(p0, 0, descr=arraydescr) +i11 = int_add(i10, i0) +jump(p0, i11, i1) +""" +self.optimize_loop(ops, expected) + def test_bug_1(self): ops = """ [i0, p1] diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py --- a/pypy/tool/jitlogparser/parser.py +++ b/pypy/tool/jitlogparser/parser.py @@ -89,7 +89,7 @@ while asm[asm_index][0] < op.offset: asm_index += 1 end_index = asm_index -while asm[end_index][0] < end: +while asm[end_index][0] < end and end_index < len(asm) - 1: end_index += 1 op.asm = '\n'.join([asm[i][1] for i in range(asm_index, end_index)]) return loop @@ -343,18 +343,20 @@ addr = int(m.group(1), 16) entry = entry.lower() m = re.search('guard \d+', entry) -addrs[addr] = m.group(0) +name = m.group(0) else: name = entry[:entry.find('(') - 1].lower() -addrs[int(m.group(1), 16)] = name +addr = int(m.group(1), 16) +addrs.setdefault(addr, []).append(name) dumps = {} for entry in extract_category(log, 'jit-backend-dump'): backend, _, dump, _ = entry.split("\n") _, addr, _, data = re.split(" +", dump) backend_name = backend.split(" ")[1] addr = int(addr[1:], 16) -if addr in addrs: -dumps[addrs[addr]] = (backend_name, addr, data) +if addr in addrs and addrs[addr]: +name = addrs[addr].pop(0) # they should come in order +dumps[name] = (backend_name, addr, data) loops = [] for entry in extract_category(log, 'jit-log-opt'): parser = ParserCls(entry, None, {}, 'lltype', None, @@ -369,7 +371,10 @@ name = comm[2:comm.find(':')-1] if name in dumps: bname, start_ofs, dum
[pypy-commit] pypy heap-caching-during-tracing: merge
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45682:e617ed3242d8 Date: 2011-07-16 20:08 +0200 http://bitbucket.org/pypy/pypy/changeset/e617ed3242d8/ Log:merge diff --git a/pypy/jit/metainterp/optimizeopt/heap.py b/pypy/jit/metainterp/optimizeopt/heap.py --- a/pypy/jit/metainterp/optimizeopt/heap.py +++ b/pypy/jit/metainterp/optimizeopt/heap.py @@ -91,6 +91,8 @@ structvalue = optheap.getvalue(op.getarg(0)) fieldvalue = optheap.getvalue(op.getarglist()[-1]) self.remember_field_value(structvalue, fieldvalue) +elif not can_cache: +self._cached_fields.clear() def get_reconstructed(self, optimizer, valuemap): assert self._lazy_setfield is None @@ -204,20 +206,9 @@ for arraydescr in effectinfo.readonly_descrs_arrays: self.force_lazy_setarrayitem(arraydescr) for fielddescr in effectinfo.write_descrs_fields: -self.force_lazy_setfield(fielddescr) -try: -cf = self.cached_fields[fielddescr] -cf._cached_fields.clear() -except KeyError: -pass +self.force_lazy_setfield(fielddescr, can_cache=False) for arraydescr in effectinfo.write_descrs_arrays: -self.force_lazy_setarrayitem(arraydescr) -try: -submap = self.cached_arrayitems[arraydescr] -for cf in submap.itervalues(): -cf._cached_fields.clear() -except KeyError: -pass +self.force_lazy_setarrayitem(arraydescr, can_cache=False) if effectinfo.check_forces_virtual_or_virtualizable(): vrefinfo = self.optimizer.metainterp_sd.virtualref_info self.force_lazy_setfield(vrefinfo.descr_forced) @@ -240,12 +231,12 @@ if value in cf._cached_fields: cf._cached_fields[newvalue] = cf._cached_fields[value] -def force_lazy_setfield(self, descr): +def force_lazy_setfield(self, descr, can_cache=True): try: cf = self.cached_fields[descr] except KeyError: return -cf.force_lazy_setfield(self) +cf.force_lazy_setfield(self, can_cache) def force_lazy_setarrayitem(self, arraydescr, can_cache=True): try: diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -1776,6 +1776,27 @@ """ self.optimize_loop(ops, expected) +def test_duplicate_getarrayitem_after_setarrayitem_bug2(self): +ops = """ +[p0, i0, i1] +i2 = getarrayitem_gc(p0, 0, descr=arraydescr) +i6 = int_add(i0, 1) +setarrayitem_gc(p0, i1, i6, descr=arraydescr) +i10 = getarrayitem_gc(p0, 0, descr=arraydescr) +i11 = int_add(i10, i2) +jump(p0, i11, i1) +""" +expected = """ +[p0, i0, i1] +i2 = getarrayitem_gc(p0, 0, descr=arraydescr) +i6 = int_add(i0, 1) +setarrayitem_gc(p0, i1, i6, descr=arraydescr) +i10 = getarrayitem_gc(p0, 0, descr=arraydescr) +i11 = int_add(i10, i2) +jump(p0, i11, i1) +""" +self.optimize_loop(ops, expected) + def test_bug_1(self): ops = """ [i0, p1] ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy heap-caching-during-tracing: fix second half of the test
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45683:feafe98006d1 Date: 2011-07-16 20:10 +0200 http://bitbucket.org/pypy/pypy/changeset/feafe98006d1/ Log:fix second half of the test diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -399,6 +399,10 @@ return tobox resbox = self.execute_with_descr(rop.GETARRAYITEM_GC, arraydescr, arraybox, indexbox) +if index >= 0: +if not cache: +cache = self.metainterp.heap_array_cache[arraydescr] = {} +cache[index] = arraybox, resbox return resbox ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-setslice: numpy: setslice added but doesn't work correctly for setting a slice of a slice yet
Author: Justin Peel Branch: numpy-setslice Changeset: r45685:9d55cebe8768 Date: 2011-07-16 12:49 -0600 http://bitbucket.org/pypy/pypy/changeset/9d55cebe8768/ Log:numpy: setslice added but doesn't work correctly for setting a slice of a slice yet diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -21,6 +21,8 @@ reds = ['result_size', 'i', 'self', 'result']) all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self']) any_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self']) +slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 'stop', 'self', 'arr']) +slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 'stop', 'self', 'arr']) class Signature(object): def __init__(self): @@ -255,10 +257,18 @@ res = SingleDimSlice(start, stop, step, slice_length, self, self.signature.transition(SingleDimSlice.static_signature)) return space.wrap(res) -@unwrap_spec(item=int, value=float) -def descr_setitem(self, space, item, value): +def descr_setitem(self, space, w_idx, w_value): +# TODO: indexing by tuples and lists self.invalidated() -return self.get_concrete().descr_setitem(space, item, value) +start, stop, step, slice_length = space.decode_index4(w_idx, + self.find_size()) +if step == 0: +# Single index +self.get_concrete().setitem(start, + space.float_w(w_value)) +else: +self.get_concrete().setslice(space, start, stop, step, + slice_length, w_value) def descr_mean(self, space): return space.wrap(space.float_w(self.descr_sum(space))/self.find_size()) @@ -407,8 +417,8 @@ return self.parent.getitem(self.calc_index(item)) @unwrap_spec(item=int, value=float) -def descr_setitem(self, space, item, value): -return self.parent.descr_setitem(space, self.calc_index(item), value) +def setitem(self, item, value): +return self.parent.setitem(self.calc_index(item), value) def descr_len(self, space): return space.wrap(self.find_size()) @@ -430,6 +440,47 @@ def find_size(self): return self.size +def _sliceloop1(self, start, stop, step, arr): +signature = Signature() +new_sig = self.signature.transition(signature) +i = start +j = 0 +while i < stop: +slice_driver1.jit_merge_point(signature=signature, self=self, +step=step, stop=stop, i=i, j=j, arr=arr) +self.parent.setitem(i, arr.eval(j)) +j += 1 +i += step + +def _sliceloop2(self, start, stop, step, arr): +signature = Signature() +new_sig = self.signature.transition(signature) +i = start +j = 0 +while i > stop: +slice_driver2.jit_merge_point(signature=signature, self=self, +step=step, stop=stop, i=i, j=j, arr=arr) +self.parent.setitem(i, arr.eval(j)) +j += 1 +i += step + +def setslice(self, space, start, stop, step, slice_length, arr): +# can't set a slice of a slice yet +if stop < 0: +stop += self.find_size() +if step > 0: +stop = min(stop, self.find_size()) +else: +stop = max(stop, 0) +arr = convert_to_array(space, arr) +start = self.calc_index(start) +stop = self.calc_index(stop) +step = self.step * step +if step > 0: +self._sliceloop1(start, stop, step, arr) +else: +self._sliceloop2(start, stop, step, arr) + def calc_index(self, item): return (self.start + item * self.step) @@ -453,7 +504,7 @@ def eval(self, i): return self.storage[i] -def getindex(self, space, item): +def getindex(self, item): if item >= self.size: raise operationerrfmt(space.w_IndexError, '%d above array size', item) @@ -471,11 +522,50 @@ return self.storage[item] @unwrap_spec(item=int, value=float) -def descr_setitem(self, space, item, value): -item = self.getindex(space, item) +def setitem(self, item, value): +item = self.getindex(item) self.invalidated() self.storage[item] = value +def _sliceloop1(self, start, stop, step, arr): +signature = Signature() +new_sig = self.signature.transition(signature) +i = start +j = 0 +while i < stop: +slice_driver1.jit_merge_point(signature=signature, self=self, +step
[pypy-commit] pypy heap-caching-during-tracing: proper invalidation for the array cache
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45686:420fc8c6b8cd Date: 2011-07-16 21:27 +0200 http://bitbucket.org/pypy/pypy/changeset/420fc8c6b8cd/ Log:proper invalidation for the array cache diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -391,7 +391,6 @@ @arguments("box", "descr", "box") def _opimpl_getarrayitem_gc_any(self, arraybox, arraydescr, indexbox): cache = self.metainterp.heap_array_cache.get(arraydescr, None) -index = -1 if cache and isinstance(indexbox, ConstInt): index = indexbox.getint() frombox, tobox = cache.get(index, (None, None)) @@ -399,9 +398,10 @@ return tobox resbox = self.execute_with_descr(rop.GETARRAYITEM_GC, arraydescr, arraybox, indexbox) -if index >= 0: +if isinstance(indexbox, ConstInt): if not cache: cache = self.metainterp.heap_array_cache[arraydescr] = {} +index = indexbox.getint() cache[index] = arraybox, resbox return resbox @@ -1671,10 +1671,13 @@ # record the operation profiler = self.staticdata.profiler profiler.count_ops(opnum, RECORDED_OPS) -if (self.heap_cache and opnum != rop.SETFIELD_GC and +if (opnum != rop.SETFIELD_GC and opnum != rop.SETARRAYITEM_GC): if not (rop._NOSIDEEFFECT_FIRST <= opnum <= rop._NOSIDEEFFECT_LAST): -self.heap_cache = {} +if self.heap_cache: +self.heap_cache.clear() +if self.heap_array_cache: +self.heap_array_cache.clear() op = self.history.record(opnum, argboxes, resbox, descr) self.attach_debug_info(op) return resbox diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py --- a/pypy/jit/metainterp/test/test_tracingopts.py +++ b/pypy/jit/metainterp/test/test_tracingopts.py @@ -184,3 +184,27 @@ res = self.interp_operations(fn, [-7, 1, 1]) assert res == -7 * 2 self.check_operations_history(getarrayitem_gc=1) + +def test_array_caching_while_tracing_invalidation(self): +a1 = [0, 0] +a2 = [0, 0] +@jit.dont_look_inside +def f(a): +a[0] = 5 +class A: pass +l = A() +def fn(n): +if n > 0: +a = a1 +else: +a = a2 +a[0] = n +x1 = a[0] +f(a) +x2 = a[0] +l.x = x2 +return a[0] + x1 + x2 +res = self.interp_operations(fn, [7]) +assert res == 5 * 2 + 7 +self.check_operations_history(getarrayitem_gc=1) + ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy heap-caching-during-tracing: a passing test
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45687:ca2a85b7eef9 Date: 2011-07-16 21:50 +0200 http://bitbucket.org/pypy/pypy/changeset/ca2a85b7eef9/ Log:a passing test diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py --- a/pypy/jit/metainterp/test/test_tracingopts.py +++ b/pypy/jit/metainterp/test/test_tracingopts.py @@ -208,3 +208,27 @@ assert res == 5 * 2 + 7 self.check_operations_history(getarrayitem_gc=1) +def test_array_and_getfield_interaction(self): +class A: pass +a1 = A() +a2 = A() +a1.l = a2.l = [0, 0] +def fn(n): +if n > 0: +a = a1 +else: +a = a2 +a.l = [0, 0] +a.x = 0 +a.l[a.x] = n +a.x += 1 +a.l[a.x] = n + 1 +x1 = a.l[a.x] +a.x -= 1 +x2 = a.l[a.x] +return x1 + x2 +res = self.interp_operations(fn, [7]) +assert res == 7 * 2 + 1 +self.check_operations_history(setarrayitem_gc=2, setfield_gc=3, + getarrayitem_gc=0, getfield_gc=1) + ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy heap-caching-during-tracing: make promotion influence the heap cache
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45688:22dc9cdf9e06 Date: 2011-07-16 21:59 +0200 http://bitbucket.org/pypy/pypy/changeset/22dc9cdf9e06/ Log:make promotion influence the heap cache diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -2354,6 +2354,16 @@ for i in range(len(boxes)): if boxes[i] is oldbox: boxes[i] = newbox +for descr, (frombox, tobox) in self.heap_cache.iteritems(): +change = False +if frombox is oldbox: +change = True +frombox = newbox +if tobox is oldbox: +change = True +tobox = newbox +if change: +self.heap_cache[descr] = frombox, tobox def find_biggest_function(self): start_stack = [] diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py --- a/pypy/jit/metainterp/test/test_tracingopts.py +++ b/pypy/jit/metainterp/test/test_tracingopts.py @@ -232,3 +232,27 @@ self.check_operations_history(setarrayitem_gc=2, setfield_gc=3, getarrayitem_gc=0, getfield_gc=1) +def test_promote_changes_heap_cache(self): +class A: pass +a1 = A() +a2 = A() +a1.l = a2.l = [0, 0] +a1.x = a2.x = 0 +def fn(n): +if n > 0: +a = a1 +else: +a = a2 +a.l = [0, 0] +jit.promote(a.x) +a.l[a.x] = n +a.x += 1 +a.l[a.x] = n + 1 +x1 = a.l[a.x] +a.x -= 1 +x2 = a.l[a.x] +return x1 + x2 +res = self.interp_operations(fn, [7]) +assert res == 7 * 2 + 1 +self.check_operations_history(setarrayitem_gc=2, setfield_gc=2, + getarrayitem_gc=0, getfield_gc=2) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] benchmarks default: oops
Author: Maciej Fijalkowski Branch: Changeset: r126:0893b0a1eea4 Date: 2011-07-16 22:07 +0200 http://bitbucket.org/pypy/benchmarks/changeset/0893b0a1eea4/ Log:oops diff --git a/saveresults.py b/saveresults.py --- a/saveresults.py +++ b/saveresults.py @@ -8,7 +8,7 @@ SPEEDURL = "http://speed.pypy.org/"; -def save(project, revision, results, options, interpreter, host, testing=True, +def save(project, revision, results, options, interpreter, host, testing=False, changed=True): testparams = [] #Parse data ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] benchmarks default: add a postfix parameter
Author: Maciej Fijalkowski Branch: Changeset: r127:846fa56a282b Date: 2011-07-16 23:21 +0200 http://bitbucket.org/pypy/benchmarks/changeset/846fa56a282b/ Log:add a postfix parameter diff --git a/runner.py b/runner.py --- a/runner.py +++ b/runner.py @@ -9,13 +9,13 @@ import socket def perform_upload(pypy_c_path, args, force_host, options, res, revision, - changed=True): + changed=True, postfix=''): from saveresults import save project = 'PyPy' if "--jit" in args: -name = "pypy-c" +name = "pypy-c" + postfix else: -name = "pypy-c-jit" +name = "pypy-c-jit" + postfix if "psyco.sh" in pypy_c_path: name = "cpython psyco-profile" revision = 100 @@ -30,7 +30,7 @@ def run_and_store(benchmark_set, result_filename, pypy_c_path, revision=0, options='', branch='trunk', args='', upload=False, force_host=None, fast=False, baseline=sys.executable, - full_store=False): + full_store=False, postfix=''): funcs = perf.BENCH_FUNCS.copy() funcs.update(perf._FindAllBenchmarks(benchmarks.__dict__)) opts = ['-b', ','.join(benchmark_set), '--inherit_env=PATH', @@ -60,9 +60,9 @@ argsbase, argschanged = args, args if 'pypy' in baseline: perform_upload(pypy_c_path, argsbase, force_host, options, res, - revision, changed=False) + revision, changed=False, postfix=postfix) perform_upload(pypy_c_path, argschanged, force_host, options, res, - revision, changed=True) + revision, changed=True, postfix=postfix) BENCHMARK_SET = ['richards', 'slowspitfire', 'django', 'spambayes', 'rietveld', 'html5lib', 'ai'] @@ -110,6 +110,8 @@ help="Run shorter benchmark runs") parser.add_option("--full-store", default=False, action="store_true", help="") +parser.add_option('--postfix', default='', action='store', + help='Append a postfix to uploaded executable') options, args = parser.parse_args(argv) benchmarks = options.benchmarks.split(',') for benchmark in benchmarks: @@ -118,7 +120,8 @@ run_and_store(benchmarks, options.output_filename, options.pypy_c, options.revision, args=options.args, upload=options.upload, force_host=options.force_host, fast=options.fast, - baseline=options.baseline, full_store=options.full_store) + baseline=options.baseline, full_store=options.full_store, + postfix=options.postfix) if __name__ == '__main__': main(sys.argv[1:]) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] buildbot default: change the URL to the canonical one. will revert if it breaks stuff
Author: Maciej Fijalkowski Branch: Changeset: r530:3ca6784afb86 Date: 2011-07-16 18:35 +0200 http://bitbucket.org/pypy/buildbot/changeset/3ca6784afb86/ Log:change the URL to the canonical one. will revert if it breaks stuff diff --git a/bot2/pypybuildbot/master.py b/bot2/pypybuildbot/master.py --- a/bot2/pypybuildbot/master.py +++ b/bot2/pypybuildbot/master.py @@ -338,6 +338,6 @@ }, ], -'buildbotURL': 'http://wyvern.cs.uni-duesseldorf.de:%d/'%(httpPortNumber), +'buildbotURL': 'http://buildbot.pypy.org), 'projectURL': 'http://pypy.org/', 'projectName': 'PyPy'} ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] buildbot default: enable nightly builds of pypy-c-64bit
Author: Maciej Fijalkowski Branch: Changeset: r531:9f67b389b4fa Date: 2011-07-16 23:22 +0200 http://bitbucket.org/pypy/buildbot/changeset/9f67b389b4fa/ Log:enable nightly builds of pypy-c-64bit diff --git a/bot2/pypybuildbot/builds.py b/bot2/pypybuildbot/builds.py --- a/bot2/pypybuildbot/builds.py +++ b/bot2/pypybuildbot/builds.py @@ -277,7 +277,7 @@ blocksize=100*1024)) class JITBenchmark(factory.BuildFactory): -def __init__(self, platform='linux'): +def __init__(self, platform='linux', host='tannit', postfix=None): factory.BuildFactory.__init__(self) setup_steps(platform, self) @@ -287,15 +287,20 @@ workdir='.')) self.addStep(Translate(['-Ojit'], [])) pypy_c_rel = "../build/pypy/translator/goal/pypy-c" +if postfix: +addopts = ['--postfix', postfix] +else: +addopts = None self.addStep(ShellCmd( description="run benchmarks on top of pypy-c", command=["python", "runner.py", '--output-filename', 'result.json', '--pypy-c', pypy_c_rel, '--baseline', pypy_c_rel, '--args', ',--jit off', - '--upload', #'--force-host', 'bigdog', + '--upload', '--revision', WithProperties('%(got_revision)s'), - '--branch', WithProperties('%(branch)s')], + '--branch', WithProperties('%(branch)s'), + ] + addopts, workdir='./benchmarks', haltOnFailure=True)) # a bit obscure hack to get both os.path.expand and a property @@ -303,14 +308,3 @@ self.addStep(transfer.FileUpload(slavesrc="benchmarks/result.json", masterdest=WithProperties(resfile), workdir=".")) - -##self.addStep(ShellCmd( -##description="run on top of python with psyco", -##command=["python", "runner.py", '--output-filename', 'result.json', -##'--pypy-c', 'psyco/python_with_psyco.sh', -## '--revision', WithProperties('%(got_revision)s'), -## '--upload', #'--force-host', 'bigdog', -## '--branch', WithProperties('%(branch)s'), -## ], -##workdir='./benchmarks', -##haltOnFailure=True)) diff --git a/bot2/pypybuildbot/master.py b/bot2/pypybuildbot/master.py --- a/bot2/pypybuildbot/master.py +++ b/bot2/pypybuildbot/master.py @@ -180,6 +180,8 @@ ) pypyJITBenchmarkFactory = pypybuilds.JITBenchmark() +pypyJITBenchmarkFactory64 = pypybuilds.JITBenchmark(platform='linux64', +postfix='-64') LINUX32 = "own-linux-x86-32" LINUX64 = "own-linux-x86-64" @@ -200,16 +202,20 @@ JITONLYLINUX32 = "jitonly-own-linux-x86-32" JITBENCH = "jit-benchmark-linux-x86-32" +JITBENCH64 = "jit-benchmark-linux-x86-64" BuildmasterConfig = { 'slavePortnum': slavePortnum, 'change_source': [], 'schedulers': [ -Nightly("nightly-0-45", [ +Nightly("nightly-0-00", [ JITBENCH, # on tannit -- nothing else there during first round! MACOSX32, # on minime -], hour=0, minute=45), +], hour=0, minute=0), +Nightly("nighly-2-00", [ +JITBENCH64, # on tannit -- nothing else there during first round! +], hour=2, minute=0), Nightly("nightly-4-00", [ # rule: what we pick here on tannit should take at most 8 cores # and be hopefully finished after 2 hours @@ -336,6 +342,12 @@ "factory": pypyJITBenchmarkFactory, "category": 'benchmark-run', }, + {"name": JITBENCH64, + "slavenames": ["tannit64"], + "builddir": JITBENCH64, + "factory": pypyJITBenchmarkFactory64, + "category": "benchmark-run", + }, ], 'buildbotURL': 'http://buildbot.pypy.org), ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] buildbot default: typo
Author: Maciej Fijalkowski Branch: Changeset: r532:ada781d23a2d Date: 2011-07-16 23:24 +0200 http://bitbucket.org/pypy/buildbot/changeset/ada781d23a2d/ Log:typo diff --git a/bot2/pypybuildbot/master.py b/bot2/pypybuildbot/master.py --- a/bot2/pypybuildbot/master.py +++ b/bot2/pypybuildbot/master.py @@ -350,6 +350,6 @@ }, ], -'buildbotURL': 'http://buildbot.pypy.org), +'buildbotURL': 'http://buildbot.pypy.org', 'projectURL': 'http://pypy.org/', 'projectName': 'PyPy'} ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] buildbot default: another fix
Author: Maciej Fijalkowski Branch: Changeset: r533:00b2db6f1765 Date: 2011-07-16 23:24 +0200 http://bitbucket.org/pypy/buildbot/changeset/00b2db6f1765/ Log:another fix diff --git a/bot2/pypybuildbot/builds.py b/bot2/pypybuildbot/builds.py --- a/bot2/pypybuildbot/builds.py +++ b/bot2/pypybuildbot/builds.py @@ -290,7 +290,7 @@ if postfix: addopts = ['--postfix', postfix] else: -addopts = None +addopts = [] self.addStep(ShellCmd( description="run benchmarks on top of pypy-c", command=["python", "runner.py", '--output-filename', 'result.json', ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy heap-caching-during-tracing: make new construction go via the normal setfield code
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45690:34414cbab3ef Date: 2011-07-17 00:22 +0200 http://bitbucket.org/pypy/pypy/changeset/34414cbab3ef/ Log:make new construction go via the normal setfield code diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -474,12 +474,10 @@ def opimpl_newlist(self, structdescr, lengthdescr, itemsdescr, arraydescr, sizebox): sbox = self.metainterp.execute_and_record(rop.NEW, structdescr) -self.metainterp.execute_and_record(rop.SETFIELD_GC, lengthdescr, - sbox, sizebox) +self._opimpl_setfield_gc_any(sbox, lengthdescr, sizebox) abox = self.metainterp.execute_and_record(rop.NEW_ARRAY, arraydescr, sizebox) -self.metainterp.execute_and_record(rop.SETFIELD_GC, itemsdescr, - sbox, abox) +self._opimpl_setfield_gc_any(sbox, itemsdescr, abox) return sbox @arguments("box", "descr", "descr", "box") diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py --- a/pypy/jit/metainterp/test/test_tracingopts.py +++ b/pypy/jit/metainterp/test/test_tracingopts.py @@ -300,3 +300,18 @@ assert res == -7 * 2 self.check_operations_history(getarrayitem_gc=1, getfield_gc=3) + +def test_list_caching_negative(self): +def fn(n): +jit.promote(n) +a = [0] * n +if n > 1000: +a.append(0) +a[-1] = n +x1 = a[-1] +a[n - n - 1] = n + 1 +return a[-1] + x1 +res = self.interp_operations(fn, [7]) +assert res == 7 + 7 + 1 +self.check_operations_history(setarrayitem_gc=2, +setfield_gc=2) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy heap-caching-during-tracing: make virtualizable code delegate to default implementations to get the right
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45691:823933ada2fb Date: 2011-07-17 00:37 +0200 http://bitbucket.org/pypy/pypy/changeset/823933ada2fb/ Log:make virtualizable code delegate to default implementations to get the right caching effect. diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -683,10 +683,8 @@ @arguments("orgpc", "box", "descr", "descr", "box") def _opimpl_getarrayitem_vable(self, pc, box, fdescr, adescr, indexbox): if self._nonstandard_virtualizable(pc, box): -arraybox = self.metainterp.execute_and_record(rop.GETFIELD_GC, - fdescr, box) -return self.execute_with_descr(rop.GETARRAYITEM_GC, adescr, - arraybox, indexbox) +arraybox = self._opimpl_getfield_gc_any(box, fdescr) +return self._opimpl_getarrayitem_gc_any(arraybox, adescr, indexbox) self.metainterp.check_synchronized_virtualizable() index = self._get_arrayitem_vable_index(pc, fdescr, indexbox) return self.metainterp.virtualizable_boxes[index] @@ -699,10 +697,9 @@ def _opimpl_setarrayitem_vable(self, pc, box, fdescr, adescr, indexbox, valuebox): if self._nonstandard_virtualizable(pc, box): -arraybox = self.metainterp.execute_and_record(rop.GETFIELD_GC, - fdescr, box) -self.execute_with_descr(rop.SETARRAYITEM_GC, adescr, -arraybox, indexbox, valuebox) +arraybox = self._opimpl_getfield_gc_any(box, fdescr) +self._opimpl_setarrayitem_gc_any(arraybox, adescr, + indexbox, valuebox) return index = self._get_arrayitem_vable_index(pc, fdescr, indexbox) self.metainterp.virtualizable_boxes[index] = valuebox diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py --- a/pypy/jit/metainterp/test/test_tracingopts.py +++ b/pypy/jit/metainterp/test/test_tracingopts.py @@ -315,3 +315,45 @@ assert res == 7 + 7 + 1 self.check_operations_history(setarrayitem_gc=2, setfield_gc=2) + +def test_virtualizable_with_array_heap_cache(self): +myjitdriver = jit.JitDriver(greens = [], reds = ['n', 'x', 'i', 'frame'], +virtualizables = ['frame']) + +class Frame(object): +_virtualizable2_ = ['l[*]', 's'] + +def __init__(self, a, s): +self = jit.hint(self, access_directly=True, fresh_virtualizable=True) +self.l = [0] * 4 +self.s = s + +def f(n, a, i): +frame = Frame(a, 0) +frame.l[0] = a +frame.l[1] = a + 1 +frame.l[2] = a + 2 +frame.l[3] = a + 3 +if not i: +return frame.l[0] +x = 0 +while n > 0: +myjitdriver.can_enter_jit(frame=frame, n=n, x=x, i=i) +myjitdriver.jit_merge_point(frame=frame, n=n, x=x, i=i) +frame.s = jit.promote(frame.s) +n -= 1 +s = frame.s +assert s >= 0 +x += frame.l[s] +frame.s += 1 +s = frame.s +assert s >= 0 +x += frame.l[s] +x += len(frame.l) +x += f(n, n, 0) +frame.s -= 1 +return x + +res = self.meta_interp(f, [10, 1, 1], listops=True) +assert res == f(10, 1, 1) +self.check_history(getarrayitem_gc=0, getfield_gc=0) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy heap-caching-during-tracing: make sure the stuff works with resizable lists too
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45689:160b69e37ce6 Date: 2011-07-16 23:04 +0200 http://bitbucket.org/pypy/pypy/changeset/160b69e37ce6/ Log:make sure the stuff works with resizable lists too diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -485,10 +485,8 @@ @arguments("box", "descr", "descr", "box") def _opimpl_getlistitem_gc_any(self, listbox, itemsdescr, arraydescr, indexbox): -arraybox = self.metainterp.execute_and_record(rop.GETFIELD_GC, - itemsdescr, listbox) -return self.execute_with_descr(rop.GETARRAYITEM_GC, - arraydescr, arraybox, indexbox) +arraybox = self._opimpl_getfield_gc_any(listbox, itemsdescr) +return self._opimpl_getarrayitem_gc_any(arraybox, arraydescr, indexbox) opimpl_getlistitem_gc_i = _opimpl_getlistitem_gc_any opimpl_getlistitem_gc_r = _opimpl_getlistitem_gc_any @@ -497,10 +495,9 @@ @arguments("box", "descr", "descr", "box", "box") def _opimpl_setlistitem_gc_any(self, listbox, itemsdescr, arraydescr, indexbox, valuebox): -arraybox = self.metainterp.execute_and_record(rop.GETFIELD_GC, - itemsdescr, listbox) -self.execute_with_descr(rop.SETARRAYITEM_GC, arraydescr, arraybox, -indexbox, valuebox) +arraybox = self._opimpl_getfield_gc_any(listbox, itemsdescr) +self._opimpl_setarrayitem_gc_any(arraybox, arraydescr, indexbox, + valuebox) opimpl_setlistitem_gc_i = _opimpl_setlistitem_gc_any opimpl_setlistitem_gc_r = _opimpl_setlistitem_gc_any diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py --- a/pypy/jit/metainterp/test/test_tracingopts.py +++ b/pypy/jit/metainterp/test/test_tracingopts.py @@ -256,3 +256,47 @@ assert res == 7 * 2 + 1 self.check_operations_history(setarrayitem_gc=2, setfield_gc=2, getarrayitem_gc=0, getfield_gc=2) + +def test_list_caching(self): +a1 = [0, 0] +a2 = [0, 0] +def fn(n): +if n > 0: +a = a1 +else: +a = a2 +if n < -1000: +a.append(5) +a[0] = n +x1 = a[0] +a[n - n] = n + 1 +return a[0] + x1 +res = self.interp_operations(fn, [7]) +assert res == 7 + 7 + 1 +self.check_operations_history(getarrayitem_gc=1, +getfield_gc=1) +res = self.interp_operations(fn, [-7]) +assert res == -7 - 7 + 1 +self.check_operations_history(getarrayitem_gc=1, +getfield_gc=1) + +def fn(n, ca, cb): +a1[0] = n +a2[0] = n +a = a1 +if ca: +a = a2 +if n < -100: +a.append(5) +b = a1 +if cb: +b = a +return a[0] + b[0] +res = self.interp_operations(fn, [7, 0, 1]) +assert res == 7 * 2 +self.check_operations_history(getarrayitem_gc=1, +getfield_gc=3) +res = self.interp_operations(fn, [-7, 1, 1]) +assert res == -7 * 2 +self.check_operations_history(getarrayitem_gc=1, +getfield_gc=3) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: name this something useful.
Author: Alex Gaynor Branch: Changeset: r45692:a279306f0a8e Date: 2011-07-16 19:03 -0700 http://bitbucket.org/pypy/pypy/changeset/a279306f0a8e/ Log:name this something useful. diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -4553,7 +4553,7 @@ """ self.optimize_loop(ops, expected) -def test_strslice_with_other_stuff(self): +def test_strslice_subtraction_folds(self): ops = """ [p0, i0] i1 = int_add(i0, 1) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: Another thing I keep seeing.
Author: Alex Gaynor Branch: extradoc Changeset: r3833:44e83b7f5d3d Date: 2011-07-16 19:07 -0700 http://bitbucket.org/pypy/extradoc/changeset/44e83b7f5d3d/ Log:Another thing I keep seeing. diff --git a/planning/jit.txt b/planning/jit.txt --- a/planning/jit.txt +++ b/planning/jit.txt @@ -80,6 +80,16 @@ maybe we should move promote even higher, before the first use and we could possibly remove more stuff? + This shows up in another way as well, the Python code + + if x is None: + i += x + + We promote the guard_nonnull when we load x into guard_nonnull class, + however this happens after the optimizer sees `x is None`, so that ptr_eq + still remains, even though it's obviously not necessary since x and None + will have different known_classes. + - f31 = f17 * f16 f32 = f16 * f17 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: merged upstream
Author: Alex Gaynor Branch: extradoc Changeset: r3834:b9f7d7a21139 Date: 2011-07-16 19:07 -0700 http://bitbucket.org/pypy/extradoc/changeset/b9f7d7a21139/ Log:merged upstream diff --git a/sprintinfo/ddorf2011-cppyy/planning.txt b/sprintinfo/ddorf2011-cppyy/planning.txt new file mode 100644 --- /dev/null +++ b/sprintinfo/ddorf2011-cppyy/planning.txt @@ -0,0 +1,25 @@ +people: + + - Sven + - Armin + - Carl Friedrich + - Wim + - Lukas + - David + +tasks: + +cppyy + - memory management + - split between rpython/python (Carl Friedrich) + - fast path improvements DONE + - test fast path (Carl Friedrich) + - global data members + - code duplication: IN PROGRESS + - array problems: IN PROGRESS (Armin, Wim) + + +auxilliary tasks + + - look more into PPC (Sven, David) + - list/set improvements (Lukas) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: synthesize reverse operations for float multiplcatoin.
Author: Alex Gaynor Branch: Changeset: r45693:3468fc4c3e4a Date: 2011-07-16 19:35 -0700 http://bitbucket.org/pypy/pypy/changeset/3468fc4c3e4a/ Log:synthesize reverse operations for float multiplcatoin. diff --git a/pypy/jit/metainterp/optimizeopt/rewrite.py b/pypy/jit/metainterp/optimizeopt/rewrite.py --- a/pypy/jit/metainterp/optimizeopt/rewrite.py +++ b/pypy/jit/metainterp/optimizeopt/rewrite.py @@ -199,6 +199,7 @@ )) return self.emit_operation(op) +self.pure(rop.FLOAT_MUL, [arg2, arg1], op.result) def optimize_FLOAT_NEG(self, op): v1 = op.getarg(0) diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py --- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py @@ -4572,6 +4572,20 @@ """ self.optimize_strunicode_loop(ops, expected) +def test_float_mul_reversed(self): +ops = """ +[f0, f1] +f2 = float_mul(f0, f1) +f3 = float_mul(f1, f0) +jump(f2, f3) +""" +expected = """ +[f0, f1] +f2 = float_mul(f0, f1) +jump(f2, f2) +""" +self.optimize_loop(ops, expected) + class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin): pass ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: did this.
Author: Alex Gaynor Branch: extradoc Changeset: r3835:58e1c1b75f8a Date: 2011-07-16 21:48 -0700 http://bitbucket.org/pypy/extradoc/changeset/58e1c1b75f8a/ Log:did this. diff --git a/planning/jit.txt b/planning/jit.txt --- a/planning/jit.txt +++ b/planning/jit.txt @@ -80,11 +80,6 @@ maybe we should move promote even higher, before the first use and we could possibly remove more stuff? -- f31 = f17 * f16 - f32 = f16 * f17 - - Should be just a matter of synthesizing reverse operations in rewrite.py - - optimize arraycopy also in the cases where one of the arrays is a virtual and short. This is seen a lot in translate.py ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] extradoc extradoc: mergec upstream.
Author: Alex Gaynor Branch: extradoc Changeset: r3836:ec767df04faa Date: 2011-07-16 21:50 -0700 http://bitbucket.org/pypy/extradoc/changeset/ec767df04faa/ Log:mergec upstream. diff --git a/planning/jit.txt b/planning/jit.txt --- a/planning/jit.txt +++ b/planning/jit.txt @@ -80,6 +80,16 @@ maybe we should move promote even higher, before the first use and we could possibly remove more stuff? + This shows up in another way as well, the Python code + + if x is None: + i += x + + We promote the guard_nonnull when we load x into guard_nonnull class, + however this happens after the optimizer sees `x is None`, so that ptr_eq + still remains, even though it's obviously not necessary since x and None + will have different known_classes. + - optimize arraycopy also in the cases where one of the arrays is a virtual and short. This is seen a lot in translate.py diff --git a/sprintinfo/ddorf2011-cppyy/planning.txt b/sprintinfo/ddorf2011-cppyy/planning.txt new file mode 100644 --- /dev/null +++ b/sprintinfo/ddorf2011-cppyy/planning.txt @@ -0,0 +1,25 @@ +people: + + - Sven + - Armin + - Carl Friedrich + - Wim + - Lukas + - David + +tasks: + +cppyy + - memory management + - split between rpython/python (Carl Friedrich) + - fast path improvements DONE + - test fast path (Carl Friedrich) + - global data members + - code duplication: IN PROGRESS + - array problems: IN PROGRESS (Armin, Wim) + + +auxilliary tasks + + - look more into PPC (Sven, David) + - list/set improvements (Lukas) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] benchmarks default: kill the symlink, and use a python hack to share the content of util.py in both directories
Author: Antonio Cuni Branch: Changeset: r122:8c862863e7fb Date: 2011-07-16 10:27 +0200 http://bitbucket.org/pypy/benchmarks/changeset/8c862863e7fb/ Log:kill the symlink, and use a python hack to share the content of util.py in both directories diff --git a/own/util.py b/own/util.py old mode 12 new mode 100644 --- a/own/util.py +++ b/own/util.py @@ -1,1 +1,5 @@ -../unladen_swallow/performance/util.py \ No newline at end of file +import os.path + +root = os.path.abspath(os.path.join(__file__, '..', '..')) +util_py = os.path.join(root, 'unladen_swallow', 'performance', 'util.py') +execfile(util_py) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy faster-nested-scopes: fix flow space. needs a slightly annoying hack
Author: Carl Friedrich Bolz Branch: faster-nested-scopes Changeset: r45658:c6b24da7b2b9 Date: 2011-07-16 11:33 +0200 http://bitbucket.org/pypy/pypy/changeset/c6b24da7b2b9/ Log:fix flow space. needs a slightly annoying hack diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py --- a/pypy/objspace/flow/flowcontext.py +++ b/pypy/objspace/flow/flowcontext.py @@ -184,7 +184,7 @@ class FlowExecutionContext(ExecutionContext): -def __init__(self, space, code, globals, constargs={}, closure=None, +def __init__(self, space, code, globals, constargs={}, outer_func=None, name=None): ExecutionContext.__init__(self, space) self.code = code @@ -193,11 +193,11 @@ self.crnt_offset = -1 self.crnt_frame = None -if closure is None: +if outer_func and outer_func.closure: +self.closure = [nestedscope.Cell(Constant(value)) +for value in outer_func.closure] +else: self.closure = None -else: -self.closure = [nestedscope.Cell(Constant(value)) -for value in closure] frame = self.create_frame() formalargcount = code.getformalargcount() arg_list = [Variable() for i in range(formalargcount)] @@ -216,7 +216,7 @@ # while ignoring any operation like the creation of the locals dict self.recorder = [] frame = FlowSpaceFrame(self.space, self.code, - self.w_globals, self.closure) + self.w_globals, self) frame.last_instr = 0 return frame diff --git a/pypy/objspace/flow/objspace.py b/pypy/objspace/flow/objspace.py --- a/pypy/objspace/flow/objspace.py +++ b/pypy/objspace/flow/objspace.py @@ -252,9 +252,9 @@ raise TypeError("%r is a generator" % (func,)) code = PyCode._from_code(self, code) if func.func_closure is None: -closure = None +cl = None else: -closure = [extract_cell_content(c) for c in func.func_closure] +cl = [extract_cell_content(c) for c in func.func_closure] # CallableFactory.pycall may add class_ to functions that are methods name = func.func_name class_ = getattr(func, 'class_', None) @@ -262,8 +262,10 @@ name = '%s.%s' % (class_.__name__, name) for c in "<>&!": name = name.replace(c, '_') +class outerfunc: # hack +closure = cl ec = flowcontext.FlowExecutionContext(self, code, func.func_globals, - constargs, closure, name) + constargs, outerfunc, name) graph = ec.graph graph.func = func # attach a signature and defaults to the graph ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy faster-nested-scopes: fix cpyext
Author: Carl Friedrich Bolz Branch: faster-nested-scopes Changeset: r45659:5994465ca0d0 Date: 2011-07-16 11:49 +0200 http://bitbucket.org/pypy/pypy/changeset/5994465ca0d0/ Log:fix cpyext diff --git a/pypy/module/cpyext/frameobject.py b/pypy/module/cpyext/frameobject.py --- a/pypy/module/cpyext/frameobject.py +++ b/pypy/module/cpyext/frameobject.py @@ -57,7 +57,7 @@ code = space.interp_w(PyCode, w_code) w_globals = from_ref(space, py_frame.c_f_globals) -frame = PyFrame(space, code, w_globals, closure=None) +frame = PyFrame(space, code, w_globals, outer_func=None) frame.f_lineno = py_frame.c_f_lineno w_obj = space.wrap(frame) track_reference(space, py_obj, w_obj) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: typo
Author: Carl Friedrich Bolz Branch: Changeset: r45660:0eee4b30304a Date: 2011-07-16 13:06 +0200 http://bitbucket.org/pypy/pypy/changeset/0eee4b30304a/ Log:typo diff --git a/pypy/jit/metainterp/test/test_ajit.py b/pypy/jit/metainterp/test/test_ajit.py --- a/pypy/jit/metainterp/test/test_ajit.py +++ b/pypy/jit/metainterp/test/test_ajit.py @@ -2381,7 +2381,7 @@ assert res == -2 #self.check_loops(getarrayitem_gc=0, setarrayitem_gc=0) -- xxx? -def test_retrace_ending_up_retrazing_another_loop(self): +def test_retrace_ending_up_retracing_another_loop(self): myjitdriver = JitDriver(greens = ['pc'], reds = ['n', 'i', 'sa']) bytecode = "0+sI0+SI" ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy heap-caching-during-tracing: add a minimal heap cache to be used when tracing
Author: Carl Friedrich Bolz Branch: heap-caching-during-tracing Changeset: r45661:be79442107df Date: 2011-07-16 14:32 +0200 http://bitbucket.org/pypy/pypy/changeset/be79442107df/ Log:add a minimal heap cache to be used when tracing diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py --- a/pypy/jit/metainterp/pyjitpl.py +++ b/pypy/jit/metainterp/pyjitpl.py @@ -502,7 +502,12 @@ @arguments("box", "descr") def _opimpl_getfield_gc_any(self, box, fielddescr): -return self.execute_with_descr(rop.GETFIELD_GC, fielddescr, box) +frombox, tobox = self.metainterp.heap_cache.get(fielddescr, (None, None)) +if frombox is box: +return tobox +resbox = self.execute_with_descr(rop.GETFIELD_GC, fielddescr, box) +self.metainterp.heap_cache[fielddescr] = (box, resbox) +return resbox opimpl_getfield_gc_i = _opimpl_getfield_gc_any opimpl_getfield_gc_r = _opimpl_getfield_gc_any opimpl_getfield_gc_f = _opimpl_getfield_gc_any @@ -532,7 +537,11 @@ @arguments("box", "descr", "box") def _opimpl_setfield_gc_any(self, box, fielddescr, valuebox): +frombox, tobox = self.metainterp.heap_cache.get(fielddescr, (None, None)) +if frombox is box and tobox is valuebox: +return self.execute_with_descr(rop.SETFIELD_GC, fielddescr, box, valuebox) +self.metainterp.heap_cache[fielddescr] = (box, valuebox) opimpl_setfield_gc_i = _opimpl_setfield_gc_any opimpl_setfield_gc_r = _opimpl_setfield_gc_any opimpl_setfield_gc_f = _opimpl_setfield_gc_any @@ -617,7 +626,7 @@ @arguments("orgpc", "box", "descr") def _opimpl_getfield_vable(self, pc, box, fielddescr): if self._nonstandard_virtualizable(pc, box): -return self.execute_with_descr(rop.GETFIELD_GC, fielddescr, box) +return self._opimpl_getfield_gc_any(box, fielddescr) self.metainterp.check_synchronized_virtualizable() index = self._get_virtualizable_field_index(fielddescr) return self.metainterp.virtualizable_boxes[index] @@ -629,8 +638,7 @@ @arguments("orgpc", "box", "descr", "box") def _opimpl_setfield_vable(self, pc, box, fielddescr, valuebox): if self._nonstandard_virtualizable(pc, box): -self.execute_with_descr(rop.SETFIELD_GC, fielddescr, box, valuebox) -return +return self._opimpl_setfield_gc_any(box, fielddescr, valuebox) index = self._get_virtualizable_field_index(fielddescr) self.metainterp.virtualizable_boxes[index] = valuebox self.metainterp.synchronize_virtualizable() @@ -1462,6 +1470,9 @@ self.known_class_boxes = {} # contains frame boxes that are not virtualizables self.nonstandard_virtualizables = {} +# heap cache +# maps descrs to (from_box, to_box) tuples +self.heap_cache = {} def perform_call(self, jitcode, boxes, greenkey=None): # causes the metainterp to enter the given subfunction @@ -1637,6 +1648,9 @@ # record the operation profiler = self.staticdata.profiler profiler.count_ops(opnum, RECORDED_OPS) +if opnum != rop.SETFIELD_GC and self.heap_cache: +if not (rop._NOSIDEEFFECT_FIRST <= opnum <= rop._NOSIDEEFFECT_LAST): +self.heap_cache = {} op = self.history.record(opnum, argboxes, resbox, descr) self.attach_debug_info(op) return resbox @@ -1804,6 +1818,7 @@ def reached_loop_header(self, greenboxes, redboxes, resumedescr): self.known_class_boxes = {} self.nonstandard_virtualizables = {} # XXX maybe not needed? +self.heap_cache = {} duplicates = {} self.remove_consts_and_duplicates(redboxes, len(redboxes), diff --git a/pypy/jit/metainterp/test/test_ajit.py b/pypy/jit/metainterp/test/test_ajit.py --- a/pypy/jit/metainterp/test/test_ajit.py +++ b/pypy/jit/metainterp/test/test_ajit.py @@ -1024,69 +1024,6 @@ res = self.meta_interp(main, []) assert res == 55 -def test_dont_record_repeated_guard_class(self): -class A: -pass -class B(A): -pass -@dont_look_inside -def extern(n): -if n == -7: -return None -elif n: -return A() -else: -return B() -def fn(n): -obj = extern(n) -return isinstance(obj, B) + isinstance(obj, B) + isinstance(obj, B) + isinstance(obj, B) -res = self.interp_operations(fn, [0]) -assert res == 4 -self.check_operations_history(guard_class=1, guard_nonnull=1) -res = self.interp_operations(fn, [1]) -assert not res - -def test_dont_record_guard_class_after_new(self): -class A: -pass -class B(A): -pass -def fn(n): -if n == -7: -
[pypy-commit] pypy jit-short_from_state: Some extra debug prints. Make optimize_STRLEN keep the original result box if the strlen op is emitted.
Author: Hakan Ardo Branch: jit-short_from_state Changeset: r45662:a8eedb9a9b64 Date: 2011-07-16 14:59 +0200 http://bitbucket.org/pypy/pypy/changeset/a8eedb9a9b64/ Log:Some extra debug prints. Make optimize_STRLEN keep the original result box if the strlen op is emitted. diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py --- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py +++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py @@ -6453,6 +6453,20 @@ """ self.optimize_loop(ops, expected) +def test_loopinvariant_strlen(self): +ops = """ +[p9] +i843 = strlen(p9) +call(i843, descr=nonwritedescr) +jump(p9) +""" +expected = """ +[p9, i2] +call(i2, descr=nonwritedescr) +jump(p9, i2) +""" +self.optimize_loop(ops, expected) + class TestLLtype(OptimizeOptTest, LLtypeMixin): pass diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py --- a/pypy/jit/metainterp/optimizeopt/unroll.py +++ b/pypy/jit/metainterp/optimizeopt/unroll.py @@ -184,7 +184,7 @@ virtual_state = modifier.get_virtual_state(jump_args) values = [self.getvalue(arg) for arg in jump_args] inputargs = virtual_state.make_inputargs(values) -short_inputargs = virtual_state.make_inputargs(values, keyboxes=True) +short_inputargs = virtual_state.make_inputargs(values, keyboxes=True) self.constant_inputargs = {} for box in jump_args: @@ -201,6 +201,20 @@ self.optimizer = self.optimizer.new() loop.quasi_immutable_deps = self.optimizer.quasi_immutable_deps +logops = self.optimizer.loop.logops +if logops: +args = ", ".join([logops.repr_of_arg(arg) for arg in inputargs]) +debug_print('inputargs: ' + args) +args = ", ".join([logops.repr_of_arg(arg) for arg in short_inputargs]) +debug_print('short inputargs: ' + args) +debug_start('jit-short-boxes') +for box, op in self.short_boxes.items(): +if op: +debug_print(logops.repr_of_arg(box) + ': ' + logops.repr_of_resop(op)) +else: +debug_print(logops.repr_of_arg(box) + ': None') +debug_stop('jit-short-boxes') + # Force virtuals amoung the jump_args of the preamble to get the # operations needed to setup the proper state of those virtuals # in the peeled loop @@ -229,7 +243,7 @@ self.optimizer.send_extra_operation(guard) self.optimizer.flush() self.optimizer.emitting_dissabled = False - + initial_inputargs_len = len(inputargs) self.inliner = Inliner(loop.inputargs, jump_args) @@ -351,8 +365,12 @@ args = op.getarglist() if op.is_guard(): args = args + op.getfailargs() - + +if self.optimizer.loop.logops: +debug_print('OP: ' + self.optimizer.loop.logops.repr_of_resop(op)) for a in args: +if self.optimizer.loop.logops: +debug_print('A: ' + self.optimizer.loop.logops.repr_of_arg(a)) self.import_box(a, inputargs, short, short_jumpargs, jumpargs, short_seen) i += 1 diff --git a/pypy/jit/metainterp/optimizeopt/vstring.py b/pypy/jit/metainterp/optimizeopt/vstring.py --- a/pypy/jit/metainterp/optimizeopt/vstring.py +++ b/pypy/jit/metainterp/optimizeopt/vstring.py @@ -47,7 +47,7 @@ class __extend__(optimizer.OptValue): """New methods added to the base class OptValue for this file.""" -def getstrlen(self, optimization, mode): +def getstrlen(self, optimization, mode, lengthbox=None): if mode is mode_string: s = self.get_constant_string_spec(mode_string) if s is not None: @@ -60,7 +60,8 @@ return None self.ensure_nonnull() box = self.force_box() -lengthbox = BoxInt() +if not lengthbox: +lengthbox = BoxInt() optimization.emit_operation(ResOperation(mode.STRLEN, [box], lengthbox)) return lengthbox @@ -124,7 +125,7 @@ assert 0 <= start <= stop <= len(longerlist) self._chars = longerlist[start:stop] -def getstrlen(self, _, mode): +def getstrlen(self, _, mode, lengthbox=None): if self._lengthbox is None: self._lengthbox = ConstInt(len(self._chars)) return self._lengthbox @@ -185,7 +186,7 @@ self.left = left self.right = right -def getstrlen(self, optimizer, mode)
[pypy-commit] pypy default: Write the progbits section magic marker to make the stack non-executable under (at least) Gentoo linux. Thanks Amaury.
Author: Armin Rigo Branch: Changeset: r45663:eef75a4b072e Date: 2011-07-16 16:06 +0200 http://bitbucket.org/pypy/pypy/changeset/eef75a4b072e/ Log:Write the progbits section magic marker to make the stack non-executable under (at least) Gentoo linux. Thanks Amaury. diff --git a/pypy/translator/c/gcc/trackgcroot.py b/pypy/translator/c/gcc/trackgcroot.py --- a/pypy/translator/c/gcc/trackgcroot.py +++ b/pypy/translator/c/gcc/trackgcroot.py @@ -1824,6 +1824,11 @@ __gccallshapes: """.replace("__gccallshapes", _globalname("__gccallshapes")) output.writelines(shapelines) +print >> output, """\ +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif +""" def process(self, iterlines, newfile, filename='?'): parser = PARSERS[format](verbose=self.verbose, shuffle=self.shuffle) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix tests
Author: Maciej Fijalkowski Branch: Changeset: r45664:f12c4e733acd Date: 2011-07-16 10:00 +0200 http://bitbucket.org/pypy/pypy/changeset/f12c4e733acd/ Log:fix tests diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py --- a/pypy/module/micronumpy/compile.py +++ b/pypy/module/micronumpy/compile.py @@ -4,6 +4,7 @@ """ from pypy.module.micronumpy.interp_numarray import FloatWrapper, SingleDimArray +from pypy.rlib.objectmodel import specialize class BogusBytecode(Exception): pass @@ -15,8 +16,12 @@ return a class TrivialSpace(object): -def wrap(self, x): -return x +w_ValueError = None + +@specialize.argtype(1) +def wrap(self, w_obj): +return w_obj + def numpy_compile(bytecode, array_size): space = TrivialSpace() diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -7,6 +7,8 @@ from pypy.tool.sourcetools import func_with_new_name import math +INSERT_SORT_THRESH = 15 + def dummy1(v): assert isinstance(v, float) return v @@ -21,6 +23,8 @@ reds = ['result_size', 'i', 'self', 'result']) all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self']) any_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self']) +slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 'stop', 'self', 'arr']) +slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 'stop', 'self', 'arr']) class Signature(object): def __init__(self): @@ -88,6 +92,18 @@ signature = Signature() def impl(self, space, w_other): w_other = convert_to_array(space, w_other) +try: +w_other_size = w_other.find_size() +self_size = self.find_size() +except ValueError: +# this will be raised if one of the arrays is a scalar. +pass +else: +# Need a better dimension check here for N-dim arrays +if w_other_size != self_size: +raise OperationError(space.w_ValueError, +space.wrap("Cannot %s arrays of unequal dimensions" \ +% function.__name__)) new_sig = self.signature.transition(signature) res = Call2( function, @@ -111,7 +127,7 @@ signature = Signature() def impl(self, space, w_other): new_sig = self.signature.transition(signature) -w_other = FloatWrapper(space.float_w(w_other)) +w_other = convert_to_array(space, w_other) res = Call2( function, w_other, @@ -235,6 +251,80 @@ else: return self.descr_mul(space, w_other) +def _insertion_sort(self, storage, left, right): +i = left + 1 +while i <= right: +temp = storage[i] +j = i - 1 +while j >= left and storage[j] > temp: +storage[j + 1] = storage[j] +j -= 1 +storage[j + 1] = temp +i += 1 + +def descr_sort(self, space): +storage = self.get_concrete().storage +# can replace these with integer/bool numpy arrays when we add dtypes +lefts = [0] +rights = [self.find_size() - 1] +checkpivots = [False] +while lefts: +left = lefts.pop() +right = rights.pop() +checkpivot = checkpivots.pop() +# just use middle element for now. will change to med of 3 soon +mid = left + (right - left) / 2 +pivot = storage[mid] +if checkpivot and pivot == storage[left - 1]: +storage[mid], storage[left] = storage[left], storage[mid] +i = left + 1 +j = right +while 1: +while storage[j] != pivot: +j -= 1 +while storage[i] == pivot: +if i >= j: break +i += 1 +if i >= j: break +storage[i], storage[j] = storage[j], storage[i] +storage[j] = pivot +if right > j + 1: +if right - j + 1 < INSERT_SORT_THRESH: +self._insertion_sort(storage, j + 1, right) +else: +lefts.append(j + 1) +rights.append(right) +checkpivots.append(False) +else: +storage[mid], storage[right] = storage[right], storage[mid] +i = left +j = right - 1 +while 1: +while storage[i] < pivot: +i += 1 +
[pypy-commit] pypy default: Backed out changeset f12c4e733acd
Author: Maciej Fijalkowski Branch: Changeset: r45665:eaa6922449c1 Date: 2011-07-16 10:14 +0200 http://bitbucket.org/pypy/pypy/changeset/eaa6922449c1/ Log:Backed out changeset f12c4e733acd Ops, too much diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py --- a/pypy/module/micronumpy/compile.py +++ b/pypy/module/micronumpy/compile.py @@ -4,7 +4,6 @@ """ from pypy.module.micronumpy.interp_numarray import FloatWrapper, SingleDimArray -from pypy.rlib.objectmodel import specialize class BogusBytecode(Exception): pass @@ -16,12 +15,8 @@ return a class TrivialSpace(object): -w_ValueError = None - -@specialize.argtype(1) -def wrap(self, w_obj): -return w_obj - +def wrap(self, x): +return x def numpy_compile(bytecode, array_size): space = TrivialSpace() diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -7,8 +7,6 @@ from pypy.tool.sourcetools import func_with_new_name import math -INSERT_SORT_THRESH = 15 - def dummy1(v): assert isinstance(v, float) return v @@ -23,8 +21,6 @@ reds = ['result_size', 'i', 'self', 'result']) all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self']) any_driver = jit.JitDriver(greens=['signature'], reds=['i', 'size', 'self']) -slice_driver1 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 'stop', 'self', 'arr']) -slice_driver2 = jit.JitDriver(greens=['signature'], reds=['i', 'j', 'step', 'stop', 'self', 'arr']) class Signature(object): def __init__(self): @@ -92,18 +88,6 @@ signature = Signature() def impl(self, space, w_other): w_other = convert_to_array(space, w_other) -try: -w_other_size = w_other.find_size() -self_size = self.find_size() -except ValueError: -# this will be raised if one of the arrays is a scalar. -pass -else: -# Need a better dimension check here for N-dim arrays -if w_other_size != self_size: -raise OperationError(space.w_ValueError, -space.wrap("Cannot %s arrays of unequal dimensions" \ -% function.__name__)) new_sig = self.signature.transition(signature) res = Call2( function, @@ -127,7 +111,7 @@ signature = Signature() def impl(self, space, w_other): new_sig = self.signature.transition(signature) -w_other = convert_to_array(space, w_other) +w_other = FloatWrapper(space.float_w(w_other)) res = Call2( function, w_other, @@ -251,80 +235,6 @@ else: return self.descr_mul(space, w_other) -def _insertion_sort(self, storage, left, right): -i = left + 1 -while i <= right: -temp = storage[i] -j = i - 1 -while j >= left and storage[j] > temp: -storage[j + 1] = storage[j] -j -= 1 -storage[j + 1] = temp -i += 1 - -def descr_sort(self, space): -storage = self.get_concrete().storage -# can replace these with integer/bool numpy arrays when we add dtypes -lefts = [0] -rights = [self.find_size() - 1] -checkpivots = [False] -while lefts: -left = lefts.pop() -right = rights.pop() -checkpivot = checkpivots.pop() -# just use middle element for now. will change to med of 3 soon -mid = left + (right - left) / 2 -pivot = storage[mid] -if checkpivot and pivot == storage[left - 1]: -storage[mid], storage[left] = storage[left], storage[mid] -i = left + 1 -j = right -while 1: -while storage[j] != pivot: -j -= 1 -while storage[i] == pivot: -if i >= j: break -i += 1 -if i >= j: break -storage[i], storage[j] = storage[j], storage[i] -storage[j] = pivot -if right > j + 1: -if right - j + 1 < INSERT_SORT_THRESH: -self._insertion_sort(storage, j + 1, right) -else: -lefts.append(j + 1) -rights.append(right) -checkpivots.append(False) -else: -storage[mid], storage[right] = storage[right], storage[mid] -i = left -j = right - 1 -while 1: -while storage[i] < pivot: -
[pypy-commit] pypy default: fix tests
Author: Maciej Fijalkowski Branch: Changeset: r45666:a3c110ceadc2 Date: 2011-07-16 10:16 +0200 http://bitbucket.org/pypy/pypy/changeset/a3c110ceadc2/ Log:fix tests diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py --- a/pypy/tool/jitlogparser/parser.py +++ b/pypy/tool/jitlogparser/parser.py @@ -89,7 +89,7 @@ while asm[asm_index][0] < op.offset: asm_index += 1 end_index = asm_index -while asm[end_index][0] < end: +while asm[end_index][0] < end and end_index < len(asm) - 1: end_index += 1 op.asm = '\n'.join([asm[i][1] for i in range(asm_index, end_index)]) return loop diff --git a/pypy/tool/jitlogparser/test/logtest2.log b/pypy/tool/jitlogparser/test/logtest2.log new file mode 100644 --- /dev/null +++ b/pypy/tool/jitlogparser/test/logtest2.log @@ -0,0 +1,301 @@ +[1f5e7f69779] {jit-backend-dump +BACKEND x86_64 +SYS_EXECUTABLE python +CODE_DUMP @7f8907a0b000 +0 4157415641554154415341524151415057565554535251504889E349C7C340BC920041FFD34889DF4883E4F049C7C350BC920041FFD3488D65D8415F415E415D415C5B5DC3 +[1f5e7f7fe75] jit-backend-dump} +[1f5e7f84fc4] {jit-backend-dump +BACKEND x86_64 +SYS_EXECUTABLE python +CODE_DUMP @7f8907a0b045 +0 4157415641554154415341524151415057565554535251504889E349C7C3F0BB920041FFD34889DF4883E4F049C7C350BC920041FFD3488D65D8415F415E415D415C5B5DC3 +[1f5e7f87ac1] jit-backend-dump} +[1f5e7f8a0b4] {jit-backend-dump +BACKEND x86_64 +SYS_EXECUTABLE python +CODE_DUMP @7f8907a0b08a +0 4157415641554154415341524151415057565554535251504889E34881EC8000F20F110424F20F114C2408F20F11542410F20F115C2418F20F11642420F20F116C2428F20F11742430F20F117C2438F2440F11442440F2440F114C2448F2440F11542450F2440F115C2458F2440F11642460F2440F116C2468F2440F11742470F2440F117C247849C7C340BC920041FFD34889DF4883E4F049C7C350BC920041FFD3488D65D8415F415E415D415C5B5DC3 +[1f5e7f8da6b] jit-backend-dump} +[1f5e7f8f4f6] {jit-backend-dump +BACKEND x86_64 +SYS_EXECUTABLE python +CODE_DUMP @7f8907a0b13d +0 4157415641554154415341524151415057565554535251504889E34881EC8000F20F110424F20F114C2408F20F11542410F20F115C2418F20F11642420F20F116C2428F20F11742430F20F117C2438F2440F11442440F2440F114C2448F2440F11542450F2440F115C2458F2440F11642460F2440F116C2468F2440F11742470F2440F117C247849C7C3F0BB920041FFD34889DF4883E4F049C7C350BC920041FFD3488D65D8415F415E415D415C5B5DC3 +[1f5e7f92b83] jit-backend-dump} +[1f5e7f95b99] {jit-backend-dump +BACKEND x86_64 +SYS_EXECUTABLE python +CODE_DUMP @7f8907a0b210 +0 F20F11442410F20F114C2418F20F11542420F20F115C2428F20F11642430F20F116C2438F20F11742440F20F117C2448F2440F11442450F2440F114C2458F2440F11542460F2440F115C2468F2440F11642470F2440F116C2478F2440F11B4248000F2440F11BC2488004829C24889D749C7C350A8920041FFE3 +[1f5e7f988d0] jit-backend-dump} +[1f5e7fa16fb] {jit-backend-dump +BACKEND x86_64 +SYS_EXECUTABLE python +CODE_DUMP @7f8907a0b28e +0 F20F10442410F20F104C2418F20F10542420F20F105C2428F20F10642430F20F106C2438F20F10742440F20F107C2448F2440F10442450F2440F104C2458F2440F10542460F2440F105C2468F2440F10642470F2440F106C2478F2440F10B4248000F2440F10BC248800488B1425704F3D01C3 +[1f5e7fa47ac] jit-backend-dump} +[1f5e7fab3a4] {jit-backend-dump +BACKEND x86_64 +SYS_EXECUTABLE python +CODE_DUMP @7f8907a0b305 +0 57565251415041514883EC40F20F110424F20F114C2408F20F11542410F20F115C2418F20F11642420F20F116C2428F20F11742430F20F117C2438488D7D1049C7C340BA520041FFD3488B042550546B024885C0753CF20F107C2438F20F10742430F20F106C2428F20F10642420F20F105C2418F20F10542410F20F104C2408F20F1004244883C44041594158595A5E5FC3488B042558546B0248C7042550546B0248C7042558546B024889042590C2540149C7C340BC920041FFD348C7C002004883C478C3 +[1f5e7faf1ca] jit-backend-dump} +[1f5e7fb0813] {jit-backend-counts +[1f5e7fb0f61] jit-backend-counts} +[1f5fd38be3e] {jit-backend +[1f5fe729336] {jit-backend-dump +BACKEND x86_64 +SYS_EXECUTABLE python +CODE_DUMP @7f8907a0b3d5 +0 554889E5534154415541564157488DA5488B042590C2540148C7042590C2540148898570FF488B042598C2540148C7042598C2540148898568FF488B0425A0C2540148C70425A0C2540148898560FF488B0425A8C2540148C70425A8C2540148898558FF4C8B3C25D04D5B0149BB30B00C0A897F4D8B334983C60149BB30B00C0A897F4D89334981FF10270F8D4D89FE4983E7024983FF000F854983C6034C8B3C25A0536B024983EF014C893C25A0536B024983FF000F8C4D89F7E99AFF488B0425A8536B024829E0483B042580DC3C01760D49BB05B3A007897F41FFD3554889E5534154415541564157488DA550FF4889BD70FF4889B568FF48899560FF48898D58FF4D89C7E940FF49BB00B0A007897F41FFD34440484C3D03030049BB00B0A007897F41FFD34440484C3D3903040049BB00B0A007897F41FFD34440484C390707030500 +[1f5fe73276a] jit-backend-dump} +[1f5fe73438f] {jit-backend-addr +Loop 0 ( #9 LOAD_FAST) has address 7f8907a0b45d to 7f8907a0b4c3 (bootstrap 7f8907a0b3d5) +[1f5fe7369af] jit