Commits

Armin Rigo  committed 1519a5a

More in-progress-ness

  • Participants
  • Parent commits 499acfe
  • Branches stmgc-c7

Comments (0)

Files changed (5)

File rpython/memory/gc/stmgc.py

     malloc_zero_filled = True
     #gcflag_extra = GCFLAG_EXTRA
 
-    GCHDR = lltype.Struct(
-        'GCPTR',
-        ('h_tid', lltype.Unsigned),
-        ('h_revision', lltype.Signed),
-        ('h_original', lltype.Unsigned))
-    GCHDRP = lltype.Ptr(GCHDR)
-    GCHDRSIZE = 3 * WORD
-
     HDR = stmgcintf.GCPTR.TO
     H_TID = 0
     H_REVISION = WORD

File rpython/translator/c/database.py

         return self.translator.config.translation.stm
 
     def gettypedefnode(self, T, varlength=None):
-        if self.with_stm():
-            varlength = None
         if varlength is None:
             key = T
         else:
         return node
 
     def gettype(self, T, varlength=None, who_asks=None, argnames=[]):
-        if self.with_stm():
-            varlength = None
         if isinstance(T, Primitive) or T == GCREF:
             return PrimitiveType[T]
         elif isinstance(T, Typedef):

File rpython/translator/c/genc.py

     print >> f
     print >> f, "#ifndef _PYPY_STRUCTDEF_H"
     print >> f, "#define _PYPY_STRUCTDEF_H"
+    if database.with_stm():
+        print >> f
+        print >> f, 'typedef TLPREFIX struct rpyobj_s {'
+        print >> f, '\tstruct object_s lib;'
+        print >> f, '\tuint32_t tid;'
+        print >> f, '} rpyobj_t;'
+        print >> f
     for node in structdeflist:
         if hasattr(node, 'forward_decl'):
             if node.forward_decl:
     print >> f, "#endif"
 
 def gen_preimpl(f, database):
-    f.write('#ifndef _PY_PREIMPLE_H\n#define _PY_PREIMPL_H\n')
+    f.write('#ifndef _PY_PREIMPL_H\n#define _PY_PREIMPL_H\n')
     if database.translator is None or database.translator.rtyper is None:
         return
     preimplementationlines = pre_include_code_lines(

File rpython/translator/c/node.py

         Node.__init__(self, db)
         self.dependencies = set()
 
+    def make_normalizedtypename(self):
+        if self.varlength is not None:
+            assert self.typetag == 'struct'
+            self.normalizedtypename = self.db.gettype(self.LLTYPE,
+                                                      who_asks=self)
+            if not self.normalizedtypename.startswith('struct '):
+                assert self.db.with_stm()
+                assert self.normalizedtypename.endswith('_t @')
+                self.normalizedtypename = 'struct %s @' % (
+                    self.normalizedtypename[:-4],)
+
     def make_full_type_name(self):
         if self.db.with_stm() and self.LLTYPE._gckind == 'gc':
             assert self.typetag == 'struct'
             self.fulltypename = '%s_t @' % (self.name,)
-            if self.db.with_stm():
-                tlprefix = ' TLPREFIX'
-            else:
-                tlprefix = ''
-            self.forward_decl = 'typedef%s struct %s %s_t;' % (
-                tlprefix, self.name, self.name)
+            self.forward_decl = 'typedef TLPREFIX struct %s %s_t;' % (
+                self.name, self.name)
         else:
             self.fulltypename = '%s %s @' % (self.typetag, self.name)
 
     def getfieldtype(self, T, is_array=False):
+        if is_array:
+            varlength = self.varlength
+        else:
+            varlength = None
         if self.db.with_stm():
             if isinstance(T, GcStruct):
-                node = self.db.gettypedefnode(T)
+                node = self.db.gettypedefnode(T, varlength=varlength)
                 self.dependencies.add(node)
                 return 'struct %s' % node.name
             if isinstance(T, OpaqueType):
                 if T.hints.get("is_stm_header", False):
-                    return 'struct object_s @'
-        if is_array:
-            varlength = self.varlength
-        else:
-            varlength = None
-        return self.db.gettype(T, varlength=self.varlength, who_asks=self)
+                    return 'struct rpyobj_s @'
+        return self.db.gettype(T, varlength=varlength, who_asks=self)
 
 
 class StructDefNode(NodeWithDependencies):
         self.fields = []
         db = self.db
         STRUCT = self.STRUCT
-        if self.varlength is not None:
-            self.normalizedtypename = db.gettype(STRUCT, who_asks=self)
+        self.make_normalizedtypename()
         if needs_gcheader(self.STRUCT):
             HDR = db.gcpolicy.struct_gcheader_definition(self)
             if HDR is not None:
         db = self.db
         ARRAY = self.ARRAY
         self.gcinfo    # force it to be computed
-        if self.varlength is not None:
-            self.normalizedtypename = db.gettype(ARRAY, who_asks=self)
+        self.make_normalizedtypename()
         if needs_gcheader(ARRAY):
             HDR = db.gcpolicy.array_gcheader_definition(self)
             if HDR is not None:
     def get_declaration(self):
         if self.name[-2:] == '.b':
             # xxx fish fish
-            assert self.implementationtypename.startswith('struct ')
-            assert self.implementationtypename.endswith(' @')
-            uniontypename = 'union %su @' % self.implementationtypename[7:-2]
+            if self.implementationtypename.startswith('struct '):
+                assert self.implementationtypename.endswith(' @')
+                uniontypename = 'union %su @'%self.implementationtypename[7:-2]
+            else:
+                assert self.implementationtypename.endswith('_t @')
+                uniontypename = 'union %su @'%self.implementationtypename[:-4]
+            if self.db.with_stm():
+                uniontypename = 'TLPREFIX ' + uniontypename
             return uniontypename, self.name[:-2]
         else:
             return self.implementationtypename, self.name

File rpython/translator/stm/stmgcintf.py

 extern Signed pypy_stmcb_size(void*);
 extern void pypy_stmcb_trace(void*, void(*)(void*));
 
-inline size_t stmcb_size(gcptr obj) {
+inline size_t stmcb_size(struct object_s *obj) {
     return pypy_stmcb_size(obj);
 }
 
-inline void stmcb_trace(gcptr obj, void visit(gcptr *)) {
+inline void stmcb_trace(struct object_s *obj, void visit(object_t **)) {
     pypy_stmcb_trace(obj, (void(*)(void*))visit);
 }
 
     separate_module_sources = [separate_source],
 )
 
-GCPTR = lltype.Ptr(rffi.COpaque('object_t', hints={"is_stm_header": True}))
+GCPTR = lltype.Ptr(rffi.COpaque('rpyobj_t',
+                                hints={"is_stm_header": True}))
 CALLBACK_TX = lltype.Ptr(lltype.FuncType([GCPTR, rffi.INT_real],
                                          rffi.INT_real))