Author: Armin Rigo <ar...@tunes.org>
Branch: stmgc-c7
Changeset: r69749:499acfed5c41
Date: 2014-03-06 09:07 +0100
http://bitbucket.org/pypy/pypy/changeset/499acfed5c41/

Log:    hack hack hack in-progress

diff --git a/rpython/memory/gc/stmgc.py b/rpython/memory/gc/stmgc.py
--- a/rpython/memory/gc/stmgc.py
+++ b/rpython/memory/gc/stmgc.py
@@ -10,6 +10,7 @@
 from rpython.rlib.debug import ll_assert
 from rpython.rlib.rarithmetic import LONG_BIT, r_uint
 from rpython.rtyper.extregistry import ExtRegistryEntry
+from rpython.translator.stm import stmgcintf
 
 WORD = LONG_BIT // 8
 NULL = llmemory.NULL
@@ -45,7 +46,7 @@
     GCHDRP = lltype.Ptr(GCHDR)
     GCHDRSIZE = 3 * WORD
 
-    HDR = rffi.COpaque('struct stm_object_s')
+    HDR = stmgcintf.GCPTR.TO
     H_TID = 0
     H_REVISION = WORD
     H_ORIGINAL = WORD * 2
diff --git a/rpython/translator/c/database.py b/rpython/translator/c/database.py
--- a/rpython/translator/c/database.py
+++ b/rpython/translator/c/database.py
@@ -64,7 +64,12 @@
 
         self.instrument_ncounter = 0
 
+    def with_stm(self):
+        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:
@@ -87,7 +92,7 @@
             elif T == WeakRef:
                 REALT = self.gcpolicy.get_real_weakref_type()
                 node = self.gettypedefnode(REALT)
-            elif isinstance(T, OpaqueType) and T.__name__ == "struct 
stm_object_s":
+            elif isinstance(T, OpaqueType) and T.hints.get("is_stm_header", 
False):
                 from rpython.translator.stm.funcgen import 
StmHeaderOpaqueDefNode
                 node = StmHeaderOpaqueDefNode(self, T)
             else:
@@ -97,6 +102,8 @@
         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):
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -428,12 +428,16 @@
         cfiles = [self.c_source_filename] + self.extrafiles + 
list(module_files)
         if exe_name is not None:
             exe_name = targetdir.join(exe_name)
+        kwds = {}
+        if self.config.translation.stm:
+            kwds['cc'] = 'clang'     # force the use of clang
         mk = self.translator.platform.gen_makefile(
             cfiles, self.eci,
             path=targetdir, exe_name=exe_name,
             headers_to_precompile=headers_to_precompile,
             no_precompile_cfiles = module_files,
-            shared=self.config.translation.shared)
+            shared=self.config.translation.shared,
+            **kwds)
 
         if self.has_profopt():
             profopt = self.config.translation.profopt
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
@@ -43,6 +43,35 @@
         Node.__init__(self, db)
         self.dependencies = set()
 
+    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)
+        else:
+            self.fulltypename = '%s %s @' % (self.typetag, self.name)
+
+    def getfieldtype(self, T, is_array=False):
+        if self.db.with_stm():
+            if isinstance(T, GcStruct):
+                node = self.db.gettypedefnode(T)
+                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)
+
+
 class StructDefNode(NodeWithDependencies):
     typetag = 'struct'
     extra_union_for_varlength = True
@@ -83,7 +112,7 @@
                 assert self.fieldnames == ('typeptr',)
                 self.fieldnames = ()
         #
-        self.fulltypename = '%s %s @' % (self.typetag, self.name)
+        self.make_full_type_name()
 
     def setup(self):
         # this computes self.fields
@@ -98,15 +127,11 @@
         if needs_gcheader(self.STRUCT):
             HDR = db.gcpolicy.struct_gcheader_definition(self)
             if HDR is not None:
-                gc_field = ("_gcheader", db.gettype(HDR, who_asks=self))
+                gc_field = ("_gcheader", self.getfieldtype(HDR))
                 self.fields.append(gc_field)
         for name in self.fieldnames:
             T = self.c_struct_field_type(name)
-            if name == STRUCT._arrayfld:
-                typename = db.gettype(T, varlength=self.varlength,
-                                         who_asks=self)
-            else:
-                typename = db.gettype(T, who_asks=self)
+            typename = self.getfieldtype(T, name==STRUCT._arrayfld)
             self.fields.append((self.c_struct_field_name(name), typename))
         self.gcinfo  # force it to be computed
 
@@ -211,8 +236,8 @@
         (self.barename,
          self.name) = db.namespace.uniquename(basename, 
with_number=with_number,
                                               bare=True)
