Author: Matti Picus <matti.pi...@gmail.com> Branch: py3.6 Changeset: r96389:4547d8edb215 Date: 2019-03-31 15:18 +0300 http://bitbucket.org/pypy/pypy/changeset/4547d8edb215/
Log: merge default into py3.6 diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py --- a/pypy/interpreter/astcompiler/test/test_compiler.py +++ b/pypy/interpreter/astcompiler/test/test_compiler.py @@ -1597,6 +1597,17 @@ w_res = self.run_and_check_stacksize(source) assert self.space.unwrap(w_res) == range(200) + def test_list_unpacking(self): + space = self.space + source = "[" + ",".join(['b%d' % i for i in range(200)]) + "] = a\n" + code = compile_with_astcompiler(source, 'exec', space) + assert code.co_stacksize == 200 # xxx remains big + w_dict = space.newdict() + space.setitem(w_dict, space.newtext("a"), space.wrap(range(42, 242))) + code.exec_code(space, w_dict, w_dict) + assert space.unwrap(space.getitem(w_dict, space.newtext("b0"))) == 42 + assert space.unwrap(space.getitem(w_dict, space.newtext("b199"))) == 241 + def test_set(self): source = "{" + ",".join([str(i) for i in range(200)]) + "}\n" w_res = self.run_and_check_stacksize(source) diff --git a/pypy/objspace/std/celldict.py b/pypy/objspace/std/celldict.py --- a/pypy/objspace/std/celldict.py +++ b/pypy/objspace/std/celldict.py @@ -11,17 +11,12 @@ DictStrategy, ObjectDictStrategy, _never_equal_to_string, create_iterator_classes) from pypy.objspace.std.typeobject import ( - MutableCell, IntMutableCell, ObjectMutableCell, write_cell) + MutableCell, IntMutableCell, ObjectMutableCell, write_cell, unwrap_cell) class VersionTag(object): pass -def unwrap_cell(space, w_value): - if isinstance(w_value, MutableCell): - return w_value.unwrap_cell(space) - return w_value - def _wrapkey(space, key): return space.newtext(key) diff --git a/rpython/jit/codewriter/effectinfo.py b/rpython/jit/codewriter/effectinfo.py --- a/rpython/jit/codewriter/effectinfo.py +++ b/rpython/jit/codewriter/effectinfo.py @@ -326,14 +326,17 @@ # a read or a write to an interiorfield, inside an array of # structs, is additionally recorded as a read or write of # the array itself - extraef = set() + extraef = list() for tup in effects: if tup[0] == "interiorfield" or tup[0] == "readinteriorfield": T = deref(tup[1]) if isinstance(T, lltype.Array) and consider_array(T): - extraef.add((tup[0].replace("interiorfield", "array"), - tup[1])) - effects |= extraef + val = (tup[0].replace("interiorfield", "array"), + tup[1]) + if val not in effects: + extraef.append(val) + # preserve order in the added effects issue bitbucket #2984 + effects = tuple(effects) + tuple(extraef) for tup in effects: if tup[0] == "struct": diff --git a/rpython/jit/metainterp/heapcache.py b/rpython/jit/metainterp/heapcache.py --- a/rpython/jit/metainterp/heapcache.py +++ b/rpython/jit/metainterp/heapcache.py @@ -264,6 +264,7 @@ opnum == rop.SETFIELD_RAW or opnum == rop.SETARRAYITEM_RAW or opnum == rop.SETINTERIORFIELD_RAW or + opnum == rop.RECORD_EXACT_CLASS or opnum == rop.RAW_STORE or opnum == rop.ASSERT_NOT_NONE): return diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py @@ -7210,6 +7210,7 @@ [p0] p1 = getfield_gc_r(p0, descr=nextdescr) record_exact_class(p1, ConstClass(node_vtable)) + guard_nonnull(p1) [] guard_class(p1, ConstClass(node_vtable)) [] jump(p1) """ diff --git a/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py --- a/rpython/jit/metainterp/pyjitpl.py +++ b/rpython/jit/metainterp/pyjitpl.py @@ -287,8 +287,19 @@ from rpython.rtyper.lltypesystem import llmemory if self.metainterp.heapcache.is_class_known(box): return - self.execute(rop.RECORD_EXACT_CLASS, box, clsbox) - self.metainterp.heapcache.class_now_known(box) + if isinstance(clsbox, Const): + self.execute(rop.RECORD_EXACT_CLASS, box, clsbox) + self.metainterp.heapcache.class_now_known(box) + self.metainterp.heapcache.nullity_now_known(box) + elif have_debug_prints(): + if len(self.metainterp.framestack) >= 2: + # caller of ll_record_exact_class + name = self.metainterp.framestack[-2].jitcode.name + else: + name = self.jitcode.name + loc = self.metainterp.jitdriver_sd.warmstate.get_location_str(self.greenkey) + debug_print("record_exact_class with non-constant second argument, ignored", + name, loc) @arguments("box") def _opimpl_any_return(self, box): diff --git a/rpython/jit/metainterp/test/test_ajit.py b/rpython/jit/metainterp/test/test_ajit.py --- a/rpython/jit/metainterp/test/test_ajit.py +++ b/rpython/jit/metainterp/test/test_ajit.py @@ -109,6 +109,35 @@ self.check_trace_count(1) self.check_simple_loop(int_mul=1) + def test_rutf8(self): + from rpython.rlib import rutf8, jit + class U(object): + def __init__(self, u, l): + self.u = u + self.l = l + self._index_storage = rutf8.null_storage() + + def _get_index_storage(self): + return jit.conditional_call_elidable(self._index_storage, + U._compute_index_storage, self) + + def _compute_index_storage(self): + storage = rutf8.create_utf8_index_storage(self.u, self.l) + self._index_storage = storage + return storage + + def m(a): + return f(a) + def f(a): + x = str(a) + u = U(x, len(x)) + st = u._get_index_storage() + return rutf8.codepoint_index_at_byte_position( + u.u, st, 1) + + self.interp_operations(m, [123232]) + + def test_loop_variant_mul_ovf(self): myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x']) def f(x, y): @@ -3960,6 +3989,55 @@ # here it works again self.check_operations_history(guard_class=0, record_exact_class=1) + def test_record_exact_class_nonconst(self): + class Base(object): + def f(self): + raise NotImplementedError + def g(self): + raise NotImplementedError + class A(Base): + def f(self): + return self.a + def g(self): + return self.a + 1 + class B(Base): + def f(self): + return self.b + def g(self): + return self.b + 1 + class C(B): + def f(self): + self.c += 1 + return self.c + def g(self): + return self.c + 1 + @dont_look_inside + def make(x): + if x > 0: + a = A() + a.a = x + 1 + elif x < 0: + a = B() + a.b = -x + else: + a = C() + a.c = 10 + return a, type(a) + def f(x): + a, cls = make(x) + record_exact_class(a, cls) + if x > 0: + z = a.f() + elif x < 0: + z = a.f() + else: + z = a.f() + return z + a.g() + res1 = f(6) + res2 = self.interp_operations(f, [6]) + assert res1 == res2 + self.check_operations_history(guard_class=1, record_exact_class=0) + def test_generator(self): def g(n): yield n+1 diff --git a/rpython/jit/metainterp/test/test_tracingopts.py b/rpython/jit/metainterp/test/test_tracingopts.py --- a/rpython/jit/metainterp/test/test_tracingopts.py +++ b/rpython/jit/metainterp/test/test_tracingopts.py @@ -743,3 +743,30 @@ res = self.interp_operations(fn, [0]) assert res == 0 self.check_operations_history(setfield_gc=0) + + def test_record_known_class_does_not_invalidate(self): + class A: + pass + class B(A): + pass + class C(object): + _immutable_fields_ = ['x?'] + c = C() + c.x = 5 + c.b = A() + c.b.x = 14 + def fn(n): + if n == 99: + c.x = 12 + c.b = B() + c.b.x = 12 + return 15 + b = c.b + x = b.x + jit.record_exact_class(c.b, A) + y = b.x + return x + y + res = self.interp_operations(fn, [1]) + assert res == 2 * 14 + self.check_operations_history(getfield_gc_i=1) + diff --git a/rpython/jit/metainterp/test/test_virtualizable.py b/rpython/jit/metainterp/test/test_virtualizable.py --- a/rpython/jit/metainterp/test/test_virtualizable.py +++ b/rpython/jit/metainterp/test/test_virtualizable.py @@ -542,6 +542,41 @@ self.check_resops(getfield_gc_r=1, getarrayitem_gc_i=4, getfield_gc_i=1) + @py.test.mark.xfail + def test_virtualizable_with_array_huge(self): + myjitdriver = JitDriver(greens = [], reds = ['n', 'x', 'frame'], + virtualizables = ['frame']) + + class Frame(object): + _virtualizable_ = ['l[*]', 's'] + + def __init__(self, l, s): + self.l = l + self.s = s + + def f(n, a): + frame = Frame([a] * 1024, 0) # make a huge frame + x = 0 + while n > 0: + myjitdriver.can_enter_jit(frame=frame, n=n, x=x) + myjitdriver.jit_merge_point(frame=frame, n=n, x=x) + frame.s = promote(frame.s) + n -= 1 + s = frame.s + assert s >= 0 + x += frame.l[s] + frame.s += 1 + s = frame.s + assert s >= 0 + x += frame.l[s] + x += len(frame.l) + frame.s -= 1 + return x + + res = self.meta_interp(f, [50, 1], listops=True) + # should stop giving up to compile, eventually + assert get_stats().aborted_count < 6 + def test_subclass_of_virtualizable(self): myjitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) diff --git a/rpython/memory/gc/base.py b/rpython/memory/gc/base.py --- a/rpython/memory/gc/base.py +++ b/rpython/memory/gc/base.py @@ -22,7 +22,7 @@ prebuilt_gc_objects_are_static_roots = True can_usually_pin_objects = False object_minimal_size = 0 - gcflag_extra = 0 # or a real GC flag that is always 0 when not collecting + gcflag_extra = 0 # or a dedicated GC flag that the GC initializes to 0 _totalroots_rpy = 0 # for inspector.py def __init__(self, config, chunk_size=DEFAULT_CHUNK_SIZE, diff --git a/rpython/rlib/rwin32.py b/rpython/rlib/rwin32.py --- a/rpython/rlib/rwin32.py +++ b/rpython/rlib/rwin32.py @@ -261,7 +261,7 @@ 132: 13, 145: 41, 158: 13, 161: 2, 164: 11, 167: 13, 183: 17, 188: 8, 189: 8, 190: 8, 191: 8, 192: 8, 193: 8, 194: 8, 195: 8, 196: 8, 197: 8, 198: 8, 199: 8, 200: 8, 201: 8, - 202: 8, 206: 2, 215: 11, 232: 32, 267: 20, 1816: 12, 1225: 111, + 202: 8, 206: 2, 215: 11, 232: 32, 267: 20, 1816: 12, } return errors, errno.EINVAL diff --git a/rpython/tool/jitlogparser/test/test_modulefinder.py b/rpython/tool/jitlogparser/test/test_modulefinder.py deleted file mode 100644 --- a/rpython/tool/jitlogparser/test/test_modulefinder.py +++ /dev/null @@ -1,22 +0,0 @@ -import py -from rpython.tool.jitlogparser.module_finder import gather_all_code_objs -import re, sys - -def setup_module(mod): - if sys.version_info[:2] != (2, 6): - py.test.skip("Specific python 2.6 tests") - -def test_gather_code_py(): - py.test.skip("XXX broken, fix me") - fname = re.__file__ - codes = gather_all_code_objs(fname) - assert len(codes) == 21 - assert sorted(codes.keys()) == [102, 134, 139, 144, 153, 164, 169, 181, 188, 192, 197, 206, 229, 251, 266, 271, 277, 285, 293, 294, 308] - -def test_load_code(): - py.test.skip("XXX broken, fix me") - fname = re.__file__ - code = gather_all_code_objs(fname)[144] - assert code.co_name == 'sub' - assert code.co_filename == '/usr/lib/python2.6/re.py' - assert code.co_firstlineno == 144 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit