[pypy-commit] pypy default: fix tests
Author: Maciej Fijalkowski Branch: Changeset: r44227:46e0c62dd02e Date: 2011-05-17 09:23 +0200 http://bitbucket.org/pypy/pypy/changeset/46e0c62dd02e/ Log:fix tests diff --git a/pypy/jit/metainterp/test/test_optimizeutil.py b/pypy/jit/metainterp/test/test_optimizeutil.py --- a/pypy/jit/metainterp/test/test_optimizeutil.py +++ b/pypy/jit/metainterp/test/test_optimizeutil.py @@ -133,7 +133,8 @@ EffectInfo([adescr], [], [])) mayforcevirtdescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT, EffectInfo([nextdescr], [], [], -EffectInfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE)) +EffectInfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE, +can_invalidate=True)) arraycopydescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT, EffectInfo([], [], [], oopspecindex=EffectInfo.OS_ARRAYCOPY)) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: a "typo"
Author: Maciej Fijalkowski Branch: Changeset: r44228:cc96d750090a Date: 2011-05-17 09:36 +0200 http://bitbucket.org/pypy/pypy/changeset/cc96d750090a/ Log:a "typo" diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py --- a/pypy/rlib/jit.py +++ b/pypy/rlib/jit.py @@ -258,7 +258,7 @@ vref_None = non_virtual_ref(None) # -# User interface for the hotpath JIT policy +# User interface for the warmspot JIT policy class JitHintError(Exception): """Inconsistency in the JIT hints.""" ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix the test, now that we switched to frozenlist
Author: Antonio Cuni Branch: Changeset: r44229:4984eac57425 Date: 2011-05-17 10:10 +0200 http://bitbucket.org/pypy/pypy/changeset/4984eac57425/ Log:fix the test, now that we switched to frozenlist diff --git a/pypy/jit/metainterp/test/test_resoperation.py b/pypy/jit/metainterp/test/test_resoperation.py --- a/pypy/jit/metainterp/test/test_resoperation.py +++ b/pypy/jit/metainterp/test/test_resoperation.py @@ -72,7 +72,7 @@ def test_get_deep_immutable_oplist(): ops = [rop.ResOperation(rop.rop.INT_ADD, ['a', 'b'], 'c')] newops = rop.get_deep_immutable_oplist(ops) -py.test.raises(AttributeError, "newops.append('foobar')") +py.test.raises(TypeError, "newops.append('foobar')") py.test.raises(TypeError, "newops[0] = 'foobar'") py.test.raises(AssertionError, "newops[0].setarg(0, 'd')") py.test.raises(AssertionError, "newops[0].setdescr('foobar')") ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy jitypes2: kill this leftover of a merge
Author: Antonio Cuni Branch: jitypes2 Changeset: r44230:422d0cda79cc Date: 2011-05-17 10:18 +0200 http://bitbucket.org/pypy/pypy/changeset/422d0cda79cc/ Log:kill this leftover of a merge diff --git a/pypy/module/pypyjit/test/test_pypy_c.py b/pypy/module/pypyjit/test/test_pypy_c.py --- a/pypy/module/pypyjit/test/test_pypy_c.py +++ b/pypy/module/pypyjit/test/test_pypy_c.py @@ -247,7 +247,6 @@ return total ''' % startvalue, 170, ([], startvalue + 499945L)) -<<< local def test_boolrewrite_invers(self): for a, b, res, ops in (('2000', '2000', 20001000, 51), ( '500', '500', 15001500, 81), ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Wrote a new test for mix of old and new style classes. Note that this is
Author: Maciej Fijalkowski Branch: Changeset: r44231:4ba3c304d4bd Date: 2011-05-17 11:57 +0200 http://bitbucket.org/pypy/pypy/changeset/4ba3c304d4bd/ Log:Wrote a new test for mix of old and new style classes. Note that this is much worse than old-style classes alone (2 dict lookups), but unsure if anything can be done short of enabling version tags on such mixtures. diff --git a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py --- a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py +++ b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py @@ -1676,3 +1676,36 @@ loop, = log.loops_by_filename(self.filepath) import pdb;pdb.set_trace() assert loop.match_by_id('div', "") # optimized away + +def test_oldstyle_newstyle_mix(self): +def main(): +class A: +pass + +class B(object, A): +def __init__(self, x): +self.x = x + +i = 0 +b = B(1) +while i < 100: +v = b.x # ID: loadattr +i += v +return i + +log = self.run(main, [], threshold=80) +loop, = log.loops_by_filename(self.filepath) +loop.match_by_id('loadattr', +''' +guard_not_invalidated(descr=...) +i19 = call(ConstClass(ll_dict_lookup), _, _, _, descr=...) +guard_no_exception(descr=...) +i21 = int_and(i19, _) +i22 = int_is_true(i21) +guard_true(i22, descr=...) +i26 = call(ConstClass(ll_dict_lookup), _, _, _, descr=...) +guard_no_exception(descr=...) +i28 = int_and(i26, _) +i29 = int_is_true(i28) +guard_true(i29, descr=...) +''') ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge heads
Author: Maciej Fijalkowski Branch: Changeset: r44232:9de1975e5281 Date: 2011-05-17 11:59 +0200 http://bitbucket.org/pypy/pypy/changeset/9de1975e5281/ Log:merge heads diff --git a/pypy/jit/metainterp/test/test_resoperation.py b/pypy/jit/metainterp/test/test_resoperation.py --- a/pypy/jit/metainterp/test/test_resoperation.py +++ b/pypy/jit/metainterp/test/test_resoperation.py @@ -72,7 +72,7 @@ def test_get_deep_immutable_oplist(): ops = [rop.ResOperation(rop.rop.INT_ADD, ['a', 'b'], 'c')] newops = rop.get_deep_immutable_oplist(ops) -py.test.raises(AttributeError, "newops.append('foobar')") +py.test.raises(TypeError, "newops.append('foobar')") py.test.raises(TypeError, "newops[0] = 'foobar'") py.test.raises(AssertionError, "newops[0].setarg(0, 'd')") py.test.raises(AssertionError, "newops[0].setdescr('foobar')") ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (cfbolz, arigo)
Author: Armin Rigo Branch: Changeset: r44235:8624cde59095 Date: 2011-05-17 12:57 +0200 http://bitbucket.org/pypy/pypy/changeset/8624cde59095/ Log:(cfbolz, arigo) Decided that this code is too brittle. We found two kinds of bugs in it: bugs that were already there, and bugs that arose because of TypeCells. * for the 1st kind of bug: just because the map of an object doesn't change does not mean that getdictvalue() returns from the same spot (case of DevolvedDictTerminator); and in that case, getdictvalue() can actually have random side-effects like changing version_tag. * for the 2nd kind of bug: the point is that w_type.lookup() can now return a different result without the version_tag changing. diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py --- a/pypy/interpreter/pycode.py +++ b/pypy/interpreter/pycode.py @@ -116,10 +116,6 @@ self._compute_flatcall() -if self.space.config.objspace.std.withmapdict: -from pypy.objspace.std.mapdict import init_mapdict_cache -init_mapdict_cache(self) - def _freeze_(self): if (self.magic == cpython_magic and '__pypy__' not in sys.builtin_module_names): diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -723,13 +723,8 @@ def LOAD_ATTR(self, nameindex, next_instr): "obj.attributename" w_obj = self.popvalue() -if (self.space.config.objspace.std.withmapdict -and not jit.we_are_jitted()): -from pypy.objspace.std.mapdict import LOAD_ATTR_caching -w_value = LOAD_ATTR_caching(self.getcode(), w_obj, nameindex) -else: -w_attributename = self.getname_w(nameindex) -w_value = self.space.getattr(w_obj, w_attributename) +w_attributename = self.getname_w(nameindex) +w_value = self.space.getattr(w_obj, w_attributename) self.pushvalue(w_value) LOAD_ATTR._always_inline_ = True diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py --- a/pypy/objspace/std/callmethod.py +++ b/pypy/objspace/std/callmethod.py @@ -13,8 +13,6 @@ from pypy.interpreter import function from pypy.objspace.descroperation import object_getattribute from pypy.rlib import jit, rstack # for resume points -from pypy.objspace.std.mapdict import LOOKUP_METHOD_mapdict, \ -LOOKUP_METHOD_mapdict_fill_cache_method # This module exports two extra methods for StdObjSpaceFrame implementing @@ -33,13 +31,6 @@ # space = f.space w_obj = f.popvalue() - -if space.config.objspace.std.withmapdict and not jit.we_are_jitted(): -# mapdict has an extra-fast version of this function -from pypy.objspace.std.mapdict import LOOKUP_METHOD_mapdict -if LOOKUP_METHOD_mapdict(f, nameindex, w_obj): -return - w_name = f.getname_w(nameindex) w_value = None @@ -60,11 +51,6 @@ # nothing in the instance f.pushvalue(w_descr) f.pushvalue(w_obj) -if (space.config.objspace.std.withmapdict and -not jit.we_are_jitted()): -# let mapdict cache stuff -LOOKUP_METHOD_mapdict_fill_cache_method( -f.getcode(), nameindex, w_obj, w_type, w_descr) return if w_value is None: w_value = space.getattr(w_obj, w_name) diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py --- a/pypy/objspace/std/mapdict.py +++ b/pypy/objspace/std/mapdict.py @@ -683,118 +683,3 @@ w_attr = self.space.wrap(attr) return w_attr, self.w_obj.getdictvalue(self.space, attr) return None, None - -# -# Magic caching - -class CacheEntry(object): -version_tag = None -index = 0 -w_method = None # for callmethod -success_counter = 0 -failure_counter = 0 - -def is_valid_for_obj(self, w_obj): -map = w_obj._get_mapdict_map() -return self.is_valid_for_map(map) - -@jit.dont_look_inside -def is_valid_for_map(self, map): -# note that 'map' can be None here -mymap = self.map_wref() -if mymap is not None and mymap is map: -version_tag = map.terminator.w_cls.version_tag() -if version_tag is self.version_tag: -# everything matches, it's incredibly fast -if map.space.config.objspace.std.withmethodcachecounter: -self.success_counter += 1 -return True -return False - -_invalid_cache_entry_map = objectmodel.instantiate(AbstractAttribute) -_invalid_cache_entry_map.terminator = None -INVALID_CACHE_ENTRY = CacheEntry() -INVALID_CACH
[pypy-commit] pypy default: merge heads
Author: Armin Rigo Branch: Changeset: r44236:486804f86247 Date: 2011-05-17 12:58 +0200 http://bitbucket.org/pypy/pypy/changeset/486804f86247/ Log:merge heads diff --git a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py --- a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py +++ b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py @@ -1676,3 +1676,36 @@ loop, = log.loops_by_filename(self.filepath) import pdb;pdb.set_trace() assert loop.match_by_id('div', "") # optimized away + +def test_oldstyle_newstyle_mix(self): +def main(): +class A: +pass + +class B(object, A): +def __init__(self, x): +self.x = x + +i = 0 +b = B(1) +while i < 100: +v = b.x # ID: loadattr +i += v +return i + +log = self.run(main, [], threshold=80) +loop, = log.loops_by_filename(self.filepath) +loop.match_by_id('loadattr', +''' +guard_not_invalidated(descr=...) +i19 = call(ConstClass(ll_dict_lookup), _, _, _, descr=...) +guard_no_exception(descr=...) +i21 = int_and(i19, _) +i22 = int_is_true(i21) +guard_true(i22, descr=...) +i26 = call(ConstClass(ll_dict_lookup), _, _, _, descr=...) +guard_no_exception(descr=...) +i28 = int_and(i26, _) +i29 = int_is_true(i28) +guard_true(i29, descr=...) +''') ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (cfbolz, arigo) Fix.
Author: Armin Rigo Branch: Changeset: r44234:78fefaebb1b3 Date: 2011-05-17 11:38 +0200 http://bitbucket.org/pypy/pypy/changeset/78fefaebb1b3/ Log:(cfbolz, arigo) Fix. diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py --- a/pypy/objspace/std/mapdict.py +++ b/pypy/objspace/std/mapdict.py @@ -769,6 +769,8 @@ if selector[1] != INVALID: index = map.index(selector) if index >= 0: +# note that if map.terminator is a DevolvedDictTerminator, +# map.index() will always return -1 if selector[1]==DICT _fill_cache(pycode, nameindex, map, version_tag, index) return w_obj._mapdict_read_storage(index) if space.config.objspace.std.withmethodcachecounter: @@ -793,6 +795,6 @@ if version_tag is None: return map = w_obj._get_mapdict_map() -if map is None: +if map is None or isinstance(map.terminator, DevolvedDictTerminator): return _fill_cache(pycode, nameindex, map, version_tag, -1, w_method) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (cfbolz, arigo)
Author: Armin Rigo Branch: Changeset: r44233:0605b7aa9005 Date: 2011-05-17 11:31 +0200 http://bitbucket.org/pypy/pypy/changeset/0605b7aa9005/ Log:(cfbolz, arigo) Found bug B while looking for bug A in mapdict :-( diff --git a/pypy/objspace/std/test/test_mapdict.py b/pypy/objspace/std/test/test_mapdict.py --- a/pypy/objspace/std/test/test_mapdict.py +++ b/pypy/objspace/std/test/test_mapdict.py @@ -902,7 +902,19 @@ return c.m() val = f() assert val == 42 -f() +f() + +def test_bug_lookup_method_devolved_dict_caching(self): +class A(object): +def method(self): +return 42 +a = A() +a.__dict__[1] = 'foo' +got = a.method() +assert got == 42 +a.__dict__['method'] = lambda: 43 +got = a.method() +assert got == 43 class AppTestGlobalCaching(AppTestWithMapDict): def setup_class(cls): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (fijal, agaynor, tons of other people) merge numpy-exp.
Author: Maciej Fijalkowski Branch: Changeset: r44237:335d1f0d4d8f Date: 2011-05-17 13:37 +0200 http://bitbucket.org/pypy/pypy/changeset/335d1f0d4d8f/ Log:(fijal, agaynor, tons of other people) merge numpy-exp. This brings a start to numpy module being developed on trunk (and enabled by default) with JIT support. diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py --- a/pypy/config/pypyoption.py +++ b/pypy/config/pypyoption.py @@ -33,7 +33,7 @@ "struct", "_hashlib", "_md5", "_sha", "_minimal_curses", "cStringIO", "thread", "itertools", "pyexpat", "_ssl", "cpyext", "array", "_bisect", "binascii", "_multiprocessing", '_warnings', - "_collections", "_multibytecodec"] + "_collections", "_multibytecodec", 'micronumpy'] )) translation_modules = default_modules.copy() diff --git a/pypy/conftest.py b/pypy/conftest.py --- a/pypy/conftest.py +++ b/pypy/conftest.py @@ -46,6 +46,10 @@ group.addoption('-P', '--platform', action="callback", type="string", default="host", callback=_set_platform, help="set up tests to use specified platform as compile/run target") +group = parser.getgroup("JIT options") +group.addoption('--viewloops', action="store_true", + default=False, dest="viewloops", + help="show only the compiled loops") def pytest_sessionstart(): # have python subprocesses avoid startup customizations by default diff --git a/pypy/jit/backend/llgraph/runner.py b/pypy/jit/backend/llgraph/runner.py --- a/pypy/jit/backend/llgraph/runner.py +++ b/pypy/jit/backend/llgraph/runner.py @@ -209,7 +209,7 @@ llimpl.compile_add_fail_arg(c, var2index[box]) else: llimpl.compile_add_fail_arg(c, -1) - + x = op.result if x is not None: if isinstance(x, history.BoxInt): diff --git a/pypy/jit/backend/x86/regalloc.py b/pypy/jit/backend/x86/regalloc.py --- a/pypy/jit/backend/x86/regalloc.py +++ b/pypy/jit/backend/x86/regalloc.py @@ -330,7 +330,7 @@ if not we_are_translated(): self.assembler.dump('%s <- %s(%s)' % (result_loc, op, arglocs)) self.assembler.regalloc_perform_llong(op, arglocs, result_loc) - + def PerformMath(self, op, arglocs, result_loc): if not we_are_translated(): self.assembler.dump('%s <- %s(%s)' % (result_loc, op, arglocs)) @@ -676,7 +676,7 @@ loc0 = self.xrm.force_result_in_reg(op.result, op.getarg(0)) self.Perform(op, [loc0], loc0) self.xrm.possibly_free_var(op.getarg(0)) - + consider_float_neg = _consider_float_unary_op consider_float_abs = _consider_float_unary_op @@ -764,7 +764,7 @@ loc1 = self.rm.make_sure_var_in_reg(op.getarg(1)) self.PerformLLong(op, [loc1], loc0) self.rm.possibly_free_vars_for_op(op) - + def _consider_math_sqrt(self, op): loc0 = self.xrm.force_result_in_reg(op.result, op.getarg(1)) self.PerformMath(op, [loc0], loc0) @@ -1271,12 +1271,12 @@ xmmtmploc = self.xrm.force_allocate_reg(box1, selected_reg=xmmtmp) # Part about non-floats # XXX we don't need a copy, we only just the original list -src_locations1 = [self.loc(op.getarg(i)) for i in range(op.numargs()) +src_locations1 = [self.loc(op.getarg(i)) for i in range(op.numargs()) if op.getarg(i).type != FLOAT] assert tmploc not in nonfloatlocs dst_locations1 = [loc for loc in nonfloatlocs if loc is not None] # Part about floats -src_locations2 = [self.loc(op.getarg(i)) for i in range(op.numargs()) +src_locations2 = [self.loc(op.getarg(i)) for i in range(op.numargs()) if op.getarg(i).type == FLOAT] dst_locations2 = [loc for loc in floatlocs if loc is not None] remap_frame_layout_mixed(assembler, diff --git a/pypy/jit/backend/x86/regloc.py b/pypy/jit/backend/x86/regloc.py --- a/pypy/jit/backend/x86/regloc.py +++ b/pypy/jit/backend/x86/regloc.py @@ -508,7 +508,9 @@ LEA = _binaryop('LEA') MOVSD = _binaryop('MOVSD') +MOVAPD = _binaryop('MOVAPD') ADDSD = _binaryop('ADDSD') +ADDPD = _binaryop('ADDPD') SUBSD = _binaryop('SUBSD') MULSD = _binaryop('MULSD') DIVSD = _binaryop('DIVSD') diff --git a/pypy/jit/backend/x86/rx86.py b/pypy/jit/backend/x86/rx86.py --- a/pypy/jit/backend/x86/rx86.py +++ b/pypy/jit/backend/x86/rx86.py @@ -690,12 +690,17 @@ define_modrm_modes('MOVSD_x*', ['\xF2', rex_nw, '\x0F\x10', register(1,8)], regtype='XMM') define_modrm_modes('MOVSD_*x', ['\xF2', rex_nw, '\x0F\x11', register(2,8)], regtype='XMM') +define_modrm_modes('MOVAPD_x*', ['\x66', rex_nw, '\x0F\x28', register(1,8)], + regtype='XMM') +define_modrm_modes('MOVAPD_*x', ['\x66', rex_nw, '\x0F\x29', register(2,8)], +
[pypy-commit] pypy numpy-exp: Close merged branch
Author: Maciej Fijalkowski Branch: numpy-exp Changeset: r44238:dd3bcd84b145 Date: 2011-05-17 13:38 +0200 http://bitbucket.org/pypy/pypy/changeset/dd3bcd84b145/ Log:Close merged branch ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: a no-op to reduce number of dangling heads
Author: Maciej Fijalkowski Branch: Changeset: r44239:f1fae29c1769 Date: 2011-05-17 13:51 +0200 http://bitbucket.org/pypy/pypy/changeset/f1fae29c1769/ Log:a no-op to reduce number of dangling heads ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: remove long-dead code
Author: Maciej Fijalkowski Branch: Changeset: r44240:37b48a86e06c Date: 2011-05-17 15:43 +0200 http://bitbucket.org/pypy/pypy/changeset/37b48a86e06c/ Log:remove long-dead code diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py --- a/pypy/module/pypyjit/interp_jit.py +++ b/pypy/module/pypyjit/interp_jit.py @@ -49,14 +49,6 @@ greens = ['next_instr', 'is_being_profiled', 'pycode'] virtualizables = ['frame'] -##def compute_invariants(self, reds, next_instr, pycode): -### compute the information that really only depends on next_instr -### and pycode -##frame = reds.frame -##valuestackdepth = frame.valuestackdepth -##blockstack = frame.blockstack -##return (valuestackdepth, blockstack) - pypyjitdriver = PyPyJitDriver(get_printable_location = get_printable_location, get_jitcell_at = get_jitcell_at, set_jitcell_at = set_jitcell_at, ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: remove yet another dead commented-out code
Author: Maciej Fijalkowski Branch: Changeset: r44241:c187ff03cd45 Date: 2011-05-17 15:46 +0200 http://bitbucket.org/pypy/pypy/changeset/c187ff03cd45/ Log:remove yet another dead commented-out code diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py --- a/pypy/rlib/jit.py +++ b/pypy/rlib/jit.py @@ -477,8 +477,6 @@ r_green = hop.args_r[i] v_green = hop.inputarg(r_green, arg=i) else: -#if hop.rtyper.type_system.name == 'ootypesystem': -#py.test.skip("lltype only") objname, fieldname = name.split('.') # see test_green_field assert objname in driver.reds i = kwds_i['i_' + objname] ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: No-op cleanup.
Author: Armin Rigo Branch: Changeset: r44242:c65d9223f6ec Date: 2011-05-17 15:16 +0200 http://bitbucket.org/pypy/pypy/changeset/c65d9223f6ec/ Log:No-op cleanup. diff --git a/pypy/translator/c/funcgen.py b/pypy/translator/c/funcgen.py --- a/pypy/translator/c/funcgen.py +++ b/pypy/translator/c/funcgen.py @@ -705,7 +705,7 @@ offset = self.expr(op.args[2]) value = self.expr(op.args[3]) typename = cdecl(self.db.gettype(TYPE).replace('@', '*@'), '') -return "*(((%(typename)s) %(addr)s ) + %(offset)s) = %(value)s;" % locals() +return "((%(typename)s) %(addr)s)[%(offset)s] = %(value)s;" % locals() def OP_RAW_LOAD(self, op): addr = self.expr(op.args[0]) @@ -713,7 +713,7 @@ offset = self.expr(op.args[2]) result = self.expr(op.result) typename = cdecl(self.db.gettype(TYPE).replace('@', '*@'), '') -return "%(result)s = *(((%(typename)s) %(addr)s ) + %(offset)s);" % locals() +return "%(result)s = ((%(typename)s) %(addr)s)[%(offset)s];" % locals() def OP_CAST_PRIMITIVE(self, op): TYPE = self.lltypemap(op.result) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy mapdict-interp: A branch in which to re-introduce the fast paths killed in
Author: Armin Rigo Branch: mapdict-interp Changeset: r44243:e778e215e313 Date: 2011-05-17 15:18 +0200 http://bitbucket.org/pypy/pypy/changeset/e778e215e313/ Log:A branch in which to re-introduce the fast paths killed in 8624cde59095, to avoid slowing down interpreted execution too much. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy mapdict-interp: hg backout 8624cde59095
Author: Armin Rigo Branch: mapdict-interp Changeset: r44244:6cd3180f036e Date: 2011-05-17 15:18 +0200 http://bitbucket.org/pypy/pypy/changeset/6cd3180f036e/ Log:hg backout 8624cde59095 diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py --- a/pypy/interpreter/pycode.py +++ b/pypy/interpreter/pycode.py @@ -116,6 +116,10 @@ self._compute_flatcall() +if self.space.config.objspace.std.withmapdict: +from pypy.objspace.std.mapdict import init_mapdict_cache +init_mapdict_cache(self) + def _freeze_(self): if (self.magic == cpython_magic and '__pypy__' not in sys.builtin_module_names): diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -723,8 +723,13 @@ def LOAD_ATTR(self, nameindex, next_instr): "obj.attributename" w_obj = self.popvalue() -w_attributename = self.getname_w(nameindex) -w_value = self.space.getattr(w_obj, w_attributename) +if (self.space.config.objspace.std.withmapdict +and not jit.we_are_jitted()): +from pypy.objspace.std.mapdict import LOAD_ATTR_caching +w_value = LOAD_ATTR_caching(self.getcode(), w_obj, nameindex) +else: +w_attributename = self.getname_w(nameindex) +w_value = self.space.getattr(w_obj, w_attributename) self.pushvalue(w_value) LOAD_ATTR._always_inline_ = True diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py --- a/pypy/objspace/std/callmethod.py +++ b/pypy/objspace/std/callmethod.py @@ -13,6 +13,8 @@ from pypy.interpreter import function from pypy.objspace.descroperation import object_getattribute from pypy.rlib import jit, rstack # for resume points +from pypy.objspace.std.mapdict import LOOKUP_METHOD_mapdict, \ +LOOKUP_METHOD_mapdict_fill_cache_method # This module exports two extra methods for StdObjSpaceFrame implementing @@ -31,6 +33,13 @@ # space = f.space w_obj = f.popvalue() + +if space.config.objspace.std.withmapdict and not jit.we_are_jitted(): +# mapdict has an extra-fast version of this function +from pypy.objspace.std.mapdict import LOOKUP_METHOD_mapdict +if LOOKUP_METHOD_mapdict(f, nameindex, w_obj): +return + w_name = f.getname_w(nameindex) w_value = None @@ -51,6 +60,11 @@ # nothing in the instance f.pushvalue(w_descr) f.pushvalue(w_obj) +if (space.config.objspace.std.withmapdict and +not jit.we_are_jitted()): +# let mapdict cache stuff +LOOKUP_METHOD_mapdict_fill_cache_method( +f.getcode(), nameindex, w_obj, w_type, w_descr) return if w_value is None: w_value = space.getattr(w_obj, w_name) diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py --- a/pypy/objspace/std/mapdict.py +++ b/pypy/objspace/std/mapdict.py @@ -683,3 +683,118 @@ w_attr = self.space.wrap(attr) return w_attr, self.w_obj.getdictvalue(self.space, attr) return None, None + +# +# Magic caching + +class CacheEntry(object): +version_tag = None +index = 0 +w_method = None # for callmethod +success_counter = 0 +failure_counter = 0 + +def is_valid_for_obj(self, w_obj): +map = w_obj._get_mapdict_map() +return self.is_valid_for_map(map) + +@jit.dont_look_inside +def is_valid_for_map(self, map): +# note that 'map' can be None here +mymap = self.map_wref() +if mymap is not None and mymap is map: +version_tag = map.terminator.w_cls.version_tag() +if version_tag is self.version_tag: +# everything matches, it's incredibly fast +if map.space.config.objspace.std.withmethodcachecounter: +self.success_counter += 1 +return True +return False + +_invalid_cache_entry_map = objectmodel.instantiate(AbstractAttribute) +_invalid_cache_entry_map.terminator = None +INVALID_CACHE_ENTRY = CacheEntry() +INVALID_CACHE_ENTRY.map_wref = weakref.ref(_invalid_cache_entry_map) + # different from any real map ^^^ + +def init_mapdict_cache(pycode): +num_entries = len(pycode.co_names_w) +pycode._mapdict_caches = [INVALID_CACHE_ENTRY] * num_entries + +@jit.dont_look_inside +def _fill_cache(pycode, nameindex, map, version_tag, index, w_method=None): +entry = pycode._mapdict_caches[nameindex] +if entry is INVALID_CACHE_ENTRY: +entry = CacheEntry() +pycode._mapdict_caches[nameindex] = entry +entry.map_wref = weakref.ref(map) +entry.version_ta
[pypy-commit] pypy mapdict-interp: A bug.
Author: Armin Rigo Branch: mapdict-interp Changeset: r44245:c8ef5a8e3000 Date: 2011-05-17 15:31 +0200 http://bitbucket.org/pypy/pypy/changeset/c8ef5a8e3000/ Log:A bug. diff --git a/pypy/objspace/std/test/test_mapdict.py b/pypy/objspace/std/test/test_mapdict.py --- a/pypy/objspace/std/test/test_mapdict.py +++ b/pypy/objspace/std/test/test_mapdict.py @@ -916,6 +916,20 @@ got = a.method() assert got == 43 +def test_bug_method_change(self): +class A(object): +def method(self): +return 42 +a = A() +got = a.method() +assert got == 42 +A.method = lambda self: 43 +got = a.method() +assert got == 43 +A.method = lambda self: 44 +got = a.method() +assert got == 44 + class AppTestGlobalCaching(AppTestWithMapDict): def setup_class(cls): cls.space = gettestobjspace( ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy mapdict-interp: Trying to fix the bug.
Author: Armin Rigo Branch: mapdict-interp Changeset: r44246:59519f8875b6 Date: 2011-05-17 15:38 +0200 http://bitbucket.org/pypy/pypy/changeset/59519f8875b6/ Log:Trying to fix the bug. diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py --- a/pypy/config/pypyoption.py +++ b/pypy/config/pypyoption.py @@ -269,7 +269,7 @@ "make instances really small but slow without the JIT", default=False, requires=[("objspace.std.getattributeshortcut", True), - ("objspace.std.withtypeversion", True), + ("objspace.std.withmethodcache", True), ]), BoolOption("withrangelist", diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py --- a/pypy/objspace/std/callmethod.py +++ b/pypy/objspace/std/callmethod.py @@ -64,7 +64,7 @@ not jit.we_are_jitted()): # let mapdict cache stuff LOOKUP_METHOD_mapdict_fill_cache_method( -f.getcode(), nameindex, w_obj, w_type, w_descr) +space, f.getcode(), name, nameindex, w_obj, w_type) return if w_value is None: w_value = space.getattr(w_obj, w_name) diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py --- a/pypy/objspace/std/mapdict.py +++ b/pypy/objspace/std/mapdict.py @@ -8,6 +8,7 @@ from pypy.objspace.std.dictmultiobject import IteratorImplementation from pypy.objspace.std.dictmultiobject import _is_sane_hash from pypy.objspace.std.objectobject import W_ObjectObject +from pypy.objspace.std.typeobject import TypeCell # # attribute shapes @@ -790,11 +791,17 @@ return True return False -def LOOKUP_METHOD_mapdict_fill_cache_method(pycode, nameindex, w_obj, w_type, w_method): +def LOOKUP_METHOD_mapdict_fill_cache_method(space, pycode, name, nameindex, +w_obj, w_type): version_tag = w_type.version_tag() if version_tag is None: return map = w_obj._get_mapdict_map() if map is None or isinstance(map.terminator, DevolvedDictTerminator): return +assert space.config.objspace.std.withmethodcache +_, w_method = w_type._pure_lookup_where_with_method_cache(name, + version_tag) +if w_method is None or isinstance(w_method, TypeCell): +return _fill_cache(pycode, nameindex, map, version_tag, -1, w_method) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge heads
Author: Armin Rigo Branch: Changeset: r44248:c2ef69b1dd56 Date: 2011-05-17 15:55 +0200 http://bitbucket.org/pypy/pypy/changeset/c2ef69b1dd56/ Log:merge heads diff --git a/pypy/translator/c/funcgen.py b/pypy/translator/c/funcgen.py --- a/pypy/translator/c/funcgen.py +++ b/pypy/translator/c/funcgen.py @@ -705,7 +705,7 @@ offset = self.expr(op.args[2]) value = self.expr(op.args[3]) typename = cdecl(self.db.gettype(TYPE).replace('@', '*@'), '') -return "*(((%(typename)s) %(addr)s ) + %(offset)s) = %(value)s;" % locals() +return "((%(typename)s) %(addr)s)[%(offset)s] = %(value)s;" % locals() def OP_RAW_LOAD(self, op): addr = self.expr(op.args[0]) @@ -713,7 +713,7 @@ offset = self.expr(op.args[2]) result = self.expr(op.result) typename = cdecl(self.db.gettype(TYPE).replace('@', '*@'), '') -return "%(result)s = *(((%(typename)s) %(addr)s ) + %(offset)s);" % locals() +return "%(result)s = ((%(typename)s) %(addr)s)[%(offset)s];" % locals() def OP_CAST_PRIMITIVE(self, op): TYPE = self.lltypemap(op.result) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Bug and fix.
Author: Armin Rigo Branch: Changeset: r44249:79205a147ee3 Date: 2011-05-17 15:59 +0200 http://bitbucket.org/pypy/pypy/changeset/79205a147ee3/ Log:Bug and fix. diff --git a/pypy/objspace/std/inttype.py b/pypy/objspace/std/inttype.py --- a/pypy/objspace/std/inttype.py +++ b/pypy/objspace/std/inttype.py @@ -179,7 +179,7 @@ return space.wrap(1) def descr_get_real(space, w_obj): -return w_obj +return space.int(w_obj) def descr_get_imag(space, w_obj): return space.wrap(0) diff --git a/pypy/objspace/std/test/test_intobject.py b/pypy/objspace/std/test/test_intobject.py --- a/pypy/objspace/std/test/test_intobject.py +++ b/pypy/objspace/std/test/test_intobject.py @@ -480,6 +480,11 @@ ]: assert val.bit_length() == bits +def test_int_real(self): +class A(int): pass +b = A(5).real +assert type(b) is int + class AppTestIntOptimizedAdd(AppTestInt): def setup_class(cls): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Same issue with subclasses of 'long' or 'float'.
Author: Armin Rigo Branch: Changeset: r44250:f06654c419a4 Date: 2011-05-17 16:03 +0200 http://bitbucket.org/pypy/pypy/changeset/f06654c419a4/ Log:Same issue with subclasses of 'long' or 'float'. diff --git a/pypy/objspace/std/floattype.py b/pypy/objspace/std/floattype.py --- a/pypy/objspace/std/floattype.py +++ b/pypy/objspace/std/floattype.py @@ -264,7 +264,7 @@ return space.call_function(w_cls, w_float) def descr_get_real(space, w_obj): -return w_obj +return space.float(w_obj) def descr_get_imag(space, w_obj): return space.wrap(0.0) diff --git a/pypy/objspace/std/longtype.py b/pypy/objspace/std/longtype.py --- a/pypy/objspace/std/longtype.py +++ b/pypy/objspace/std/longtype.py @@ -104,7 +104,7 @@ return space.newlong(1) def descr_get_real(space, w_obj): -return w_obj +return space.long(w_obj) def descr_get_imag(space, w_obj): return space.newlong(0) diff --git a/pypy/objspace/std/test/test_floatobject.py b/pypy/objspace/std/test/test_floatobject.py --- a/pypy/objspace/std/test/test_floatobject.py +++ b/pypy/objspace/std/test/test_floatobject.py @@ -417,6 +417,11 @@ f = 1.1234e200 assert f.__format__("G") == "1.1234E+200" +def test_float_real(self): +class A(float): pass +b = A(5).real +assert type(b) is float + class AppTestFloatHex: def w_identical(self, x, y): diff --git a/pypy/objspace/std/test/test_longobject.py b/pypy/objspace/std/test/test_longobject.py --- a/pypy/objspace/std/test/test_longobject.py +++ b/pypy/objspace/std/test/test_longobject.py @@ -323,3 +323,7 @@ assert type(as_long) is long assert as_long == 64 +def test_long_real(self): +class A(long): pass +b = A(5).real +assert type(b) is long ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy mapdict-interp: A test, and fix.
Author: Armin Rigo Branch: mapdict-interp Changeset: r44247:924fc7a7a0f4 Date: 2011-05-17 15:51 +0200 http://bitbucket.org/pypy/pypy/changeset/924fc7a7a0f4/ Log:A test, and fix. diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py --- a/pypy/objspace/std/mapdict.py +++ b/pypy/objspace/std/mapdict.py @@ -754,24 +754,32 @@ w_descr = w_type.getattribute_if_not_from_object() if w_descr is not None: return space._handle_getattribute(w_descr, w_obj, w_name) - version_tag = w_type.version_tag() if version_tag is not None: name = space.str_w(w_name) -w_descr = w_type.lookup(name) +# We need to care for obscure cases in which the w_descr is +# a TypeCell, which may change without changing the version_tag +assert space.config.objspace.std.withmethodcache +_, w_descr = w_type._pure_lookup_where_with_method_cache( +name, version_tag) selector = ("", INVALID) -if w_descr is not None and space.is_data_descr(w_descr): -from pypy.interpreter.typedef import Member -descr = space.interpclass_w(w_descr) -if isinstance(descr, Member): -selector = ("slot", SLOTS_STARTING_FROM + descr.index) +if w_descr is None: +selector = (name, DICT) # common case: not shadowing anything +elif isinstance(w_descr, TypeCell): +pass# shadowing a TypeCell: give up else: -selector = (name, DICT) +if space.is_data_descr(w_descr): +from pypy.interpreter.typedef import Member +descr = space.interpclass_w(w_descr) +if isinstance(descr, Member):# a slot +selector = ("slot", SLOTS_STARTING_FROM + descr.index) +else: +selector = (name, DICT) # shadowing a non-data descr if selector[1] != INVALID: index = map.index(selector) if index >= 0: -# note that if map.terminator is a DevolvedDictTerminator, -# map.index() will always return -1 if selector[1]==DICT +# Note that if map.terminator is a DevolvedDictTerminator, +# map.index() will always return -1 if selector[1]==DICT. _fill_cache(pycode, nameindex, map, version_tag, index) return w_obj._mapdict_read_storage(index) if space.config.objspace.std.withmethodcachecounter: diff --git a/pypy/objspace/std/test/test_mapdict.py b/pypy/objspace/std/test/test_mapdict.py --- a/pypy/objspace/std/test/test_mapdict.py +++ b/pypy/objspace/std/test/test_mapdict.py @@ -930,6 +930,26 @@ got = a.method() assert got == 44 +def test_bug_slot_via_changing_member_descr(self): +class A(object): +__slots__ = ['a', 'b', 'c', 'd'] +x = A() +x.a = 'a' +x.b = 'b' +x.c = 'c' +x.d = 'd' +got = x.a +assert got == 'a' +A.a = A.b +got = x.a +assert got == 'b' +A.a = A.c +got = x.a +assert got == 'c' +A.a = A.d +got = x.a +assert got == 'd' + class AppTestGlobalCaching(AppTestWithMapDict): def setup_class(cls): cls.space = gettestobjspace( ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: another bunch of dead unused code
Author: Maciej Fijalkowski Branch: Changeset: r44251:89bfcaf69dc8 Date: 2011-05-17 16:52 +0200 http://bitbucket.org/pypy/pypy/changeset/89bfcaf69dc8/ Log:another bunch of dead unused code diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py --- a/pypy/rlib/jit.py +++ b/pypy/rlib/jit.py @@ -179,24 +179,6 @@ pass -##def force_virtualizable(virtualizable): -##pass - -##class Entry(ExtRegistryEntry): -##_about_ = force_virtualizable - -##def compute_result_annotation(self): -##from pypy.annotation import model as annmodel -##return annmodel.s_None - -##def specialize_call(self, hop): -##[vinst] = hop.inputargs(hop.args_r[0]) -##cname = inputconst(lltype.Void, None) -##cflags = inputconst(lltype.Void, {}) -##hop.exception_cannot_occur() -##return hop.genop('jit_force_virtualizable', [vinst, cname, cflags], -## resulttype=lltype.Void) - # # VRefs ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge heads
Author: Maciej Fijalkowski Branch: Changeset: r44252:6d32191a0ae3 Date: 2011-05-17 16:53 +0200 http://bitbucket.org/pypy/pypy/changeset/6d32191a0ae3/ Log:merge heads diff --git a/pypy/objspace/std/floattype.py b/pypy/objspace/std/floattype.py --- a/pypy/objspace/std/floattype.py +++ b/pypy/objspace/std/floattype.py @@ -264,7 +264,7 @@ return space.call_function(w_cls, w_float) def descr_get_real(space, w_obj): -return w_obj +return space.float(w_obj) def descr_get_imag(space, w_obj): return space.wrap(0.0) diff --git a/pypy/objspace/std/inttype.py b/pypy/objspace/std/inttype.py --- a/pypy/objspace/std/inttype.py +++ b/pypy/objspace/std/inttype.py @@ -179,7 +179,7 @@ return space.wrap(1) def descr_get_real(space, w_obj): -return w_obj +return space.int(w_obj) def descr_get_imag(space, w_obj): return space.wrap(0) diff --git a/pypy/objspace/std/longtype.py b/pypy/objspace/std/longtype.py --- a/pypy/objspace/std/longtype.py +++ b/pypy/objspace/std/longtype.py @@ -104,7 +104,7 @@ return space.newlong(1) def descr_get_real(space, w_obj): -return w_obj +return space.long(w_obj) def descr_get_imag(space, w_obj): return space.newlong(0) diff --git a/pypy/objspace/std/test/test_floatobject.py b/pypy/objspace/std/test/test_floatobject.py --- a/pypy/objspace/std/test/test_floatobject.py +++ b/pypy/objspace/std/test/test_floatobject.py @@ -417,6 +417,11 @@ f = 1.1234e200 assert f.__format__("G") == "1.1234E+200" +def test_float_real(self): +class A(float): pass +b = A(5).real +assert type(b) is float + class AppTestFloatHex: def w_identical(self, x, y): diff --git a/pypy/objspace/std/test/test_intobject.py b/pypy/objspace/std/test/test_intobject.py --- a/pypy/objspace/std/test/test_intobject.py +++ b/pypy/objspace/std/test/test_intobject.py @@ -480,6 +480,11 @@ ]: assert val.bit_length() == bits +def test_int_real(self): +class A(int): pass +b = A(5).real +assert type(b) is int + class AppTestIntOptimizedAdd(AppTestInt): def setup_class(cls): diff --git a/pypy/objspace/std/test/test_longobject.py b/pypy/objspace/std/test/test_longobject.py --- a/pypy/objspace/std/test/test_longobject.py +++ b/pypy/objspace/std/test/test_longobject.py @@ -323,3 +323,7 @@ assert type(as_long) is long assert as_long == 64 +def test_long_real(self): +class A(long): pass +b = A(5).real +assert type(b) is long diff --git a/pypy/translator/c/funcgen.py b/pypy/translator/c/funcgen.py --- a/pypy/translator/c/funcgen.py +++ b/pypy/translator/c/funcgen.py @@ -705,7 +705,7 @@ offset = self.expr(op.args[2]) value = self.expr(op.args[3]) typename = cdecl(self.db.gettype(TYPE).replace('@', '*@'), '') -return "*(((%(typename)s) %(addr)s ) + %(offset)s) = %(value)s;" % locals() +return "((%(typename)s) %(addr)s)[%(offset)s] = %(value)s;" % locals() def OP_RAW_LOAD(self, op): addr = self.expr(op.args[0]) @@ -713,7 +713,7 @@ offset = self.expr(op.args[2]) result = self.expr(op.result) typename = cdecl(self.db.gettype(TYPE).replace('@', '*@'), '') -return "%(result)s = *(((%(typename)s) %(addr)s ) + %(offset)s);" % locals() +return "%(result)s = ((%(typename)s) %(addr)s)[%(offset)s];" % locals() def OP_CAST_PRIMITIVE(self, op): TYPE = self.lltypemap(op.result) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy jit-applevel-info: A branch to expose some of jit data on applevel.
Author: Maciej Fijalkowski Branch: jit-applevel-info Changeset: r44253:4ffd7284eeae Date: 2011-05-17 17:07 +0200 http://bitbucket.org/pypy/pypy/changeset/4ffd7284eeae/ Log:A branch to expose some of jit data on applevel. diff --git a/pypy/module/pypyjit/__init__.py b/pypy/module/pypyjit/__init__.py --- a/pypy/module/pypyjit/__init__.py +++ b/pypy/module/pypyjit/__init__.py @@ -7,6 +7,7 @@ interpleveldefs = { 'set_param':'interp_jit.set_param', 'residual_call': 'interp_jit.residual_call', +'getjitinfo': 'interp_info.getjitinfo', } def setup_after_space_initialization(self): diff --git a/pypy/module/pypyjit/interp_info.py b/pypy/module/pypyjit/interp_info.py new file mode 100644 --- /dev/null +++ b/pypy/module/pypyjit/interp_info.py @@ -0,0 +1,21 @@ + +from pypy.interpreter.baseobjspace import W_Root, ObjSpace +from pypy.interpreter.typedef import TypeDef +from pypy.interpreter.gateway import unwrap_spec +from pypy.interpreter.pycode import PyCode + +class JitInfo(W_Root): +pass + +JitInfo.typedef = TypeDef( +'JitInfo', +) +JitInfo.typedef.acceptable_as_base_class = False + +@unwrap_spec(ObjSpace, W_Root) +def getjitinfo(space, w_obj): +pycode = space.interp_w(PyCode, w_obj) +w_dict = space.newdict() +for k in pycode.jit_cells: +space.setitem(w_dict, space.wrap(k), JitInfo()) +return w_dict diff --git a/pypy/module/pypyjit/test/test_jit_info.py b/pypy/module/pypyjit/test/test_jit_info.py new file mode 100644 --- /dev/null +++ b/pypy/module/pypyjit/test/test_jit_info.py @@ -0,0 +1,16 @@ +from pypy.conftest import gettestobjspace + +class AppTestJitInfo(object): +def setup_class(cls): +space = gettestobjspace(usemodules=('pypyjit',)) +cls.space = space + +def test_getjitinfo(self): +import pypyjit + +def f(): +pass + +pypyjit.getjitinfo(f.func_code) +# assert did not crash + ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy mapdict-interp: Add a comment.
Author: Armin Rigo Branch: mapdict-interp Changeset: r44254:e3248082e8ef Date: 2011-05-17 17:26 +0200 http://bitbucket.org/pypy/pypy/changeset/e3248082e8ef/ Log:Add a comment. diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py --- a/pypy/objspace/std/mapdict.py +++ b/pypy/objspace/std/mapdict.py @@ -807,6 +807,11 @@ map = w_obj._get_mapdict_map() if map is None or isinstance(map.terminator, DevolvedDictTerminator): return +# We know here that w_obj.getdictvalue(space, name) just returned None, +# so the 'name' is not in the instance. We repeat the lookup to find it +# in the class, this time taking care of the result: it can be either a +# quasi-constant class attribute, or actually a TypeCell --- which we +# must not cache. (It should not be None here, but you never know...) assert space.config.objspace.std.withmethodcache _, w_method = w_type._pure_lookup_where_with_method_cache(name, version_tag) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy mapdict-interp: Comments.
Author: Armin Rigo Branch: mapdict-interp Changeset: r44255:0eedad4896ba Date: 2011-05-17 17:36 +0200 http://bitbucket.org/pypy/pypy/changeset/0eedad4896ba/ Log:Comments. diff --git a/pypy/objspace/std/callmethod.py b/pypy/objspace/std/callmethod.py --- a/pypy/objspace/std/callmethod.py +++ b/pypy/objspace/std/callmethod.py @@ -51,6 +51,7 @@ # this handles directly the common case # module.function(args..) w_value = w_obj.getdictvalue(space, name) +# xxx we could also use the mapdict cache in that case, probably else: typ = type(w_descr) if typ is function.Function or typ is function.FunctionWithFixedCode: diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py --- a/pypy/objspace/std/mapdict.py +++ b/pypy/objspace/std/mapdict.py @@ -762,19 +762,27 @@ assert space.config.objspace.std.withmethodcache _, w_descr = w_type._pure_lookup_where_with_method_cache( name, version_tag) +# selector = ("", INVALID) if w_descr is None: -selector = (name, DICT) # common case: not shadowing anything +selector = (name, DICT) #common case: no such attr in the class elif isinstance(w_descr, TypeCell): -pass# shadowing a TypeCell: give up +pass # we have a TypeCell in the class: give up +elif space.is_data_descr(w_descr): +# we have a data descriptor, which means the dictionary value +# (if any) has no relevance. +from pypy.interpreter.typedef import Member +descr = space.interpclass_w(w_descr) +if isinstance(descr, Member):# it is a slot -- easy case +selector = ("slot", SLOTS_STARTING_FROM + descr.index) else: -if space.is_data_descr(w_descr): -from pypy.interpreter.typedef import Member -descr = space.interpclass_w(w_descr) -if isinstance(descr, Member):# a slot -selector = ("slot", SLOTS_STARTING_FROM + descr.index) -else: -selector = (name, DICT) # shadowing a non-data descr +# There is a non-data descriptor in the class. If there is +# also a dict attribute, use the latter, caching its position. +# If not, we loose. We could do better in this case too, +# but we don't care too much; the common case of a method +# invocation is handled by LOOKUP_METHOD_xxx below. +selector = (name, DICT) +# if selector[1] != INVALID: index = map.index(selector) if index >= 0: @@ -818,3 +826,7 @@ if w_method is None or isinstance(w_method, TypeCell): return _fill_cache(pycode, nameindex, map, version_tag, -1, w_method) + +# XXX fix me: if a function contains a loop with both LOAD_ATTR and +# XXX LOOKUP_METHOD on the same attribute name, it keeps trashing and +# XXX rebuilding the cache ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy jitypes2: fix test_freeing_block, which assumes asmgcc to be imported at top level
Author: Antonio Cuni Branch: jitypes2 Changeset: r44256:d6bc02216e99 Date: 2011-05-17 17:47 +0200 http://bitbucket.org/pypy/pypy/changeset/d6bc02216e99/ Log:fix test_freeing_block, which assumes asmgcc to be imported at top level diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py --- a/pypy/jit/backend/llsupport/gc.py +++ b/pypy/jit/backend/llsupport/gc.py @@ -17,6 +17,7 @@ from pypy.jit.backend.llsupport.descr import GcCache, get_field_descr from pypy.jit.backend.llsupport.descr import GcPtrFieldDescr from pypy.jit.backend.llsupport.descr import get_call_descr +from pypy.rpython.memory.gctransform import asmgcroot # @@ -323,7 +324,6 @@ @rgc.no_collect def freeing_block(self, start, stop): -from pypy.rpython.memory.gctransform import asmgcroot # if [start:stop] is a raw block of assembler, then look up the # corresponding gcroot markers, and mark them as freed now in # self._gcmap by setting the 2nd address of every entry to NULL. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (Da_Blitz) fix ctypes warnings
Author: Antonio Cuni Branch: Changeset: r44257:034d4ee955ad Date: 2011-05-17 17:50 +0200 http://bitbucket.org/pypy/pypy/changeset/034d4ee955ad/ Log:(Da_Blitz) fix ctypes warnings diff --git a/lib_pypy/_pypy_wait.py b/lib_pypy/_pypy_wait.py --- a/lib_pypy/_pypy_wait.py +++ b/lib_pypy/_pypy_wait.py @@ -6,12 +6,12 @@ libc = CDLL(find_library("c")) c_wait3 = libc.wait3 - c_wait3.argtypes = [POINTER(c_int), c_int, POINTER(_struct_rusage)] +c_wait3.restype = c_int c_wait4 = libc.wait4 - c_wait4.argtypes = [c_int, POINTER(c_int), c_int, POINTER(_struct_rusage)] +c_wait4.restype = c_int def create_struct_rusage(c_struct): return struct_rusage(( ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy jit-applevel-info: progress - expose counters
Author: Maciej Fijalkowski Branch: jit-applevel-info Changeset: r44258:86d27eb00b27 Date: 2011-05-17 18:21 +0200 http://bitbucket.org/pypy/pypy/changeset/86d27eb00b27/ Log:progress - expose counters diff --git a/pypy/module/pypyjit/interp_info.py b/pypy/module/pypyjit/interp_info.py --- a/pypy/module/pypyjit/interp_info.py +++ b/pypy/module/pypyjit/interp_info.py @@ -1,21 +1,23 @@ -from pypy.interpreter.baseobjspace import W_Root, ObjSpace -from pypy.interpreter.typedef import TypeDef +from pypy.interpreter.baseobjspace import Wrappable, ObjSpace, W_Root +from pypy.interpreter.typedef import TypeDef, interp_attrproperty from pypy.interpreter.gateway import unwrap_spec from pypy.interpreter.pycode import PyCode -class JitInfo(W_Root): -pass +class MergePointInfo(Wrappable): +def __init__(self, jitcell): +self.counter = jitcell.counter -JitInfo.typedef = TypeDef( -'JitInfo', +MergePointInfo.typedef = TypeDef( +'MergePointInfo', +counter = interp_attrproperty('counter', cls=MergePointInfo), ) -JitInfo.typedef.acceptable_as_base_class = False +MergePointInfo.typedef.acceptable_as_base_class = False @unwrap_spec(ObjSpace, W_Root) def getjitinfo(space, w_obj): pycode = space.interp_w(PyCode, w_obj) w_dict = space.newdict() -for k in pycode.jit_cells: -space.setitem(w_dict, space.wrap(k), JitInfo()) +for k, v in pycode.jit_cells.items(): +space.setitem(w_dict, space.wrap(k), MergePointInfo(v)) return w_dict diff --git a/pypy/module/pypyjit/test/test_jit_info.py b/pypy/module/pypyjit/test/test_jit_info.py --- a/pypy/module/pypyjit/test/test_jit_info.py +++ b/pypy/module/pypyjit/test/test_jit_info.py @@ -1,16 +1,24 @@ from pypy.conftest import gettestobjspace +from pypy.jit.metainterp.warmstate import JitCell class AppTestJitInfo(object): def setup_class(cls): space = gettestobjspace(usemodules=('pypyjit',)) cls.space = space +cell = JitCell() +cell.counter = 13 +w_code = space.appexec([], '''(): +def f(): + pass +return f.func_code +''') +w_code.jit_cells[13] = cell +cls.w_code = w_code def test_getjitinfo(self): import pypyjit -def f(): -pass - -pypyjit.getjitinfo(f.func_code) +info = pypyjit.getjitinfo(self.code) +assert info[13].counter == 13 # assert did not crash ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy jit-applevel-info: add debug_offset operation (doesn't do much so far)
Author: Maciej Fijalkowski Branch: jit-applevel-info Changeset: r44259:89fb267cfc53 Date: 2011-05-17 19:11 +0200 http://bitbucket.org/pypy/pypy/changeset/89fb267cfc53/ Log:add debug_offset operation (doesn't do much so far) diff --git a/pypy/rlib/debug.py b/pypy/rlib/debug.py --- a/pypy/rlib/debug.py +++ b/pypy/rlib/debug.py @@ -140,6 +140,23 @@ return hop.inputconst(lltype.Bool, False) +def debug_offset(): +""" Return an offset in log file +""" +return -1 + +class Entry(ExtRegistryEntry): +_about_ = debug_offset + +def compute_result_annotation(self): +from pypy.annotation import model as annmodel +return annmodel.SomeInteger() + +def specialize_call(self, hop): +from pypy.rpython.lltypesystem import lltype +hop.exception_cannot_occur() +return hop.genop('debug_offset', [], resulttype=lltype.Signed) + def llinterpcall(RESTYPE, pythonfunction, *args): """When running on the llinterp, this causes the llinterp to call to the provided Python function with the run-time value of the given args. diff --git a/pypy/rlib/test/test_debug.py b/pypy/rlib/test/test_debug.py --- a/pypy/rlib/test/test_debug.py +++ b/pypy/rlib/test/test_debug.py @@ -2,7 +2,7 @@ import py from pypy.rlib.debug import check_annotation, make_sure_not_resized from pypy.rlib.debug import debug_print, debug_start, debug_stop -from pypy.rlib.debug import have_debug_prints +from pypy.rlib.debug import have_debug_prints, debug_offset from pypy.rlib.debug import check_nonneg, IntegerCanBeNegative from pypy.rlib import debug from pypy.rpython.test.test_llinterp import interpret @@ -60,6 +60,7 @@ debug_start("mycat") debug_print("foo", 2, "bar", x) debug_stop("mycat") +debug_offset() # should not explode at least return have_debug_prints() try: diff --git a/pypy/rpython/lltypesystem/lloperation.py b/pypy/rpython/lltypesystem/lloperation.py --- a/pypy/rpython/lltypesystem/lloperation.py +++ b/pypy/rpython/lltypesystem/lloperation.py @@ -553,6 +553,7 @@ 'debug_start': LLOp(canrun=True), 'debug_stop': LLOp(canrun=True), 'have_debug_prints':LLOp(canrun=True), +'debug_offset': LLOp(canrun=True), 'debug_pdb':LLOp(), 'debug_assert': LLOp(tryfold=True), 'debug_fatalerror': LLOp(), diff --git a/pypy/rpython/lltypesystem/opimpl.py b/pypy/rpython/lltypesystem/opimpl.py --- a/pypy/rpython/lltypesystem/opimpl.py +++ b/pypy/rpython/lltypesystem/opimpl.py @@ -513,6 +513,9 @@ def op_debug_stop(category): debug.debug_stop(_normalize(category)) +def op_debug_offset(): +return debug.debug_offset() + def op_have_debug_prints(): return debug.have_debug_prints() ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy jit-applevel-info: finish implementing debug_offset and test it on the C backend
Author: Maciej Fijalkowski Branch: jit-applevel-info Changeset: r44260:542b67a26432 Date: 2011-05-17 19:19 +0200 http://bitbucket.org/pypy/pypy/changeset/542b67a26432/ Log:finish implementing debug_offset and test it on the C backend diff --git a/pypy/jit/metainterp/history.py b/pypy/jit/metainterp/history.py --- a/pypy/jit/metainterp/history.py +++ b/pypy/jit/metainterp/history.py @@ -771,6 +771,9 @@ # CompiledLoopToken has its __del__ called, which frees the assembler # memory and the ResumeGuards. compiled_loop_token = None +# extra debugging info to fish from the log +jitlog_start = -1 +jitlog_end = -1 def __init__(self): # For memory management of assembled loops diff --git a/pypy/module/pypyjit/test/test_jit_info.py b/pypy/module/pypyjit/test/test_jit_info.py --- a/pypy/module/pypyjit/test/test_jit_info.py +++ b/pypy/module/pypyjit/test/test_jit_info.py @@ -20,5 +20,5 @@ info = pypyjit.getjitinfo(self.code) assert info[13].counter == 13 -# assert did not crash + diff --git a/pypy/translator/c/src/debug_print.c b/pypy/translator/c/src/debug_print.c --- a/pypy/translator/c/src/debug_print.c +++ b/pypy/translator/c/src/debug_print.c @@ -65,6 +65,15 @@ debug_ready = 1; } +long pypy_debug_offset(void) +{ + if (!debug_ready) +return -1; + // note that we deliberately ignore errno, since -1 is fine + // in case this is not a real file + return ftell(pypy_debug_file); +} + void pypy_debug_ensure_opened(void) { if (!debug_ready) diff --git a/pypy/translator/c/src/debug_print.h b/pypy/translator/c/src/debug_print.h --- a/pypy/translator/c/src/debug_print.h +++ b/pypy/translator/c/src/debug_print.h @@ -26,6 +26,7 @@ #define PYPY_DEBUG_FILE pypy_debug_file #define PYPY_DEBUG_START(cat) pypy_debug_start(cat) #define PYPY_DEBUG_STOP(cat) pypy_debug_stop(cat) +#define OP_DEBUG_OFFSET(res) res = pypy_debug_offset() #define OP_HAVE_DEBUG_PRINTS(r) r = (pypy_have_debug_prints & 1) @@ -35,6 +36,7 @@ void pypy_debug_ensure_opened(void); void pypy_debug_start(const char *category); void pypy_debug_stop(const char *category); +long pypy_debug_offset(void); extern long pypy_have_debug_prints; extern FILE *pypy_debug_file; diff --git a/pypy/translator/c/test/test_standalone.py b/pypy/translator/c/test/test_standalone.py --- a/pypy/translator/c/test/test_standalone.py +++ b/pypy/translator/c/test/test_standalone.py @@ -4,7 +4,7 @@ from pypy.rlib.objectmodel import keepalive_until_here from pypy.rlib.rarithmetic import r_longlong from pypy.rlib.debug import ll_assert, have_debug_prints -from pypy.rlib.debug import debug_print, debug_start, debug_stop +from pypy.rlib.debug import debug_print, debug_start, debug_stop, debug_offset from pypy.translator.translator import TranslationContext from pypy.translator.backendopt import all from pypy.translator.c.genc import CStandaloneBuilder, ExternalCompilationInfo @@ -284,12 +284,12 @@ debug_stop ("mycat") if have_debug_prints(): x += "a" debug_print("toplevel") -os.write(1, x + '.\n') +os.write(1, x + "." + str(debug_offset()) + '.\n') return 0 t, cbuilder = self.compile(entry_point) # check with PYPYLOG undefined out, err = cbuilder.cmdexec("", err=True, env={}) -assert out.strip() == 'got:a.' +assert out.strip() == 'got:a.-1.' assert 'toplevel' in err assert 'mycat' not in err assert 'foo 2 bar 3' not in err @@ -298,7 +298,7 @@ assert 'bok' not in err # check with PYPYLOG defined to an empty string (same as undefined) out, err = cbuilder.cmdexec("", err=True, env={'PYPYLOG': ''}) -assert out.strip() == 'got:a.' +assert out.strip() == 'got:a.-1.' assert 'toplevel' in err assert 'mycat' not in err assert 'foo 2 bar 3' not in err @@ -307,7 +307,7 @@ assert 'bok' not in err # check with PYPYLOG=:- (means print to stderr) out, err = cbuilder.cmdexec("", err=True, env={'PYPYLOG': ':-'}) -assert out.strip() == 'got:bcda.' +assert out.strip() == 'got:bcda.-1.' assert 'toplevel' in err assert '{mycat' in err assert 'mycat}' in err @@ -320,7 +320,8 @@ path = udir.join('test_debug_xxx.log') out, err = cbuilder.cmdexec("", err=True, env={'PYPYLOG': ':%s' % path}) -assert out.strip() == 'got:bcda.' +size = os.stat(str(path)).st_size +assert out.strip() == 'got:bcda.' + str(size) + '.' assert not err assert path.check(file=1) data = path.read() @@ -335,7 +336,8 @@ # check with PYPYLOG=somefilename path = udir.join('test_debug_xxx_prof.log') out, err = cbuilder.cmdexec("", err=True, env={'PYPYLOG': str(path)}) -assert out.strip(
[pypy-commit] pypy jit-applevel-info: implement debug_flush, no tests checking if it works :-/
Author: Maciej Fijalkowski Branch: jit-applevel-info Changeset: r44261:53a68f64c59d Date: 2011-05-17 19:33 +0200 http://bitbucket.org/pypy/pypy/changeset/53a68f64c59d/ Log:implement debug_flush, no tests checking if it works :-/ diff --git a/pypy/rlib/debug.py b/pypy/rlib/debug.py --- a/pypy/rlib/debug.py +++ b/pypy/rlib/debug.py @@ -157,6 +157,23 @@ hop.exception_cannot_occur() return hop.genop('debug_offset', [], resulttype=lltype.Signed) + +def debug_flush(): +""" Flushes the debug file +""" +pass + +class Entry(ExtRegistryEntry): +_about_ = debug_flush + +def compute_result_annotation(self): +return None + +def specialize_call(self, hop): +hop.exception_cannot_occur() +return hop.genop('debug_flush', []) + + def llinterpcall(RESTYPE, pythonfunction, *args): """When running on the llinterp, this causes the llinterp to call to the provided Python function with the run-time value of the given args. diff --git a/pypy/rlib/test/test_debug.py b/pypy/rlib/test/test_debug.py --- a/pypy/rlib/test/test_debug.py +++ b/pypy/rlib/test/test_debug.py @@ -60,6 +60,7 @@ debug_start("mycat") debug_print("foo", 2, "bar", x) debug_stop("mycat") +debug_flush() # does nothing debug_offset() # should not explode at least return have_debug_prints() diff --git a/pypy/rpython/lltypesystem/lloperation.py b/pypy/rpython/lltypesystem/lloperation.py --- a/pypy/rpython/lltypesystem/lloperation.py +++ b/pypy/rpython/lltypesystem/lloperation.py @@ -554,6 +554,7 @@ 'debug_stop': LLOp(canrun=True), 'have_debug_prints':LLOp(canrun=True), 'debug_offset': LLOp(canrun=True), +'debug_flush': LLOp(canrun=True), 'debug_pdb':LLOp(), 'debug_assert': LLOp(tryfold=True), 'debug_fatalerror': LLOp(), diff --git a/pypy/rpython/lltypesystem/opimpl.py b/pypy/rpython/lltypesystem/opimpl.py --- a/pypy/rpython/lltypesystem/opimpl.py +++ b/pypy/rpython/lltypesystem/opimpl.py @@ -516,6 +516,9 @@ def op_debug_offset(): return debug.debug_offset() +def op_debug_flush(): +pass + def op_have_debug_prints(): return debug.have_debug_prints() diff --git a/pypy/translator/c/src/debug_print.h b/pypy/translator/c/src/debug_print.h --- a/pypy/translator/c/src/debug_print.h +++ b/pypy/translator/c/src/debug_print.h @@ -28,7 +28,7 @@ #define PYPY_DEBUG_STOP(cat) pypy_debug_stop(cat) #define OP_DEBUG_OFFSET(res) res = pypy_debug_offset() #define OP_HAVE_DEBUG_PRINTS(r) r = (pypy_have_debug_prints & 1) - +#define OP_DEBUG_FLUSH() fflush(pypy_debug_file) // diff --git a/pypy/translator/c/test/test_standalone.py b/pypy/translator/c/test/test_standalone.py --- a/pypy/translator/c/test/test_standalone.py +++ b/pypy/translator/c/test/test_standalone.py @@ -3,7 +3,7 @@ from pypy.rlib.objectmodel import keepalive_until_here from pypy.rlib.rarithmetic import r_longlong -from pypy.rlib.debug import ll_assert, have_debug_prints +from pypy.rlib.debug import ll_assert, have_debug_prints, debug_flush from pypy.rlib.debug import debug_print, debug_start, debug_stop, debug_offset from pypy.translator.translator import TranslationContext from pypy.translator.backendopt import all @@ -284,6 +284,7 @@ debug_stop ("mycat") if have_debug_prints(): x += "a" debug_print("toplevel") +debug_flush() os.write(1, x + "." + str(debug_offset()) + '.\n') return 0 t, cbuilder = self.compile(entry_point) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: remove debug_pdb
Author: Maciej Fijalkowski Branch: Changeset: r44262:dd756c36a5ac Date: 2011-05-17 19:34 +0200 http://bitbucket.org/pypy/pypy/changeset/dd756c36a5ac/ Log:remove debug_pdb diff --git a/pypy/rpython/llinterp.py b/pypy/rpython/llinterp.py --- a/pypy/rpython/llinterp.py +++ b/pypy/rpython/llinterp.py @@ -513,13 +513,6 @@ from pypy.translator.tool.lltracker import track track(*ll_objects) -def op_debug_pdb(self, *ll_args): -if self.llinterpreter.tracer: -self.llinterpreter.tracer.flush() -print "entering pdb...", ll_args -import pdb -pdb.set_trace() - def op_debug_assert(self, x, msg): assert x, msg diff --git a/pypy/rpython/lltypesystem/lloperation.py b/pypy/rpython/lltypesystem/lloperation.py --- a/pypy/rpython/lltypesystem/lloperation.py +++ b/pypy/rpython/lltypesystem/lloperation.py @@ -553,7 +553,6 @@ 'debug_start': LLOp(canrun=True), 'debug_stop': LLOp(canrun=True), 'have_debug_prints':LLOp(canrun=True), -'debug_pdb':LLOp(), 'debug_assert': LLOp(tryfold=True), 'debug_fatalerror': LLOp(), 'debug_llinterpcall': LLOp(canraise=(Exception,)), diff --git a/pypy/rpython/lltypesystem/rpbc.py b/pypy/rpython/lltypesystem/rpbc.py --- a/pypy/rpython/lltypesystem/rpbc.py +++ b/pypy/rpython/lltypesystem/rpbc.py @@ -198,7 +198,6 @@ inputargs = [varoftype(t) for t in [Char] + argtypes] startblock = Block(inputargs) startblock.exitswitch = inputargs[0] -#startblock.operations.append(SpaceOperation('debug_pdb', [], varoftype(Void))) graph = FunctionGraph("dispatcher", startblock, varoftype(resulttype)) row_of_graphs = self.callfamily.calltables[shape][index] links = [] ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reflex-support: RPython and pylint fixes
Author: Wim Lavrijsen Branch: reflex-support Changeset: r44263:b53fddb460b3 Date: 2011-05-16 17:05 -0700 http://bitbucket.org/pypy/pypy/changeset/b53fddb460b3/ Log:RPython and pylint fixes diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py --- a/pypy/module/cppyy/converter.py +++ b/pypy/module/cppyy/converter.py @@ -15,7 +15,6 @@ def get_rawobject(space, w_obj): if w_obj: -from pypy.module.cppyy.interp_cppyy import W_CPPInstance w_cpp_instance = space.findattr(w_obj, space.wrap("_cppinstance")) if w_cpp_instance: return w_cpp_instance.rawobject @@ -87,9 +86,9 @@ class PtrTypeConverter(ArrayTypeConverter): def _get_raw_address(self, space, w_obj, offset): -fieldptr = TypeConverter._get_raw_address(self, space, w_obj, offset) -ptrptr = rffi.cast(rffi.LONGP, fieldptr) -return ptrptr[0] +address = TypeConverter._get_raw_address(self, space, w_obj, offset) +ptr2ptr = rffi.cast(rffi.LONGP, address) +return rffi.cast(rffi.CCHARP, ptr2ptr[0]) class VoidConverter(TypeConverter): @@ -127,9 +126,9 @@ raise OperationError(space.w_TypeError, space.wrap("boolean value should be bool, or integer 1 or 0")) if arg: - address[0] = '\x01' +address[0] = '\x01' else: - address[0] = '\x00' +address[0] = '\x00' class CharConverter(TypeConverter): _immutable = True @@ -191,7 +190,7 @@ longptr = rffi.cast(rffi.LONGP, address) longptr[0] = space.c_int_w(w_value) -class UnsignedLongConverter(LongConverter): +class UnsignedLongConverter(TypeConverter): _immutable = True libffitype = libffi.types.ulong diff --git a/pypy/module/cppyy/interp_cppyy.py b/pypy/module/cppyy/interp_cppyy.py --- a/pypy/module/cppyy/interp_cppyy.py +++ b/pypy/module/cppyy/interp_cppyy.py @@ -248,14 +248,14 @@ self.offset = offset def is_static(self): -return self.space.wrap(False) +return self.space.w_False def __get__(self, args_w): return self.converter.from_memory(self.space, args_w[0], self.offset) def __set__(self, args_w): self.converter.to_memory(self.space, args_w[0], args_w[1], self.offset) -return None +return self.space.w_None W_CPPDataMember.typedef = TypeDef( 'CPPDataMember', @@ -267,14 +267,14 @@ class W_CPPStaticDataMember(W_CPPDataMember): def is_static(self): -return self.space.wrap(True) +return self.space.w_True def __get__(self, args_w): return self.converter.from_memory(self.space, self.space.w_None, self.offset) def __set__(self, args_w): self.converter.to_memory(self.space, self.space.w_None, args_w[1], self.offset) -return None +return self.space.w_None W_CPPStaticDataMember.typedef = TypeDef( 'CPPStaticDataMember', ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reflex-support: rpython fixes
Author: Wim Lavrijsen Branch: reflex-support Changeset: r44264:249cfd1d8127 Date: 2011-05-17 13:22 -0700 http://bitbucket.org/pypy/pypy/changeset/249cfd1d8127/ Log:rpython fixes diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py --- a/pypy/module/cppyy/converter.py +++ b/pypy/module/cppyy/converter.py @@ -14,10 +14,12 @@ _converters = {} def get_rawobject(space, w_obj): -if w_obj: +if not space.eq_w(w_obj, space.w_None): +from pypy.module.cppyy.interp_cppyy import W_CPPInstance w_cpp_instance = space.findattr(w_obj, space.wrap("_cppinstance")) -if w_cpp_instance: -return w_cpp_instance.rawobject +cpp_instance = space.interp_w(W_CPPInstance, w_cpp_instance, can_be_None=True) +if cpp_instance: +return cpp_instance.rawobject return lltype.nullptr(rffi.CCHARP.TO) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] buildbot default: rename the ugly bitbucket_hook into bbhook
Author: Antonio Cuni Branch: Changeset: r509:719c9a48c26f Date: 2011-05-17 22:48 +0200 http://bitbucket.org/pypy/buildbot/changeset/719c9a48c26f/ Log:rename the ugly bitbucket_hook into bbhook diff --git a/bitbucket_hook/__init__.py b/bbhook/__init__.py rename from bitbucket_hook/__init__.py rename to bbhook/__init__.py diff --git a/bitbucket_hook/hook.py b/bbhook/hook.py rename from bitbucket_hook/hook.py rename to bbhook/hook.py diff --git a/bitbucket_hook/irc.py b/bbhook/irc.py rename from bitbucket_hook/irc.py rename to bbhook/irc.py diff --git a/bitbucket_hook/mail.py b/bbhook/mail.py rename from bitbucket_hook/mail.py rename to bbhook/mail.py diff --git a/bitbucket_hook/main.py b/bbhook/main.py rename from bitbucket_hook/main.py rename to bbhook/main.py diff --git a/bitbucket_hook/repos/README b/bbhook/repos/README rename from bitbucket_hook/repos/README rename to bbhook/repos/README diff --git a/bitbucket_hook/run.py b/bbhook/run.py rename from bitbucket_hook/run.py rename to bbhook/run.py diff --git a/bitbucket_hook/scm.py b/bbhook/scm.py rename from bitbucket_hook/scm.py rename to bbhook/scm.py diff --git a/bitbucket_hook/stdoutlog.py b/bbhook/stdoutlog.py rename from bitbucket_hook/stdoutlog.py rename to bbhook/stdoutlog.py diff --git a/bitbucket_hook/test/__init__.py b/bbhook/test/__init__.py rename from bitbucket_hook/test/__init__.py rename to bbhook/test/__init__.py diff --git a/bitbucket_hook/test/conftest.py b/bbhook/test/conftest.py rename from bitbucket_hook/test/conftest.py rename to bbhook/test/conftest.py --- a/bitbucket_hook/test/conftest.py +++ b/bbhook/test/conftest.py @@ -10,7 +10,7 @@ def pytest_funcarg__monkeypatch(request): -from bitbucket_hook import irc, mail +from bbhook import irc, mail mp = request.getfuncargvalue('monkeypatch') mails = request.getfuncargvalue('mails') diff --git a/bitbucket_hook/test/test_hook.py b/bbhook/test/test_hook.py rename from bitbucket_hook/test/test_hook.py rename to bbhook/test/test_hook.py --- a/bitbucket_hook/test/test_hook.py +++ b/bbhook/test/test_hook.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- import py import pytest -from bitbucket_hook import hook, scm, mail, irc +from bbhook import hook, scm, mail, irc #XXX hook.app.config['USE_COLOR_CODES'] = False diff --git a/bitbucket_hook/test/test_irc.py b/bbhook/test/test_irc.py rename from bitbucket_hook/test/test_irc.py rename to bbhook/test/test_irc.py --- a/bitbucket_hook/test/test_irc.py +++ b/bbhook/test/test_irc.py @@ -1,4 +1,4 @@ -from bitbucket_hook import irc +from bbhook import irc import subprocess def fl(*paths): diff --git a/bitbucket_hook/test/test_main.py b/bbhook/test/test_main.py rename from bitbucket_hook/test/test_main.py rename to bbhook/test/test_main.py --- a/bitbucket_hook/test/test_main.py +++ b/bbhook/test/test_main.py @@ -1,5 +1,5 @@ -from bitbucket_hook.main import app -from bitbucket_hook import hook +from bbhook.main import app +from bbhook import hook def test_get(): client = app.test_client() diff --git a/bitbucket_hook/test/test_scm.py b/bbhook/test/test_scm.py rename from bitbucket_hook/test/test_scm.py rename to bbhook/test/test_scm.py --- a/bitbucket_hook/test/test_scm.py +++ b/bbhook/test/test_scm.py @@ -2,7 +2,7 @@ import py import pytest -from bitbucket_hook import scm +from bbhook import scm def test_non_ascii_encoding_guess_utf8(monkeypatch): diff --git a/bitbucket_hook/test_hook_testcall.py b/bbhook/test_hook_testcall.py rename from bitbucket_hook/test_hook_testcall.py rename to bbhook/test_hook_testcall.py --- a/bitbucket_hook/test_hook_testcall.py +++ b/bbhook/test_hook_testcall.py @@ -3,8 +3,8 @@ def test_handlecall(): -from bitbucket_hook.hook import handle -from bitbucket_hook.main import app +from bbhook.hook import handle +from bbhook.main import app repopath = os.path.dirname(os.path.dirname(__file__)) print 'Repository path:', repopath test_payload = {u'repository': {u'absolute_url': '', @@ -28,7 +28,7 @@ {u'author': u'antocuni', u'branch': u'default', -u'files': [{u'file': u'bitbucket_hook/hook.py', +u'files': [{u'file': u'bbhook/hook.py', u'type': u'modified'}], u'message': u"don't send newlines to irc", u'node': u'e17583fbfa5c', @@ -53,13 +53,13 @@ {u'author': u'antocuni', u'branch': u'default', -u'files': [{u'file': u'bitbucket_hook/hook.py', +u'files': [{u'file': u'bbhook/hook.py', u'type': u'modified'}, - {u'file': u'bitbucket_hook/__init__.py', + {u'file': u'bbhook/__init__.py', u'type': u'added'}, - {u'file': u'bitbucket_hook/test/__init__.py', + {u'file': u'bbhook/test/__init__.py',
[pypy-commit] buildbot default: merge heads
Author: Antonio Cuni Branch: Changeset: r510:2d1be537ed24 Date: 2011-05-17 22:48 +0200 http://bitbucket.org/pypy/buildbot/changeset/2d1be537ed24/ Log:merge heads diff --git a/bbhook/main.py b/bbhook/main.py --- a/bbhook/main.py +++ b/bbhook/main.py @@ -64,7 +64,7 @@ class WyvernConfig(DefaultConfig): SMTP_SERVER = 'localhost' SMTP_PORT = 25 -ADDRESS = 'pypy-...@codespeak.net' +ADDRESS = 'pypy-commit@python.org' # CHANNEL = '#pypy' #BOT = '/svn/hooks/commit-bot/message' ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reflex-support: translation fixes
Author: Wim Lavrijsen Branch: reflex-support Changeset: r44265:2e8a5d96cd07 Date: 2011-05-17 14:33 -0700 http://bitbucket.org/pypy/pypy/changeset/2e8a5d96cd07/ Log:translation fixes diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py --- a/pypy/module/cppyy/converter.py +++ b/pypy/module/cppyy/converter.py @@ -62,6 +62,7 @@ class ArrayTypeConverter(TypeConverter): _immutable = True +_immutable_fields_ = ["size"] typecode = '' typesize = 0 # TODO: get sizeof(type) from system @@ -87,6 +88,8 @@ class PtrTypeConverter(ArrayTypeConverter): +_immutable_ = True + def _get_raw_address(self, space, w_obj, offset): address = TypeConverter._get_raw_address(self, space, w_obj, offset) ptr2ptr = rffi.cast(rffi.LONGP, address) @@ -106,6 +109,8 @@ class BoolConverter(TypeConverter): +_immutable = True + def convert_argument(self, space, w_obj): arg = space.c_int_w(w_obj) if arg != False and arg != True: @@ -230,6 +235,8 @@ shortptr[0] = rffi.cast(rffi.SHORT, self._unwrap_object(space, w_value)) class FloatConverter(TypeConverter): +_immutable = True + def _unwrap_object(self, space, w_obj): return r_singlefloat(space.float_w(w_obj)) @@ -275,6 +282,8 @@ class CStringConverter(TypeConverter): +_immutable = True + def convert_argument(self, space, w_obj): arg = space.str_w(w_obj) x = rffi.str2charp(arg) @@ -282,28 +291,23 @@ class ShortArrayConverter(ArrayTypeConverter): -_immutable_ = True typecode = 'h' typesize = 2 class LongArrayConverter(ArrayTypeConverter): -_immutable_ = True typecode = 'l' typesize = 4 class FloatArrayConverter(ArrayTypeConverter): -_immutable_ = True typecode = 'f' typesize = 4 class DoubleArrayConverter(ArrayTypeConverter): -_immutable_ = True typecode = 'd' typesize = 8 class ShortPtrConverter(PtrTypeConverter): -_immutable_ = True typecode = 'h' typesize = 2 @@ -315,23 +319,22 @@ #byteptr[0] = space.unwrap(space.id(w_value.getslotvalue(2))) class LongPtrConverter(PtrTypeConverter): -_immutable_ = True typecode = 'l' typesize = 4 class FloatPtrConverter(PtrTypeConverter): -_immutable_ = True typecode = 'f' typesize = 4 class DoublePtrConverter(PtrTypeConverter): -_immutable_ = True typecode = 'd' typesize = 8 class InstancePtrConverter(TypeConverter): _immutable_ = True +_immutable_fields_ = ["cpptype"] + def __init__(self, space, cpptype): self.cpptype = cpptype ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reflex-support: coding convention fixes
Author: Wim Lavrijsen Branch: reflex-support Changeset: r44267:a1cbea871a80 Date: 2011-05-17 17:44 -0700 http://bitbucket.org/pypy/pypy/changeset/a1cbea871a80/ Log:coding convention fixes diff --git a/pypy/module/cppyy/test/test_datatypes.py b/pypy/module/cppyy/test/test_datatypes.py --- a/pypy/module/cppyy/test/test_datatypes.py +++ b/pypy/module/cppyy/test/test_datatypes.py @@ -1,6 +1,5 @@ import py, os, sys from pypy.conftest import gettestobjspace -from pypy.module.cppyy import interp_cppyy, executor currpath = py.path.local(__file__).dirpath() @@ -25,13 +24,13 @@ import cppyy return cppyy.load_lib(%r)""" % (shared_lib, )) -def testLoadLibCache(self): +def test0_load_lib_cache(self): """Test whether loading a library twice results in the same object.""" import cppyy lib2 = cppyy.load_lib(self.shared_lib) assert self.datatypes is lib2 -def test1InstanceDataReadAccess( self ): +def test1_instance_data_read_access( self ): """Test read access to instance public data and verify values""" import cppyy, sys @@ -105,7 +104,7 @@ c.destruct() -def test2InstanceDataWriteAccess(self): +def test2_instance_data_write_access(self): """Test write access to instance public data and verify values""" import cppyy, sys @@ -187,7 +186,7 @@ c.destruct() -def test3ClassReadAccess(self): +def test3_class_read_access(self): """Test read access to class public data and verify values""" import cppyy, sys @@ -224,7 +223,7 @@ c.destruct() -def test4ClassDataWriteAccess(self): +def test4_class_data_write_access(self): """Test write access to class public data and verify values""" import cppyy, sys @@ -288,7 +287,7 @@ c.destruct() -def test5RangeAccess(self): +def test5_range_access(self): """Test the ranges of integer types""" import cppyy, sys @@ -304,7 +303,7 @@ c.destruct() -def test6TypeConversions(self): +def test6_type_conversions(self): """Test conversions between builtin types""" import cppyy, sys ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reflex-support: add (start of) new series of tests
Author: Wim Lavrijsen Branch: reflex-support Changeset: r44268:1f7198bb9628 Date: 2011-05-17 17:45 -0700 http://bitbucket.org/pypy/pypy/changeset/1f7198bb9628/ Log:add (start of) new series of tests diff --git a/pypy/module/cppyy/test/Makefile b/pypy/module/cppyy/test/Makefile --- a/pypy/module/cppyy/test/Makefile +++ b/pypy/module/cppyy/test/Makefile @@ -25,3 +25,7 @@ datatypesDict.so: datatypes.cxx datatypes.h $(genreflex) datatypes.h $(genreflexflags) g++ -o $@ datatypes_rflx.cpp datatypes.cxx -shared -lReflex $(cppflags) $(cppflags2) + +advancedcppDict.so: advancedcpp.cxx advancedcpp.h + $(genreflex) advancedcpp.h $(genreflexflags) + g++ -o $@ advancedcpp_rflx.cpp advancedcpp.cxx -shared -lReflex $(cppflags) $(cppflags2) diff --git a/pypy/module/cppyy/test/advancedcpp.cxx b/pypy/module/cppyy/test/advancedcpp.cxx new file mode 100644 --- /dev/null +++ b/pypy/module/cppyy/test/advancedcpp.cxx @@ -0,0 +1,38 @@ +#include "advancedcpp.h" + + +// for esoteric inheritance testing +int get_a( a_class& a ) { return a.m_a; } +int get_b( b_class& b ) { return b.m_b; } +int get_c( c_class& c ) { return c.m_c; } +int get_d( d_class& d ) { return d.m_d; } + + +// helpers for checking pass-by-ref +void set_int_through_ref(int& i, int val) { i = val; } +int pass_int_through_const_ref(const int& i) { return i; } +void set_long_through_ref(long& l, long val) { l = val; } +long pass_long_through_const_ref(const long& l) { return l; } +void set_double_through_ref(double& d, double val){ d = val; } +double pass_double_through_const_ref(const double& d) { return d; } + + +// for math conversions testing +bool operator==(const some_comparable& c1, const some_comparable& c2 ) +{ + return &c1 != &c2; // the opposite of a pointer comparison +} + +bool operator!=( const some_comparable& c1, const some_comparable& c2 ) +{ + return &c1 == &c2; // the opposite of a pointer comparison +} + + +// a couple of globals for access testing +double my_global_double = 12.; +double my_global_array[500]; + + +// for life-line testing +int some_class_with_data::some_data::s_num_data = 0; diff --git a/pypy/module/cppyy/test/advancedcpp.h b/pypy/module/cppyy/test/advancedcpp.h new file mode 100644 --- /dev/null +++ b/pypy/module/cppyy/test/advancedcpp.h @@ -0,0 +1,197 @@ +#include + + +//=== +class base_class { // for simple inheritance testing +public: + base_class() { m_a = 1; m_da = 1.1; } + virtual ~base_class() {} + virtual int get_value() = 0; + +public: + int m_a; + double m_da; +}; + +class derived_class : public base_class { +public: + derived_class() { m_b = 2; m_db = 2.2;} + virtual int get_value() { return m_b; } + +public: + int m_b; + double m_db; +}; + + +//=== +class a_class {// for esoteric inheritance testing +public: + a_class() { m_a = 1; m_da = 1.1; } + virtual ~a_class() {} + virtual int get_value() = 0; + +public: + int m_a; + double m_da; +}; + +class b_class : public virtual a_class { +public: + b_class() { m_b = 2; m_db = 2.2;} + virtual int get_value() { return m_b; } + +public: + int m_b; + double m_db; +}; + +class c_class_1 : public virtual a_class, public virtual b_class { +public: + c_class_1() { m_c = 3; } + virtual int get_value() { return m_c; } + +public: + int m_c; +}; + +class c_class_2 : public virtual b_class, public virtual a_class { +public: + c_class_2() { m_c = 3; } + virtual int get_value() { return m_c; } + +public: + int m_c; +}; + +typedef c_class_2 c_class; + +class d_class : public virtual c_class, public virtual a_class { +public: + d_class() { m_d = 4; } + virtual int get_value() { return m_d; } + +public: + int m_d; +}; + +int get_a( a_class& a ); +int get_b( b_class& b ); +int get_c( c_class& c ); +int get_d( d_class& d ); + + +//=== +template< typename T > // for template testing +class T1 { +public: + T1( T t = T(0) ) : m_t1( t ) {} + T value() { return m_t1; } + +public: + T m_t1; +}; + +template< typename T > +class T2 { +public: + T m_t2; +}; + +namespace { + T1< int > tt1; + T2< T1< int > > tt2; +} + +// helpers for checking pass-by-ref +void set_int_through_ref(int& i, int val); +int pass_int_through_const_ref(const int& i); +void set_long_through_ref(long& l, long val); +long pass_long_through_const_ref(const long& l); +void set_double_through_ref(double& d, double val); +double pass_double_through_const_ref(const double& d); + + +//=== +class some_abstract_class {// to test abstract class handling +public: + virtual void a_virtual_method() = 0; +}; + +class some_concrete