[pypy-svn] r50987 - in pypy/branch/asmgcroot/pypy: config config/test doc/config translator/c translator/c/gcc/test translator/llvm

cfbolz at codespeak.net cfbolz at codespeak.net
Thu Jan 24 19:34:29 CET 2008


Author: cfbolz
Date: Thu Jan 24 19:34:28 2008
New Revision: 50987

Added:
   pypy/branch/asmgcroot/pypy/doc/config/translation.gcrootfinder.txt   (contents, props changed)
Modified:
   pypy/branch/asmgcroot/pypy/config/test/test_pypyoption.py
   pypy/branch/asmgcroot/pypy/config/translationoption.py
   pypy/branch/asmgcroot/pypy/translator/c/gcc/test/test_asmgcroot.py
   pypy/branch/asmgcroot/pypy/translator/c/genc.py
   pypy/branch/asmgcroot/pypy/translator/llvm/codewriter.py
Log:
unify the various options for chosing a GC root finding algorithm


Modified: pypy/branch/asmgcroot/pypy/config/test/test_pypyoption.py
==============================================================================
--- pypy/branch/asmgcroot/pypy/config/test/test_pypyoption.py	(original)
+++ pypy/branch/asmgcroot/pypy/config/test/test_pypyoption.py	Thu Jan 24 19:34:28 2008
@@ -18,14 +18,14 @@
 
 def test_stacklessgc_required():
     conf = get_pypy_config()
-    conf.translation.stacklessgc = True
+    conf.translation.gcrootfinder = "stackless"
     assert conf.translation.stackless
     assert conf.translation.type_system == "lltype"
     assert conf.translation.gctransformer == "framework"
-    assert conf.translation.gc == "marksweep"
+    assert conf.translation.gc == "generation"
     conf = get_pypy_config()
     conf.translation.gc = "boehm"
-    py.test.raises(ValueError, "conf.translation.stacklessgc = True")
+    py.test.raises(ValueError, "conf.translation.gcrootfinder = 'stackless'")
 
 
 def test_frameworkgc():

Modified: pypy/branch/asmgcroot/pypy/config/translationoption.py
==============================================================================
--- pypy/branch/asmgcroot/pypy/config/translationoption.py	(original)
+++ pypy/branch/asmgcroot/pypy/config/translationoption.py	Thu Jan 24 19:34:28 2008
@@ -56,19 +56,27 @@
     ChoiceOption("gctransformer", "GC transformer that is used - internal",
                  ["boehm", "ref", "framework", "none"],
                  default="ref", cmdline=None),
-
-    BoolOption("stacklessgc", "Use stackless to find roots in a framework GC",
-               default=False, cmdline="--stacklessgc",
-               requires=[("translation.gctransformer", "framework"),
-                         ("translation.stackless", True)],
-               suggests=[("translation.gc", "marksweep")]),
-    BoolOption("llvmgcroot", "Use the 'llvm.gcroot' primitive to find roots",
-               default=False, cmdline="--llvmgcroot",
-               requires=[("translation.gctransformer", "framework"),
-                         ("translation.backend", "llvm")]),
-    BoolOption("asmgcroot", "Use the 'trackgcroot' asm hack to find roots",
-               default=False, cmdline="--asmgcroot",
-               requires=[("translation.gctransformer", "framework")]),
+    ChoiceOption("gcrootfinder", "Strategy for finding GC Roots",
+                 ["ref", "boehm", "shadowstack", "stackless", "llvmgc",
+                  "asmgcc"], "ref",
+                 cmdline="--gcrootfinder",
+                 requires={
+                     "ref": [("translation.gc", "ref")],
+                     "boehm": [("translation.gc", "boehm")],
+                     "shadowstack": [("translation.gctransformer", "framework")],
+                     "stackless": [("translation.gctransformer", "framework"),
+                                   ("translation.stackless", True)],
+                     "llvmgc": [("translation.gctransformer", "framework"),
+                                ("translation.backend", "llvm")],
+                     "asmgcc": [("translation.gctransformer", "framework"),
+                                ("translation.backend", "c")],
+                    },
+                 suggests={
+                     "shadowstack": [("translation.gc", "generation")],
+                     "stackless": [("translation.gc", "generation")],
+                     "llvmgc": [("translation.gc", "generation")],
+                     "asmgcc": [("translation.gc", "generation")],
+                 }),
     BoolOption("thread", "enable use of threading primitives",
                default=False, cmdline="--thread",
                requires=[("translation.gc", "boehm")]),

Added: pypy/branch/asmgcroot/pypy/doc/config/translation.gcrootfinder.txt
==============================================================================
--- (empty file)
+++ pypy/branch/asmgcroot/pypy/doc/config/translation.gcrootfinder.txt	Thu Jan 24 19:34:28 2008
@@ -0,0 +1,13 @@
+Choose method how to find roots in the GC. Boehm and refcounting have their own
+methods, this is mostly only interesting for framework GCs. For those you have
+a choice of various alternatives:
+
+ - use a shadow stack (XXX link to paper), e.g. explicitely maintaining a stack
+   of roots
+
+ - use stackless to find roots by unwinding the stack
+
+ - use GCC and i386 specific assembler hackery to find the roots on the stack.
+   This is fastest but platform specific.
+
+ - Use LLVM's GC facilities to find the roots.

Modified: pypy/branch/asmgcroot/pypy/translator/c/gcc/test/test_asmgcroot.py
==============================================================================
--- pypy/branch/asmgcroot/pypy/translator/c/gcc/test/test_asmgcroot.py	(original)
+++ pypy/branch/asmgcroot/pypy/translator/c/gcc/test/test_asmgcroot.py	Thu Jan 24 19:34:28 2008
@@ -24,7 +24,7 @@
         from pypy.config.pypyoption import get_pypy_config
         config = get_pypy_config(translating=True)
         config.translation.gc = self.gcpolicy
-        config.translation.asmgcroot = True
+        config.translation.gcrootfinder = "asmgcc"
         t = TranslationContext(config=config)
         self.t = t
         a = t.buildannotator()

Modified: pypy/branch/asmgcroot/pypy/translator/c/genc.py
==============================================================================
--- pypy/branch/asmgcroot/pypy/translator/c/genc.py	(original)
+++ pypy/branch/asmgcroot/pypy/translator/c/genc.py	Thu Jan 24 19:34:28 2008
@@ -41,9 +41,9 @@
 
         gcpolicyclass = self.get_gcpolicyclass()
 
-        if self.config.translation.asmgcroot:
+        if self.config.translation.gcrootfinder == "asmgcc":
             if not self.standalone:
-                raise NotImplementedError("--asmgcroot requires standalone")
+                raise NotImplementedError("--gcrootfinder=asmgcc requires standalone")
 
         if self.config.translation.stackless:
             if not self.standalone:
@@ -95,11 +95,11 @@
     def get_gcpolicyclass(self):
         if self.gcpolicy is None:
             name = self.config.translation.gctransformer
-            if self.config.translation.stacklessgc:
+            if self.config.translation.gcrootfinder == "stackless":
                 name = "%s+stacklessgc" % (name,)
-            if self.config.translation.llvmgcroot:
+            elif self.config.translation.gcrootfinder == "llvmgc":
                 name = "%s+llvmgcroot" % (name,)
-            if self.config.translation.asmgcroot:
+            elif self.config.translation.gcrootfinder == "asmgcc":
                 name = "%s+asmgcroot" % (name,)
             return gc.name_to_gcpolicy[name]
         return self.gcpolicy
@@ -284,7 +284,7 @@
         assert self.c_source_filename
         assert not self._compiled
         compiler = self.getccompiler()
-        if self.config.translation.asmgcroot:
+        if self.config.translation.gcrootfinder == "asmgcc":
             # as we are gcc-only anyway, let's just use the Makefile.
             cmdline = "make -C '%s'" % (self.targetdir,)
             err = os.system(cmdline)
@@ -327,7 +327,7 @@
             compiler.compile_extra.append(self.config.translation.compilerflags)
         if self.config.translation.linkerflags:
             compiler.link_extra.append(self.config.translation.linkerflags)
-        assert not self.config.translation.llvmgcroot
+        assert self.config.translation.gcrootfinder != "llvmgc"
         cfiles = []
         ofiles = []
         for fn in compiler.cfilenames:
@@ -338,7 +338,7 @@
                 assert fn.dirpath().dirpath() == udir
                 name = '../' + fn.relto(udir)
             cfiles.append(name)
-            if self.config.translation.asmgcroot:
+            if self.config.translation.gcrootfinder == "asmgcc":
                 ofiles.append(name[:-2] + '.s')
             else:
                 ofiles.append(name[:-2] + '.o')
@@ -359,13 +359,13 @@
         print >> f
         write_list(cfiles, 'SOURCES =')
         print >> f
-        if self.config.translation.asmgcroot:
+        if self.config.translation.gcrootfinder == "asmgcc":
             write_list(ofiles, 'ASMFILES =')
             print >> f, 'OBJECTS = $(ASMFILES) gcmaptable.s'
         else:
             write_list(ofiles, 'OBJECTS =')
         print >> f
-        if self.config.translation.asmgcroot:
+        if self.config.translation.gcrootfinder == "asmgcc":
             print >> f, 'TRACKGCROOT="%s"' % (os.path.join(autopath.this_dir,
                                               'gcc', 'trackgcroot.py'),)
         print >> f

Modified: pypy/branch/asmgcroot/pypy/translator/llvm/codewriter.py
==============================================================================
--- pypy/branch/asmgcroot/pypy/translator/llvm/codewriter.py	(original)
+++ pypy/branch/asmgcroot/pypy/translator/llvm/codewriter.py	Thu Jan 24 19:34:28 2008
@@ -178,7 +178,7 @@
     # Special support for llvm.gcroot
 
     def declare_gcroots(self, gcrootscount):
-        assert self.db.genllvm.config.translation.llvmgcroot
+        assert self.db.genllvm.config.translation.gcrootfinder == "llvmgc"
         for i in range(gcrootscount):
             self._indent("%%gcroot%d = alloca i8*" % i)
         for i in range(gcrootscount):



More information about the Pypy-commit mailing list