[pypy-svn] pypy out-of-line-guards-2: Adapt the _immutable_ and _immutable_fields_ hints left and right.

arigo commits-noreply at bitbucket.org
Sat May 7 12:49:27 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: out-of-line-guards-2
Changeset: r43936:98ad343ba2a4
Date: 2011-05-07 10:09 +0000
http://bitbucket.org/pypy/pypy/changeset/98ad343ba2a4/

Log:	Adapt the _immutable_ and _immutable_fields_ hints left and right. I
	think this branch is now ready to be merged, if it passes all tests.

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1266,10 +1266,11 @@
 
 
 class FrameBlock(object):
-
     """Abstract base class for frame blocks from the blockstack,
     used by the SETUP_XXX and POP_BLOCK opcodes."""
 
+    _immutable_ = True
+
     def __init__(self, frame, handlerposition):
         self.handlerposition = handlerposition
         self.valuestackdepth = frame.valuestackdepth
@@ -1311,6 +1312,7 @@
 class LoopBlock(FrameBlock):
     """A loop block.  Stores the end-of-loop pointer in case of 'break'."""
 
+    _immutable_ = True
     _opname = 'SETUP_LOOP'
     handling_mask = SBreakLoop.kind | SContinueLoop.kind
 
@@ -1330,6 +1332,7 @@
 class ExceptBlock(FrameBlock):
     """An try:except: block.  Stores the position of the exception handler."""
 
+    _immutable_ = True
     _opname = 'SETUP_EXCEPT'
     handling_mask = SApplicationException.kind
 
@@ -1354,6 +1357,7 @@
 class FinallyBlock(FrameBlock):
     """A try:finally: block.  Stores the position of the exception handler."""
 
+    _immutable_ = True
     _opname = 'SETUP_FINALLY'
     handling_mask = -1     # handles every kind of SuspendedUnroller
 
@@ -1381,6 +1385,8 @@
 
 class WithBlock(FinallyBlock):
 
+    _immutable_ = True
+
     def really_handle(self, frame, unroller):
         if (frame.space.full_exceptions and
             isinstance(unroller, SApplicationException)):
diff --git a/pypy/interpreter/special.py b/pypy/interpreter/special.py
--- a/pypy/interpreter/special.py
+++ b/pypy/interpreter/special.py
@@ -2,14 +2,12 @@
 from pypy.interpreter.baseobjspace import Wrappable
 
 class Ellipsis(Wrappable):
-    _immutable_ = True
     def __init__(self, space):
         self.space = space 
     def descr__repr__(self):
         return self.space.wrap('Ellipsis')
 
 class NotImplemented(Wrappable): 
-    _immutable_ = True
     def __init__(self, space):
         self.space = space 
     def descr__repr__(self):
diff --git a/pypy/objspace/std/boolobject.py b/pypy/objspace/std/boolobject.py
--- a/pypy/objspace/std/boolobject.py
+++ b/pypy/objspace/std/boolobject.py
@@ -5,8 +5,7 @@
 
 class W_BoolObject(W_Object):
     from pypy.objspace.std.booltype import bool_typedef as typedef
-
-    _immutable_ = True
+    _immutable_fields_ = ['boolval']
 
     def __init__(w_self, boolval):
         w_self.boolval = not not boolval
diff --git a/pypy/objspace/std/noneobject.py b/pypy/objspace/std/noneobject.py
--- a/pypy/objspace/std/noneobject.py
+++ b/pypy/objspace/std/noneobject.py
@@ -9,7 +9,6 @@
 
 class W_NoneObject(W_Object):
     from pypy.objspace.std.nonetype import none_typedef as typedef
-    _immutable_ = True
 
     def unwrap(w_self, space):
         return None
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -88,7 +88,7 @@
 
     _immutable_fields_ = ["flag_heaptype",
                           "flag_cpytype",
-                          #  flag_abstract is not immutable
+                          "flag_abstract?",
                           'needsdel',
                           'weakrefable',
                           'hasdict',


More information about the Pypy-commit mailing list