[pypy-svn] r28116 - in pypy/dist/pypy: interpreter lib module/gc rpython rpython/test
ac at codespeak.net
ac at codespeak.net
Fri Jun 2 18:03:16 CEST 2006
Author: ac
Date: Fri Jun 2 18:03:16 2006
New Revision: 28116
Added:
pypy/dist/pypy/module/gc/ (props changed)
pypy/dist/pypy/module/gc/__init__.py (contents, props changed)
pypy/dist/pypy/module/gc/app_gc.py (contents, props changed)
pypy/dist/pypy/module/gc/interp_gc.py (contents, props changed)
pypy/dist/pypy/rpython/test/test_rgc.py (contents, props changed)
Removed:
pypy/dist/pypy/lib/gc.py
Modified:
pypy/dist/pypy/interpreter/baseobjspace.py
pypy/dist/pypy/rpython/rgc.py
Log:
Implement gc.collect.
Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py (original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py Fri Jun 2 18:03:16 2006
@@ -211,7 +211,7 @@
if name not in modules:
modules.append(name)
- modules.extend(['unicodedata', '_codecs',
+ modules.extend(['unicodedata', '_codecs', 'gc',
'array', 'marshal', 'errno', 'math', '_sre'])
modules.append('_pickle_support')
Added: pypy/dist/pypy/module/gc/__init__.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/gc/__init__.py Fri Jun 2 18:03:16 2006
@@ -0,0 +1,11 @@
+from pypy.interpreter.mixedmodule import MixedModule
+
+class Module(MixedModule):
+ appleveldefs = {
+ 'enable': 'app_gc.enable',
+ 'disable': 'app_gc.disable',
+ 'isenabled': 'app_gc.isenabled',
+ }
+ interpleveldefs = {
+ 'collect': 'interp_gc.collect',
+ }
Added: pypy/dist/pypy/module/gc/app_gc.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/gc/app_gc.py Fri Jun 2 18:03:16 2006
@@ -0,0 +1,9 @@
+
+def isenabled():
+ pass
+
+def enable():
+ pass
+
+def disable():
+ pass
Added: pypy/dist/pypy/module/gc/interp_gc.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/module/gc/interp_gc.py Fri Jun 2 18:03:16 2006
@@ -0,0 +1,9 @@
+from pypy.interpreter.gateway import ObjSpace
+from pypy.rpython import rgc # Force registration of gc.collect
+import gc
+
+def collect(space):
+ gc.collect()
+
+collect.unwrap_spec = [ObjSpace]
+
Modified: pypy/dist/pypy/rpython/rgc.py
==============================================================================
--- pypy/dist/pypy/rpython/rgc.py (original)
+++ pypy/dist/pypy/rpython/rgc.py Fri Jun 2 18:03:16 2006
@@ -1,5 +1,4 @@
from pypy.rpython.extregistry import ExtRegistryEntry
-
# ____________________________________________________________
# Framework GC features
@@ -92,3 +91,18 @@
v_gcobject = hop.genop('cast_opaque_ptr', [v_gcobjectptr],
resulttype = r_tuple.items_r[0])
return rtuple.newtuple(hop.llops, r_tuple, [v_gcobject, v_pool])
+
+# Support for collection.
+import gc
+
+class CollectEntry(ExtRegistryEntry):
+ _about_ = gc.collect
+
+ def compute_result_annotation(self):
+ from pypy.annotation import model as annmodel
+ return annmodel.SomeImpossibleValue()
+
+ def specialize_call(self, hop):
+ return hop.genop('gc__collect', [], resulttype=hop.r_result)
+
+
Added: pypy/dist/pypy/rpython/test/test_rgc.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/test/test_rgc.py Fri Jun 2 18:03:16 2006
@@ -0,0 +1,13 @@
+from pypy.rpython.test.test_llinterp import gengraph
+from pypy.rpython import rgc # Force registration of gc.collect
+import gc
+
+def test_collect():
+ def f():
+ gc.collect()
+
+ t, typer, graph = gengraph(f, [])
+ ops = list(graph.iterblockops())
+ assert len(ops) == 1
+ op = ops[0][1]
+ assert op.opname == 'gc__collect'
More information about the Pypy-commit
mailing list