Author: Spenser Bauman <saba...@gmail.com>
Branch: value-classes
Changeset: r87259:ad12c5eab511
Date: 2016-09-20 14:52 -0400
http://bitbucket.org/pypy/pypy/changeset/ad12c5eab511/

Log:    Add value_class information to SizeDescr

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
@@ -139,6 +139,9 @@
     def is_immutable(self):
         return heaptracker.is_immutable_struct(self.S)
 
+    def is_value_class(self):
+        return heaptracker.is_value_class(self.S)
+
     def get_type_id(self):
         assert isinstance(self.S, lltype.GcStruct)
         return TypeIDSymbolic(self.S)     # integer-like symbolic
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
@@ -61,16 +61,19 @@
     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):
+                 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):
         return self.all_fielddescrs
@@ -94,6 +97,9 @@
     def is_immutable(self):
         return self.immutable_flag
 
+    def is_value_class(self):
+        return self.value_class_flag
+
     def get_vtable(self):
         return heaptracker.adr2int(llmemory.cast_ptr_to_adr(self.vtable))
 
@@ -109,12 +115,14 @@
     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)
+                              immutable_flag=immutable_flag,
+                              value_class_flag=value_class_flag)
         gccache.init_size_descr(STRUCT, sizedescr)
         cache[STRUCT] = sizedescr
         # XXX do we really need gc_fielddescrs if we also have
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
@@ -52,6 +52,26 @@
             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)
+    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_value_class() == True
+
 def test_get_field_descr():
     U = lltype.Struct('U')
     T = lltype.GcStruct('T')
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
@@ -23,6 +23,9 @@
 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)
+
 # ____________________________________________________________
 
 def has_gcstruct_a_vtable(GCSTRUCT):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to