Commits

wlav committed 9b63976 Merge

merge default into branch

Comments (0)

Files changed (62)

 
 The getting-started document will help guide you:
 
-    http://codespeak.net/pypy/dist/pypy/doc/getting-started.html
+    http://doc.pypy.org/en/latest/getting-started.html
 
 It will also point you to the rest of the documentation which is generated
 from files in the pypy/doc directory within the source repositories. Enjoy
 and send us feedback!
 
-    the pypy-dev team <pypy-dev@codespeak.net>
+    the pypy-dev team <pypy-dev@python.org>

pypy/config/pypyoption.py

      "struct", "_hashlib", "_md5", "_sha", "_minimal_curses", "cStringIO",
      "thread", "itertools", "pyexpat", "_ssl", "cpyext", "array",
      "_bisect", "binascii", "_multiprocessing", '_warnings',
-     "_collections", "_multibytecodec", 'micronumpy', "cppyy"]
+     "_collections", "_multibytecodec", "micronumpy", "cppyy"]
 ))
 
 translation_modules = default_modules.copy()
                    "make instances really small but slow without the JIT",
                    default=False,
                    requires=[("objspace.std.getattributeshortcut", True),
-                             ("objspace.std.withtypeversion", True),
+                             ("objspace.std.withmethodcache", True),
                        ]),
 
         BoolOption("withrangelist",

pypy/interpreter/pycode.py

 
         self._compute_flatcall()
 
+        if self.space.config.objspace.std.withmapdict:
+            from pypy.objspace.std.mapdict import init_mapdict_cache
+            init_mapdict_cache(self)
+
     def _freeze_(self):
         if (self.magic == cpython_magic and
             '__pypy__' not in sys.builtin_module_names):

pypy/interpreter/pyopcode.py

     def LOAD_ATTR(self, nameindex, next_instr):
         "obj.attributename"
         w_obj = self.popvalue()
-        w_attributename = self.getname_w(nameindex)
-        w_value = self.space.getattr(w_obj, w_attributename)
+        if (self.space.config.objspace.std.withmapdict
+            and not jit.we_are_jitted()):
+            from pypy.objspace.std.mapdict import LOAD_ATTR_caching
+            w_value = LOAD_ATTR_caching(self.getcode(), w_obj, nameindex)
+        else:
+            w_attributename = self.getname_w(nameindex)
+            w_value = self.space.getattr(w_obj, w_attributename)
         self.pushvalue(w_value)
     LOAD_ATTR._always_inline_ = True
 

pypy/jit/backend/llgraph/llimpl.py

File contents unchanged.

pypy/jit/backend/test/calling_convention_test.py

+from pypy.jit.metainterp.history import (AbstractFailDescr,
+                                         AbstractDescr,
+                                         BasicFailDescr,
+                                         BoxInt, Box, BoxPtr,
+                                         LoopToken,
+                                         ConstInt, ConstPtr,
+                                         BoxObj, Const,
+                                         ConstObj, BoxFloat, ConstFloat)
+from pypy.jit.metainterp.resoperation import ResOperation, rop
+from pypy.jit.metainterp.typesystem import deref
+from pypy.jit.tool.oparser import parse
+from pypy.rpython.lltypesystem import lltype, llmemory, rstr, rffi, rclass
+from pypy.rpython.ootypesystem import ootype
+from pypy.rpython.annlowlevel import llhelper
+from pypy.rpython.llinterp import LLException
+from pypy.jit.codewriter import heaptracker, longlong
+from pypy.rlib.rarithmetic import intmask
+from pypy.jit.backend.detect_cpu import getcpuclass
+from pypy.jit.backend.test.runner_test import Runner
+
+def boxfloat(x):
+    return BoxFloat(longlong.getfloatstorage(x))
+
+def constfloat(x):
+    return ConstFloat(longlong.getfloatstorage(x))
+class FakeStats(object):
+    pass
+class TestCallingConv(Runner):
+    type_system = 'lltype'
+    Ptr = lltype.Ptr
+    FuncType = lltype.FuncType
+
+    def __init__(self):
+        self.cpu = getcpuclass()(rtyper=None, stats=FakeStats())
+        self.cpu.setup_once()
+
+    @classmethod
+    def get_funcbox(cls, cpu, func_ptr):
+        addr = llmemory.cast_ptr_to_adr(func_ptr)
+        return ConstInt(heaptracker.adr2int(addr))
+
+    def test_call_aligned_with_args_on_the_stack(self):
+            from pypy.rlib.libffi import types
+            cpu = self.cpu
+            if not cpu.supports_floats:
+                py.test.skip('requires floats')
+
+
+            def func(*args):
+                return float(sum(args))
+
+            F = lltype.Float
+            I = lltype.Signed
+            floats = [0.7, 5.8, 0.1, 0.3, 0.9, -2.34, -3.45, -4.56]
+            ints = [7, 11, 23, 13, -42, 1111, 95, 1]
+            for case in range(256):
+                result = 0.0
+                args = []
+                argslist = []
+                local_floats = list(floats)
+                local_ints = list(ints)
+                for i in range(8):
+                    if case & (1<<i):
+                        args.append(F)
+                        arg = local_floats.pop()
+                        result += arg
+                        argslist.append(boxfloat(arg))
+                    else:
+                        args.append(I)
+                        arg = local_ints.pop()
+                        result += arg
+                        argslist.append(BoxInt(arg))
+                FUNC = self.FuncType(args, F)
+                FPTR = self.Ptr(FUNC)
+                func_ptr = llhelper(FPTR, func)
+                calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
+                funcbox = self.get_funcbox(cpu, func_ptr)
+
+                res = self.execute_operation(rop.CALL,
+                                             [funcbox] + argslist,
+                                             'float', descr=calldescr)
+                assert abs(res.getfloat() - result) < 0.0001
+
+    def test_call_alignment_call_assembler(self):
+        from pypy.rlib.libffi import types
+        cpu = self.cpu
+        if not cpu.supports_floats:
+            py.test.skip('requires floats')
+
+        fdescr3 = BasicFailDescr(3)
+        fdescr4 = BasicFailDescr(4)
+
+        def assembler_helper(failindex, virtualizable):
+            assert 0, 'should not be called, but was with failindex (%d)' % failindex
+            return 13
+
+        FUNCPTR = lltype.Ptr(lltype.FuncType([lltype.Signed, llmemory.GCREF],
+                                             lltype.Signed))
+        class FakeJitDriverSD:
+            index_of_virtualizable = -1
+            _assembler_helper_ptr = llhelper(FUNCPTR, assembler_helper)
+            assembler_helper_adr = llmemory.cast_ptr_to_adr(
+                _assembler_helper_ptr)
+
+        floats = [0.7, 5.8, 0.1, 0.3, 0.9, -2.34, -3.45, -4.56]
+        ints = [7, 11, 23, 42, -42, 1111, 95, 1]
+        def _prepare_args(args):
+            local_floats = list(floats)
+            local_ints = list(ints)
+            expected_result = 0.0
+            for i in range(len(args)):
+                x = args[i]
+                if x[0] == 'f':
+                    x = local_floats.pop()
+                    t = longlong.getfloatstorage(x)
+                    cpu.set_future_value_float(i, t)
+                else:
+                    x = local_ints.pop()
+                    cpu.set_future_value_int(i, x)
+                expected_result += x
+            return expected_result
+
+        for case in range(256):
+            float_count = 0
+            int_count = 0
+            args = []
+            called_ops = ''
+            total_index = -1
+            for i in range(8):
+                if case & (1<<i):
+                    args.append('f%d' % float_count)
+                else:
+                    args.append('i%d' % int_count)
+                    called_ops += 'f%d = cast_int_to_float(i%d)\n' % (
+                        float_count, int_count)
+                    int_count += 1
+                if total_index == -1:
+                    total_index = float_count
+                    float_count += 1
+                else:
+                    called_ops += 'f%d = float_add(f%d, f%d)\n' % (
+                        float_count + 1, total_index, float_count)
+                    total_index = float_count + 1
+                    float_count += 2
+            arguments = ', '.join(args)
+            called_ops = '[%s]\n' % arguments + called_ops
+            called_ops += 'finish(f%d, descr=fdescr3)\n' % total_index
+            # compile called loop
+            called_loop = parse(called_ops, namespace=locals())
+            called_looptoken = LoopToken()
+            called_looptoken.outermost_jitdriver_sd = FakeJitDriverSD()
+            done_number = self.cpu.get_fail_descr_number(called_loop.operations[-1].getdescr())
+            self.cpu.compile_loop(called_loop.inputargs, called_loop.operations, called_looptoken)
+
+            expected_result = _prepare_args(args)
+            res = cpu.execute_token(called_looptoken)
+            assert res.identifier == 3
+            t = longlong.getrealfloat(cpu.get_latest_value_float(0))
+            assert abs(t - expected_result) < 0.0001
+
+            ARGS = []
+            RES = lltype.Float
+            for x in args:
+                if x[0] == 'f':
+                    ARGS.append(lltype.Float)
+                else:
+                    ARGS.append(lltype.Signed)
+            FakeJitDriverSD.portal_calldescr = self.cpu.calldescrof(
+                lltype.Ptr(lltype.FuncType(ARGS, RES)), ARGS, RES)
+            ops = '''
+            [%s]
+            f99 = call_assembler(%s, descr=called_looptoken)
+            guard_not_forced()[]
+            finish(f99, descr=fdescr4)
+            ''' % (arguments, arguments)
+            loop = parse(ops, namespace=locals())
+            # we want to take the fast path
+            self.cpu.done_with_this_frame_float_v = done_number
+            try:
+                othertoken = LoopToken()
+                self.cpu.compile_loop(loop.inputargs, loop.operations, othertoken)
+
+                # prepare call to called_loop
+                _prepare_args(args)
+                res = cpu.execute_token(othertoken)
+                x = longlong.getrealfloat(cpu.get_latest_value_float(0))
+                assert res.identifier == 4
+                assert abs(x - expected_result) < 0.0001
+            finally:
+                del self.cpu.done_with_this_frame_float_v

pypy/jit/backend/x86/assembler.py

         self.current_clt = looptoken.compiled_loop_token
         self.pending_guard_tokens = []
         self.mc = codebuf.MachineCodeBlockWrapper()
-        if self.datablockwrapper is None:
-            allblocks = self.get_asmmemmgr_blocks(looptoken)
-            self.datablockwrapper = MachineDataBlockWrapper(self.cpu.asmmemmgr,
-                                                            allblocks)
+        assert self.datablockwrapper is None
+        allblocks = self.get_asmmemmgr_blocks(looptoken)
+        self.datablockwrapper = MachineDataBlockWrapper(self.cpu.asmmemmgr,
+                                                        allblocks)
 
     def teardown(self):
         self.pending_guard_tokens = None
         nonfloatlocs, floatlocs = arglocs
         self._call_header_with_stack_check()
         self.mc.LEA_rb(esp.value, self._get_offset_of_ebp_from_esp(stackdepth))
-        for i in range(len(nonfloatlocs)):
-            loc = nonfloatlocs[i]
-            if isinstance(loc, RegLoc):
-                assert not loc.is_xmm
-                self.mc.MOV_rb(loc.value, (2 + i) * WORD)
-            loc = floatlocs[i]
-            if isinstance(loc, RegLoc):
-                assert loc.is_xmm
-                self.mc.MOVSD_xb(loc.value, (1 + i) * 2 * WORD)
+        offset = 2 * WORD
         tmp = eax
         xmmtmp = xmm0
         for i in range(len(nonfloatlocs)):
             loc = nonfloatlocs[i]
-            if loc is not None and not isinstance(loc, RegLoc):
-                self.mc.MOV_rb(tmp.value, (2 + i) * WORD)
-                self.mc.MOV(loc, tmp)
+            if loc is not None:
+                if isinstance(loc, RegLoc):
+                    assert not loc.is_xmm
+                    self.mc.MOV_rb(loc.value, offset)
+                else:
+                    self.mc.MOV_rb(tmp.value, offset)
+                    self.mc.MOV(loc, tmp)
+                offset += WORD
             loc = floatlocs[i]
-            if loc is not None and not isinstance(loc, RegLoc):
-                self.mc.MOVSD_xb(xmmtmp.value, (1 + i) * 2 * WORD)
-                assert isinstance(loc, StackLoc)
-                self.mc.MOVSD_bx(loc.value, xmmtmp.value)
+            if loc is not None:
+                if isinstance(loc, RegLoc):
+                    assert loc.is_xmm
+                    self.mc.MOVSD_xb(loc.value, offset)
+                else:
+                    self.mc.MOVSD_xb(xmmtmp.value, offset)
+                    assert isinstance(loc, StackLoc)
+                    self.mc.MOVSD_bx(loc.value, xmmtmp.value)
+                offset += 2 * WORD
         endpos = self.mc.get_relative_pos() + 5
         self.mc.JMP_l(jmppos - endpos)
         assert endpos == self.mc.get_relative_pos()
         # a no-op.
 
         # reserve room for the argument to the real malloc and the
-        # 8 saved XMM regs
+        # saved XMM regs (on 32 bit: 8 * 2 words; on 64 bit: 16 * 1
+        # word)
         self._regalloc.reserve_param(1+16)
 
         gcrootmap = self.cpu.gc_ll_descr.gcrootmap

pypy/jit/backend/x86/test/test_calling_convention.py

+from pypy.jit.backend.test.calling_convention_test import TestCallingConv

pypy/jit/codewriter/jitcode.py

     def __repr__(self):
         return '<JitCode %r>' % self.name
 
+    def _clone_if_mutable(self):
+        raise NotImplementedError
+    
 class MissingLiveness(Exception):
     pass
 
         dict = getattr(self, 'dict', '?')
         return '<SwitchDictDescr %s>' % (dict,)
 
+    def _clone_if_mutable(self):
+        raise NotImplementedError
+
 
 class LiveVarsInfo(object):
     def __init__(self, live_i, live_r, live_f):

pypy/jit/metainterp/compile.py

 
     history = metainterp.history
     loop = create_empty_loop(metainterp)
-    loop.inputargs = history.inputargs
+    loop.inputargs = history.inputargs[:]
     for box in loop.inputargs:
         assert isinstance(box, Box)
     # make a copy, because optimize_loop can mutate the ops and descrs
     # Attempt to use optimize_bridge().  This may return None in case
     # it does not work -- i.e. none of the existing old_loop_tokens match.
     new_loop = create_empty_loop(metainterp)
-    new_loop.inputargs = metainterp.history.inputargs
+    new_loop.inputargs = metainterp.history.inputargs[:]
     # clone ops, as optimize_bridge can mutate the ops
     new_loop.operations = [op.clone() for op in metainterp.history.operations]
     metainterp_sd = metainterp.staticdata

pypy/jit/metainterp/executor.py

File contents unchanged.

pypy/jit/metainterp/history.py

         cpu.set_future_value_int(j, self.value)
 
     def same_constant(self, other):
-        if isinstance(other, Const):
-            return self.value == other.getint()
+        if isinstance(other, ConstInt):
+            return self.value == other.value
         return False
 
     def nonnull(self):
 
     def dump(self):
         self.compiled_loop_token.cpu.dump_loop_token(self)
-
 class TreeLoop(object):
     inputargs = None
     operations = None
     compiled_count = 0
     enter_count = 0
     aborted_count = 0
-    history = None
+    operations = None
 
     def __init__(self):
         self.loops = []
         self.aborted_keys = []
 
     def set_history(self, history):
-        self.history = history
+        self.operations = history.operations
 
     def aborted(self):
         self.aborted_count += 1
 
     def check_history(self, expected=None, **check):
         insns = {}
-        for op in self.history.operations:
+        for op in self.operations:
             opname = op.getopname()
             insns[opname] = insns.get(opname, 0) + 1
         if expected is not None:

pypy/jit/metainterp/optimizeopt/intbounds.py

             if self.nextop.getopnum() == rop.GUARD_NO_OVERFLOW:
                 # Synthesize the non overflowing op for optimize_default to reuse
                 self.pure(rop.INT_ADD, op.getarglist()[:], op.result)
+                # Synthesize the reverse op for optimize_default to reuse
+                self.pure(rop.INT_SUB, [op.result, op.getarg(1)], op.getarg(0))
+                self.pure(rop.INT_SUB, [op.result, op.getarg(0)], op.getarg(1))
 
 
     def optimize_INT_SUB_OVF(self, op):
             if self.nextop.getopnum() == rop.GUARD_NO_OVERFLOW:
                 # Synthesize the non overflowing op for optimize_default to reuse
                 self.pure(rop.INT_SUB, op.getarglist()[:], op.result)
+                # Synthesize the reverse ops for optimize_default to reuse
+                self.pure(rop.INT_ADD, [op.result, op.getarg(1)], op.getarg(0))
+                self.pure(rop.INT_SUB, [op.getarg(0), op.result], op.getarg(1))
+                
 
     def optimize_INT_MUL_OVF(self, op):
         v1 = self.getvalue(op.getarg(0))

pypy/jit/metainterp/optimizeopt/simplify.py

File contents unchanged.

pypy/jit/metainterp/optimizeopt/virtualize.py

File contents unchanged.

pypy/jit/metainterp/pyjitpl.py

                 else:
                     self.compile(original_boxes, live_arg_boxes, start, resumedescr)
                 # creation of the loop was cancelled!
-                #self.staticdata.log('cancelled, tracing more...')
-                self.staticdata.log('cancelled, stopping tracing')
-                raise SwitchToBlackhole(ABORT_BAD_LOOP)
+                self.staticdata.log('cancelled, tracing more...')
+                #self.staticdata.log('cancelled, stopping tracing')
+                #raise SwitchToBlackhole(ABORT_BAD_LOOP)
 
         # Otherwise, no loop found so far, so continue tracing.
         start = len(self.history.operations)
 
     def compile(self, original_boxes, live_arg_boxes, start, start_resumedescr):
         num_green_args = self.jitdriver_sd.num_green_args
+        original_inputargs = self.history.inputargs
         self.history.inputargs = original_boxes[num_green_args:]
         greenkey = original_boxes[:num_green_args]
         old_loop_tokens = self.get_compiled_merge_points(greenkey)
                                               greenkey, start, start_resumedescr)
         if loop_token is not None: # raise if it *worked* correctly
             self.set_compiled_merge_points(greenkey, old_loop_tokens)
+            self.history.inputargs = None
+            self.history.operations = None
             raise GenerateMergePoint(live_arg_boxes, loop_token)
+
+        self.history.inputargs = original_inputargs
         self.history.operations.pop()     # remove the JUMP
         # FIXME: Why is self.history.inputargs not restored?
 
             target_loop_token = compile.compile_new_bridge(self,
                                                            old_loop_tokens,
                                                            self.resumekey)
-            if target_loop_token is not None: # raise if it *worked* correctly
-                raise GenerateMergePoint(live_arg_boxes, target_loop_token)
         finally:
             self.history.operations.pop()     # remove the JUMP
+        if target_loop_token is not None: # raise if it *worked* correctly
+            self.history.inputargs = None
+            self.history.operations = None
+            raise GenerateMergePoint(live_arg_boxes, target_loop_token)
 
     def compile_bridge_and_loop(self, original_boxes, live_arg_boxes, start,
                                 bridge_arg_boxes, start_resumedescr):
             assert False
         assert target_loop_token is not None
 
-        self.history.operations = original_operations
+        self.history.inputargs = None
+        self.history.operations = None
         raise GenerateMergePoint(live_arg_boxes, old_loop_tokens[0])
 
     def compile_done_with_this_frame(self, exitbox):

pypy/jit/metainterp/resoperation.py

