Commits

Armin Rigo committed b8cabb1

Added the option --gc=stacklessgc to translate.py. Some clean-up of way this option is parsed.

  • Participants
  • Parent commits 28240f0

Comments (0)

Files changed (4)

pypy/translator/c/database.py

         self.namespace = CNameManager()
         if not standalone:
             self.pyobjmaker = PyObjMaker(self.namespace, self.get, translator)
-        if gcpolicy is None:
+
+        gcpolicy = gcpolicy or conftest.option.gcpolicy or 'ref'
+        if isinstance(gcpolicy, str):
             from pypy.translator.c import gc
-            polname = conftest.option.gcpolicy
-            if polname is not None:
-                if polname == 'boehm':
-                    gcpolicy = gc.BoehmGcPolicy
-                elif polname == 'exact_boehm':
-                    gcpolicy = gc.MoreExactBoehmGcPolicy
-                elif polname == 'ref':
-                    gcpolicy = gc.RefcountingGcPolicy
-                elif polname == 'none':
-                    gcpolicy = gc.NoneGcPolicy
-                elif polname == 'framework':
-                    gcpolicy = gc.FrameworkGcPolicy
-                elif polname == 'stacklessgc':
-                    gcpolicy = gc.StacklessFrameworkGcPolicy
-                else:
-                    assert False, "unknown gc policy %r"%polname
+            polname = gcpolicy
+            if polname == 'boehm':
+                gcpolicy = gc.BoehmGcPolicy
+            elif polname == 'exact_boehm':
+                gcpolicy = gc.MoreExactBoehmGcPolicy
+            elif polname == 'ref':
+                gcpolicy = gc.RefcountingGcPolicy
+            elif polname == 'none':
+                gcpolicy = gc.NoneGcPolicy
+            elif polname == 'framework':
+                gcpolicy = gc.FrameworkGcPolicy
+            elif polname == 'stacklessgc':
+                gcpolicy = gc.StacklessFrameworkGcPolicy
             else:
-                gcpolicy = gc.RefcountingGcPolicy
+                assert False, "unknown gc policy %r"%polname
         if translator is None or translator.rtyper is None:
             self.exctransformer = None
         else:

pypy/translator/driver.py

             translator.frozen = True
 
         standalone = self.standalone
-        gcpolicy = None
-        if opt.gc =='boehm':
-            from pypy.translator.c import gc
-            gcpolicy = gc.BoehmGcPolicy
-        if opt.gc =='exact_boehm':
-            from pypy.translator.c import gc
-            gcpolicy = gc.MoreExactBoehmGcPolicy
-        if opt.gc == 'none':
-            from pypy.translator.c import gc
-            gcpolicy = gc.NoneGcPolicy
-        if opt.gc == 'framework':
-            from pypy.translator.c import gc
-            gcpolicy = gc.FrameworkGcPolicy
 
         if standalone:
             from pypy.translator.c.genc import CStandaloneBuilder as CBuilder
         else:
             from pypy.translator.c.genc import CExtModuleBuilder as CBuilder
         cbuilder = CBuilder(self.translator, self.entry_point,
-                            gcpolicy       = gcpolicy,
+                            gcpolicy       = opt.gc,
                             thread_enabled = getattr(opt, 'thread', False))
         cbuilder.stackless = opt.stackless
         if not standalone:     # xxx more messy

pypy/translator/goal/targetgcbench.py

 from pypy.translator.goal import gcbench
 
 def entry_point(argv):
-    gcbench.main()
+    if len(argv) > 1:
+        n = int(argv[1])
+    else:
+        n = 1
+    while n > 0:
+        gcbench.main()
+        n -= 1
     return 0
 
 # _____ Define and setup target ___

pypy/translator/goal/translate.py

 
     '1_backend': [OPT(('-b', '--backend'), "Backend", ['c', 'llvm', 'cl', 'squeak', 'js'])],
 
-    '2_gc': [OPT(('--gc',), "Garbage collector", ['boehm', 'ref', 'framework', 'none', 'exact_boehm'])],
+    '2_gc': [OPT(('--gc',), "Garbage collector", ['boehm', 'ref', 'framework', 'none', 'exact_boehm', 'stacklessgc'])],
     '3_stackless': [OPT(('--new-stackless',), "Stackless code generation (graph transformer)", True)],
     '4_stackless': [OPT(('--stackless',), "Stackless code generation (old GenC way)", 'old')],
     '5_merge_if_blocks': [OPT(('--no-if-blocks-merge',), "Do not merge if ... elif ... chains and use a switch statement for them.", False)],