[pypy-svn] r69059 - in pypy/trunk/pypy/jit: backend/llsupport backend/x86 metainterp

arigo at codespeak.net arigo at codespeak.net
Sun Nov 8 14:54:39 CET 2009


Author: arigo
Date: Sun Nov  8 14:54:36 2009
New Revision: 69059

Modified:
   pypy/trunk/pypy/jit/backend/llsupport/descr.py
   pypy/trunk/pypy/jit/backend/x86/regalloc.py
   pypy/trunk/pypy/jit/metainterp/optimizeopt.py
   pypy/trunk/pypy/jit/metainterp/pyjitpl.py
   pypy/trunk/pypy/jit/metainterp/resoperation.py
   pypy/trunk/pypy/jit/metainterp/warmspot.py
Log:
Make the list ResOperation.args non-resizable.  Fight a bit
to understand how that list is unified with inputargs, which
is a definitely resizable list.


Modified: pypy/trunk/pypy/jit/backend/llsupport/descr.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/llsupport/descr.py	(original)
+++ pypy/trunk/pypy/jit/backend/llsupport/descr.py	Sun Nov  8 14:54:36 2009
@@ -224,13 +224,17 @@
                 result = BoxInt()
             result_list = [result]
         operations = [
-            ResOperation(rop.CALL, args, result, self),
+            ResOperation(rop.CALL, args[:], result, self),
             ResOperation(rop.GUARD_NO_EXCEPTION, [], None,
                          descr=BasicFailDescr()),
             ResOperation(rop.FINISH, result_list, None,
                          descr=BasicFailDescr())]
         operations[1].fail_args = []
         loop_token = LoopToken()
+        # note: the 'args' that we pass below is not the same object as the
+        # 'args[:]' that was passed above to ResOperation, because we want
+        # the argument to ResOperation to be non-resizable, but the argument
+        # to compile_loop to be resizable.
         cpu.compile_loop(args, operations, loop_token)
         self.loop_token = loop_token
         return loop_token

Modified: pypy/trunk/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/regalloc.py	Sun Nov  8 14:54:36 2009
@@ -190,7 +190,9 @@
         self.xrm.free_regs.insert(0, xmmtmp)
         assert tmpreg not in nonfloatlocs
         assert xmmtmp not in floatlocs
-        self.possibly_free_vars(inputargs)
+        # note: we need to make a copy of inputargs because possibly_free_vars
+        # is also used on op.args, which is a non-resizable list
+        self.possibly_free_vars(list(inputargs))
         return nonfloatlocs, floatlocs
 
     def possibly_free_var(self, var):
@@ -234,11 +236,11 @@
                     loop_consts[inputargs[i]] = i
         return loop_consts
 
-    def _update_bindings(self, locs, args):
+    def _update_bindings(self, locs, inputargs):
         # XXX this should probably go to llsupport/regalloc.py
         used = {}
-        for i in range(len(args)):
-            arg = args[i]
+        for i in range(len(inputargs)):
+            arg = inputargs[i]
             loc = locs[i]
             if arg.type == FLOAT:
                 if isinstance(loc, REG):
@@ -260,7 +262,9 @@
         for reg in X86XMMRegisterManager.all_regs:
             if reg not in used:
                 self.xrm.free_regs.append(reg)
-        self.possibly_free_vars(args)
+        # note: we need to make a copy of inputargs because possibly_free_vars
+        # is also used on op.args, which is a non-resizable list
+        self.possibly_free_vars(list(inputargs))
         self.rm._check_invariants()
         self.xrm._check_invariants()
 
@@ -851,7 +855,7 @@
         ofs = arraydescr.get_ofs_length(self.translate_support_code)
         base_loc = self.rm.make_sure_var_in_reg(op.args[0], op.args)
         self.rm.possibly_free_vars(op.args)
-        result_loc = self.rm.force_allocate_reg(op.result, [])
+        result_loc = self.rm.force_allocate_reg(op.result)
         self.Perform(op, [base_loc, imm(ofs)], result_loc)
 
     def consider_strgetitem(self, op, ignored):

Modified: pypy/trunk/pypy/jit/metainterp/optimizeopt.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/optimizeopt.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/optimizeopt.py	Sun Nov  8 14:54:36 2009
@@ -540,8 +540,7 @@
             else:
                 raise AssertionError("uh?")
             op.opnum = opnum
-            assert len(op.args) == 2
-            op.args.pop()
+            op.args = [op.args[0]]
 
     def optimize_default(self, op):
         if op.is_always_pure():
@@ -568,7 +567,7 @@
             value = self.getvalue(op.args[i])
             specnodes[i].teardown_virtual_node(self, value, exitargs)
         op2 = op.clone()
-        op2.args = exitargs
+        op2.args = exitargs[:]
         self.emit_operation(op2, must_clone=False)
 
     def optimize_guard(self, op, constbox):

Modified: pypy/trunk/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/pyjitpl.py	Sun Nov  8 14:54:36 2009
@@ -1283,6 +1283,7 @@
             if require_attention:
                 require_attention = self.after_residual_call()
             # check if the operation can be constant-folded away
+            argboxes = list(argboxes)
             if rop._ALWAYS_PURE_FIRST <= opnum <= rop._ALWAYS_PURE_LAST:
                 resbox = self._record_helper_pure_varargs(opnum, resbox, descr, argboxes)
             else:

Modified: pypy/trunk/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/resoperation.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/resoperation.py	Sun Nov  8 14:54:36 2009
@@ -1,4 +1,5 @@
 from pypy.rlib.objectmodel import we_are_translated
+from pypy.rlib.debug import make_sure_not_resized
 
 
 class ResOperation(object):
@@ -12,9 +13,11 @@
     pc = 0
 
     def __init__(self, opnum, args, result, descr=None):
+        make_sure_not_resized(args)
         assert isinstance(opnum, int)
         self.opnum = opnum
         self.args = list(args)
+        make_sure_not_resized(self.args)
         assert not isinstance(result, list)
         self.result = result
         self.setdescr(descr)

Modified: pypy/trunk/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/warmspot.py	Sun Nov  8 14:54:36 2009
@@ -66,6 +66,7 @@
                     debug_level=DEBUG_STEPS, inline=False, **kwds):
     translator = interp.typer.annotator.translator
     translator.config.translation.gc = "boehm"
+    translator.config.translation.list_comprehension_operations = True
     warmrunnerdesc = WarmRunnerDesc(translator, backendopt=backendopt, **kwds)
     warmrunnerdesc.state.set_param_threshold(3)          # for tests
     warmrunnerdesc.state.set_param_trace_eagerness(2)    # for tests



More information about the Pypy-commit mailing list