Author: Alex Gaynor <[email protected]>
Branch: kill-someobject
Changeset: r57855:e101d8f7ba51
Date: 2012-10-07 20:30 +0200
http://bitbucket.org/pypy/pypy/changeset/e101d8f7ba51/
Log: kill tons of pyobj code
diff --git a/pypy/rpython/llinterp.py b/pypy/rpython/llinterp.py
--- a/pypy/rpython/llinterp.py
+++ b/pypy/rpython/llinterp.py
@@ -846,12 +846,6 @@
def op_gc_deallocate(self, TYPE, addr):
raise NotImplementedError("gc_deallocate")
- def op_gc_push_alive_pyobj(self, pyobj):
- raise NotImplementedError("gc_push_alive_pyobj")
-
- def op_gc_pop_alive_pyobj(self, pyobj):
- raise NotImplementedError("gc_pop_alive_pyobj")
-
def op_gc_reload_possibly_moved(self, v_newaddr, v_ptr):
assert v_newaddr.concretetype is llmemory.Address
assert isinstance(v_ptr.concretetype, lltype.Ptr)
@@ -938,28 +932,6 @@
def op_stack_current(self):
return 0
- # operations on pyobjects!
- for opname in lloperation.opimpls.keys():
- exec py.code.Source("""
- def op_%(opname)s(self, *pyobjs):
- for pyo in pyobjs:
- assert lltype.typeOf(pyo) == lltype.Ptr(lltype.PyObject)
- func = lloperation.opimpls[%(opname)r]
- try:
- pyo = func(*[pyo._obj.value for pyo in pyobjs])
- except Exception:
- self.make_llexception()
- return self.heap.pyobjectptr(pyo)
- """ % locals()).compile()
- del opname
-
- def op_simple_call(self, f, *args):
- assert lltype.typeOf(f) == lltype.Ptr(lltype.PyObject)
- for pyo in args:
- assert lltype.typeOf(pyo) == lltype.Ptr(lltype.PyObject)
- res = f._obj.value(*[pyo._obj.value for pyo in args])
- return self.heap.pyobjectptr(res)
-
# __________________________________________________________
# operations on addresses
@@ -980,7 +952,7 @@
return llmemory.raw_malloc_usage(size)
def op_raw_free(self, addr):
- checkadr(addr)
+ checkadr(addr)
llmemory.raw_free(addr)
def op_raw_memclear(self, addr, size):
diff --git a/pypy/rpython/lltypesystem/lloperation.py
b/pypy/rpython/lltypesystem/lloperation.py
--- a/pypy/rpython/lltypesystem/lloperation.py
+++ b/pypy/rpython/lltypesystem/lloperation.py
@@ -8,7 +8,7 @@
class LLOp(object):
def __init__(self, sideeffects=True, canfold=False, canraise=(),
- pyobj=False, canmallocgc=False, canrun=False, oo=False,
+ canmallocgc=False, canrun=False, oo=False,
tryfold=False):
# self.opname = ... (set afterwards)
@@ -32,9 +32,6 @@
assert not canraise or not canfold
- # The operation manipulates PyObjects
- self.pyobj = pyobj
-
# The operation can go a GC malloc
self.canmallocgc = canmallocgc
if canmallocgc:
@@ -476,8 +473,6 @@
'gc_restore_exception': LLOp(),
'gc_call_rtti_destructor': LLOp(),
'gc_deallocate': LLOp(),
- 'gc_push_alive_pyobj': LLOp(),
- 'gc_pop_alive_pyobj': LLOp(),
'gc_reload_possibly_moved': LLOp(),
# see rlib/objectmodel for gc_identityhash and gc_id
'gc_identityhash': LLOp(sideeffects=False, canmallocgc=True),
@@ -602,17 +597,6 @@
}
# ***** Run test_lloperation after changes. *****
-
- # __________ operations on PyObjects __________
-
-from pypy.objspace.flow.operation import FunctionByName
-opimpls = FunctionByName.copy()
-opimpls['is_true'] = bool
-for opname in opimpls:
- LL_OPERATIONS[opname] = LLOp(canraise=(Exception,), pyobj=True)
-LL_OPERATIONS['simple_call'] = LLOp(canraise=(Exception,), pyobj=True)
-del opname, FunctionByName
-
# ____________________________________________________________
# Post-processing
diff --git a/pypy/rpython/memory/gctransform/boehm.py
b/pypy/rpython/memory/gctransform/boehm.py
--- a/pypy/rpython/memory/gctransform/boehm.py
+++ b/pypy/rpython/memory/gctransform/boehm.py
@@ -1,12 +1,12 @@
from pypy.rpython.memory.gctransform.transform import GCTransformer,
mallocHelpers
-from pypy.rpython.memory.gctransform.support import type_contains_pyobjs, \
- get_rtti, _static_deallocator_body_for_type, LLTransformerOp,
ll_call_destructor
+from pypy.rpython.memory.gctransform.support import (get_rtti,
+ _static_deallocator_body_for_type, LLTransformerOp, ll_call_destructor)
from pypy.rpython.lltypesystem import lltype, llmemory
from pypy.objspace.flow.model import Constant
from pypy.rpython.lltypesystem.lloperation import llop
-from pypy.rpython.lltypesystem import rffi
from pypy.rpython import rmodel
+
class BoehmGCTransformer(GCTransformer):
malloc_zero_filled = True
FINALIZER_PTR = lltype.Ptr(lltype.FuncType([llmemory.Address],
lltype.Void))
@@ -99,20 +99,7 @@
destrptr = None
DESTR_ARG = None
- if type_contains_pyobjs(TYPE):
- if destrptr:
- raise Exception("can't mix PyObjects and __del__ with Boehm")
-
- static_body = '\n'.join(_static_deallocator_body_for_type('v',
TYPE))
- d = {'pop_alive': LLTransformerOp(self.pop_alive),
- 'PTR_TYPE':lltype.Ptr(TYPE),
- 'cast_adr_to_ptr': llmemory.cast_adr_to_ptr}
- src = ("def ll_finalizer(addr):\n"
- " v = cast_adr_to_ptr(addr, PTR_TYPE)\n"
- "%s\n")%(static_body,)
- exec src in d
- fptr = self.annotate_finalizer(d['ll_finalizer'],
[llmemory.Address], lltype.Void)
- elif destrptr:
+ if destrptr:
EXC_INSTANCE_TYPE =
self.translator.rtyper.exceptiondata.lltype_of_exception_value
typename = TYPE.__name__
def ll_finalizer(addr):
diff --git a/pypy/translator/c/test/test_boehm.py
b/pypy/translator/c/test/test_boehm.py
--- a/pypy/translator/c/test/test_boehm.py
+++ b/pypy/translator/c/test/test_boehm.py
@@ -2,11 +2,11 @@
from pypy.translator.translator import TranslationContext
from pypy.rpython.lltypesystem import lltype, llmemory
from pypy.rpython.lltypesystem.lloperation import llop
-from pypy.rpython.memory.test import snippet
from pypy.translator.c.genc import CExtModuleBuilder
from pypy.rlib.objectmodel import keepalive_until_here
from pypy import conftest
+
def setup_module(mod):
from pypy.rpython.tool.rffi_platform import configure_boehm
from pypy.translator.platform import CompilationError
@@ -69,7 +69,6 @@
fn()
def test__del__(self):
- from pypy.rpython.lltypesystem.lloperation import llop
class State:
pass
s = State()
@@ -105,7 +104,6 @@
def test_id_is_weak(self):
# test that compute_unique_id(obj) does not keep obj alive
- from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rlib.objectmodel import compute_unique_id
class State:
pass
@@ -155,7 +153,6 @@
assert 0 < res2 <= 5
def test_del_raises(self):
- from pypy.rpython.lltypesystem.lloperation import llop
class A(object):
def __del__(self):
s.dels += 1
@@ -199,31 +196,6 @@
fn = self.getcompiled(f)
res = fn()
assert res == 10
-
- # this test shows if we have a problem with refcounting PyObject
- def test_refcount_pyobj(self):
- from pypy.rpython.lltypesystem.lloperation import llop
- def prob_with_pyobj(b):
- return 3, b
- def collect():
- llop.gc__collect(lltype.Void)
- f = self.getcompiled(prob_with_pyobj, [object])
- c = self.getcompiled(collect, [])
- from sys import getrefcount as g
- obj = None
- before = g(obj)
- f(obj)
- f(obj)
- f(obj)
- f(obj)
- f(obj)
- c()
- c()
- c()
- c()
- c()
- after = g(obj)
- assert abs(before - after) < 5
def test_zero_malloc(self):
T = lltype.GcStruct("C", ('x', lltype.Signed))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit