[pypy-svn] r46472 - in pypy/dist/pypy: config doc/config rpython

arigo at codespeak.net arigo at codespeak.net
Tue Sep 11 16:00:01 CEST 2007


Author: arigo
Date: Tue Sep 11 16:00:00 2007
New Revision: 46472

Added:
   pypy/dist/pypy/doc/config/translation.rweakref.txt   (contents, props changed)
Modified:
   pypy/dist/pypy/config/translationoption.py
   pypy/dist/pypy/rpython/rweakref.py
Log:
Added a configuration "option", translator.rweakref, set to False
when the backend or GC policy doesn't support RPython-level weakrefs.
Can be tested in an RPython program to select between two implementation
strategies.


Modified: pypy/dist/pypy/config/translationoption.py
==============================================================================
--- pypy/dist/pypy/config/translationoption.py	(original)
+++ pypy/dist/pypy/config/translationoption.py	Tue Sep 11 16:00:00 2007
@@ -20,7 +20,8 @@
                      "ootype": [("translation.backendopt.raisingop2direct_call", False),
                                 ("translation.backendopt.constfold", False),
                                 ("translation.backendopt.heap2stack", False),
-                                ("translation.backendopt.clever_malloc_removal", False)]
+                                ("translation.backendopt.clever_malloc_removal", False),
+                                ("translation.rweakref", False)],  # XXX
                      }),
     ChoiceOption("backend", "Backend to use for code generation",
                  ["c", "llvm", "cli", "jvm", "js", "squeak", "cl"],
@@ -43,7 +44,11 @@
                  ["boehm", "ref", "framework", "none", "stacklessgc",
                   "exact_boehm"],
                   "ref", requires={
-                     "stacklessgc": [("translation.stackless", True)]},
+                     "ref": [("translation.rweakref", False)], # XXX
+                     "framework": [("translation.rweakref", False)], # XXX
+                     "none": [("translation.rweakref", False)], # XXX
+                     "stacklessgc": [("translation.stackless", True),
+                                     ("translation.rweakref", False)]}, # XXX
                   cmdline="--gc"),
     BoolOption("thread", "enable use of threading primitives",
                default=False, cmdline="--thread",
@@ -60,6 +65,8 @@
                cmdline=None),
     BoolOption("sandbox", "Produce a fully-sandboxed executable",
                default=False, cmdline="--sandbox"),
+    BoolOption("rweakref", "The backend supports RPython-level weakrefs",
+               default=True),
 
     # misc
     StrOption("cc", "Specify compiler to use for compiling generated C", cmdline="--cc"),

Added: pypy/dist/pypy/doc/config/translation.rweakref.txt
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/doc/config/translation.rweakref.txt	Tue Sep 11 16:00:00 2007
@@ -0,0 +1,3 @@
+This indicates if the backend and GC policy support RPython-level weakrefs.
+Can be tested in an RPython program to select between two implementation
+strategies.

Modified: pypy/dist/pypy/rpython/rweakref.py
==============================================================================
--- pypy/dist/pypy/rpython/rweakref.py	(original)
+++ pypy/dist/pypy/rpython/rweakref.py	Tue Sep 11 16:00:00 2007
@@ -1,6 +1,7 @@
 import weakref
 from pypy.annotation import model as annmodel
 from pypy.objspace.flow.model import Constant
+from pypy.rpython.error import TyperError
 from pypy.rpython.rmodel import Repr
 from pypy.rpython.rclass import getinstancerepr
 from pypy.rpython.lltypesystem import lltype, llmemory
@@ -31,6 +32,9 @@
 
     def __init__(self, rtyper):
         self.rtyper = rtyper
+        if not rtyper.getconfig().translation.rweakref:
+            raise TyperError("RPython-level weakrefs are not supported by "
+                             "this backend or GC policy")
 
     def rtype_simple_call(self, hop):
         v_wref, = hop.inputargs(self)



More information about the Pypy-commit mailing list