[pypy-svn] r17593 - pypy/dist/pypy/translator/c

arigo at codespeak.net arigo at codespeak.net
Fri Sep 16 14:12:06 CEST 2005


Author: arigo
Date: Fri Sep 16 14:12:03 2005
New Revision: 17593

Modified:
   pypy/dist/pypy/translator/c/database.py
   pypy/dist/pypy/translator/c/gc.py
   pypy/dist/pypy/translator/c/node.py
Log:
Show progress while collecting objects in genc.


Modified: pypy/dist/pypy/translator/c/database.py
==============================================================================
--- pypy/dist/pypy/translator/c/database.py	(original)
+++ pypy/dist/pypy/translator/c/database.py	Fri Sep 16 14:12:03 2005
@@ -1,3 +1,4 @@
+import sys
 from pypy.rpython.lltype import Primitive, Ptr, typeOf, RuntimeTypeInfo
 from pypy.rpython.lltype import Struct, Array, FuncType, PyObject, Void
 from pypy.rpython.lltype import ContainerType, pyobjectptr, OpaqueType, GcStruct
@@ -19,6 +20,8 @@
         self.structdefnodes = {}
         self.containernodes = {}
         self.containerlist = []
+        self.completedcontainers = 0
+        self.containerstats = {}
         self.externalfuncs = {}
         self.namespace = CNameManager()
         if not standalone:
@@ -98,6 +101,8 @@
             node = nodefactory(self, T, container)
             self.containernodes[container] = node
             self.containerlist.append(node)
+            kind = getattr(node, 'nodekind', '?')
+            self.containerstats[kind] = self.containerstats.get(kind, 0) + 1
         return node
 
     def get(self, obj):
@@ -152,8 +157,17 @@
         return ''
 """
 
-    def complete(self):
-        i = 0
+    def complete(self, show_progress=True):
+        def dump():
+            lst = ['%s: %d' % keyvalue
+                   for keyvalue in self.containerstats.items()]
+            lst.sort()
+            print '%8d nodes  [ %s ]' % (i, '  '.join(lst))
+        i = self.completedcontainers
+        if show_progress:
+            show_i = (i//1000 + 1) * 1000
+        else:
+            show_i = -1
         while True:
             if hasattr(self, 'pyobjmaker'):
                 self.pyobjmaker.collect_initcode()
@@ -166,6 +180,12 @@
                 else:
                     self.get(value)
             i += 1
+            self.completedcontainers = i
+            if i == show_i:
+                dump()
+                show_i += 1000
+        if show_progress:
+            dump()
 
     def globalcontainers(self):
         for node in self.containerlist:

Modified: pypy/dist/pypy/translator/c/gc.py
==============================================================================
--- pypy/dist/pypy/translator/c/gc.py	(original)
+++ pypy/dist/pypy/translator/c/gc.py	Fri Sep 16 14:12:03 2005
@@ -257,6 +257,7 @@
                                                 err)
 
 class RefcountingRuntimeTypeInfo_OpaqueNode(ContainerNode):
+    nodekind = 'refcnt rtti'
     globalcontainer = True
     includes = ()
     typename = 'void (@)(void *)'
@@ -365,6 +366,7 @@
 
 
 class BoehmGcRuntimeTypeInfo_OpaqueNode(ContainerNode):
+    nodekind = 'boehm rtti'
     globalcontainer = True
     includes = ()
     typename = 'char @'

Modified: pypy/dist/pypy/translator/c/node.py
==============================================================================
--- pypy/dist/pypy/translator/c/node.py	(original)
+++ pypy/dist/pypy/translator/c/node.py	Fri Sep 16 14:12:03 2005
@@ -318,6 +318,7 @@
 assert not USESLOTS or '__dict__' not in dir(ContainerNode)
 
 class StructNode(ContainerNode):
+    nodekind = 'struct'
     if USESLOTS:
         __slots__ = ()
 
@@ -360,6 +361,7 @@
 assert not USESLOTS or '__dict__' not in dir(StructNode)
 
 class ArrayNode(ContainerNode):
+    nodekind = 'array'
     if USESLOTS:
         __slots__ = ()
 
@@ -419,6 +421,7 @@
 
 
 class FuncNode(ContainerNode):
+    nodekind = 'func'
     if USESLOTS:
         __slots__ = """funcgen""".split()
 
@@ -526,6 +529,7 @@
         raise ValueError, "don't know how to generate code for %r" % (fnobj,)
 
 class ExtType_OpaqueNode(ContainerNode):
+    nodekind = 'rpyopaque'
 
     def enum_dependencies(self):
         return []
@@ -554,6 +558,7 @@
 
 
 class PyObjectNode(ContainerNode):
+    nodekind = 'pyobj'
     globalcontainer = True
     typename = 'PyObject @'
     implementationtypename = 'PyObject *@'



More information about the Pypy-commit mailing list