File contents unchanged.

pypy/jit/metainterp/test/test_ajit.py

             return a1.val + b1.val
         res = self.meta_interp(g, [3, 23])
         assert res == 7068153
-        self.check_loop_count(6)
+        self.check_loop_count(7)
         self.check_loops(guard_true=4, guard_class=0, int_add=2, int_mul=2,
                          guard_false=2)
 
         assert self.meta_interp(f, [5, 100]) == 0
         self.check_loops(int_rshift=1, everywhere=True)
 
+    def test_inputarg_reset_bug(self):
+        ## j = 0
+        ## while j < 100:
+        ##     j += 1
+
+        ## c = 0
+        ## j = 0
+        ## while j < 2:
+        ##     j += 1
+        ##     if c == 0:
+        ##         c = 1
+        ##     else:
+        ##         c = 0
+
+        ## j = 0
+        ## while j < 100:
+        ##     j += 1
+
+        def get_printable_location(i):
+            return str(i)
+        
+        myjitdriver = JitDriver(greens = ['i'], reds = ['j', 'c', 'a'],
+                                get_printable_location=get_printable_location)
+        bytecode = "0j10jc20a3"
+        def f():
+            myjitdriver.set_param('threshold', 7)
+            myjitdriver.set_param('trace_eagerness', 1)
+            i = j = c = a = 1
+            while True:
+                myjitdriver.jit_merge_point(i=i, j=j, c=c, a=a)
+                if i >= len(bytecode):
+                    break
+                op = bytecode[i]
+                if op == 'j':
+                    j += 1
+                elif op == 'c':
+                    c = hint(c, promote=True)
+                    c = 1 - c
+                elif op == '2':
+                    if j < 3:
+                        i -= 3
+                        myjitdriver.can_enter_jit(i=i, j=j, c=c, a=a)
+                elif op == '1':
+                    k = j*a
+                    if j < 100:
+                        i -= 2
+                        a += k
+                        myjitdriver.can_enter_jit(i=i, j=j, c=c, a=a)
+                    else:
+                        a += k*2
+                elif op == '0':
+                    j = c = a = 0
+                elif op == 'a':
+                    j += 1
+                    a += 1
+                elif op == '3':
+                    if a < 100:
+                        i -= 2
+                        myjitdriver.can_enter_jit(i=i, j=j, c=c, a=a)
+
+                else:
+                    return ord(op)
+                i += 1
+            return 42
+        assert f() == 42
+        def g():
+            res = 1
+            for i in range(10):
+                res = f()
+            return res
+        res = self.meta_interp(g, [])
+        assert res == 42
+
     def test_read_timestamp(self):
         import time
         from pypy.rlib.rtimer import read_timestamp

pypy/jit/metainterp/test/test_history.py

     s = lltype.cast_pointer(lltype.Ptr(S), t)
     const = ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s))
     assert const._getrepr_() == "*T"
+
+def test_same_constant():
+    c1a = ConstInt(0)
+    c1b = ConstInt(0)
+    c2a = ConstPtr(lltype.nullptr(llmemory.GCREF.TO))
+    c2b = ConstPtr(lltype.nullptr(llmemory.GCREF.TO))
+    c3a = Const._new(0.0)
+    c3b = Const._new(0.0)
+    assert     c1a.same_constant(c1b)
+    assert not c1a.same_constant(c2b)
+    assert not c1a.same_constant(c3b)
+    assert not c2a.same_constant(c1b)
+    assert     c2a.same_constant(c2b)
+    assert not c2a.same_constant(c3b)
+    assert not c3a.same_constant(c1b)
+    assert not c3a.same_constant(c2b)
+    assert     c3a.same_constant(c3b)

pypy/jit/metainterp/test/test_optimizeopt.py

         jump(i4, i10)
         """
         self.optimize_loop(ops, expected)
+        
+    def test_add_sub_ovf(self):
+        ops = """
+        [i1]
+        i2 = int_add_ovf(i1, 1)
+        guard_no_overflow() []
+        i3 = int_sub_ovf(i2, 1)
+        guard_no_overflow() []
+        escape(i3)
+        jump(i2)
+        """
+        expected = """
+        [i1]
+        i2 = int_add_ovf(i1, 1)
+        guard_no_overflow() []
+        escape(i1)
+        jump(i2)
+        """
+        self.optimize_loop(ops, expected)
+
+    def test_add_sub_ovf_virtual_unroll(self):
+        ops = """
+        [p15]
+        i886 = getfield_gc_pure(p15, descr=valuedescr)
+        i888 = int_sub_ovf(i886, 1)
+        guard_no_overflow() []
+        escape(i888)
+        i4360 = getfield_gc_pure(p15, descr=valuedescr)
+        i4362 = int_add_ovf(i4360, 1)
+        guard_no_overflow() []
+        i4360p = int_sub_ovf(i4362, 1)
+        guard_no_overflow() []
+        p4364 = new_with_vtable(ConstClass(node_vtable))
+        setfield_gc(p4364, i4362, descr=valuedescr)
+        jump(p4364)
+        """
+        expected = """
+        [i0, i1]
+        escape(i1)
+        i2 = int_add_ovf(i0, 1)
+        guard_no_overflow() []        
+        jump(i2, i0)
+        """
+        self.optimize_loop(ops, expected)
 
     def test_framestackdepth_overhead(self):
         ops = """

pypy/jit/metainterp/test/test_recursive.py

File contents unchanged.

pypy/jit/metainterp/test/test_send.py

         # InvalidLoop condition, and was then unrolled, giving two copies
         # of the body in a single bigger loop with no failing guard except
         # the final one.
-        py.test.skip('dissabled "try to trace some more when compile fails"')
         self.check_loop_count(1)
         self.check_loops(guard_class=0,
                                 int_add=2, int_sub=2)
                 return self.y
         w1 = W1(10)
         w2 = W2(20)
+
         def f(x, y):
             if x & 1:
                 w = w1
         assert res == f(3, 28)
         res = self.meta_interp(f, [4, 28])
         assert res == f(4, 28)
-        py.test.skip('dissabled "try to trace some more when compile fails"')
         self.check_loop_count(1)
         self.check_loops(guard_class=0,
                                 int_add=2, int_sub=2)

pypy/jit/metainterp/test/test_virtualref.py

         assert res == main(10, 2)
         self.check_aborted_count(0)
 
+    def test_alloc_virtualref_and_then_alloc_structure(self):
+        myjitdriver = JitDriver(greens = [], reds = ['n'])
+        #
+        class XY:
+            pass
+        class ExCtx:
+            pass
+        exctx = ExCtx()
+        @dont_look_inside
+        def escapexy(xy):
+            print 'escapexy:', xy.n
+            if xy.n % 5 == 0:
+                vr = exctx.vr
+                print 'accessing via vr:', vr()
+                assert vr() is xy
+        #
+        def f(n):
+            while n > 0:
+                myjitdriver.jit_merge_point(n=n)
+                xy = XY()
+                xy.n = n
+                vr = virtual_ref(xy)
+                # force the virtualref to be allocated
+                exctx.vr = vr
+                # force xy to be allocated
+                escapexy(xy)
+                # clean up
+                exctx.vr = vref_None
+                virtual_ref_finish(xy)
+                n -= 1
+            return 1
+        #
+        res = self.meta_interp(f, [15])
+        assert res == 1
+        self.check_loops(new_with_vtable=2)     # vref, xy
+
 
 class TestLLtype(VRefTests, LLJitMixin):
     pass

pypy/jit/metainterp/test/test_ztranslation.py

                 self.i = i
                 self.l = [float(i)]
 
-        class OtherFrame(object):
-            _virtualizable2_ = ['i']
-
-            def __init__(self, i):
-                self.i = i
-
         class JitCellCache:
             entry = None
         jitcellcache = JitCellCache()
                 frame.l[0] -= 1
             return total * 10
         #
-        myjitdriver2 = JitDriver(greens = ['g'], reds = ['m', 's', 'f'],
+        myjitdriver2 = JitDriver(greens = ['g'],
+                                 reds = ['m', 's', 'f', 'float_s'],
                                  virtualizables = ['f'])
         def f2(g, m, x):
             s = ""

pypy/jit/tool/cpython.vmrss

-124
-16600
-20620
-20640
-22036
-94084
-94084
-94108
-94108
-94108
-94108
-94108
-94120
-94164
-94160
-94160
-94160
-94160
-94160
-94216
-110644
-123144
-135236
-143680
-148500
-153104
-157088
-160640
-164760
-167992
-163108
-163232
-163232
-163436
-163436
-163436
-163444
-163444
-163444
-163448
-163448
-163448
-163448
-163448
-163448
-167060
-170948
-174432
-177212
-177216
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176508
-176520
-176520
-176520
-176520
-176520
-176520
-176520
-176520
-176520
-176540
-176544
-176544
-176544
-176544
-176544
-176544
-176544
-176544
-176544
-176544
-176544
-176544
-179120
-187120
-189380
-191052
-192156
-193320
-194900
-195860
-198516
-201484
-202600
-202600
-202600
-202600
-202832
-202832
-202836
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-202840
-207784
-212136
-216320
-220508
-224696
-228876
-245088
-245088
-247844
-252032
-256212
-260400
-264592
-268776
-272776
-275060
-279244
-283428
-287616
-291032
-293900
-298080
-302272
-304364
-308548
-310644
-312740
-316924
-319016
-323208
-325296
-327392
-331572
-333668
-335760
-337856
-354328
-356424
-358520
-362700
-364792
-366892
-368984
-371080
-373168
-375260
-377356
-379448
-381540
-383636
-383636
-385732
-387820
-390032
-391160
-392292
-394552
-396816
-397092
-399072
-401340
-403600
-405860
-408008
-408148
-412640
-414900
-417164
-419420
-421680
-423944
-426204
-428464
-430724
-432768
-434980
-436476
-437932
-440332
-441984
-442740
-445152
-447688
-449148
-449960
-452436
-454712
-454896
-457180
-458888
-459688
-462040
-463480
-464408
-466812
-467244
-469224
-471096
-471684
-474136
-474328
-476508
-478872
-481356
-483472
-483780
-486072
-488480
-489668
-490888
-493420
-495704
-496836
-498116
-500520
-502756
-503668
-505400
-507760
-509296
-510204
-512764
-514708
-515508
-517372
-519764
-520648
-522188
-524596
-525524
-527004
-529412
-534224
-536632
-538080
-539216
-541588
-542560
-543384
-543384
-518804
-518804
-518804
-518804
-518804
-518804
-518804
-518804
-518804
-518804
-518804
-518804
-518804
-518804
-518804
-518804
-518804
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519024
-519028
-519028
-519028
-519028
-519028
-519028
-519028
-519028
-519028
-519028
-519028
-519028
-519032
-519032
-519032
-519032
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519036
-519048
-519048
-519048
-519048
-519048
-519048
-519048
-519048
-519048
-519048
-519048
-519048
-519048
-519048
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519052
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519056
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519060
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519064
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068
-519068