-        self.fulltypename =  '%s %s @' % (self.typetag, self.name)
-        self.fullptrtypename = '%s %s *@' % (self.typetag, self.name)
+        self.make_full_type_name()
+        self.fullptrtypename = self.fulltypename.replace('@', '*@')
 
     def setup(self):
         if hasattr(self, 'itemtypename'):
@@ -225,7 +250,7 @@
         if needs_gcheader(ARRAY):
             HDR = db.gcpolicy.array_gcheader_definition(self)
             if HDR is not None:
-                gc_field = ("_gcheader", db.gettype(HDR, who_asks=self))
+                gc_field = ("_gcheader", self.getfieldtype(HDR))
                 self.gcfields.append(gc_field)
         self.itemtypename = db.gettype(ARRAY.OF, who_asks=self)
 
@@ -494,8 +519,7 @@
     def is_thread_local(self):
         T = self.getTYPE()
         return hasattr(T, "_hints") and (T._hints.get('thread_local') or (
-                  T._hints.get('stm_thread_local') and
-                  self.db.translator.config.translation.stm))
+                  T._hints.get('stm_thread_local') and self.db.with_stm()))
 
     def compilation_info(self):
         return getattr(self.obj, self.eci_name, None)
@@ -967,7 +991,7 @@
         return db.gcpolicy.rtti_node_factory()(db, T, obj)
     if T.hints.get("render_structure", False):
         return ExtType_OpaqueNode(db, T, obj)
-    if T.__name__ == 'struct stm_object_s':
+    if T.hints.get("is_stm_header", False):
         from rpython.translator.stm.funcgen import StmHeader_OpaqueNode
         return StmHeader_OpaqueNode(db, T, obj)
     raise Exception("don't know about %r" % (T,))
diff --git a/rpython/translator/platform/posix.py 
b/rpython/translator/platform/posix.py
--- a/rpython/translator/platform/posix.py
+++ b/rpython/translator/platform/posix.py
@@ -84,7 +84,7 @@
 
     def gen_makefile(self, cfiles, eci, exe_name=None, path=None,
                      shared=False, headers_to_precompile=[],
-                     no_precompile_cfiles = []):
+                     no_precompile_cfiles = [], cc=None):
         cfiles = self._all_cfiles(cfiles, eci)
 
         if path is None:
@@ -154,7 +154,7 @@
             ('LDFLAGS', linkflags),
             ('LDFLAGS_LINK', list(self.link_flags)),
             ('LDFLAGSEXTRA', list(eci.link_extra)),
-            ('CC', self.cc),
+            ('CC', cc or self.cc),
             ('CC_LINK', eci.use_cpp_linker and 'g++' or '$(CC)'),
             ('LINKFILES', eci.link_files),
             ]
diff --git a/rpython/translator/stm/funcgen.py 
b/rpython/translator/stm/funcgen.py
--- a/rpython/translator/stm/funcgen.py
+++ b/rpython/translator/stm/funcgen.py
@@ -5,13 +5,13 @@
 
 
 class StmHeaderOpaqueDefNode(Node):
-    typetag = 'struct'
+    typetag = ''
     dependencies = ()
 
     def __init__(self, db, T):
         Node.__init__(self, db)
         self.T = T
-        self.name = 'stm_object_s'
+        self.name = 'object_t'
 
     def setup(self):
         pass
@@ -26,7 +26,7 @@
 class StmHeader_OpaqueNode(ContainerNode):
     nodekind = 'stmhdr'
     globalcontainer = True
-    typename = 'struct stm_object_s @'
+    typename = 'object_t @'
     implementationtypename = typename
     _funccodegen_owner = None
 
@@ -37,9 +37,9 @@
         self.obj = obj
 
     def initializationexpr(self, decoration=''):
-        yield '{ %s | PREBUILT_FLAGS, PREBUILT_REVISION, %dL }' % (
-            name_small_integer(self.obj.typeid16, self.db),
-            self.obj.prebuilt_hash)
+        yield '{ { }, %s }' % (
+            name_small_integer(self.obj.typeid16, self.db))
+        #    self.obj.prebuilt_hash
 
 
 def stm_initialize(funcgen, op):
diff --git a/rpython/translator/stm/stmgcintf.py 
b/rpython/translator/stm/stmgcintf.py
--- a/rpython/translator/stm/stmgcintf.py
+++ b/rpython/translator/stm/stmgcintf.py
@@ -32,6 +32,6 @@
     separate_module_sources = [separate_source],
 )
 
-GCPTR = lltype.Ptr(rffi.COpaque('struct stm_object_s'))
+GCPTR = lltype.Ptr(rffi.COpaque('object_t', hints={"is_stm_header": True}))
 CALLBACK_TX = lltype.Ptr(lltype.FuncType([GCPTR, rffi.INT_real],
                                          rffi.INT_real))
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to