Author: Spenser Bauman <saba...@gmail.com>
Branch: value-classes
Changeset: r87285:28ad6be3c6c6
Date: 2016-09-21 13:13 -0400
http://bitbucket.org/pypy/pypy/changeset/28ad6be3c6c6/

Log:    Change is_immutable to is_value_class

diff --git a/rpython/jit/backend/llgraph/runner.py 
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -136,9 +136,6 @@
                                                                self.S)
         return heaptracker.adr2int(llmemory.cast_ptr_to_adr(self._vtable))
 
-    def is_immutable(self):
-        return heaptracker.is_immutable_struct(self.S)
-
     def is_value_class(self):
         return heaptracker.is_value_class(self.S)
 
diff --git a/rpython/jit/backend/llsupport/descr.py 
b/rpython/jit/backend/llsupport/descr.py
--- a/rpython/jit/backend/llsupport/descr.py
+++ b/rpython/jit/backend/llsupport/descr.py
@@ -60,19 +60,16 @@
     size = 0      # help translation
     tid = llop.combine_ushort(lltype.Signed, 0, 0)
     vtable = lltype.nullptr(rclass.OBJECT_VTABLE)
-    immutable_flag = False
     value_class_flag = False
 
     def __init__(self, size, gc_fielddescrs=None, all_fielddescrs=None,
                  vtable=lltype.nullptr(rclass.OBJECT_VTABLE),
-                 immutable_flag=False,
                  value_class_flag=False):
         assert lltype.typeOf(vtable) == lltype.Ptr(rclass.OBJECT_VTABLE)
         self.size = size
         self.gc_fielddescrs = gc_fielddescrs
         self.all_fielddescrs = all_fielddescrs
         self.vtable = vtable
-        self.immutable_flag = immutable_flag
         self.value_class_flag = value_class_flag
 
     def get_all_fielddescrs(self):
@@ -94,9 +91,6 @@
         # fields
         return objptr.typeptr == cls or rclass.ll_isinstance(objptr, cls)
 
-    def is_immutable(self):
-        return self.immutable_flag
-
     def is_value_class(self):
         return self.value_class_flag
 
@@ -114,14 +108,12 @@
         return cache[STRUCT]
     except KeyError:
         size = symbolic.get_size(STRUCT, gccache.translate_support_code)
-        immutable_flag = heaptracker.is_immutable_struct(STRUCT)
         value_class_flag = heaptracker.is_value_class(STRUCT)
         if vtable:
             assert heaptracker.has_gcstruct_a_vtable(STRUCT)
         else:
             assert not heaptracker.has_gcstruct_a_vtable(STRUCT)
         sizedescr = SizeDescr(size, vtable=vtable,
-                              immutable_flag=immutable_flag,
                               value_class_flag=value_class_flag)
         gccache.init_size_descr(STRUCT, sizedescr)
         cache[STRUCT] = sizedescr
diff --git a/rpython/jit/backend/llsupport/test/test_descr.py 
b/rpython/jit/backend/llsupport/test/test_descr.py
--- a/rpython/jit/backend/llsupport/test/test_descr.py
+++ b/rpython/jit/backend/llsupport/test/test_descr.py
@@ -17,8 +17,8 @@
     descr_t = get_size_descr(c0, T)
     assert descr_s.size == symbolic.get_size(S, False)
     assert descr_t.size == symbolic.get_size(T, False)
-    assert descr_s.is_immutable() == False
-    assert descr_t.is_immutable() == False
+    assert descr_s.is_value_class() == False
+    assert descr_t.is_value_class() == False
     assert descr_t.gc_fielddescrs == []
     assert len(descr_s.gc_fielddescrs) == 1
     assert descr_s == get_size_descr(c0, S)
@@ -26,7 +26,7 @@
     #
     descr_s = get_size_descr(c1, S)
     assert isinstance(descr_s.size, Symbolic)
-    assert descr_s.is_immutable() == False
+    assert descr_s.is_value_class() == False
 
     PARENT = lltype.Struct('P', ('x', lltype.Ptr(T)))
     STRUCT = lltype.GcStruct('S', ('parent', PARENT), ('y', lltype.Ptr(T)))
@@ -34,38 +34,18 @@
     assert len(descr_struct.gc_fielddescrs) == 2
 
 def test_get_size_descr_immut():
