Author: Ronan Lamy <[email protected]>
Branch: exctrans
Changeset: r81409:6fdf80c493ae
Date: 2015-12-20 17:47 +0100
http://bitbucket.org/pypy/pypy/changeset/6fdf80c493ae/
Log: Inline rtyper.attachRuntimeTypeInfoFunc into its only caller (and
delete dead test)
diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -13,8 +13,9 @@
from rpython.rtyper.lltypesystem.lltype import (
Ptr, Struct, GcStruct, malloc, cast_pointer, castable, nullptr,
RuntimeTypeInfo, getRuntimeTypeInfo, typeOf, Void, FuncType, Bool, Signed,
- functionptr)
+ functionptr, attachRuntimeTypeInfo)
from rpython.rtyper.lltypesystem.lloperation import llop
+from rpython.rtyper.llannotation import SomePtr
from rpython.rtyper.lltypesystem import rstr
from rpython.rtyper.rmodel import (
Repr, getgcflavor, inputconst, warning, mangle)
@@ -590,10 +591,17 @@
_callable=graph.func)
else:
destrptr = None
- OBJECT = OBJECT_BY_FLAVOR[LLFLAVOR[self.gcflavor]]
- self.rtyper.attachRuntimeTypeInfoFunc(self.object_type,
- ll_runtime_type_info,
- OBJECT, destrptr)
+ self.rtyper.call_all_setups() # compute ForwardReferences now
+ args_s = [SomePtr(Ptr(OBJECT))]
+ graph = self.rtyper.annotate_helper(ll_runtime_type_info, args_s)
+ s = self.rtyper.annotation(graph.getreturnvar())
+ if (not isinstance(s, SomePtr) or
+ s.ll_ptrtype != Ptr(RuntimeTypeInfo)):
+ raise TyperError("runtime type info function returns %r, "
+ "expected Ptr(RuntimeTypeInfo)" % (s))
+ funcptr = self.rtyper.getcallable(graph)
+ attachRuntimeTypeInfo(self.object_type, funcptr, destrptr)
+
vtable = self.rclass.getvtable()
self.rtyper.set_type_for_typeptr(vtable, self.lowleveltype.TO)
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -16,15 +16,15 @@
import py, math
from rpython.annotator import model as annmodel, unaryop, binaryop
-from rpython.rtyper.llannotation import SomePtr, lltype_to_annotation
+from rpython.rtyper.llannotation import lltype_to_annotation
from rpython.flowspace.model import Variable, Constant, SpaceOperation
from rpython.rtyper.annlowlevel import annotate_lowlevel_helper,
LowLevelAnnotatorPolicy
from rpython.rtyper.error import TyperError
from rpython.rtyper.exceptiondata import ExceptionData
from rpython.rtyper.lltypesystem.lltype import (Signed, Void, LowLevelType,
- Ptr, ContainerType, FuncType, functionptr, typeOf, RuntimeTypeInfo,
- attachRuntimeTypeInfo, Primitive, getfunctionptr)
-from rpython.rtyper.rmodel import Repr, inputconst, BrokenReprTyperError
+ ContainerType, FuncType, functionptr, typeOf,
+ Primitive, getfunctionptr)
+from rpython.rtyper.rmodel import Repr, inputconst
from rpython.rtyper import rclass
from rpython.rtyper.rclass import RootClassRepr
from rpython.tool.pairtype import pair
@@ -590,21 +590,6 @@
graph = self.annotate_helper(ll_function, argtypes)
return self.getcallable(graph)
- def attachRuntimeTypeInfoFunc(self, GCSTRUCT, func, ARG_GCSTRUCT=None,
- destrptr=None):
- self.call_all_setups() # compute ForwardReferences now
- if ARG_GCSTRUCT is None:
- ARG_GCSTRUCT = GCSTRUCT
- args_s = [SomePtr(Ptr(ARG_GCSTRUCT))]
- graph = self.annotate_helper(func, args_s)
- s = self.annotation(graph.getreturnvar())
- if (not isinstance(s, SomePtr) or
- s.ll_ptrtype != Ptr(RuntimeTypeInfo)):
- raise TyperError("runtime type info function %r returns %r, "
- "excepted Ptr(RuntimeTypeInfo)" % (func, s))
- funcptr = self.getcallable(graph)
- attachRuntimeTypeInfo(GCSTRUCT, funcptr, destrptr)
-
# register operations from annotation model
RPythonTyper._registeroperations(unaryop.UNARY_OPERATIONS,
binaryop.BINARY_OPERATIONS)
diff --git a/rpython/translator/c/test/test_refcount.py
b/rpython/translator/c/test/test_refcount.py
--- a/rpython/translator/c/test/test_refcount.py
+++ b/rpython/translator/c/test/test_refcount.py
@@ -106,37 +106,6 @@
assert fn(1) == 4
assert fn(0) == 5
- def test_del_basic(self):
- py.test.skip("xxx fix or kill")
- S = lltype.GcStruct('S', ('x', lltype.Signed), rtti=True)
- TRASH = lltype.GcStruct('TRASH', ('x', lltype.Signed))
- GLOBAL = lltype.Struct('GLOBAL', ('x', lltype.Signed))
- glob = lltype.malloc(GLOBAL, immortal=True)
- def destructor(s):
- glob.x = s.x + 1
- def type_info_S(s):
- return lltype.getRuntimeTypeInfo(S)
-
- def g(n):
- s = lltype.malloc(S)
- s.x = n
- # now 's' should go away
- def entrypoint(n):
- g(n)
- # llop.gc__collect(lltype.Void)
- return glob.x
-
- t = TranslationContext()
- t.buildannotator().build_types(entrypoint, [int])
- rtyper = t.buildrtyper()
- destrptr = rtyper.annotate_helper_fn(destructor, [lltype.Ptr(S)])
- rtyper.attachRuntimeTypeInfoFunc(S, type_info_S, destrptr=destrptr)
- rtyper.specialize()
- fn = self.compile_func(entrypoint, None, t)
-
- res = fn(123)
- assert res == 124
-
def test_del_catches(self):
import os
def g():
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit