From arigo at codespeak.net Thu Feb 1 00:09:25 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 1 Feb 2007 00:09:25 +0100 (CET) Subject: [pypy-svn] r37705 - in pypy/branch/jit-virtual-world/pypy/jit/timeshifter: . test Message-ID: <20070131230925.63F8510087@code0.codespeak.net> Author: arigo Date: Thu Feb 1 00:09:20 2007 New Revision: 37705 Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rvalue.py pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_exception.py pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_portal.py pypy/branch/jit-virtual-world/pypy/jit/timeshifter/vlist.py Log: (arre, pedronis, arigo) Don't merge jit states with exceptions and jit states without. Some related minor fixes done while looking at it. Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py ============================================================================== --- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py (original) +++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py Thu Feb 1 00:09:20 2007 @@ -761,6 +761,14 @@ #fz_virtualizables = ... set by freeze() def exactmatch(self, jitstate, outgoingvarboxes, memo): + if not memo.force_merge: + null1 = self.fz_exc_type_box.is_constant_nullptr() + box = jitstate.exc_type_box + null2 = (box.is_constant() and + not rvalue.ll_getvalue(box, llmemory.Address)) + if null1 != null2: + raise rvalue.DontMerge # a jit-with-exc. and a jit-without-exc. + fullmatch = True if not self.fz_frame.exactmatch(jitstate.frame, outgoingvarboxes, Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rvalue.py ============================================================================== --- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rvalue.py (original) +++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rvalue.py Thu Feb 1 00:09:20 2007 @@ -309,6 +309,9 @@ def is_constant_equal(self, box): return False + def is_constant_nullptr(self): + return False + class FrozenConst(FrozenValue): @@ -403,6 +406,9 @@ self.gv_const.revealconst(llmemory.Address) == box.genvar.revealconst(llmemory.Address)) + def is_constant_nullptr(self): + return not self.gv_const.revealconst(llmemory.Address) + def exactmatch(self, box, outgoingvarboxes, memo): assert isinstance(box, PtrRedBox) memo.partialdatamatch[box] = None # could do better @@ -410,7 +416,7 @@ if not memo.force_merge and not match: from pypy.jit.timeshifter.rcontainer import VirtualContainer if isinstance(box.content, VirtualContainer): - raise DontMerge + raise DontMerge # XXX recursive data structures? return match def unfreeze(self, incomingvarboxes, memo): @@ -426,7 +432,7 @@ if not memo.force_merge and not match: from pypy.jit.timeshifter.rcontainer import VirtualContainer if isinstance(box.content, VirtualContainer): - raise DontMerge + raise DontMerge # XXX recursive data structures? return match def unfreeze(self, incomingvarboxes, memo): @@ -454,7 +460,7 @@ if not memo.force_merge and not match: from pypy.jit.timeshifter.rcontainer import VirtualContainer if isinstance(box.content, VirtualContainer): - raise DontMerge + raise DontMerge # XXX recursive data structures? return match Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_exception.py ============================================================================== --- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_exception.py (original) +++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_exception.py Thu Feb 1 00:09:20 2007 @@ -122,3 +122,19 @@ self.timeshift_raises(ValueError, ll_function, [-3], [0], policy=P_OOPSPEC) + + def test_raise_or_return_virtual(self): + class A: + def __init__(self, n): + self.n = n + def g(x): + if x < 3: + raise ValueError + return A(x) + def ll_function(n): + a = g(n) + return a.n + + res = self.timeshift(ll_function, [5], [], policy=P_NOVIRTUAL) + assert res == 5 + self.check_insns(malloc=0) Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_portal.py ============================================================================== --- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_portal.py (original) +++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_portal.py Thu Feb 1 00:09:20 2007 @@ -2,7 +2,7 @@ from pypy.translator.translator import graphof from pypy.jit.timeshifter.test.test_timeshift import hannotate, getargtypes from pypy.jit.timeshifter.hrtyper import HintRTyper -from pypy.jit.timeshifter.test.test_timeshift import P_NOVIRTUAL +from pypy.jit.timeshifter.test.test_timeshift import P_NOVIRTUAL, StopAtXPolicy from pypy.jit.timeshifter.test.test_vlist import P_OOPSPEC from pypy.rpython.llinterp import LLInterpreter from pypy.objspace.flow.model import checkgraph, summary @@ -338,11 +338,13 @@ hint(o.__class__, promote=True) return o.double().get() - res = self.timeshift_from_portal(ll_function, ll_function, [5], policy=P_NOVIRTUAL) + res = self.timeshift_from_portal(ll_function, ll_function, [5], + policy=StopAtXPolicy(ll_make)) assert res == 10 self.check_insns(indirect_call=0, malloc=0) - res = self.timeshift_from_portal(ll_function, ll_function, [0], policy=P_NOVIRTUAL) + res = self.timeshift_from_portal(ll_function, ll_function, [0], + policy=StopAtXPolicy(ll_make)) assert res == ord('2') self.check_insns(indirect_call=0, malloc=0) Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/vlist.py ============================================================================== --- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/vlist.py (original) +++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/vlist.py Thu Feb 1 00:09:20 2007 @@ -3,6 +3,9 @@ from pypy.jit.timeshifter.rcontainer import cachedtype from pypy.jit.timeshifter import rvalue, rvirtualizable +from pypy.rpython.lltypesystem import lloperation +debug_print = lloperation.llop.debug_print + class ItemDesc(object): __metaclass__ = cachedtype @@ -160,6 +163,7 @@ boxes = self.item_boxes self.item_boxes = None + debug_print(lltype.Void, "FORCE LIST (%d items)" % (len(boxes),)) args_gv = [builder.rgenop.genconst(len(boxes))] gv_list = builder.genop_call(typedesc.tok_ll_newlist, typedesc.gv_ll_newlist, From cfbolz at codespeak.net Thu Feb 1 00:32:20 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 00:32:20 +0100 (CET) Subject: [pypy-svn] r37706 - pypy/dist/pypy/objspace/std/test Message-ID: <20070131233220.40F1010083@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 00:32:17 2007 New Revision: 37706 Modified: pypy/dist/pypy/objspace/std/test/test_shadowtracking.py Log: remove debug prints (they are uplevel and can therefore come through the py.test output capturing) Modified: pypy/dist/pypy/objspace/std/test/test_shadowtracking.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_shadowtracking.py (original) +++ pypy/dist/pypy/objspace/std/test/test_shadowtracking.py Thu Feb 1 00:32:17 2007 @@ -109,7 +109,6 @@ for i, a in enumerate(l): assert a.f() == 42 + i % 3 cache_counter = pypymagic.method_cache_counter("f") - print cache_counter assert cache_counter[1] >= 3 # should be (27, 3) assert sum(cache_counter) == 30 @@ -133,7 +132,6 @@ for i, a in enumerate(l): assert a.f() == 42 + i % 3 cache_counter = pypymagic.method_cache_counter("f") - print cache_counter assert cache_counter[1] >= 2 # should be (18, 2) assert sum(cache_counter) == 20 @@ -148,7 +146,6 @@ assert a.f() == 42 + i A.f = eval("lambda self: %s" % (42 + i + 1, )) cache_counter = pypymagic.method_cache_counter("f") - print cache_counter assert cache_counter == (0, 10) def test_subclasses(self): @@ -166,7 +163,6 @@ for i, a in enumerate(l): assert a.f() == 42 + (i % 3 == 1) cache_counter = pypymagic.method_cache_counter("f") - print cache_counter assert cache_counter[1] >= 3 # should be (27, 3) assert sum(cache_counter) == 30 From cfbolz at codespeak.net Thu Feb 1 00:53:30 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 00:53:30 +0100 (CET) Subject: [pypy-svn] r37707 - pypy/dist/pypy/objspace/std Message-ID: <20070131235330.12F4E10077@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 00:53:28 2007 New Revision: 37707 Modified: pypy/dist/pypy/objspace/std/stringobject.py Log: cleanups: make str_join use the rpython join. remove some commented out code Modified: pypy/dist/pypy/objspace/std/stringobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/stringobject.py (original) +++ pypy/dist/pypy/objspace/std/stringobject.py Thu Feb 1 00:53:28 2007 @@ -316,54 +316,28 @@ return W_ListObject(res_w) def str_join__String_ANY(space, w_self, w_list): - list = space.unpackiterable(w_list) + list_w = space.unpackiterable(w_list) str_w = space.str_w - if list: + if list_w: self = w_self._value - firstelem = 1 listlen = 0 reslen = 0 - #compute the length of the resulting string - for i in range(len(list)): - if not space.is_true(space.isinstance(list[i], space.w_str)): - if space.is_true(space.isinstance(list[i], space.w_unicode)): + l = [] + for i in range(len(list_w)): + w_s = list_w[i] + if not space.is_true(space.isinstance(w_s, space.w_str)): + if space.is_true(space.isinstance(w_s, space.w_unicode)): w_u = space.call_function(space.w_unicode, w_self) - return space.call_method(w_u, "join", space.newlist(list)) + return space.call_method(w_u, "join", space.newlist(list_w)) raise OperationError( space.w_TypeError, space.wrap("sequence item %d: expected string, %s " - "found"%(i, space.type(list[i]).name))) - reslen = reslen + len(str_w(list[i])) - listlen = listlen + 1 - - reslen = reslen + (listlen - 1) * len(self) - - #allocate the string buffer - res = [' '] * reslen - - pos = 0 - #fill in the string buffer - for w_item in list: - item = str_w(w_item) - if firstelem: - for i in range(len(item)): - res[i+pos] = item[i] - pos = pos + len(item) - firstelem = 0 - else: - for i in range(len(self)): - res[i+pos] = self[i] - pos = pos + len(self) - - for i in range(len(item)): - res[i+pos] = item[i] - pos = pos + len(item) - - return space.wrap("".join(res)) + "found" % (i, space.type(w_s).name))) + l.append(space.str_w(w_s)) + return space.wrap(self.join(l)) else: return space.wrap("") - def str_rjust__String_ANY_ANY(space, w_self, w_arg, w_fillchar): u_arg = space.int_w(w_arg) @@ -454,7 +428,7 @@ input = w_self._value sub = w_sub._value by = w_by._value - maxsplit = space.int_w(w_maxsplit) #I don't use it now + maxsplit = space.int_w(w_maxsplit) #print "from replace, input: %s, sub: %s, by: %s" % (input, sub, by) @@ -493,54 +467,6 @@ bufpos = bufpos + 1 return space.wrap("".join(buf)) -##def _find(self, sub, start, end, dir): - -## length = len(self) - -## #adjust_indicies -## if (end > length): -## end = length -## elif (end < 0): -## end += length -## if (end < 0): -## end = 0 -## if (start < 0): -## start += length -## if (start < 0): -## start = 0 - -## if dir > 0: -## if len(sub) == 0 and start < end: -## return start - -## end = end - len(sub) + 1 - -## for i in range(start, end): -## match = 1 -## for idx in range(len(sub)): -## if sub[idx] != self[idx+i]: -## match = 0 -## break -## if match: -## return i -## return -1 -## else: -## if len(sub) == 0 and start < end: -## return end - -## end = end - len(sub) - -## for j in range(end, start-1, -1): -## match = 1 -## for idx in range(len(sub)): -## if sub[idx] != self[idx+j]: -## match = 0 -## break -## if match: -## return j -## return -1 - - def _strip(space, w_self, w_chars, left, right): "internal function called by str_xstrip methods" u_self = w_self._value @@ -732,6 +658,7 @@ # cannot return w_self, in case it is a subclass of str return space.wrap(input) + result = [] buf = [' '] * width if len(input) > 0 and (input[0] == '+' or input[0] == '-'): buf[0] = input[0] From arigo at codespeak.net Thu Feb 1 03:36:28 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Thu, 1 Feb 2007 03:36:28 +0100 (CET) Subject: [pypy-svn] r37708 - in pypy/branch/jit-virtual-world/pypy/jit/timeshifter: . test Message-ID: <20070201023628.CB29D10069@code0.codespeak.net> Author: arigo Date: Thu Feb 1 03:36:26 2007 New Revision: 37708 Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py Log: (pedronis, arigo) Test case eventually designed (ha!) after a pypyjit assertion. Fix. Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py ============================================================================== --- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py (original) +++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py Thu Feb 1 03:36:26 2007 @@ -226,13 +226,16 @@ states_dic[key][index] = (frozen, newblock) if global_resumer is not None and global_resumer is not return_marker: + assert jitstate.resuming is None jitstate.curbuilder.log('start_new_block %s' % (key,)) greens_gv = jitstate.greens rgenop = jitstate.curbuilder.rgenop node = PromotionPathRoot(greens_gv, rgenop, frozen, newblock, global_resumer) - jitstate.frame.dispatchqueue.mergecounter = 0 + dispatchqueue = jitstate.frame.dispatchqueue + assert dispatchqueue.split_chain is None + dispatchqueue.clearlocalcaches() jitstate.promotion_path = PromotionPathMergesToSee(node, 0) #debug_print(lltype.Void, "PROMOTION ROOT") start_new_block._annspecialcase_ = "specialize:arglltype(2)" @@ -701,6 +704,9 @@ self.split_chain = None self.global_merge_chain = None self.return_chain = None + self.clearlocalcaches() + + def clearlocalcaches(self): self.mergecounter = 0 def clear(self): @@ -711,8 +717,8 @@ return BaseDispatchQueue attrnames = unrolling_iterable(attrnames) class DispatchQueue(BaseDispatchQueue): - def __init__(self): - BaseDispatchQueue.__init__(self) + def clearlocalcaches(self): + BaseDispatchQueue.clearlocalcaches(self) for name in attrnames: setattr(self, name, {}) # the new dicts have various types! return DispatchQueue Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py ============================================================================== --- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py (original) +++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py Thu Feb 1 03:36:26 2007 @@ -275,3 +275,27 @@ assert res == 6 self.check_oops(**{'newlist': 1, 'list.len': 1}) + def test_promote_bug_1(self): + def ll_function(x, y, z): + a = 17 + while True: + hint(None, global_merge_point=True) + y += 1 + + if a != 17: + z = -z + + if z > 0: + b = 1 - z + else: + b = 2 + y = -y + if b == 2: + hint(z, promote=True) + return y + z + a + a += z + + assert ll_function(1, 5, 8) == 22 + res = self.timeshift(ll_function, [1, 5, 8], [], + policy=P_NOVIRTUAL) + assert res == 22 From cfbolz at codespeak.net Thu Feb 1 09:54:29 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 09:54:29 +0100 (CET) Subject: [pypy-svn] r37709 - pypy/dist/pypy/objspace/std Message-ID: <20070201085429.CABC310053@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 09:54:28 2007 New Revision: 37709 Modified: pypy/dist/pypy/objspace/std/stringobject.py Log: make replace use rpython join. string * 0 = "". Modified: pypy/dist/pypy/objspace/std/stringobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/stringobject.py (original) +++ pypy/dist/pypy/objspace/std/stringobject.py Thu Feb 1 09:54:28 2007 @@ -429,43 +429,32 @@ sub = w_sub._value by = w_by._value maxsplit = space.int_w(w_maxsplit) + if maxsplit == 0: + return space.wrap(input) #print "from replace, input: %s, sub: %s, by: %s" % (input, sub, by) - #what do we have to replace? + if not sub: + upper = len(input) + if maxsplit > 0 and maxsplit < upper + 2: + upper = maxsplit - 1 + assert upper >= 0 + substrings = [""] + for i in range(upper): + c = input[i] + substrings.append(c) + substrings.append(input[upper:]) + return space.wrap(by.join(substrings)) startidx = 0 - indices = [] + substrings = [] foundidx = input.find(sub, startidx) while foundidx >= 0 and maxsplit != 0: - indices.append(foundidx) - if len(sub) == 0: - #so that we go forward, even if sub is empty - startidx = foundidx + 1 - else: - startidx = foundidx + len(sub) + substrings.append(input[startidx:foundidx]) + startidx = foundidx + len(sub) foundidx = input.find(sub, startidx) maxsplit = maxsplit - 1 - indiceslen = len(indices) - buf = [' '] * (len(input) - indiceslen * len(sub) + indiceslen * len(by)) - startidx = 0 - - #ok, so do it - bufpos = 0 - for i in range(indiceslen): - for j in range(startidx, indices[i]): - buf[bufpos] = input[j] - bufpos = bufpos + 1 - - for j in range(len(by)): - buf[bufpos] = by[j] - bufpos = bufpos + 1 - - startidx = indices[i] + len(sub) - - for j in range(startidx, len(input)): - buf[bufpos] = input[j] - bufpos = bufpos + 1 - return space.wrap("".join(buf)) + substrings.append(input[startidx:]) + return space.wrap(by.join(substrings)) def _strip(space, w_self, w_chars, left, right): "internal function called by str_xstrip methods" @@ -771,7 +760,7 @@ if e.match(space, space.w_TypeError): raise FailedToImplement raise - if mul < 0: + if mul <= 0: return space.wrap('') input = w_str._value input_len = len(input) From cfbolz at codespeak.net Thu Feb 1 10:37:19 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 10:37:19 +0100 (CET) Subject: [pypy-svn] r37710 - pypy/dist/pypy/objspace/std Message-ID: <20070201093719.1E6E210060@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 10:37:16 2007 New Revision: 37710 Modified: pypy/dist/pypy/objspace/std/listobject.py Log: yet another small cleanup: use RPython's list.reverse Modified: pypy/dist/pypy/objspace/std/listobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/listobject.py (original) +++ pypy/dist/pypy/objspace/std/listobject.py Thu Feb 1 10:37:16 2007 @@ -442,15 +442,6 @@ # Reverse a slice of a list in place, from lo up to (exclusive) hi. # (used in sort) -def _reverse_slice(lis, lo, hi): - hi -= 1 - while lo < hi: - t = lis[lo] - lis[lo] = lis[hi] - lis[hi] = t - lo += 1 - hi -= 1 - class KeyContainer(baseobjspace.W_Root): def __init__(self, w_key, w_item): self.w_key = w_key @@ -530,14 +521,14 @@ # Reverse sort stability achieved by initially reversing the list, # applying a stable forward sort, then reversing the final result. if has_reverse: - _reverse_slice(sorter.list, 0, sorter.listlength) + sorter.list.reverse() # perform the sort sorter.sort() # reverse again if has_reverse: - _reverse_slice(sorter.list, 0, sorter.listlength) + sorter.list.reverse() finally: # unwrap each item if needed From cfbolz at codespeak.net Thu Feb 1 11:13:27 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 11:13:27 +0100 (CET) Subject: [pypy-svn] r37712 - pypy/dist/pypy/objspace/std Message-ID: <20070201101327.C500410060@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 11:13:12 2007 New Revision: 37712 Modified: pypy/dist/pypy/objspace/std/floatobject.py pypy/dist/pypy/objspace/std/intobject.py pypy/dist/pypy/objspace/std/longobject.py Log: remove strange and quite old comments and commented out code Modified: pypy/dist/pypy/objspace/std/floatobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/floatobject.py (original) +++ pypy/dist/pypy/objspace/std/floatobject.py Thu Feb 1 11:13:12 2007 @@ -4,12 +4,6 @@ from pypy.objspace.std.longobject import W_LongObject from pypy.rlib.rarithmetic import ovfcheck_float_to_int, intmask, isinf -############################################################## -# for the time being, all calls that are made to some external -# libraries in the floatobject.c, calls are made into the -# python math library -############################################################## - import math from pypy.objspace.std.intobject import W_IntObject @@ -280,11 +274,6 @@ truediv__Float_Float = div__Float_Float -# avoid space.getitem for a basic operation -##def floordiv__Float_Float(space, w_float1, w_float2): -## w_t = divmod__Float_Float(space, w_float1, w_float2) -## return space.getitem(w_t, space.wrap(0)) - def floordiv__Float_Float(space, w_float1, w_float2): w_div, w_mod = _divmod_w(space, w_float1, w_float2) return w_div @@ -397,17 +386,6 @@ def nonzero__Float(space, w_float): return space.newbool(w_float.floatval != 0.0) -######## coercion must be done later -later = """ -def float_coerce(space, w_float): - if w_float.__class__ == W_FloatObject: - return w_float - else: - return W_FloatObject(w_float.floatval) - -StdObjSpace.coerce.register(float_coerce, W_FloatObject) -""" - def getnewargs__Float(space, w_float): return space.newtuple([W_FloatObject(w_float.floatval)]) Modified: pypy/dist/pypy/objspace/std/intobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/intobject.py (original) +++ pypy/dist/pypy/objspace/std/intobject.py Thu Feb 1 11:13:12 2007 @@ -28,14 +28,6 @@ registerimplementation(W_IntObject) -""" -XXX not implemented: -free list -FromString -FromUnicode -print -""" - def int_w__Int(space, w_int1): return int(w_int1.intval) @@ -324,19 +316,6 @@ res = a | b return wrapint(space, res) -# coerce is not wanted -## -##static int -##coerce__Int(PyObject **pv, PyObject **pw) -##{ -## if (PyInt_Check(*pw)) { -## Py_INCREF(*pv); -## Py_INCREF(*pw); -## return 0; -## } -## return 1; /* Can't do it */ -##} - # int__Int is supposed to do nothing, unless it has # a derived integer object, where it should return # an exact one. @@ -346,14 +325,6 @@ a = w_int1.intval return wrapint(space, a) -""" -# Not registered -def long__Int(space, w_int1): - a = w_int1.intval - x = long(a) ## XXX should this really be done so? - return space.newlong(x) -""" - def float__Int(space, w_int1): a = w_int1.intval x = float(a) Modified: pypy/dist/pypy/objspace/std/longobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/longobject.py (original) +++ pypy/dist/pypy/objspace/std/longobject.py Thu Feb 1 11:13:12 2007 @@ -205,7 +205,7 @@ def nonzero__Long(space, w_long): return space.newbool(w_long.num.tobool()) -def invert__Long(space, w_long): #Implement ~x as -(x + 1) +def invert__Long(space, w_long): return W_LongObject(w_long.num.invert()) def lshift__Long_Long(space, w_long1, w_long2): From fijal at codespeak.net Thu Feb 1 11:33:39 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Feb 2007 11:33:39 +0100 (CET) Subject: [pypy-svn] r37713 - pypy/dist/pypy/translator/js Message-ID: <20070201103339.1489A10063@code0.codespeak.net> Author: fijal Date: Thu Feb 1 11:33:36 2007 New Revision: 37713 Modified: pypy/dist/pypy/translator/js/function.py Log: Kill unused imports Modified: pypy/dist/pypy/translator/js/function.py ============================================================================== --- pypy/dist/pypy/translator/js/function.py (original) +++ pypy/dist/pypy/translator/js/function.py Thu Feb 1 11:33:36 2007 @@ -7,12 +7,8 @@ from pypy.rpython.lltypesystem.lltype import Signed, Unsigned, Void, Bool, Float from pypy.rpython.lltypesystem.lltype import SignedLongLong, UnsignedLongLong from pypy.rpython.ootypesystem import ootype -from pypy.translator.cli.option import getoption -from pypy.translator.cli.cts import CTS -from pypy.translator.cli.opcodes import opcodes from pypy.translator.oosupport.metavm import Generator,InstructionList from pypy.translator.cli.node import Node -from pypy.translator.cli.class_ import Class from pypy.translator.js.log import log from types import FunctionType From fijal at codespeak.net Thu Feb 1 11:34:34 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Feb 2007 11:34:34 +0100 (CET) Subject: [pypy-svn] r37714 - pypy/dist/pypy/doc/js Message-ID: <20070201103434.515FA10074@code0.codespeak.net> Author: fijal Date: Thu Feb 1 11:34:32 2007 New Revision: 37714 Modified: pypy/dist/pypy/doc/js/todo.txt Log: Update a bit (means more work :-( Modified: pypy/dist/pypy/doc/js/todo.txt ============================================================================== --- pypy/dist/pypy/doc/js/todo.txt (original) +++ pypy/dist/pypy/doc/js/todo.txt Thu Feb 1 11:34:32 2007 @@ -14,3 +14,28 @@ - unnecessary jumps * Provide some high level widgets-like functionality + +* Adhere to a new external function interface + +* Support bound methods as arguments for callbacks. + + Idea is to provide following: + + - if you pass a bound method to a callback, this method is called + with previously bound self + - if you provide an unbound method for a callback, this is an error, + unless class is proper to the callback object (or high level class + apropriate for that DOM object), in which case a bound method is + called with apropriate self. + + I'm quite sure this can be done using RPython, but I'm totally unsure + how much effort this will require :-) (as usuall) + +* Cleanup of parent namespace (put all builtin functions into it's + own namespace?) + +* Dict support is very limited (only string keys right now) + +* Implement possible raising expressions int\_add\_ovf ie. + +* Make JS backend complete From ericvrp at codespeak.net Thu Feb 1 11:42:30 2007 From: ericvrp at codespeak.net (ericvrp at codespeak.net) Date: Thu, 1 Feb 2007 11:42:30 +0100 (CET) Subject: [pypy-svn] r37715 - in pypy/dist/pypy/translator/llvm: . module test Message-ID: <20070201104230.1ECF71006E@code0.codespeak.net> Author: ericvrp Date: Thu Feb 1 11:42:28 2007 New Revision: 37715 Modified: pypy/dist/pypy/translator/llvm/buildllvm.py pypy/dist/pypy/translator/llvm/externs2ll.py pypy/dist/pypy/translator/llvm/gc.py pypy/dist/pypy/translator/llvm/module/support.py pypy/dist/pypy/translator/llvm/test/runtest.py Log: Complete support for llvm-gcc4 and llvm2 Modified: pypy/dist/pypy/translator/llvm/buildllvm.py ============================================================================== --- pypy/dist/pypy/translator/llvm/buildllvm.py (original) +++ pypy/dist/pypy/translator/llvm/buildllvm.py Thu Feb 1 11:42:28 2007 @@ -15,13 +15,15 @@ return False return True -def exe_version(exe): +def _exe_version(exe): v = os.popen(exe + ' -version 2>&1').read() v = ''.join([c for c in v if c.isdigit()]) v = int(v) / 10.0 return v -def exe_version2(exe): +llvm_version = _exe_version('llvm-as') + +def _exe_version2(exe): v = os.popen(exe + ' --version 2>&1').read() i = v.index(')') v = v[i+2:].split()[0].split('.') @@ -29,6 +31,9 @@ v = float(major) + float(minor) / 10.0 return v +gcc_version = _exe_version2('gcc') +llvm_gcc_version = _exe_version2('llvm-gcc') + def optimizations(simple, use_gcc): if simple: @@ -81,8 +86,7 @@ # run llvm assembler and optimizer simple_optimizations = not optimize opts = optimizations(simple_optimizations, use_gcc) - v = exe_version('llvm-as') - if v < 2.0: + if llvm_version < 2.0: cmds = ["llvm-as < %s.ll | opt %s -f -o %s.bc" % (b, opts, b)] else: #we generate 1.x .ll files, so upgrade these first cmds = ["llvm-upgrade < %s.ll | llvm-as | opt %s -f -o %s.bc" % (b, opts, b)] Modified: pypy/dist/pypy/translator/llvm/externs2ll.py ============================================================================== --- pypy/dist/pypy/translator/llvm/externs2ll.py (original) +++ pypy/dist/pypy/translator/llvm/externs2ll.py Thu Feb 1 11:42:28 2007 @@ -7,7 +7,7 @@ from pypy.rpython.rmodel import inputconst from pypy.rpython.lltypesystem import lltype from pypy.translator.llvm.codewriter import DEFAULT_CCONV -from pypy.translator.llvm.buildllvm import exe_version2 +from pypy.translator.llvm.buildllvm import llvm_gcc_version from pypy.tool.udir import udir @@ -40,13 +40,10 @@ plain = filename[:-2] includes = get_incdirs() - global _llvm_gcc_version - if not _llvm_gcc_version: - _llvm_gcc_version = exe_version2('llvm-gcc') - if _llvm_gcc_version < 4.0: + if llvm_gcc_version < 4.0: emit_llvm = '' else: - emit_llvm = '-emit-llvm' + emit_llvm = '-emit-llvm -O3' cmd = "llvm-gcc %s %s -S %s.c -o %s.ll 2>&1" % ( includes, emit_llvm, plain, plain) Modified: pypy/dist/pypy/translator/llvm/gc.py ============================================================================== --- pypy/dist/pypy/translator/llvm/gc.py (original) +++ pypy/dist/pypy/translator/llvm/gc.py Thu Feb 1 11:42:28 2007 @@ -5,6 +5,12 @@ from pypy.translator.llvm.log import log log = log.gc +from pypy.translator.llvm.buildllvm import llvm_version +if llvm_version >= 2.0: + postfix = '.i32' +else: + postfix = '' + def have_boehm(): import distutils.sysconfig from os.path import exists @@ -151,7 +157,7 @@ # malloc_size is unsigned right now codewriter.malloc(targetvar, "sbyte", size) - codewriter.call(None, 'void', '%llvm.memset', + codewriter.call(None, 'void', '%llvm.memset' + postfix, ['sbyte*', 'ubyte', uword, uword], [targetvar, 0, size, boundary_size], cconv='ccc') @@ -204,7 +210,7 @@ codewriter.call(targetvar, 'sbyte*', fnname, [word], [sizei]) if atomic: - codewriter.call(None, 'void', '%llvm.memset', + codewriter.call(None, 'void', '%llvm.memset' + postfix, ['sbyte*', 'ubyte', uword, uword], [targetvar, 0, size, boundary_size], cconv='ccc') Modified: pypy/dist/pypy/translator/llvm/module/support.py ============================================================================== --- pypy/dist/pypy/translator/llvm/module/support.py (original) +++ pypy/dist/pypy/translator/llvm/module/support.py Thu Feb 1 11:42:28 2007 @@ -1,12 +1,18 @@ +from pypy.translator.llvm.buildllvm import llvm_version +if llvm_version >= 2.0: + postfix = '.i32' +else: + postfix = '' extdeclarations = """ %last_exception_type = internal global %RPYTHON_EXCEPTION_VTABLE* null %last_exception_value = internal global %RPYTHON_EXCEPTION* null declare ccc uint %strlen(sbyte*) -declare ccc void %llvm.memset(sbyte*, ubyte, UWORD, UWORD) -declare ccc void %llvm.memcpy(sbyte*, sbyte*, UWORD, UWORD) +declare ccc void %llvm.memsetPOSTFIX(sbyte*, ubyte, UWORD, UWORD) +declare ccc void %llvm.memcpyPOSTFIX(sbyte*, sbyte*, UWORD, UWORD) """ +extdeclarations = extdeclarations.replace('POSTFIX', postfix) extfunctions = """ internal fastcc sbyte* %RPyString_AsString(%RPyString* %structstring) { @@ -36,7 +42,7 @@ %rpystrptr = getelementptr %RPyString* %rpy, int 0, uint 1, uint 1 %rpystr = cast [0 x sbyte]* %rpystrptr to sbyte* - call ccc void %llvm.memcpy(sbyte* %rpystr, sbyte* %s, UWORD %lenuword, UWORD 0) + call ccc void %llvm.memcpyPOSTFIX(sbyte* %rpystr, sbyte* %s, UWORD %lenuword, UWORD 0) ret %RPyString* %rpy } @@ -78,6 +84,7 @@ } """ +extfunctions = extfunctions.replace('POSTFIX', postfix) from sys import maxint if maxint != 2**31-1: Modified: pypy/dist/pypy/translator/llvm/test/runtest.py ============================================================================== --- pypy/dist/pypy/translator/llvm/test/runtest.py (original) +++ pypy/dist/pypy/translator/llvm/test/runtest.py Thu Feb 1 11:42:28 2007 @@ -1,10 +1,9 @@ import py from pypy.tool import isolate from pypy.translator.llvm.genllvm import genllvm_compile -from pypy.translator.llvm.buildllvm import llvm_is_on_path, exe_version, exe_version2 +from pypy.translator.llvm.buildllvm import llvm_is_on_path, llvm_version, gcc_version optimize_tests = False -MINIMUM_LLVM_VERSION = 1.7 -MAXIMUM_LLVM_VERSION = 2.0 +MINIMUM_LLVM_VERSION = 1.9 ext_modules = [] @@ -33,21 +32,15 @@ if not llvm_is_on_path(): py.test.skip("could not find one of llvm-as or llvm-gcc") return False - v = exe_version('llvm-as') - if v < MINIMUM_LLVM_VERSION: + if llvm_version < MINIMUM_LLVM_VERSION: py.test.skip("llvm version not up-to-date (found " - "%.1f, should be >= %.1f)" % (v, MINIMUM_LLVM_VERSION)) - return False - elif v >= MAXIMUM_LLVM_VERSION: - py.test.skip("llvm version %.1f and higher are not yet supported (found %.1f)" % ( - MAXIMUM_LLVM_VERSION, v)) + "%.1f, should be >= %.1f)" % (llvm_version, MINIMUM_LLVM_VERSION)) return False return True def gcc3_test(): - v = exe_version2('gcc') - if int(v) != 3: - py.test.skip("test required gcc version 3 (found version %.1f)" % v) + if int(gcc_version) != 3: + py.test.skip("test required gcc version 3 (found version %.1f)" % gcc_version) return False return True From antocuni at codespeak.net Thu Feb 1 11:44:31 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 1 Feb 2007 11:44:31 +0100 (CET) Subject: [pypy-svn] r37716 - pypy/dist/pypy/translator/cli Message-ID: <20070201104431.0CB5110070@code0.codespeak.net> Author: antocuni Date: Thu Feb 1 11:44:30 2007 New Revision: 37716 Modified: pypy/dist/pypy/translator/cli/rte.py Log: Check for the presence of 'gmcs' only when really needed, not at import time. Thanks to fijal for the bug report. Modified: pypy/dist/pypy/translator/cli/rte.py ============================================================================== --- pypy/dist/pypy/translator/cli/rte.py (original) +++ pypy/dist/pypy/translator/cli/rte.py Thu Feb 1 11:44:30 2007 @@ -27,7 +27,10 @@ ALIAS = None FLAGS = [] DEPENDENCIES = [] - COMPILER = SDK.csc() + + def get_COMPILER(cls): + return SDK.csc() + get_COMPILER = classmethod(get_COMPILER) def get(cls): for dep in cls.DEPENDENCIES: @@ -53,7 +56,7 @@ log.red("Compiling %s" % (cls.ALIAS or cls.OUTPUT)) oldcwd = os.getcwd() os.chdir(SRC_DIR) - compiler = subprocess.Popen([cls.COMPILER] + cls.FLAGS + ['/out:%s' % out] + sources, + compiler = subprocess.Popen([cls.get_COMPILER()] + cls.FLAGS + ['/out:%s' % out] + sources, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = compiler.communicate() retval = compiler.wait() @@ -68,8 +71,11 @@ class MainStub(Target): SOURCES = ['stub/main.il'] OUTPUT = 'main.exe' - COMPILER = SDK.ilasm() + def get_COMPILER(cls): + return SDK.ilasm() + get_COMPILER = classmethod(get_COMPILER) + class FrameworkDLL(Target): SOURCES = ['pypylib.cs', 'll_os.cs', 'errno.cs', 'll_math.cs'] OUTPUT = 'pypylib.dll' From fijal at codespeak.net Thu Feb 1 11:59:13 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Feb 2007 11:59:13 +0100 (CET) Subject: [pypy-svn] r37718 - pypy/dist/pypy/lib/distributed Message-ID: <20070201105913.563B510077@code0.codespeak.net> Author: fijal Date: Thu Feb 1 11:59:12 2007 New Revision: 37718 Modified: pypy/dist/pypy/lib/distributed/protocol.py Log: Kill some dead code Modified: pypy/dist/pypy/lib/distributed/protocol.py ============================================================================== --- pypy/dist/pypy/lib/distributed/protocol.py (original) +++ pypy/dist/pypy/lib/distributed/protocol.py Thu Feb 1 11:59:12 2007 @@ -363,13 +363,7 @@ def test_env(exported_names): from stackless import channel, tasklet, run - # XXX: This is a hack, proper support for recursive type is needed inp, out = channel(), channel() remote_protocol = RemoteProtocol(inp.send, out.receive, exported_names) t = tasklet(remote_loop)(remote_protocol) return RemoteProtocol(out.send, inp.receive) - -#def bootstrap(gw): -# import py -# import sys -# return gw.remote_exec(py.code.Source(sys.modules[__name__], "remote_loop(channel.send, channel.receive)")) From fijal at codespeak.net Thu Feb 1 12:13:50 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Thu, 1 Feb 2007 12:13:50 +0100 (CET) Subject: [pypy-svn] r37719 - in pypy/dist/pypy/translator: . goal js js/test test tool transformer Message-ID: <20070201111350.31D2A10081@code0.codespeak.net> Author: fijal Date: Thu Feb 1 12:13:47 2007 New Revision: 37719 Removed: pypy/dist/pypy/translator/js/test/test_transformer.py pypy/dist/pypy/translator/transformer/ Modified: pypy/dist/pypy/translator/driver.py pypy/dist/pypy/translator/goal/translate.py pypy/dist/pypy/translator/js/main.py pypy/dist/pypy/translator/js/test/runtest.py pypy/dist/pypy/translator/test/test_driver.py pypy/dist/pypy/translator/tool/pdbplus.py Log: Kill transformer, it seems to be louse attempt to make RPython exceptions. Modified: pypy/dist/pypy/translator/driver.py ============================================================================== --- pypy/dist/pypy/translator/driver.py (original) +++ pypy/dist/pypy/translator/driver.py Thu Feb 1 12:13:47 2007 @@ -29,7 +29,6 @@ 'translation.fork_before': None, 'translation.backendopt.raisingop2direct_call' : False, 'translation.backendopt.merge_if_blocks': True, - 'translation.debug_transform' : False, } @@ -275,11 +274,6 @@ s = annotator.build_types(self.entry_point, self.inputtypes) - if self.config.translation.debug_transform: - from pypy.translator.transformer.debug import DebugTransformer - dt = DebugTransformer(translator) - dt.transform_all() - self.sanity_check_annotation() if self.standalone and s.knowntype != int: raise Exception("stand-alone program entry point must return an " @@ -550,8 +544,7 @@ def task_source_js(self): from pypy.translator.js.js import JS self.gen = JS(self.translator, functions=[self.entry_point], - stackless=self.config.translation.stackless, - use_debug=self.config.translation.debug_transform) + stackless=self.config.translation.stackless) filename = self.gen.write_source() self.log.info("Wrote %s" % (filename,)) task_source_js = taskdef(task_source_js, Modified: pypy/dist/pypy/translator/goal/translate.py ============================================================================== --- pypy/dist/pypy/translator/goal/translate.py (original) +++ pypy/dist/pypy/translator/goal/translate.py Thu Feb 1 12:13:47 2007 @@ -77,8 +77,6 @@ 'translation.cc': None, 'translation.profopt': None, 'translation.output': None, - - 'translation.debug_transform': False, } import py Modified: pypy/dist/pypy/translator/js/main.py ============================================================================== --- pypy/dist/pypy/translator/js/main.py (original) +++ pypy/dist/pypy/translator/js/main.py Thu Feb 1 12:13:47 2007 @@ -20,9 +20,6 @@ default=False, cmdline="--view"), BoolOption("use_pdb", "Use debugger", default=False, cmdline="--pdb"), - BoolOption("debug_transform", - "Use !EXPERIMENTAL! debug transform to produce tracebacks", - default=False, cmdline="-d --debug"), StrOption("output", "File to save results (default output.js)", default="output.js", cmdline="--output")]) @@ -65,7 +62,6 @@ import %(module_name)s from pypy.translator.js.helper import __show_traceback -from pypy.translator.transformer.debug import traceback_handler from pypy.rlib.nonconst import NonConstant as NonConst %(function_defs)s @@ -91,7 +87,7 @@ function_base = "%(module_name)s.%(fun_name)s(%(args)s)" wrapped_function_base = "%(fun_name)s(%(args)s)" -def get_source_ssf(mod, module_name, function_names, use_debug=True): +def get_source_ssf(mod, module_name, function_names): #source_ssf = "\n".join(["import %s" % module_name, "def some_strange_function_which_will_never_be_called():"] + [" "+\ # module_name+"."+fun_name+get_args(mod.__dict__[fun_name]) for fun_name in function_names]) function_list = [] @@ -99,12 +95,7 @@ for fun_name in function_names: args = get_args(mod.__dict__[fun_name]) arg_names = get_arg_names(mod.__dict__[fun_name]) - if not use_debug: - base = function_base - else: - base = wrapped_function_base - function_def_list.append(py.code.Source(wrapped_function_def_base % - locals())) + base = function_base function_list.append(py.code.Source(base % locals())) function_defs = "\n\n".join([str(i) for i in function_def_list]) functions = "\n".join([str(i.indent()) for i in function_list]) @@ -140,16 +131,13 @@ if func_code.func_code.co_argcount > 0 and func_code.func_code. \ co_argcount != lgt: raise BadSignature("Function %s does not have default arguments" % func_name) - source_ssf = get_source_ssf(mod, module_name, function_names, - jsconfig.debug_transform) + source_ssf = get_source_ssf(mod, module_name, function_names) exec(source_ssf) in globals() # now we gonna just cut off not needed function # XXX: Really do that #options = optparse.Values(defaults=DEFAULT_OPTIONS) - #options.debug_transform = opts.debug_transform from pypy.config.pypyoption import get_pypy_config config = get_pypy_config(translating=True) - config.translation.debug_transform = jsconfig.debug_transform driver = TranslationDriver(config=config) try: driver.setup(some_strange_function_which_will_never_be_called, [], policy = JsPolicy()) Modified: pypy/dist/pypy/translator/js/test/runtest.py ============================================================================== --- pypy/dist/pypy/translator/js/test/runtest.py (original) +++ pypy/dist/pypy/translator/js/test/runtest.py Thu Feb 1 12:13:47 2007 @@ -11,7 +11,6 @@ from pypy.translator.js.log import log from pypy.conftest import option from pypy.rpython.test.tool import BaseRtypingTest, OORtypeMixin -from pypy.translator.transformer.debug import DebugTransformer from pypy.rlib.nonconst import NonConstant from pypy.rpython.llinterp import LLException @@ -28,7 +27,7 @@ return True class compile_function(object): - def __init__(self, function, annotations, stackless=False, view=False, html=None, is_interactive=False, root = None, run_browser = True, debug_transform = False): + def __init__(self, function, annotations, stackless=False, view=False, html=None, is_interactive=False, root = None, run_browser = True): if not use_browsertest and not _CLI_is_on_path(): py.test.skip('Javascript CLI (js) not found') @@ -37,8 +36,6 @@ t = TranslationContext() ann = t.buildannotator() ann.build_types(function, annotations) - if debug_transform: - DebugTransformer(t).transform_all() if view or option.view: t.view() t.buildrtyper(type_system="ootype").specialize() Modified: pypy/dist/pypy/translator/test/test_driver.py ============================================================================== --- pypy/dist/pypy/translator/test/test_driver.py (original) +++ pypy/dist/pypy/translator/test/test_driver.py Thu Feb 1 12:13:47 2007 @@ -34,8 +34,7 @@ assert td.backend_select_goals(['backendopt_lltype']) == [ 'backendopt_lltype'] - assert cmpl(td.exposed, - ['annotate', 'backendopt_lltype', + assert cmpl(td.exposed, ['annotate', 'backendopt_lltype', 'backendopt_ootype', 'llinterpret_lltype', 'rtype_ootype', 'rtype_lltype', 'source_cl', 'source_js', @@ -55,7 +54,8 @@ assert td.backend_select_goals(['backendopt_lltype']) == [ 'backendopt_lltype'] - assert cmpl(td.exposed, - ['annotate', 'backendopt', 'llinterpret', 'rtype', 'source_c', + expected = ['annotate', 'backendopt', 'llinterpret', 'rtype', 'source_c', 'source_llvm', 'compile_c', 'compile_llvm', 'run_llvm', - 'run_c']) + 'run_c'] + + assert cmpl(td.exposed, expected) Modified: pypy/dist/pypy/translator/tool/pdbplus.py ============================================================================== --- pypy/dist/pypy/translator/tool/pdbplus.py (original) +++ pypy/dist/pypy/translator/tool/pdbplus.py Thu Feb 1 12:13:47 2007 @@ -337,7 +337,7 @@ def do_flowg(self, arg): - """callg obj + """flowg obj show flow graph for function obj, obj can be an expression or a dotted name (in which case prefixing with some packages in pypy is tried (see help pypyprefixes))""" from pypy.translator.tool import graphpage From pedronis at codespeak.net Thu Feb 1 12:57:37 2007 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Thu, 1 Feb 2007 12:57:37 +0100 (CET) Subject: [pypy-svn] r37722 - pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test Message-ID: <20070201115737.BD57F10074@code0.codespeak.net> Author: pedronis Date: Thu Feb 1 12:57:36 2007 New Revision: 37722 Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py Log: a test showing how pypyjit explode now, we need to be much more careful about exception and exception code paths. Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py ============================================================================== --- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py (original) +++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_promotion.py Thu Feb 1 12:57:36 2007 @@ -1,10 +1,11 @@ import py from pypy.rpython.lltypesystem import lltype from pypy.jit.timeshifter.test.test_timeshift import TimeshiftingTests +from pypy.jit.timeshifter.test.test_timeshift import StopAtXPolicy from pypy.jit.timeshifter.test.test_timeshift import P_NOVIRTUAL from pypy.jit.timeshifter.test.test_vlist import P_OOPSPEC from pypy.rlib.objectmodel import hint - +from pypy.rpython.module.support import LLSupport class TestPromotion(TimeshiftingTests): @@ -299,3 +300,38 @@ res = self.timeshift(ll_function, [1, 5, 8], [], policy=P_NOVIRTUAL) assert res == 22 + + def test_raise_result_mixup(self): + py.test.skip("WIP") + def w(x): + pass + class E(Exception): + def __init__(self, x): + self.x = x + def o(x): + if x < 0: + e = E(x) + w(e) + raise e + return x + def ll_function(c, x): + i = 0 + while True: + hint(None, global_merge_point=True) + op = c[i] + hint(op, concrete=True) + if op == 'e': + break + elif op == 'o': + x = o(x) + x = hint(x, promote=True) + i = x + r = hint(i, variable=True) + return r + ll_function.convert_arguments = [LLSupport.to_rstr, int] + + assert ll_function("oe", 1) == 1 + + res = self.timeshift(ll_function, ["oe", 1], [], + policy=StopAtXPolicy(w)) + res == 1 From antocuni at codespeak.net Thu Feb 1 14:53:53 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 1 Feb 2007 14:53:53 +0100 (CET) Subject: [pypy-svn] r37727 - pypy/dist/pypy/translator Message-ID: <20070201135353.23D591006F@code0.codespeak.net> Author: antocuni Date: Thu Feb 1 14:53:52 2007 New Revision: 37727 Modified: pypy/dist/pypy/translator/geninterplevel.py Log: The __file__ attribute of the CLR module from pythonnet is None. Handle this case. Modified: pypy/dist/pypy/translator/geninterplevel.py ============================================================================== --- pypy/dist/pypy/translator/geninterplevel.py (original) +++ pypy/dist/pypy/translator/geninterplevel.py Thu Feb 1 14:53:52 2007 @@ -460,7 +460,7 @@ return name def is_module_builtin(self, mod): - if not hasattr(mod, "__file__"): + if not hasattr(mod, "__file__") or mod.__file__ is None: return True if not (mod.__file__.endswith('.pyc') or mod.__file__.endswith('.py') or From antocuni at codespeak.net Thu Feb 1 14:57:46 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 1 Feb 2007 14:57:46 +0100 (CET) Subject: [pypy-svn] r37730 - in pypy/dist/pypy/module/clr: . test Message-ID: <20070201135746.49E8610070@code0.codespeak.net> Author: antocuni Date: Thu Feb 1 14:57:45 2007 New Revision: 37730 Modified: pypy/dist/pypy/module/clr/interp_clr.py pypy/dist/pypy/module/clr/test/test_clr.py Log: Always use the same wrapper class for each .NET class. Modified: pypy/dist/pypy/module/clr/interp_clr.py ============================================================================== --- pypy/dist/pypy/module/clr/interp_clr.py (original) +++ pypy/dist/pypy/module/clr/interp_clr.py Thu Feb 1 14:57:45 2007 @@ -135,8 +135,28 @@ w_indexers = wrap_list_of_tuples(space, indexers) return w_properties, w_indexers +class _CliClassCache: + def __init__(self): + self.cache = {} + + def put(self, fullname, cls): + assert fullname not in self.cache + self.cache[fullname] = cls + + def get(self, fullname): + return self.cache.get(fullname, None) +CliClassCache = _CliClassCache() + def load_cli_class(space, namespace, classname): fullname = '%s.%s' % (namespace, classname) + w_cls = CliClassCache.get(fullname) + if w_cls is None: + w_cls = build_cli_class(space, namespace, classname, fullname) + CliClassCache.put(fullname, w_cls) + return w_cls +load_cli_class.unwrap_spec = [ObjSpace, str, str] + +def build_cli_class(space, namespace, classname, fullname): b_type = System.Type.GetType(fullname) w_staticmethods, w_methods = get_methods(space, b_type) w_properties, w_indexers = get_properties(space, b_type) @@ -147,7 +167,6 @@ w_methods, w_properties, w_indexers) -load_cli_class.unwrap_spec = [ObjSpace, str, str] class W_CliObject(Wrappable): Modified: pypy/dist/pypy/module/clr/test/test_clr.py ============================================================================== --- pypy/dist/pypy/module/clr/test/test_clr.py (original) +++ pypy/dist/pypy/module/clr/test/test_clr.py Thu Feb 1 14:57:45 2007 @@ -11,6 +11,12 @@ max_index = obj.call_method('Add', [42]) assert max_index == 0 + def test_cache(self): + import clr + ArrayList = clr.load_cli_class('System.Collections', 'ArrayList') + ArrayList2 = clr.load_cli_class('System.Collections', 'ArrayList') + assert ArrayList is ArrayList2 + def test_ArrayList(self): import clr ArrayList = clr.load_cli_class('System.Collections', 'ArrayList') From antocuni at codespeak.net Thu Feb 1 15:31:26 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 1 Feb 2007 15:31:26 +0100 (CET) Subject: [pypy-svn] r37734 - pypy/dist/pypy/translator/cli Message-ID: <20070201143126.005221008E@code0.codespeak.net> Author: antocuni Date: Thu Feb 1 15:31:25 2007 New Revision: 37734 Modified: pypy/dist/pypy/translator/cli/dotnet.py Log: Pay attention to unicode objects. Modified: pypy/dist/pypy/translator/cli/dotnet.py ============================================================================== --- pypy/dist/pypy/translator/cli/dotnet.py (original) +++ pypy/dist/pypy/translator/cli/dotnet.py Thu Feb 1 15:31:25 2007 @@ -317,7 +317,7 @@ return CLR.System.Boolean(x) elif t is float: return CLR.System.Double(x) - elif t is str: + elif t is str or t is unicode: if len(x) == 1: return CLR.System.Char(x) else: From antocuni at codespeak.net Thu Feb 1 15:32:39 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 1 Feb 2007 15:32:39 +0100 (CET) Subject: [pypy-svn] r37735 - in pypy/dist/pypy/module/clr: . test Message-ID: <20070201143239.50D7E10095@code0.codespeak.net> Author: antocuni Date: Thu Feb 1 15:32:38 2007 New Revision: 37735 Modified: pypy/dist/pypy/module/clr/boxing_rules.py pypy/dist/pypy/module/clr/interp_clr.py pypy/dist/pypy/module/clr/test/test_clr.py Log: Add rules for converting strings from and to .NET Modified: pypy/dist/pypy/module/clr/boxing_rules.py ============================================================================== --- pypy/dist/pypy/module/clr/boxing_rules.py (original) +++ pypy/dist/pypy/module/clr/boxing_rules.py Thu Feb 1 15:32:38 2007 @@ -2,6 +2,7 @@ from pypy.objspace.std.intobject import W_IntObject from pypy.objspace.std.floatobject import W_FloatObject from pypy.objspace.std.noneobject import W_NoneObject +from pypy.objspace.std.stringobject import W_StringObject from pypy.translator.cli.dotnet import box def tocli(self): @@ -20,6 +21,10 @@ return None W_NoneObject.tocli = tocli +def tocli(self): + return box(self._value) +W_StringObject.tocli = tocli + from pypy.objspace.fake.objspace import W_Object as W_Object_Fake from pypy.rlib.nonconst import NonConstant Modified: pypy/dist/pypy/module/clr/interp_clr.py ============================================================================== --- pypy/dist/pypy/module/clr/interp_clr.py (original) +++ pypy/dist/pypy/module/clr/interp_clr.py Thu Feb 1 15:32:38 2007 @@ -84,6 +84,9 @@ elif b_type == typeof(System.Double): floatval = unbox(b_obj, ootype.Float) return space.wrap(floatval) + elif b_type == typeof(System.String): + strval = unbox(b_obj, ootype.String) + return space.wrap(strval) else: msg = "Can't convert object %s to Python" % str(b_obj.ToString()) raise OperationError(space.w_TypeError, space.wrap(msg)) Modified: pypy/dist/pypy/module/clr/test/test_clr.py ============================================================================== --- pypy/dist/pypy/module/clr/test/test_clr.py (original) +++ pypy/dist/pypy/module/clr/test/test_clr.py Thu Feb 1 15:32:38 2007 @@ -114,3 +114,11 @@ x.Add(obj) obj2 = x[0] assert obj is obj2 + + def test_string_wrapping(self): + import clr + ArrayList = clr.load_cli_class('System.Collections', 'ArrayList') + x = ArrayList() + x.Add("bar") + s = x[0] + assert s == "bar" From pedronis at codespeak.net Thu Feb 1 16:00:42 2007 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Thu, 1 Feb 2007 16:00:42 +0100 (CET) Subject: [pypy-svn] r37740 - pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test Message-ID: <20070201150042.E27DD1008B@code0.codespeak.net> Author: pedronis Date: Thu Feb 1 16:00:41 2007 New Revision: 37740 Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_exception.py Log: test showing the problem with malloc "exceptions" not generating segregated exception paths. Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_exception.py ============================================================================== --- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_exception.py (original) +++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_exception.py Thu Feb 1 16:00:41 2007 @@ -138,3 +138,28 @@ res = self.timeshift(ll_function, [5], [], policy=P_NOVIRTUAL) assert res == 5 self.check_insns(malloc=0) + + def test_not_segregated_malloc_exception_path(self): + py.test.skip("WIP") + class E(Exception): + def __init__(self, msg): + self.msg = msg + + def help(l, x): + if x < 0: + raise E("x negative: %d" %x) + l.append(x) + return l + + def ll_function(x): + l = [] + l = help(l, x) + return len(l)+x + + res = self.timeshift(ll_function, [5], [], policy=P_OOPSPEC) + res == 6 + self.check_oops(newlist=0) + + + + From cfbolz at codespeak.net Thu Feb 1 16:26:57 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 16:26:57 +0100 (CET) Subject: [pypy-svn] r37744 - pypy/dist/pypy/doc/config Message-ID: <20070201152657.B9F7D10090@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 16:26:57 2007 New Revision: 37744 Modified: pypy/dist/pypy/doc/config/objspace.allworkingmodules.txt pypy/dist/pypy/doc/config/objspace.geninterp.txt pypy/dist/pypy/doc/config/objspace.std.oldstyle.txt pypy/dist/pypy/doc/config/objspace.std.withprebuiltint.txt pypy/dist/pypy/doc/config/objspace.std.withrangelist.txt pypy/dist/pypy/doc/config/objspace.std.withstrjoin.txt pypy/dist/pypy/doc/config/objspace.std.withstrslice.txt pypy/dist/pypy/doc/config/objspace.std.withtypeversion.txt Log: start a rough documentation of some of the options. Modified: pypy/dist/pypy/doc/config/objspace.allworkingmodules.txt ============================================================================== --- pypy/dist/pypy/doc/config/objspace.allworkingmodules.txt (original) +++ pypy/dist/pypy/doc/config/objspace.allworkingmodules.txt Thu Feb 1 16:26:57 2007 @@ -0,0 +1,2 @@ +This option enables the usage of all modules that are known to be working well +and that translate without problem. Modified: pypy/dist/pypy/doc/config/objspace.geninterp.txt ============================================================================== --- pypy/dist/pypy/doc/config/objspace.geninterp.txt (original) +++ pypy/dist/pypy/doc/config/objspace.geninterp.txt Thu Feb 1 16:26:57 2007 @@ -0,0 +1,4 @@ +This option enables `geninterp`_. This will usually make the PyPy interpreter +significantly faster (but also a bit bigger). + +.. _`geninterp`: ../geninterp.html Modified: pypy/dist/pypy/doc/config/objspace.std.oldstyle.txt ============================================================================== --- pypy/dist/pypy/doc/config/objspace.std.oldstyle.txt (original) +++ pypy/dist/pypy/doc/config/objspace.std.oldstyle.txt Thu Feb 1 16:26:57 2007 @@ -0,0 +1,2 @@ +With this option you can enable the use of old-style classes by default. +Normally, all PyPy classes are new-style. Modified: pypy/dist/pypy/doc/config/objspace.std.withprebuiltint.txt ============================================================================== --- pypy/dist/pypy/doc/config/objspace.std.withprebuiltint.txt (original) +++ pypy/dist/pypy/doc/config/objspace.std.withprebuiltint.txt Thu Feb 1 16:26:57 2007 @@ -0,0 +1,6 @@ +This option enables the caching of small integer objects (similar to what +CPython does). The range of which integers are cached can be influenced with the +`objspace.std.prebuiltintfrom`_ and `objspace.std.prebuiltintto`_ options. + +.. _`objspace.std.prebuiltintfrom`: objspace.std.prebuiltintfrom.html +.. _`objspace.std.prebuiltintto`: objspace.std.prebuiltintto.html Modified: pypy/dist/pypy/doc/config/objspace.std.withrangelist.txt ============================================================================== --- pypy/dist/pypy/doc/config/objspace.std.withrangelist.txt (original) +++ pypy/dist/pypy/doc/config/objspace.std.withrangelist.txt Thu Feb 1 16:26:57 2007 @@ -0,0 +1,6 @@ +Enable "range list" objects. They are a different implementation of the Python +``list`` type, indistinguishable for the normal user. Whenever the ``range`` +builtin is called, an range list is returned. As long as this list is not +mutated (and for example only iterated over), it uses only enough memory to +store the start, stop and step of the range. This makes using ``range`` as +efficient as ``xrange``, as long as the result is only used in a ``for``-loop. Modified: pypy/dist/pypy/doc/config/objspace.std.withstrjoin.txt ============================================================================== --- pypy/dist/pypy/doc/config/objspace.std.withstrjoin.txt (original) +++ pypy/dist/pypy/doc/config/objspace.std.withstrjoin.txt Thu Feb 1 16:26:57 2007 @@ -0,0 +1,7 @@ +Enable "string join" objects. They are a different implementation of the Python +``str`` type, indistinguishable for the normal user. They represent the lazy +addition of several strings without actually performing the addition (which +involves copying etc.). When the actual value of the string join object is +needed, the addition is performed. This makes it possible efficiently perform +string additions in a loop without using the ``"".join(list_of_strings)`` +pattern. Modified: pypy/dist/pypy/doc/config/objspace.std.withstrslice.txt ============================================================================== --- pypy/dist/pypy/doc/config/objspace.std.withstrslice.txt (original) +++ pypy/dist/pypy/doc/config/objspace.std.withstrslice.txt Thu Feb 1 16:26:57 2007 @@ -0,0 +1,8 @@ +Enable "string slice" objects. They are a different implementation of the Python +``str`` type, indistinguishable for the normal user. They represent the lazy +slicing of a string without actually performing the slicing (which involves +copying). This is only done for slices of step one. When the actual value of +the string slice object is needed, the slicing is done (although a lot of string +methods don't make this necessary). This makes string slicing a very efficient +operation. It also saves memory in some cases but can also lead to memory leaks, +since the string slice retains a reference to the original string. Modified: pypy/dist/pypy/doc/config/objspace.std.withtypeversion.txt ============================================================================== --- pypy/dist/pypy/doc/config/objspace.std.withtypeversion.txt (original) +++ pypy/dist/pypy/doc/config/objspace.std.withtypeversion.txt Thu Feb 1 16:26:57 2007 @@ -0,0 +1,4 @@ +This (mostly internal) option enables "type versions": Every type object gets an +(only internally visible) version that is updated when the type's dict is +changed. This is e.g. used for invalidating cashes. It does not make sense to +enable this option alone. From antocuni at codespeak.net Thu Feb 1 16:38:36 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 1 Feb 2007 16:38:36 +0100 (CET) Subject: [pypy-svn] r37747 - pypy/dist/pypy/doc/config Message-ID: <20070201153836.44C89100A7@code0.codespeak.net> Author: antocuni Date: Thu Feb 1 16:38:35 2007 New Revision: 37747 Added: pypy/dist/pypy/doc/config/objspace.usemodules.clr.txt - copied unchanged from r37727, pypy/dist/pypy/doc/config/objspace.usemodules._dotnet.txt Removed: pypy/dist/pypy/doc/config/objspace.usemodules._dotnet.txt Log: rename the module also here. From antocuni at codespeak.net Thu Feb 1 16:41:42 2007 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Thu, 1 Feb 2007 16:41:42 +0100 (CET) Subject: [pypy-svn] r37748 - in pypy/dist/pypy/module/clr: . test Message-ID: <20070201154142.B2BE7100AC@code0.codespeak.net> Author: antocuni Date: Thu Feb 1 16:41:41 2007 New Revision: 37748 Modified: pypy/dist/pypy/module/clr/app_clr.py pypy/dist/pypy/module/clr/interp_clr.py pypy/dist/pypy/module/clr/test/test_clr.py Log: Support for static properties. Modified: pypy/dist/pypy/module/clr/app_clr.py ============================================================================== --- pypy/dist/pypy/module/clr/app_clr.py (original) +++ pypy/dist/pypy/module/clr/app_clr.py Thu Feb 1 16:41:41 2007 @@ -69,6 +69,22 @@ return '' % (self.im_self.__class__.__cliclass__, self.im_name, self.im_self) +class StaticProperty(object): + def __init__(self, fget=None, fset=None): + self.fget = fget + self.fset = fset + + def __get__(self, obj, type_): + return self.fget() + +class MetaCliClassWrapper(type): + def __setattr__(cls, name, value): + obj = cls.__dict__.get(name, None) + if isinstance(obj, StaticProperty): + obj.fset(value) + else: + type.__setattr__(cls, name, value) + class CliClassWrapper(object): __slots__ = ('__cliobj__',) @@ -88,22 +104,27 @@ assert len(indexers) <= 1 if indexers: - name, getter, setter = indexers[0] + name, getter, setter, is_static = indexers[0] + assert not is_static if getter: d['__getitem__'] = d[getter] if setter: d['__setitem__'] = d[setter] - cls = type(classname, (CliClassWrapper,), d) - + cls = MetaCliClassWrapper(classname, (CliClassWrapper,), d) + # we must add properties *after* the class has been created # because we need to store UnboundMethods as getters and setters - for (name, getter, setter) in properties: + for (name, getter, setter, is_static) in properties: fget = None fset = None if getter: fget = getattr(cls, getter) if setter: fset = getattr(cls, setter) - setattr(cls, name, property(fget, fset)) + if is_static: + prop = StaticProperty(fget, fset) + else: + prop = property(fget, fset) + setattr(cls, name, prop) return cls Modified: pypy/dist/pypy/module/clr/interp_clr.py ============================================================================== --- pypy/dist/pypy/module/clr/interp_clr.py (original) +++ pypy/dist/pypy/module/clr/interp_clr.py Thu Feb 1 16:41:41 2007 @@ -93,8 +93,8 @@ def wrap_list_of_tuples(space, lst): list_w = [] - for (a,b,c) in lst: - items_w = [space.wrap(a), space.wrap(b), space.wrap(c)] + for (a,b,c,d) in lst: + items_w = [space.wrap(a), space.wrap(b), space.wrap(c), space.wrap(d)] list_w.append(space.newtuple(items_w)) return space.newlist(list_w) @@ -126,14 +126,18 @@ get_name = None set_name = None if b_prop.get_CanRead(): - get_name = b_prop.GetGetMethod().get_Name() + get_meth = b_prop.GetGetMethod() + get_name = get_meth.get_Name() + is_static = get_meth.get_IsStatic() if b_prop.get_CanWrite(): - set_name = b_prop.GetSetMethod().get_Name() + set_meth = b_prop.GetSetMethod() + set_name = set_meth.get_Name() + is_static = set_meth.get_IsStatic() b_indexparams = b_prop.GetIndexParameters() if len(b_indexparams) == 0: - properties.append((b_prop.get_Name(), get_name, set_name)) + properties.append((b_prop.get_Name(), get_name, set_name, is_static)) else: - indexers.append((b_prop.get_Name(), get_name, set_name)) + indexers.append((b_prop.get_Name(), get_name, set_name, is_static)) w_properties = wrap_list_of_tuples(space, properties) w_indexers = wrap_list_of_tuples(space, indexers) return w_properties, w_indexers Modified: pypy/dist/pypy/module/clr/test/test_clr.py ============================================================================== --- pypy/dist/pypy/module/clr/test/test_clr.py (original) +++ pypy/dist/pypy/module/clr/test/test_clr.py Thu Feb 1 16:41:41 2007 @@ -122,3 +122,11 @@ x.Add("bar") s = x[0] assert s == "bar" + + def test_static_property(self): + import clr + import os + Environment = clr.load_cli_class('System', 'Environment') + assert Environment.CurrentDirectory == os.getcwd() + Environment.CurrentDirectory == '/' + assert Environment.CurrentDirectory == os.getcwd() From cfbolz at codespeak.net Thu Feb 1 16:43:01 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 16:43:01 +0100 (CET) Subject: [pypy-svn] r37749 - in pypy/dist/pypy/objspace/std: . test Message-ID: <20070201154301.DEAA9100B3@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 16:43:01 2007 New Revision: 37749 Modified: pypy/dist/pypy/objspace/std/strjoinobject.py pypy/dist/pypy/objspace/std/test/test_strjoinobject.py Log: yet another str join bug :-( Modified: pypy/dist/pypy/objspace/std/strjoinobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/strjoinobject.py (original) +++ pypy/dist/pypy/objspace/std/strjoinobject.py Thu Feb 1 16:43:01 2007 @@ -50,7 +50,7 @@ def add__StringJoin_StringJoin(space, w_self, w_other): if len(w_self.joined_strs) > w_self.until: w_self.force(True) - w_self.joined_strs.extend(w_other.joined_strs) + w_self.joined_strs.extend(w_other.joined_strs[:w_other.until]) return W_StringJoinObject(w_self.joined_strs) def add__StringJoin_String(space, w_self, w_other): @@ -60,14 +60,10 @@ w_self.joined_strs.append(other) return W_StringJoinObject(w_self.joined_strs) -#def add__String_StringJoin(space, w_other, w_self): -# other = space.str_w(w_other) -# return W_StringObject([other] + w_self.joined_strs) - def str__StringJoin(space, w_str): - if type(w_str) is W_StringJoinObject: - return w_str - return W_StringJoinObject(w_str.joined_strs) + # you cannot get subclasses of W_StringObject here + assert type(w_str) is W_StringJoinObject + return w_str from pypy.objspace.std import stringtype register_all(vars(), stringtype) Modified: pypy/dist/pypy/objspace/std/test/test_strjoinobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_strjoinobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_strjoinobject.py Thu Feb 1 16:43:01 2007 @@ -62,3 +62,11 @@ u = s + 'd' v = s + 'e' assert v == 'abe' # meaning u is abcd + + def test_buh_even_more(self): + a = 'a' + 'b' + b = a + 'c' + c = '0' + '1' + x = c + a + assert x == '01ab' + From cfbolz at codespeak.net Thu Feb 1 19:06:03 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 19:06:03 +0100 (CET) Subject: [pypy-svn] r37757 - pypy/dist/pypy/doc Message-ID: <20070201180603.4BE2610076@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 19:06:02 2007 New Revision: 37757 Modified: pypy/dist/pypy/doc/project-ideas.txt Log: some optimization ideas from discussions. Modified: pypy/dist/pypy/doc/project-ideas.txt ============================================================================== --- pypy/dist/pypy/doc/project-ideas.txt (original) +++ pypy/dist/pypy/doc/project-ideas.txt Thu Feb 1 19:06:02 2007 @@ -44,21 +44,58 @@ * dictionaries which use a different strategy when very small. -Things we've thought about but not yet implemented include: - -* lists which are specialised for int-only values (for saving memory). - * in-progress: caching the lookups of builtin names (by special forms of dictionaries that can invalidate the caches when they are written to) + + +Things we've thought about but not yet implemented include: + +* try out things like lists of integers and lists of strings to save memory. + This might be based on (boringly) implementing "multilists" in the same + spirit as multidicts. + +* neal norwitz in an old post to pypy-dev: "list slices are + often used for iteration. It would be nice if we didn't need to make + a copy of the list. This becomes difficult since the list could + change during iteration. But we could make a copy in that case at the + time it was modified. I'm not sure if that would be easy or difficult + to implement." This would probably be easy to implement in pypy and could be + based on multilists (see previous item). + * create multiple representations of Unicode string that store the character data in narrower arrays when they can. +* introduce a "call method" bytecode that is used for calls of the form + "a.b(...)". This should allow us to shortcut argument passing, and most + importantly avoid the creation of the bound method object. To be based + on the method shadowing detection optimization already implemented. + +* experiment with optimized global/builtin lookups by e.g. using + callback-on-modify-dictionaries for Module dicts, might be + done using the multidicts. Note however that CALL_LIKELY_BUILTIN already + covers the case of calls to common builtins, so this should probably + focus on global lookups. + Experiments of this kind are really experiments in the sense that we do not know whether they will work well or not and the only way to find out is to try. A project of this nature should provide benchmark results (both timing and memory usage) as much as code. +Some ideas on concrete steps for benchmarking: + +* find a set of real-world applications that can be used as benchmarks + for pypy (ideas: docutils, http://hachoir.org/, moinmoin, ...?) + +* do benchmark runs to see how much speedup the currently written + optimizations give + +* profile pypy-c and it's variants with these benchmarks, identify slow areas + +* try to come up with optimized implementations for these slow areas + + + Start or improve a back-end --------------------------- @@ -87,7 +124,7 @@ PyPy's Just-In-Time compiler relies on two assembler backends for actual code generation, one for PowerPC and the other for i386. Those two backends so far -are mostly working, but nearly no effort has been made to make them produce +are mostly working, but only some effort has been made to make them produce efficient code. This is an area where significant improvements could be made, hopefully without having to understand the full intricacies of the JIT. From cfbolz at codespeak.net Thu Feb 1 19:09:57 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 19:09:57 +0100 (CET) Subject: [pypy-svn] r37759 - pypy/dist/pypy/config Message-ID: <20070201180957.C8E6D10086@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 19:09:57 2007 New Revision: 37759 Modified: pypy/dist/pypy/config/pypyoption.py Log: fix typo Modified: pypy/dist/pypy/config/pypyoption.py ============================================================================== --- pypy/dist/pypy/config/pypyoption.py (original) +++ pypy/dist/pypy/config/pypyoption.py Thu Feb 1 19:09:57 2007 @@ -110,7 +110,7 @@ requires=[("objspace.std.withsmallint", False)]), IntOption("prebuiltintfrom", "lowest integer which is prebuilt", - default=-5, cmdline="--prebuiltinfrom"), + default=-5, cmdline="--prebuiltintfrom"), IntOption("prebuiltintto", "highest integer which is prebuilt", default=100, cmdline="--prebuiltintto"), From cfbolz at codespeak.net Thu Feb 1 19:11:38 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 19:11:38 +0100 (CET) Subject: [pypy-svn] r37760 - in pypy/dist/pypy/config: . test Message-ID: <20070201181138.D3AA810087@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 19:11:38 2007 New Revision: 37760 Modified: pypy/dist/pypy/config/config.py pypy/dist/pypy/config/makerestdoc.py pypy/dist/pypy/config/test/test_config.py Log: move the getpaths function to the OptionDescription, to not have to make a Config object only to get the paths. Modified: pypy/dist/pypy/config/config.py ============================================================================== --- pypy/dist/pypy/config/config.py (original) +++ pypy/dist/pypy/config/config.py Thu Feb 1 19:11:38 2007 @@ -151,29 +151,10 @@ result += substr return result - def getpaths(self, include_groups=False, currpath=None): + def getpaths(self, include_groups=False): """returns a list of all paths in self, recursively - - currpath should not be provided (helps with recursion) """ - if currpath is None: - currpath = [] - paths = [] - for option in self._cfgimpl_descr._children: - attr = option._name - if attr.startswith('_cfgimpl'): - continue - value = getattr(self, attr) - if isinstance(value, Config): - if include_groups: - paths.append('.'.join(currpath + [attr])) - currpath.append(attr) - paths += value.getpaths(include_groups=include_groups, - currpath=currpath) - currpath.pop() - else: - paths.append('.'.join(currpath + [attr])) - return paths + return self._cfgimpl_descr.getpaths(include_groups=include_groups) DEFAULT_OPTION_NAME = object() @@ -396,6 +377,30 @@ def add_optparse_option(self, argnames, parser, config): return + def getpaths(self, include_groups=False, currpath=None): + """returns a list of all paths in self, recursively + + currpath should not be provided (helps with recursion) + """ + if currpath is None: + currpath = [] + paths = [] + for option in self._children: + attr = option._name + if attr.startswith('_cfgimpl'): + continue + value = getattr(self, attr) + if isinstance(value, OptionDescription): + if include_groups: + paths.append('.'.join(currpath + [attr])) + currpath.append(attr) + paths += value.getpaths(include_groups=include_groups, + currpath=currpath) + currpath.pop() + else: + paths.append('.'.join(currpath + [attr])) + return paths + class OptHelpFormatter(optparse.IndentedHelpFormatter): Modified: pypy/dist/pypy/config/makerestdoc.py ============================================================================== --- pypy/dist/pypy/config/makerestdoc.py (original) +++ pypy/dist/pypy/config/makerestdoc.py Thu Feb 1 19:11:38 2007 @@ -132,21 +132,20 @@ if path: content.add( Paragraph(Link("back to parent", path + ".html"))) - for elt in [ + content.join( Title("Basic Option Information"), ListItem(Strong("name:"), self._name), ListItem(Strong("description:"), self.doc), - Title("Sub-Options") - ]: - content.add(elt) - conf = Config(self) + Title("Sub-Options")) stack = [] prefix = fullpath curr = content - for subpath in conf.getpaths(include_groups=True): + for subpath in self.getpaths(include_groups=True): subpath = fullpath + "." + subpath - while not subpath.startswith(prefix): + while not (subpath.startswith(prefix) and + subpath[len(prefix)] == "."): curr, prefix = stack.pop() + print subpath, fullpath, curr new = curr.add(ListItem(Link(subpath, subpath + ".html"))) stack.append((curr, prefix)) prefix = subpath Modified: pypy/dist/pypy/config/test/test_config.py ============================================================================== --- pypy/dist/pypy/config/test/test_config.py (original) +++ pypy/dist/pypy/config/test/test_config.py Thu Feb 1 19:11:38 2007 @@ -255,10 +255,13 @@ assert config.getpaths() == ['gc.name', 'gc.dummy', 'gc.float', 'bool', 'objspace', 'wantref', 'str', 'wantframework', 'int'] + assert config.getpaths() == descr.getpaths() assert config.gc.getpaths() == ['name', 'dummy', 'float'] + assert config.gc.getpaths() == descr.gc.getpaths() assert config.getpaths(include_groups=True) == [ 'gc', 'gc.name', 'gc.dummy', 'gc.float', 'bool', 'objspace', 'wantref', 'str', 'wantframework', 'int'] + assert config.getpaths(True) == descr.getpaths(True) def test_underscore_in_option_name(): descr = OptionDescription("opt", "", [ From cfbolz at codespeak.net Thu Feb 1 19:28:07 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 19:28:07 +0100 (CET) Subject: [pypy-svn] r37763 - pypy/extradoc/eu-report Message-ID: <20070201182807.19DB11008D@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 19:28:04 2007 New Revision: 37763 Added: pypy/extradoc/eu-report/D13.1_Build-_and_Configuration_Tool-interim-2006-02-01.pdf Log: add D13.1 interim report Added: pypy/extradoc/eu-report/D13.1_Build-_and_Configuration_Tool-interim-2006-02-01.pdf ============================================================================== Files (empty file) and pypy/extradoc/eu-report/D13.1_Build-_and_Configuration_Tool-interim-2006-02-01.pdf Thu Feb 1 19:28:04 2007 differ From cfbolz at codespeak.net Thu Feb 1 19:32:28 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 19:32:28 +0100 (CET) Subject: [pypy-svn] r37764 - pypy/dist/pypy/doc Message-ID: <20070201183228.A01031008D@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 19:32:26 2007 New Revision: 37764 Modified: pypy/dist/pypy/doc/index-report.txt Log: add stub about D13.1 interim report Modified: pypy/dist/pypy/doc/index-report.txt ============================================================================== --- pypy/dist/pypy/doc/index-report.txt (original) +++ pypy/dist/pypy/doc/index-report.txt Thu Feb 1 19:32:26 2007 @@ -12,11 +12,15 @@ Reports of 2007 =============== +`Draft D13.1 Build and Configuration Tool`_ is an interim version of a report +about our build an configuration toolchain as well as the planned Debian +packages. The report is still a draft, all feedback for it is welcome. +*(2007-02-02)* + `Draft D08.2 JIT Compiler Architecture`_ is an interim version of a report about the Architecture and working of our JIT compiler generator. The report is still a draft, all feedback for it is welcome. *(2007-01-28)* - `Draft D02.3 Testing Tool`_ is an interim version of a report about the `py.test`_ testing tool which is part of the `py-lib`_. The report is still a draft, all feedback for it is welcome. *(2007-01-28)* @@ -95,3 +99,4 @@ .. _`Draft D03.1 Extension Compiler`: http://codespeak.net/pypy/extradoc/eu-report/D03.1_Extension_Compiler-interim-2007-01-22.pdf .. _`Draft D02.3 Testing Tool`: http://codespeak.net/pypy/extradoc/eu-report/D02.3_Testing_Framework-interim-2007-01-28.pdf .. _`Draft D08.2 JIT Compiler Architecture`: http://codespeak.net/pypy/extradoc/eu-report/D08.2_JIT_Compiler_Architecture-interim-2007-01-28.pdf +.. _`Draft D13.1 Build and Configuration Tool`: http://codespeak.net/pypy/extradoc/eu-report/D13.1_Build-_and_Configuration_Tool-interim-2006-02-01.pdf From cfbolz at codespeak.net Thu Feb 1 22:48:30 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Thu, 1 Feb 2007 22:48:30 +0100 (CET) Subject: [pypy-svn] r37771 - in pypy/dist/pypy/objspace/std: . test Message-ID: <20070201214830.2152D1007F@code0.codespeak.net> Author: cfbolz Date: Thu Feb 1 22:48:28 2007 New Revision: 37771 Modified: pypy/dist/pypy/objspace/std/listobject.py pypy/dist/pypy/objspace/std/test/test_listobject.py Log: add a extend__List_List and inplace_add__List_List implementations to not have to call space.unpackiterable on the other list (which loops over the list, constructs a copy of it, etc, etc). Makes list.extend(list) a lot faster. Modified: pypy/dist/pypy/objspace/std/listobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/listobject.py (original) +++ pypy/dist/pypy/objspace/std/listobject.py Thu Feb 1 22:48:28 2007 @@ -92,6 +92,10 @@ list_extend__List_ANY(space, w_list1, w_iterable2) return w_list1 +def inplace_add__List_List(space, w_list1, w_list2): + list_extend__List_List(space, w_list1, w_list2) + return w_list1 + def mul_list_times(space, w_list, w_times): try: times = space.int_w(w_times) @@ -358,6 +362,10 @@ w_list.wrappeditems.append(w_any) return space.w_None +def list_extend__List_List(space, w_list, w_other): + w_list.wrappeditems += w_other.wrappeditems + return space.w_None + def list_extend__List_ANY(space, w_list, w_any): w_list.wrappeditems += space.unpackiterable(w_any) return space.w_None Modified: pypy/dist/pypy/objspace/std/test/test_listobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_listobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_listobject.py Thu Feb 1 22:48:28 2007 @@ -370,6 +370,12 @@ assert l is l0 assert l == [1,2] + def test_extend_iterable(self): + l = l0 = [1] + l.extend(iter([1, 2, 3, 4])) + assert l is l0 + assert l == [1, 1, 2, 3, 4] + def test_sort(self): l = l0 = [1, 5, 3, 0] l.sort() @@ -448,6 +454,12 @@ assert l is l0 assert l == [1,2,3,4,5] + def test_iadd_iterable(self): + l = l0 = [1,2,3] + l += iter([4,5]) + assert l is l0 + assert l == [1,2,3,4,5] + def test_imul(self): l = l0 = [4,3] l *= 2 From cfbolz at codespeak.net Fri Feb 2 00:11:57 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Fri, 2 Feb 2007 00:11:57 +0100 (CET) Subject: [pypy-svn] r37775 - pypy/dist/pypy/objspace/std Message-ID: <20070201231157.2B7CE10079@code0.codespeak.net> Author: cfbolz Date: Fri Feb 2 00:11:55 2007 New Revision: 37775 Modified: pypy/dist/pypy/objspace/std/listobject.py Log: at least check for the empty list that we just put there Modified: pypy/dist/pypy/objspace/std/listobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/listobject.py (original) +++ pypy/dist/pypy/objspace/std/listobject.py Fri Feb 2 00:11:55 2007 @@ -32,7 +32,10 @@ w_iterable, = __args__.parse('list', (['sequence'], None, None), # signature [EMPTY_LIST]) # default argument - w_list.wrappeditems = space.unpackiterable(w_iterable) + if w_iterable is EMPTY_LIST: + w_list.wrappeditems = [] + else: + w_list.wrappeditems = space.unpackiterable(w_iterable) def len__List(space, w_list): result = len(w_list.wrappeditems) From cfbolz at codespeak.net Fri Feb 2 00:13:51 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Fri, 2 Feb 2007 00:13:51 +0100 (CET) Subject: [pypy-svn] r37777 - pypy/dist/pypy/objspace/std Message-ID: <20070201231351.DF29510089@code0.codespeak.net> Author: cfbolz Date: Fri Feb 2 00:13:51 2007 New Revision: 37777 Modified: pypy/dist/pypy/objspace/std/listobject.py pypy/dist/pypy/objspace/std/listtype.py Log: remove old commented out code Modified: pypy/dist/pypy/objspace/std/listobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/listobject.py (original) +++ pypy/dist/pypy/objspace/std/listobject.py Fri Feb 2 00:13:51 2007 @@ -81,15 +81,6 @@ def add__List_List(space, w_list1, w_list2): return W_ListObject(w_list1.wrappeditems + w_list2.wrappeditems) -#def radd__List_List(space, w_list1, w_list2): -# return W_ListObject(w_list2.wrappeditems + w_list1.wrappeditems) - -##def add__List_ANY(space, w_list, w_any): -## if space.is_true(space.isinstance(w_any, space.w_list)): -## items1_w = w_list.wrappeditems -## items2_w = space.unpackiterable(w_any) -## return W_ListObject(items1_w + items2_w) -## raise FailedToImplement def inplace_add__List_ANY(space, w_list1, w_iterable2): list_extend__List_ANY(space, w_list1, w_iterable2) @@ -139,14 +130,6 @@ return space.w_False i += 1 return space.w_True - #return space.newbool(len(w_list1.wrappeditems) == len(w_list2.wrappeditems)) - -##def eq__List_ANY(space, w_list1, w_any): -## if space.is_true(space.isinstance(w_any, space.w_list)): -## items1_w = w_list1.wrappeditems -## items2_w = space.unpackiterable(w_any) -## return equal_wrappeditems(space, items1_w, items2_w) -## raise FailedToImplement def _min(a, b): if a < b: @@ -183,26 +166,10 @@ return lessthan_unwrappeditems(space, w_list1.wrappeditems, w_list2.wrappeditems) -##def lt__List_ANY(space, w_list1, w_any): -## # XXX: Implement it not unpacking all the elements -## if space.is_true(space.isinstance(w_any, space.w_list)): -## items1_w = w_list1.wrappeditems -## items2_w = space.unpackiterable(w_any) -## return lessthan_unwrappeditems(space, items1_w, items2_w) -## raise FailedToImplement - def gt__List_List(space, w_list1, w_list2): return greaterthan_unwrappeditems(space, w_list1.wrappeditems, w_list2.wrappeditems) -##def gt__List_ANY(space, w_list1, w_any): -## # XXX: Implement it not unpacking all the elements -## if space.is_true(space.isinstance(w_any, space.w_list)): -## items1_w = w_list1.wrappeditems -## items2_w = space.unpackiterable(w_any) -## return greaterthan_unwrappeditems(space, items1_w, items2_w) -## raise FailedToImplement - def delitem__List_ANY(space, w_list, w_idx): idx = space.int_w(w_idx) try: Modified: pypy/dist/pypy/objspace/std/listtype.py ============================================================================== --- pypy/dist/pypy/objspace/std/listtype.py (original) +++ pypy/dist/pypy/objspace/std/listtype.py Fri Feb 2 00:13:51 2007 @@ -30,16 +30,7 @@ list_reversed = SMM('__reversed__', 1, doc='L.__reversed__() -- return a reverse iterator over' ' the list') -## -##list_reversed__ANY = gateway.applevel(''' -## # NOT_RPYTHON -- uses yield -## -## def reversed(lst): -## return iter([x for x in lst[::-1]]) -## # for index in range(len(lst)-1, -1, -1): -## # yield lst[index] -## -##''', filename=__file__).interphook('reversed') + def list_reversed__ANY(space, w_list): from pypy.objspace.std.iterobject import W_ReverseSeqIterObject return W_ReverseSeqIterObject(space, w_list, -1) From mwh at codespeak.net Fri Feb 2 11:10:51 2007 From: mwh at codespeak.net (mwh at codespeak.net) Date: Fri, 2 Feb 2007 11:10:51 +0100 (CET) Subject: [pypy-svn] r37791 - pypy/dist/pypy/jit/codegen/ppc Message-ID: <20070202101051.B16941006E@code0.codespeak.net> Author: mwh Date: Fri Feb 2 11:10:48 2007 New Revision: 37791 Modified: pypy/dist/pypy/jit/codegen/ppc/rgenop.py Log: conditionalize some prints Modified: pypy/dist/pypy/jit/codegen/ppc/rgenop.py ============================================================================== --- pypy/dist/pypy/jit/codegen/ppc/rgenop.py (original) +++ pypy/dist/pypy/jit/codegen/ppc/rgenop.py Fri Feb 2 11:10:48 2007 @@ -423,8 +423,8 @@ allocator = self.allocate(outputargs_gv) if DEBUG_PRINT: before_moves = len(self.insns) - print outputargs_gv - print target.args_gv + print outputargs_gv + print target.args_gv prepare_for_jump( self.insns, outputargs_gv, allocator.var2loc, target, allocator) if DEBUG_PRINT: From mwh at codespeak.net Fri Feb 2 11:14:04 2007 From: mwh at codespeak.net (mwh at codespeak.net) Date: Fri, 2 Feb 2007 11:14:04 +0100 (CET) Subject: [pypy-svn] r37792 - in pypy/dist/pypy/jit/codegen/ppc: . test Message-ID: <20070202101404.D2A1310070@code0.codespeak.net> Author: mwh Date: Fri Feb 2 11:14:02 2007 New Revision: 37792 Modified: pypy/dist/pypy/jit/codegen/ppc/emit_moves.py pypy/dist/pypy/jit/codegen/ppc/rgenop.py pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py Log: add an ultra-inefficient ultra-safe version of emit_moves. makes test_from_random_4_direct pass, the matching test of the more efficient emit_moves is still skipped. Modified: pypy/dist/pypy/jit/codegen/ppc/emit_moves.py ============================================================================== --- pypy/dist/pypy/jit/codegen/ppc/emit_moves.py (original) +++ pypy/dist/pypy/jit/codegen/ppc/emit_moves.py Fri Feb 2 11:14:02 2007 @@ -92,3 +92,15 @@ gen.emit_move(tarloc, srcloc) # now safe to do our move data.emitted.append(tarvar) return + +def emit_moves_safe(gen, tarvars, tar2src, tar2loc, src2loc): + second_moves = [] + for tarvar in tarvars: + srcvar = tar2src[tarvar] + srcloc = src2loc[srcvar] + freshloc = gen.create_fresh_location() + gen.emit_move(freshloc, srcloc) + second_moves.append((tar2loc[tarvar], freshloc)) + + for tarloc, freshloc in second_moves: + gen.emit_move(tarloc, freshloc) Modified: pypy/dist/pypy/jit/codegen/ppc/rgenop.py ============================================================================== --- pypy/dist/pypy/jit/codegen/ppc/rgenop.py (original) +++ pypy/dist/pypy/jit/codegen/ppc/rgenop.py Fri Feb 2 11:14:02 2007 @@ -12,7 +12,7 @@ from pypy.jit.codegen.ppc.instruction import rSP, rFP, rSCRATCH, gprs from pypy.jit.codegen.ppc import instruction as insn from pypy.jit.codegen.ppc.regalloc import RegisterAllocation -from pypy.jit.codegen.ppc.emit_moves import emit_moves +from pypy.jit.codegen.ppc.emit_moves import emit_moves, emit_moves_safe from pypy.translator.asm.ppcgen.rassemblermaker import make_rassembler from pypy.translator.asm.ppcgen.ppc_assembler import MyPPCAssembler @@ -182,7 +182,7 @@ tarvars.append(tloc) gen = JumpPatchupGenerator(insns, allocator) - emit_moves(gen, tarvars, tar2src, tar2loc, src2loc) + emit_moves_safe(gen, tarvars, tar2src, tar2loc, src2loc) for i in range(len(targetlocs)): tloc = targetlocs[i] Modified: pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py ============================================================================== --- pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py (original) +++ pypy/dist/pypy/jit/codegen/ppc/test/test_rgenop.py Fri Feb 2 11:14:02 2007 @@ -25,9 +25,6 @@ def test_read_frame_place_direct(self): py.test.skip("in-progress") def test_read_frame_place_compile(self): py.test.skip("in-progress") - def test_from_random_4_direct(self): - py.test.skip("failing :( -- see test_one_to_many in test_emit_moves") - class TestRPPCGenopNoRegs(TestRPPCGenop): RGenOp = FewRegisters From arigo at codespeak.net Fri Feb 2 11:25:18 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 2 Feb 2007 11:25:18 +0100 (CET) Subject: [pypy-svn] r37793 - pypy/dist/pypy/doc Message-ID: <20070202102518.35CE310078@code0.codespeak.net> Author: arigo Date: Fri Feb 2 11:25:16 2007 New Revision: 37793 Modified: pypy/dist/pypy/doc/index.txt Log: Update links to daily test runs. Modified: pypy/dist/pypy/doc/index.txt ============================================================================== --- pypy/dist/pypy/doc/index.txt (original) +++ pypy/dist/pypy/doc/index.txt Fri Feb 2 11:25:16 2007 @@ -121,11 +121,8 @@ an attempt to keep some focus. So PyPy requires a 32-bit machine or OS for now. -*Some links below are broken because of hardware failure of the -snake server - PyPy kills machines :-)* - PyPy's own tests, daily updated, `on Linux`_ and `on Windows`_ and -on `build pypy-c`_ (various variants). +on build pypy-c (not available at the moment). `Nightly builds and benchmarks`_ of PyPy to C, CLI and LLVM. @@ -158,11 +155,10 @@ .. _`bytecode interpreter`: interpreter.html .. _`EU reports`: index-report.html .. _`garbage collection`: garbage_collection.html -.. _`on Linux`: http://snake.cs.uni-duesseldorf.de/pypytest/summary.html +.. _`on Linux`: http://wyvern.cs.uni-duesseldorf.de/pypytest/summary.html .. _`on Windows`: http://scottdial.com/pypytest/summary.html .. _`ideas for PyPy related projects`: project-ideas.html .. _`Nightly builds and benchmarks`: http://tuatara.cs.uni-duesseldorf.de/benchmark.html -.. _`build pypy-c`: http://snake.cs.uni-duesseldorf.de/pypy-c-tests/ .. _`directory reference`: .. _`rlib`: rlib.html From arigo at codespeak.net Fri Feb 2 11:32:58 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 2 Feb 2007 11:32:58 +0100 (CET) Subject: [pypy-svn] r37794 - pypy/dist/pypy/doc Message-ID: <20070202103258.6BB031007F@code0.codespeak.net> Author: arigo Date: Fri Feb 2 11:32:57 2007 New Revision: 37794 Modified: pypy/dist/pypy/doc/extradoc.txt Log: Update IronPython links. Add a link to Tunes, to give the world a reference to the webarchive-saved list of programming languages :-) Modified: pypy/dist/pypy/doc/extradoc.txt ============================================================================== --- pypy/dist/pypy/doc/extradoc.txt (original) +++ pypy/dist/pypy/doc/extradoc.txt Fri Feb 2 11:32:57 2007 @@ -128,18 +128,20 @@ * Jython_ is a Python implementation in Java. -* `Iron Python`_ a new Python implementation compiling Python into +* IronPython_ a new Python implementation compiling Python into Microsofts Common Language Runtime (CLR) Intermediate Language (IL). * `GNU lightning`_ generates assembly language at runtime. +* Tunes_ is not entierely unrelated. (See also the `review of + programming languages`_.) + .. _`CLR under the hood`: http://download.microsoft.com/download/2/4/d/24dfac0e-fec7-4252-91b9-fb2310603f14/CLRUnderTheHood.BradA.ppt .. _Stackless: http://stackless.com .. _Psyco: http://psyco.sourceforge.net .. _Jython: http://www.jython.org .. _`Squeak`: http://www.squeak.org/ .. _`Croquet`: http://www.opencroquet.org/ -.. _`Iron Python`: http://www.gotdotnet.com/workspaces/workspace.aspx?id=ad7acff7-ab1e-4bcb-99c0-57ac5a3a9742 .. _`transparent dynamic optimization`: http://www.hpl.hp.com/techreports/1999/HPL-1999-77.pdf .. _Dynamo: http://www.hpl.hp.com/techreports/1999/HPL-1999-78.pdf .. _testdesign: http://codespeak.net/pypy/dist/pypy/doc/coding-guide.html#test-design @@ -147,6 +149,8 @@ .. _rock: http://codespeak.net/pipermail/pypy-dev/2004q1/001255.html .. _`GNU lightning`: http://www.gnu.org/software/lightning/lightning.html .. _LLVM: http://llvm.org/ -.. _IronPython: http://www.python.org/pycon/dc2004/papers/9/ +.. _IronPython: http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython .. _`Dynamic Native Optimization of Native Interpreters`: http://www.ai.mit.edu/~gregs/dynamorio.html .. _JikesRVM: http://jikesrvm.sf.net +.. _Tunes: http://tunes.org +.. _`review of programming languages`: http://web.archive.org/web/20050205011706/cliki.tunes.org/Programming+Languages From guido at codespeak.net Fri Feb 2 12:40:11 2007 From: guido at codespeak.net (guido at codespeak.net) Date: Fri, 2 Feb 2007 12:40:11 +0100 (CET) Subject: [pypy-svn] r37797 - pypy/dist/pypy/translator/js/demo/jsdemo Message-ID: <20070202114011.3DB841005A@code0.codespeak.net> Author: guido Date: Fri Feb 2 12:40:09 2007 New Revision: 37797 Modified: pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py Log: Replacing some code that writed to .innerHTML with 'nicer' DOM stuff (untested!). Modified: pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py ============================================================================== --- pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py (original) +++ pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py Fri Feb 2 12:40:09 2007 @@ -15,7 +15,6 @@ from pypy.translator.js.modules.dom import setTimeout, document from pypy.rpython.ootypesystem.bltregistry import MethodDesc, BasicExternal from pypy.translator.js import commproxy -from pypy.translator.js.modules.mochikit import escapeHTML from pypy.rpython.extfunc import _callable from pypy.translator.js.demo.jsdemo import support @@ -55,7 +54,7 @@ def add_text(text): data_elem = document.getElementById("data") - data_elem.innerHTML += escapeHTML(text) + data_elem.appendChild(document.createTextNode(text)) class Storage(object): def __init__(self): From arigo at codespeak.net Fri Feb 2 12:41:04 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 2 Feb 2007 12:41:04 +0100 (CET) Subject: [pypy-svn] r37798 - pypy/dist/pypy/translator/js/demo/jsdemo Message-ID: <20070202114104.C493710069@code0.codespeak.net> Author: arigo Date: Fri Feb 2 12:41:04 2007 New Revision: 37798 Modified: pypy/dist/pypy/translator/js/demo/jsdemo/example.py Log: Argh argh argh argh argh IE7. Modified: pypy/dist/pypy/translator/js/demo/jsdemo/example.py ============================================================================== --- pypy/dist/pypy/translator/js/demo/jsdemo/example.py (original) +++ pypy/dist/pypy/translator/js/demo/jsdemo/example.py Fri Feb 2 12:41:04 2007 @@ -22,7 +22,7 @@ Example - This is a test!
From fijal at codespeak.net Fri Feb 2 12:52:55 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 2 Feb 2007 12:52:55 +0100 (CET) Subject: [pypy-svn] r37799 - pypy/dist/pypy/translator/js/demo/jsdemo Message-ID: <20070202115255.F3E9010079@code0.codespeak.net> Author: fijal Date: Fri Feb 2 12:52:53 2007 New Revision: 37799 Modified: pypy/dist/pypy/translator/js/demo/jsdemo/bnb.py pypy/dist/pypy/translator/js/demo/jsdemo/controllers.py pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py Log: Add _callable instead of simple lambdas Modified: pypy/dist/pypy/translator/js/demo/jsdemo/bnb.py ============================================================================== --- pypy/dist/pypy/translator/js/demo/jsdemo/bnb.py (original) +++ pypy/dist/pypy/translator/js/demo/jsdemo/bnb.py Fri Feb 2 12:52:53 2007 @@ -68,8 +68,6 @@ self.seen = set() return to_ret -lambda_None = _callable([]) - # Needed double inheritance for both server job # and semi-transparent communication proxy class BnbRoot(Root, BasicExternal): @@ -90,12 +88,12 @@ _render_xmlhttp = True _methods = { - 'get_message' : MethodDesc( [('player_id', int), ('keys' , str), ('callback', lambda_None)] , {str:[{str:str}]}), - 'add_player' : MethodDesc( [('player_id', int), ('callback', lambda_None)] , {str:[{str:str}]}), - 'remove_player': MethodDesc( [('player_id', int), ('callback', lambda_None)] , {str:[{str:str}]}), - 'player_name' : MethodDesc( [('player_id', int), ('name', str), ('callback', lambda_None)] , {str:[{str:str}]}), + 'get_message' : MethodDesc( [('player_id', int), ('keys' , str), ('callback', _callable([{str:[{str:str}]}]))] , {str:[{str:str}]}), + 'add_player' : MethodDesc( [('player_id', int), ('callback', _callable([{str:[{str:str}]}]))] , {str:[{str:str}]}), + 'remove_player': MethodDesc( [('player_id', int), ('callback', _callable([{str:[{str:str}]}]))] , {str:[{str:str}]}), + 'player_name' : MethodDesc( [('player_id', int), ('name', str), ('callback', _callable([{str:[{str:str}]}]))] , {str:[{str:str}]}), # 'key' : MethodDesc( [('player_id', 0), ('keynum', '0'), ('callback', (lambda : None))] , {'aa':[{'aa':'bb'}]}), - 'initialize_session' : MethodDesc( [('callback', lambda_None)], {str:str}), + 'initialize_session' : MethodDesc( [('callback', _callable([{str:str}]))], {str:str}), } def add_player(self, player_id = 0): Modified: pypy/dist/pypy/translator/js/demo/jsdemo/controllers.py ============================================================================== --- pypy/dist/pypy/translator/js/demo/jsdemo/controllers.py (original) +++ pypy/dist/pypy/translator/js/demo/jsdemo/controllers.py Fri Feb 2 12:52:53 2007 @@ -5,7 +5,7 @@ import autopath from pypy.translator.js.test.runtest import compile_function -from pypy.translator.js.modules import dom,xmlhttp +from pypy.translator.js.modules import dom from pypy.translator.js.modules.dom import document import thread @@ -24,7 +24,7 @@ def esc_html(data): return data.replace("&", "&").replace("<", "<").replace(">", ">") \ .replace("\n", "
").replace(" ", " ") - + class Root(controllers.Root): def __init__(self): self.lock = thread.allocate_lock() Modified: pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py ============================================================================== --- pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py (original) +++ pypy/dist/pypy/translator/js/demo/jsdemo/pythonconsole.py Fri Feb 2 12:52:53 2007 @@ -21,9 +21,8 @@ commproxy.USE_MOCHIKIT = True -from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler -#from SimpleHTTPServer import SimpleHTTPRequestHandler - +from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer +from SocketServer import ThreadingMixIn HTML_PAGE = """ From arigo at codespeak.net Fri Feb 2 13:03:41 2007 From: arigo at codespeak.net (arigo at codespeak.net) Date: Fri, 2 Feb 2007 13:03:41 +0100 (CET) Subject: [pypy-svn] r37800 - pypy/dist/pypy/translator/js Message-ID: <20070202120341.90D411007A@code0.codespeak.net> Author: arigo Date: Fri Feb 2 13:03:40 2007 New Revision: 37800 Modified: pypy/dist/pypy/translator/js/jsbuiltin.py Log: Render string[index] with the charAt() method. Modified: pypy/dist/pypy/translator/js/jsbuiltin.py ============================================================================== --- pypy/dist/pypy/translator/js/jsbuiltin.py (original) +++ pypy/dist/pypy/translator/js/jsbuiltin.py Fri Feb 2 13:03:40 2007 @@ -32,7 +32,7 @@ ootype.String.__class__: { 'll_strconcat' : InstructionList([PushAllArgs, '+']), 'll_strlen' : lambda g,op: GetBuiltinField.run_it(g, op.args[1], 'length'), - 'll_stritem_nonneg' : ListGetitem, + 'll_stritem_nonneg' : lambda g, op: Call._render_builtin_method(g, 'charAt', [op.args[1], op.args[2]]), 'll_streq' : InstructionList([PushAllArgs, '==']), 'll_strcmp' : CallBuiltin('strcmp'), 'll_startswith' : CallBuiltin('startswith'), From fijal at codespeak.net Fri Feb 2 13:14:08 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 2 Feb 2007 13:14:08 +0100 (CET) Subject: [pypy-svn] r37802 - pypy/dist/pypy/translator/js/test Message-ID: <20070202121408.397EF10068@code0.codespeak.net> Author: fijal Date: Fri Feb 2 13:14:04 2007 New Revision: 37802 Removed: pypy/dist/pypy/translator/js/test/test_merge_if_blocks.py Log: This test makes no sense at all From fijal at codespeak.net Fri Feb 2 13:14:56 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 2 Feb 2007 13:14:56 +0100 (CET) Subject: [pypy-svn] r37803 - pypy/dist/pypy/translator/js/test Message-ID: <20070202121456.A2EEB10081@code0.codespeak.net> Author: fijal Date: Fri Feb 2 13:14:48 2007 New Revision: 37803 Added: pypy/dist/pypy/translator/js/test/test_rsnippet.py - copied unchanged from r37798, pypy/dist/pypy/translator/js/test/test_genllvm.py pypy/dist/pypy/translator/js/test/test_rsnippet1.py - copied unchanged from r37798, pypy/dist/pypy/translator/js/test/test_genllvm1.py Removed: pypy/dist/pypy/translator/js/test/test_genllvm.py pypy/dist/pypy/translator/js/test/test_genllvm1.py Log: Move deprecated filenames From fijal at codespeak.net Fri Feb 2 13:16:50 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 2 Feb 2007 13:16:50 +0100 (CET) Subject: [pypy-svn] r37804 - in pypy/dist/pypy/translator/js: examples modules test Message-ID: <20070202121650.F29A810080@code0.codespeak.net> Author: fijal Date: Fri Feb 2 13:16:46 2007 New Revision: 37804 Added: pypy/dist/pypy/translator/js/test/test_extfunc.py Modified: pypy/dist/pypy/translator/js/examples/start_bnb.py pypy/dist/pypy/translator/js/modules/dom.py Log: Move setTimeout to new extfunc interface Modified: pypy/dist/pypy/translator/js/examples/start_bnb.py ============================================================================== --- pypy/dist/pypy/translator/js/examples/start_bnb.py (original) +++ pypy/dist/pypy/translator/js/examples/start_bnb.py Fri Feb 2 13:16:46 2007 @@ -92,7 +92,6 @@ def hide_sprite(self, s): i = self.sprites[s] i.style.visibility = "hidden" - #pass def start_clean_sprites(self): self.all_sprites = {} @@ -141,14 +140,14 @@ km = KeyManager() def appendPlayfield(msg): - bgcolor = '#000000' + bgcolor = '#FFF' document.body.setAttribute('bgcolor', bgcolor) div = document.createElement("div") div.setAttribute("id", "playfield") div.setAttribute('width', msg['width']) div.setAttribute('height', msg['height']) div.setAttribute('style', 'position:absolute; top:0px; left:0px') - document.body.appendChild(div) + document.body.childNodes.insert(0, div) def appendPlayfieldXXX(): bgcolor = '#000000' Modified: pypy/dist/pypy/translator/js/modules/dom.py ============================================================================== --- pypy/dist/pypy/translator/js/modules/dom.py (original) +++ pypy/dist/pypy/translator/js/modules/dom.py Fri Feb 2 13:16:46 2007 @@ -21,7 +21,8 @@ from pypy.rpython.ootypesystem.bltregistry import BasicExternal, MethodDesc from pypy.rlib.nonconst import NonConstant -from pypy.translator.stackless.test.test_transform import one +#from pypy.translator.stackless.test.test_transform import one +from pypy.rpython.extfunc import _callable, register_external from xml.dom import minidom from pypy.annotation.signature import annotation @@ -306,12 +307,10 @@ def some_fun(): pass - + def setTimeout(func, delay): - if one(): - setTimeout(some_fun, delay) - else: - func() + pass +register_external(setTimeout, args=[_callable([]), int], result=None) window = Window() document = window.document @@ -700,6 +699,7 @@ 'shiftKey': bool, }) +# XXX: Right now this is only way to get it rendered setTimeout.suggested_primitive = True # the following code wraps minidom nodes with Node classes, and makes Added: pypy/dist/pypy/translator/js/test/test_extfunc.py ============================================================================== --- (empty file) +++ pypy/dist/pypy/translator/js/test/test_extfunc.py Fri Feb 2 13:16:46 2007 @@ -0,0 +1,18 @@ + +""" Some external functions tests +""" + +from pypy.translator.js.test.runtest import compile_function, check_source_contains +from pypy.rpython.extfunc import _callable + +def test_set_timeout(): + from pypy.translator.js.modules.dom import setTimeout + + def to_timeout(): + pass + + def s_timeout_call(): + setTimeout(to_timeout, 300) + + c = compile_function(s_timeout_call, []) + assert check_source_contains(c, "setTimeout \( 'to_timeout\(\)',300 \)") From fijal at codespeak.net Fri Feb 2 13:17:24 2007 From: fijal at codespeak.net (fijal at codespeak.net) Date: Fri, 2 Feb 2007 13:17:24 +0100 (CET) Subject: [pypy-svn] r37805 - pypy/dist/pypy/translator/js/modules Message-ID: <20070202121724.188BA1008B@code0.codespeak.net> Author: fijal Date: Fri Feb 2 13:17:17 2007 New Revision: 37805 Modified: pypy/dist/pypy/translator/js/modules/dom.py Log: Kill dead code Modified: pypy/dist/pypy/translator/js/modules/dom.py ============================================================================== --- pypy/dist/pypy/translator/js/modules/dom.py (original) +++ pypy/dist/pypy/translator/js/modules/dom.py Fri Feb 2 13:17:17 2007 @@ -21,7 +21,6 @@ from pypy.rpython.ootypesystem.bltregistry import BasicExternal, MethodDesc from pypy.rlib.nonconst import NonConstant -#from pypy.translator.stackless.test.test_transform import one from pypy.rpython.extfunc import _callable, register_external from xml.dom import minidom From ericvrp at codespeak.net Fri Feb 2 14:17:38 2007 From: ericvrp at codespeak.net (ericvrp at codespeak.net) Date: Fri, 2 Feb 2007 14:17:38 +0100 (CET) Subject: [pypy-svn] r37806 - pypy/dist/pypy/jit/codegen/llvm/test Message-ID: <20070202131738.E767210078@code0.codespeak.net> Author: ericvrp Date: Fri Feb 2 14:17:37 2007 New Revision: 37806 Modified: pypy/dist/pypy/jit/codegen/llvm/test/test_genc_ts.py Log: skip these llvm frame var tests until frame vars are supported Modified: pypy/dist/pypy/jit/codegen/llvm/test/test_genc_ts.py ============================================================================== --- pypy/dist/pypy/jit/codegen/llvm/test/test_genc_ts.py (original) +++ pypy/dist/pypy/jit/codegen/llvm/test/test_genc_ts.py Fri Feb 2 14:17:37 2007 @@ -27,3 +27,9 @@ test_two_loops_merging = skip_too_minimal #segfault test_green_char_at_merge = skip #segfault test_residual_red_call_with_exc = skip + + def test_simple_red_meth(self): + py.test.skip('no frame var support yet') + + test_simple_red_meth_vars_around = test_simple_red_meth + From mwh at codespeak.net Fri Feb 2 15:06:17 2007 From: mwh at codespeak.net (mwh at codespeak.net) Date: Fri, 2 Feb 2007 15:06:17 +0100 (CET) Subject: [pypy-svn] r37807 - pypy/dist/pypy/jit/codegen/ppc Message-ID: <20070202140617.0030110084@code0.codespeak.net> Author: mwh Date: Fri Feb 2 15:06:16 2007 New Revision: 37807 Modified: pypy/dist/pypy/jit/codegen/ppc/rgenop.py Log: make sure that when we need a fresh location for before-jump rearrangements, we don't use part of the stack the target block considers important. with this change, the ppc backend passes demo/autorun for several hours and is so probably solid. Modified: pypy/dist/pypy/jit/codegen/ppc/rgenop.py ============================================================================== --- pypy/dist/pypy/jit/codegen/ppc/rgenop.py (original) +++ pypy/dist/pypy/jit/codegen/ppc/rgenop.py Fri Feb 2 15:06:16 2007 @@ -131,13 +131,12 @@ self.allocator = allocator def emit_move(self, tarloc, srcloc): + srcvar = None if DEBUG_PRINT: for v, loc in self.allocator.var2loc.iteritems(): if loc is srcloc: srcvar = v break - else: - srcvar = None emit = self.insns.append if tarloc == srcloc: return @@ -180,6 +179,9 @@ tar2loc[tloc] = tloc tar2src[tloc] = src tarvars.append(tloc) + if not tloc.is_register: + if tloc in allocator.free_stack_slots: + allocator.free_stack_slots.remove(tloc) gen = JumpPatchupGenerator(insns, allocator) emit_moves_safe(gen, tarvars, tar2src, tar2loc, src2loc) @@ -425,6 +427,7 @@ before_moves = len(self.insns) print outputargs_gv print target.args_gv + allocator.spill_offset = min(allocator.spill_offset, target.min_stack_offset) prepare_for_jump( self.insns, outputargs_gv, allocator.var2loc, target, allocator) if DEBUG_PRINT: From cfbolz at codespeak.net Fri Feb 2 15:22:32 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Fri, 2 Feb 2007 15:22:32 +0100 (CET) Subject: [pypy-svn] r37808 - in pypy/dist/pypy/objspace/std: . test Message-ID: <20070202142232.542E41008A@code0.codespeak.net> Author: cfbolz Date: Fri Feb 2 15:22:31 2007 New Revision: 37808 Modified: pypy/dist/pypy/objspace/std/listobject.py pypy/dist/pypy/objspace/std/test/test_listobject.py Log: make list.remove safe against list elements with an __eq__ that mutate the list. Before, you could get an interp-level exception :-(. Modified: pypy/dist/pypy/objspace/std/listobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/listobject.py (original) +++ pypy/dist/pypy/objspace/std/listobject.py Fri Feb 2 15:22:31 2007 @@ -376,11 +376,13 @@ def list_remove__List_ANY(space, w_list, w_any): # needs to be safe against eq_w() mutating the w_list behind our back items = w_list.wrappeditems - length = len(items) - for i in range(length): + i = 0 + while i < len(items): if space.eq_w(items[i], w_any): - del items[i] + if i < len(items): # if this is wrong the list was changed + del items[i] return space.w_None + i += 1 raise OperationError(space.w_ValueError, space.wrap("list.remove(x): x not in list")) Modified: pypy/dist/pypy/objspace/std/test/test_listobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_listobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_listobject.py Fri Feb 2 15:22:31 2007 @@ -1,4 +1,3 @@ -#from __future__ import nested_scopes import autopath, random from pypy.objspace.std.listobject import W_ListObject from pypy.interpreter.error import OperationError @@ -553,3 +552,28 @@ def test_reversed(self): assert list(list('hello').__reversed__()) == ['o', 'l', 'l', 'e', 'h'] assert list(reversed(list('hello'))) == ['o', 'l', 'l', 'e', 'h'] + + def test_mutate_while_remove(self): + class Mean(object): + def __init__(self, i): + self.i = i + def __eq__(self, other): + if self.i == 9: + del l[i - 1] + return True + else: + return False + l = [Mean(i) for i in range(10)] + # does not crash + l.remove(None) + class Mean2(object): + def __init__(self, i): + self.i = i + def __eq__(self, other): + l.append(self.i) + return False + l = [Mean2(i) for i in range(10)] + # does not crash + l.remove(5) + print l + assert l[10:] == [0, 1, 2, 3, 4, 6, 7, 8, 9] From cfbolz at codespeak.net Fri Feb 2 15:25:14 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Fri, 2 Feb 2007 15:25:14 +0100 (CET) Subject: [pypy-svn] r37809 - in pypy/dist/pypy: module/marshal/test objspace/std Message-ID: <20070202142514.D6E2A1008F@code0.codespeak.net> Author: cfbolz Date: Fri Feb 2 15:25:12 2007 New Revision: 37809 Modified: pypy/dist/pypy/module/marshal/test/test_marshal.py pypy/dist/pypy/objspace/std/marshal_impl.py Log: enable marshalling for multidicts Modified: pypy/dist/pypy/module/marshal/test/test_marshal.py ============================================================================== --- pypy/dist/pypy/module/marshal/test/test_marshal.py (original) +++ pypy/dist/pypy/module/marshal/test/test_marshal.py Fri Feb 2 15:25:12 2007 @@ -589,3 +589,11 @@ x = marshal.load(f) assert x == case + +class AppTestMultiDict(object): + def setup_class(cls): + from pypy.conftest import gettestobjspace + cls.space = gettestobjspace(**{"objspace.std.withmultidict": True}) + + test__dict__tcid_ = AppTestMarshal.test__dict__tcid_.im_func + test__dict_5_colon__6_comma__7_colon__8_tcid_ = AppTestMarshal.test__dict_5_colon__6_comma__7_colon__8_tcid_.im_func Modified: pypy/dist/pypy/objspace/std/marshal_impl.py ============================================================================== --- pypy/dist/pypy/objspace/std/marshal_impl.py (original) +++ pypy/dist/pypy/objspace/std/marshal_impl.py Fri Feb 2 15:25:12 2007 @@ -25,7 +25,8 @@ from pypy.objspace.std.tupleobject import W_TupleObject from pypy.objspace.std.listobject import W_ListObject from pypy.objspace.std.dictobject import W_DictObject -from pypy.objspace.std.dictstrobject import W_DictStrObject +from pypy.objspace.std.dictmultiobject import W_DictMultiObject +from pypy.objspace.std.dictstrobject import W_DictStrObject from pypy.objspace.std.stringobject import W_StringObject from pypy.objspace.std.typeobject import W_TypeObject from pypy.objspace.std.longobject import W_LongObject @@ -328,7 +329,7 @@ def unmarshal_Tuple(space, u, tc): items_w = u.get_list_w() - return W_TupleObject(items_w) + return space.newtuple(items_w) register(TYPE_TUPLE, unmarshal_Tuple) def marshal_w__List(space, w_list, m): @@ -338,10 +339,10 @@ def unmarshal_List(space, u, tc): items_w = u.get_list_w() - return W_ListObject(items_w) + return space.newlist(items_w) def finish_List(space, items_w, typecode): - return W_ListObject(items_w) + return space.newlist(items_w) register(TYPE_LIST, unmarshal_List) def marshal_w__Dict(space, w_dict, m): @@ -351,6 +352,14 @@ m.put_w_obj(w_value) m.atom(TYPE_NULL) +def marshal_w__DictMulti(space, w_dict, m): + m.start(TYPE_DICT) + for w_tuple in w_dict.implementation.items(): + w_key, w_value = space.unpacktuple(w_tuple, 2) + m.put_w_obj(w_key) + m.put_w_obj(w_value) + m.atom(TYPE_NULL) + def marshal_w__DictStr(space, w_dict, m): m.start(TYPE_DICT) if w_dict.content is not None: @@ -526,7 +535,7 @@ w_frozen = space.w_False else: w_frozen = space.w_True - w_lis = W_ListObject(items_w) + w_lis = space.newlist(items_w) return list_to_set(space, w_lis, w_frozen) register(TYPE_SET + TYPE_FROZENSET, unmarshal_set_frozenset) From cfbolz at codespeak.net Fri Feb 2 15:28:54 2007 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Fri, 2 Feb 2007 15:28:54 +0100 (CET) Subject: [pypy-svn] r37810 - in pypy/dist/pypy/objspace/std: . test Message-ID: <20070202142854.2C8521007B@code0.codespeak.net> Author: cfbolz Date: Fri Feb 2 15:28:52 2007 New Revision: 37810 Modified: pypy/dist/pypy/objspace/std/rangeobject.py pypy/dist/pypy/objspace/std/test/test_rangeobject.py Log: use FailedToImplement instead of constructing the bound method and calling that, if the rangelist is forced. implement rangelist.pop(0) and rangelist.pop(-1) without forcing the list. Modified: pypy/dist/pypy/objspace/std/rangeobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/rangeobject.py (original) +++ pypy/dist/pypy/objspace/std/rangeobject.py Fri Feb 2 15:28:52 2007 @@ -40,17 +40,16 @@ w_self.w_list = space.newlist([]) return w_self.w_list - arr = [0] * length # this is to avoid using append. + arr = [None] * length # this is to avoid using append. i = start n = 0 while n < length: - arr[n] = i + arr[n] = wrapint(space, i) i += step n += 1 - w_self.w_list = space.newlist([wrapint(space, element) - for element in arr]) + w_self.w_list = space.newlist(arr) return w_self.w_list def getitem(w_self, i): @@ -114,12 +113,33 @@ n += 1 return space.wrap("[" + ", ".join(result) + "]") + +def list_pop__RangeList_ANY(space, w_rangelist, w_idx=-1): + if w_rangelist.w_list is not None: + raise FailedToImplement + length = w_rangelist.length + if length == 0: + raise OperationError(space.w_IndexError, + space.wrap("pop from empty list")) + idx = space.int_w(w_idx) + if idx == 0: + result = w_rangelist.start + w_rangelist.start += w_rangelist.step + w_rangelist.length -= 1 + return wrapint(space, result) + if idx == -1 or idx == length - 1: + w_rangelist.length -= 1 + return wrapint( + space, w_rangelist.start + (length - 1) * w_rangelist.step) + if idx >= w_rangelist.length: + raise OperationError(space.w_IndexError, + space.wrap("pop index out of range")) + raise FailedToImplement + def list_reverse__RangeList(space, w_rangelist): # probably somewhat useless, but well... if w_rangelist.w_list is not None: - w_boundmethod = space.getattr(w_rangelist.w_list, - space.wrap("reverse")) - return space.call_function(w_boundmethod) + raise FailedToImplement w_rangelist.start = w_rangelist.getitem(-1) w_rangelist.step = -w_rangelist.step @@ -128,8 +148,7 @@ # even more useless but fun has_reverse = space.is_true(w_reverse) if w_rangelist.w_list is not None: - w_sort = space.getattr(w_rangelist.w_list, space.wrap("sort")) - return space.call_function(w_sort, w_cmp, w_keyfunc, w_reverse) + raise FailedToImplement if has_reverse: factor = -1 else: Modified: pypy/dist/pypy/objspace/std/test/test_rangeobject.py ============================================================================== --- pypy/dist/pypy/objspace/std/test/test_rangeobject.py (original) +++ pypy/dist/pypy/objspace/std/test/test_rangeobject.py Fri Feb 2 15:28:52 2007 @@ -46,6 +46,11 @@ r.reverse() assert self.not_forced(r) assert r == range(9, -1, -1) + r = range(3) + r[0] = 1 + assert r == [1, 1, 2] + r.reverse() + assert r == [2, 1, 1] def test_sort(self): r = range(