-    S = lltype.GcStruct('S', hints={'immutable': True})
+    S = lltype.GcStruct('S', hints={'value_class': True})
     T = lltype.GcStruct('T', ('parent', S),
                         ('x', lltype.Char),
-                        hints={'immutable': True})
+                        hints={'value_class': True})
     U = lltype.GcStruct('U', ('parent', T),
                         ('u', lltype.Ptr(T)),
                         ('v', lltype.Signed),
-                        hints={'immutable': True})
+                        hints={'value_class': True})
     V = lltype.GcStruct('V', ('parent', U),
                         ('miss1', lltype.Void),
                         ('miss2', lltype.Void),
-                        hints={'immutable': True})
-    for STRUCT in [S, T, U, V]:
-        for translated in [False, True]:
-            c0 = GcCache(translated)
-            descr_s = get_size_descr(c0, STRUCT)
-            assert descr_s.is_immutable() == True
-
-def test_get_size_descr_value_class():
-    hints = {'immutable': True, 'value_class': True}
-    S = lltype.GcStruct('S', hints=hints)
-    T = lltype.GcStruct('T', ('parent', S),
-                        ('x', lltype.Char),
-                        hints=hints)
-    U = lltype.GcStruct('U', ('parent', T),
-                        ('u', lltype.Ptr(T)),
-                        ('v', lltype.Signed),
-                        hints=hints)
-    V = lltype.GcStruct('V', ('parent', U),
-                        ('miss1', lltype.Void),
-                        ('miss2', lltype.Void),
-                        hints=hints)
+                        hints={'value_class': True})
     for STRUCT in [S, T, U, V]:
         for translated in [False, True]:
             c0 = GcCache(translated)
diff --git a/rpython/jit/codewriter/heaptracker.py 
b/rpython/jit/codewriter/heaptracker.py
--- a/rpython/jit/codewriter/heaptracker.py
+++ b/rpython/jit/codewriter/heaptracker.py
@@ -20,9 +20,6 @@
     a -= r_uint(1 << (b8 - 1))     # a -= 128
     return intmask(a)
 
-def is_immutable_struct(S):
-    return isinstance(S, lltype.GcStruct) and S._hints.get('immutable', False)
-
 def is_value_class(S):
     return isinstance(S, lltype.GcStruct) and S._hints.get('value_class', 
False)
 
diff --git a/rpython/jit/metainterp/optimizeopt/info.py 
b/rpython/jit/metainterp/optimizeopt/info.py
--- a/rpython/jit/metainterp/optimizeopt/info.py
+++ b/rpython/jit/metainterp/optimizeopt/info.py
@@ -30,7 +30,7 @@
     def getconst(self):
         raise Exception("not a constant")
 
-    def _is_immutable_and_filled_with_constants(self, optimizer, memo=None):
+    def _is_value_class_and_filled_with_constants(self, optimizer, memo=None):
         return False
 
 
@@ -134,7 +134,7 @@
         if self.is_virtual():
             optforce.forget_numberings()
             #
-            if 
self._is_immutable_and_filled_with_constants(optforce.optimizer):
+            if 
self._is_value_class_and_filled_with_constants(optforce.optimizer):
                 constptr = optforce.optimizer.constant_fold(op)
                 op.set_forwarded(constptr)
                 self._is_virtual = False
@@ -262,7 +262,7 @@
         getfield_op = ResOperation(opnum, [structbox], descr=fielddescr)
         shortboxes.add_heap_op(op, getfield_op)
 
-    def _is_immutable_and_filled_with_constants(self, optimizer, memo=None):
+    def _is_value_class_and_filled_with_constants(self, optimizer, memo=None):
         # check if it is possible to force the given structure into a
         # compile-time constant: this is allowed only if it is declared
         # immutable, if all fields are already filled, and if each field
@@ -270,7 +270,7 @@
         # which also answers True to the same question.
         #
         assert self.is_virtual()
-        if not self.descr.is_immutable():
+        if not self.descr.is_value_class():
             return False
         if memo is not None and self in memo:
             return True       # recursive case: assume yes
@@ -287,7 +287,7 @@
                     # recursive check
                     if memo is None:
                         memo = {self: None}
-                    if not fieldinfo._is_immutable_and_filled_with_constants(
+                    if not fieldinfo._is_value_class_and_filled_with_constants(
                             optimizer, memo):
                         return False
                 else:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to