Author: Armin Rigo <[email protected]>
Branch: gcremovetypeptr-32bit
Changeset: r67094:993a091dc081
Date: 2013-09-25 16:31 +0200
http://bitbucket.org/pypy/pypy/changeset/993a091dc081/

Log:    In-progress

diff --git a/rpython/memory/gctypelayout.py b/rpython/memory/gctypelayout.py
--- a/rpython/memory/gctypelayout.py
+++ b/rpython/memory/gctypelayout.py
@@ -311,7 +311,7 @@
                 fullinfo = lltype.malloc(GCData.VARSIZE_TYPE_INFO,
                                          immortal=True, zero=True)
                 info = fullinfo.header
-            type_id = self.type_info_group.add_member(fullinfo)
+            type_id = self.type_info_group.add_member(fullinfo, align=8)
             if self.can_encode_type_shape:
                 encode_type_shape(self, info, TYPE, type_id.index)
             else:
diff --git a/rpython/rtyper/lltypesystem/llgroup.py 
b/rpython/rtyper/lltypesystem/llgroup.py
--- a/rpython/rtyper/lltypesystem/llgroup.py
+++ b/rpython/rtyper/lltypesystem/llgroup.py
@@ -27,8 +27,9 @@
     def __init__(self, name):
         self.name = name
         self.members = []
+        self.force_aligned = set()
 
-    def add_member(self, structptr):
+    def add_member(self, structptr, align=1):
         TYPE = lltype.typeOf(structptr)
         assert isinstance(TYPE.TO, lltype.Struct)
         assert TYPE.TO._gckind == 'raw'
@@ -40,6 +41,9 @@
         assert struct._parentstructure() is None
         index = len(self.members)
         self.members.append(struct)
+        assert align in (1, 8)
+        if align == 8:
+            self.force_aligned.add(index)
         _membership[struct] = self
         return GroupMemberOffset(self, index)
 
diff --git a/rpython/translator/c/node.py b/rpython/translator/c/node.py
--- a/rpython/translator/c/node.py
+++ b/rpython/translator/c/node.py
@@ -500,6 +500,7 @@
                         _funccodegen_owner
                         globalcontainer""".split()
     eci_name = '_compilation_info'
+    force_aligned = ''
 
     def __init__(self, db, T, obj):
         Node.__init__(self, db)
@@ -563,8 +564,9 @@
         if name != self.name:
             lines[0] = '{ ' + lines[0]    # extra braces around the 'a' part
             lines[-1] += ' }'             # of the union
-        lines[0] = '%s = %s' % (
+        lines[0] = '%s%s = %s' % (
             cdecl(type, name, self.is_thread_local()),
+            self.force_aligned,
             lines[0])
         lines[-1] += ';'
         return lines
@@ -1027,6 +1029,7 @@
 class GroupNode(ContainerNode):
     nodekind = 'group'
     count_members = None
+    force_aligned = ' PYPY_GROUP_ALIGNMENT'
 
     def __init__(self, *args):
         ContainerNode.__init__(self, *args)
@@ -1057,13 +1060,18 @@
         ctype = ['%s {' % cdecl(self.implementationtypename, '')]
         for i, member in enumerate(self.obj.members):
             structtypename = self.db.gettype(typeOf(member))
-            ctype.append('\t%s;' % cdecl(structtypename, 'member%d' % i))
+            if i in self.obj.force_aligned:
+                alignment = self.force_aligned
+            else:
+                alignment = ''
+            ctype.append('\t%s%s;' % (cdecl(structtypename, 'member%d' % i),
+                                      alignment))
         ctype.append('} @')
         ctype = '\n'.join(ctype)
+        yield '#include "src/llgroup.h"'
         yield '%s;' % (
             forward_cdecl(ctype, self.name, self.db.standalone,
                           self.is_thread_local()))
-        yield '#include "src/llgroup.h"'
         yield 'PYPY_GROUP_CHECK_SIZE(%s)' % (self.name,)
         for i, member in enumerate(self.obj.members):
             structnode = self.db.getcontainernode(member)
diff --git a/rpython/translator/c/src/llgroup.h 
b/rpython/translator/c/src/llgroup.h
--- a/rpython/translator/c/src/llgroup.h
+++ b/rpython/translator/c/src/llgroup.h
@@ -6,31 +6,35 @@
 
 #if PYPY_LONG_BIT == 32 /************************************/
 /* On 32-bit platforms, a CombinedSymbolic is two USHORTs, and the
-   lower one stores the offset inside the group, divided by 4.  The
-   limitation is to have at most 256KB of data in the whole group. */
+   lower one stores the offset inside the group, divided by 8.  The
+   limitation is to have at most 512KB of data in the whole group. */
+
+#define PYPY_GROUP_ALIGNMENT  __attribute__((aligned(8)))
 
 typedef unsigned short pypy_halfword_t;
 
 #define GROUP_MEMBER_OFFSET(grouptype, membername)  \
-  ((unsigned short)(((long)&((grouptype*)NULL)->membername) / 4))
+  ((unsigned short)(((long)&((grouptype*)NULL)->membername) / 8))
 
 #define _OP_GET_GROUP_MEMBER(groupptr, compactoffset)  \
-  (((char*)groupptr) + ((long)compactoffset)*4)
+  (((char*)groupptr) + ((long)compactoffset)*8)
 
 #define _OP_GET_NEXT_GROUP_MEMBER(groupptr, compactoffset, skipoffset)  \
-  ((((char*)groupptr) + skipoffset) + ((long)compactoffset)*4)
+  ((((char*)groupptr) + skipoffset) + ((long)compactoffset)*8)
 
 /* A macro to crash at compile-time if sizeof(group) is too large.
    Uses a hack that I've found on some random forum.  Haaaaaaaaaackish. */
 #define PYPY_GROUP_CHECK_SIZE(groupname)   \
   typedef char group_##groupname##_is_too_large[   \
-       2*(sizeof(groupname) <= 65536*4)-1];
+       2*(sizeof(groupname) <= 65536*8)-1];
 
 
 #else /******************************************************/
 /* On 64-bit platforms, a CombinedSymbolic is two UINTs, and the lower
    one is an 32-bit offset from the start of the group. */
 
+#define PYPY_GROUP_ALIGNMENT  /* nothing */
+
 typedef unsigned int pypy_halfword_t;
 
 #define GROUP_MEMBER_OFFSET(grouptype, membername)  \
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to