[pypy-svn] r62511 - in pypy/branch/pyjitpl5/pypy: annotation interpreter rlib

fijal at codespeak.net fijal at codespeak.net
Wed Mar 4 10:48:46 CET 2009


Author: fijal
Date: Wed Mar  4 10:48:45 2009
New Revision: 62511

Modified:
   pypy/branch/pyjitpl5/pypy/annotation/listdef.py
   pypy/branch/pyjitpl5/pypy/interpreter/pycode.py
   pypy/branch/pyjitpl5/pypy/interpreter/pyframe.py
   pypy/branch/pyjitpl5/pypy/rlib/debug.py
Log:
A new hint for making sure that consts_w of code object is never modified


Modified: pypy/branch/pyjitpl5/pypy/annotation/listdef.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/annotation/listdef.py	(original)
+++ pypy/branch/pyjitpl5/pypy/annotation/listdef.py	Wed Mar  4 10:48:45 2009
@@ -192,6 +192,10 @@
             raise TooLateForChange()
         self.listitem.dont_resize = True
 
+    def never_mutate(self):
+        if self.listitem.resized or self.listitem.mutated:
+            raise TooLateForChange()
+        self.listitem.dont_change_any_more = True
 
 MOST_GENERAL_LISTDEF = ListDef(None, SomeObject())
 

Modified: pypy/branch/pyjitpl5/pypy/interpreter/pycode.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/interpreter/pycode.py	(original)
+++ pypy/branch/pyjitpl5/pypy/interpreter/pycode.py	Wed Mar  4 10:48:45 2009
@@ -11,7 +11,7 @@
 from pypy.interpreter.gateway import NoneNotWrapped 
 from pypy.interpreter.baseobjspace import ObjSpace, W_Root
 from pypy.rlib.rarithmetic import intmask
-from pypy.rlib.debug import make_sure_not_resized
+from pypy.rlib.debug import make_sure_not_resized, make_sure_not_modified
 
 # helper
 
@@ -67,6 +67,7 @@
         self.co_stacksize = stacksize
         self.co_flags = flags
         self.co_code = code
+        #self.co_consts_w = make_sure_not_modified(consts)
         self.co_consts_w = make_sure_not_resized(consts)
         self.co_names_w = [space.new_interned_str(aname) for aname in names]
         self.co_varnames = varnames

Modified: pypy/branch/pyjitpl5/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/interpreter/pyframe.py	(original)
+++ pypy/branch/pyjitpl5/pypy/interpreter/pyframe.py	Wed Mar  4 10:48:45 2009
@@ -9,6 +9,7 @@
 import opcode
 from pypy.rlib.objectmodel import we_are_translated, instantiate
 from pypy.rlib.jit import we_are_jitted, hint
+from pypy.rlib.debug import make_sure_not_resized
 
 # Define some opcodes used
 g = globals()
@@ -59,6 +60,7 @@
         # class bodies only have CO_NEWLOCALS.
         self.initialize_frame_scopes(closure)
         self.fastlocals_w = [None]*self.numlocals
+        make_sure_not_resized(self.fastlocals_w)
         self.f_lineno = self.pycode.co_firstlineno
 
     def get_builtin(self):

Modified: pypy/branch/pyjitpl5/pypy/rlib/debug.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rlib/debug.py	(original)
+++ pypy/branch/pyjitpl5/pypy/rlib/debug.py	Wed Mar  4 10:48:45 2009
@@ -122,3 +122,28 @@
     def specialize_call(self, hop):
         hop.exception_cannot_occur()
         return hop.inputarg(hop.args_r[0], arg=0)
+
+def make_sure_not_modified(arg):
+    """ Function checking whether annotation of SomeList is never resized
+    and never modified, useful for debugging. Does nothing when run directly
+    """
+    return arg
+
+class Entry(ExtRegistryEntry):
+    _about_ = make_sure_not_modified
+
+    def compute_result_annotation(self, s_arg):
+        from pypy.annotation.model import SomeList
+        assert isinstance(s_arg, SomeList)
+        # the logic behind it is that we try not to propagate
+        # make_sure_not_resized, when list comprehension is not on
+        if self.bookkeeper.annotator.translator.config.translation.list_comprehension_operations:
+            s_arg.listdef.never_mutate()
+        else:
+            from pypy.annotation.annrpython import log
+            log.WARNING('make_sure_not_modified called, but has no effect since list_comprehension is off')
+        return s_arg
+    
+    def specialize_call(self, hop):
+        hop.exception_cannot_occur()
+        return hop.inputarg(hop.args_r[0], arg=0)



More information about the Pypy-commit mailing list