[pypy-svn] r59293 - in pypy/branch/oo-jit/pypy: jit/hintannotator rpython/lltypesystem rpython/ootypesystem
arigo at codespeak.net
arigo at codespeak.net
Tue Oct 21 12:21:04 CEST 2008
Author: arigo
Date: Tue Oct 21 12:21:02 2008
New Revision: 59293
Modified:
pypy/branch/oo-jit/pypy/jit/hintannotator/annotator.py
pypy/branch/oo-jit/pypy/jit/hintannotator/model.py
pypy/branch/oo-jit/pypy/jit/hintannotator/policy.py
pypy/branch/oo-jit/pypy/rpython/lltypesystem/rclass.py
pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py
Log:
Some tweaks to support pyjitpl.
I hope I'm not breaking anything...
Modified: pypy/branch/oo-jit/pypy/jit/hintannotator/annotator.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/hintannotator/annotator.py (original)
+++ pypy/branch/oo-jit/pypy/jit/hintannotator/annotator.py Tue Oct 21 12:21:02 2008
@@ -19,7 +19,9 @@
bookkeeper = HintBookkeeper(self)
RPythonAnnotator.__init__(self, translator, policy=policy,
bookkeeper=bookkeeper)
- self.exceptiontransformer = base_translator.getexceptiontransformer()
+ if policy.exceptiontransform:
+ etrafo = base_translator.getexceptiontransformer()
+ self.exceptiontransformer = etrafo
def build_types(self, origgraph, input_args_hs):
desc = self.bookkeeper.getdesc(origgraph)
Modified: pypy/branch/oo-jit/pypy/jit/hintannotator/model.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/hintannotator/model.py (original)
+++ pypy/branch/oo-jit/pypy/jit/hintannotator/model.py Tue Oct 21 12:21:02 2008
@@ -381,6 +381,9 @@
return SomeLLAbstractConstant(lltype.Bool, {})
def getfield(hs_v1, hs_fieldname):
+ hs_res = handle_getfield_typeptr(hs_v1, hs_fieldname)
+ if hs_res is not None:
+ return hs_res
S = hs_v1.concretetype.TO
FIELD_TYPE = getattr(S, hs_fieldname.const)
return variableoftype(FIELD_TYPE, hs_v1.deepfrozen, cause=hs_v1)
@@ -558,6 +561,9 @@
return hs_f1._call_single_graph(fnobj.graph, lltype.typeOf(fnobj).RESULT, *args_hs)
def getfield(hs_c1, hs_fieldname):
+ hs_res = handle_getfield_typeptr(hs_c1, hs_fieldname)
+ if hs_res is not None:
+ return hs_res
S = hs_c1.concretetype.TO
FIELD_TYPE = getattr(S, hs_fieldname.const)
return hs_c1.getfield_impl(S, FIELD_TYPE)
@@ -851,6 +857,17 @@
cause="non-pure residual call to %s" % graph)
return h_res
+def handle_getfield_typeptr(hs_struct, hs_fieldname):
+ if hs_fieldname.const == 'typeptr':
+ S = originalconcretetype(hs_struct).TO
+ if S._hints.get('typeptr'):
+ bookkeeper = getbookkeeper()
+ if bookkeeper.annotator.policy.pyjitpl:
+ RESTYPE = getattr(S, 'typeptr')
+ hs_concrete = SomeLLAbstractConstant(RESTYPE, {})
+ return hs_concrete
+ return None
+
# ____________________________________________________________
#
# Register automatically simple operations
Modified: pypy/branch/oo-jit/pypy/jit/hintannotator/policy.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/hintannotator/policy.py (original)
+++ pypy/branch/oo-jit/pypy/jit/hintannotator/policy.py Tue Oct 21 12:21:02 2008
@@ -8,19 +8,13 @@
oopspec = False
entrypoint_returns_red = True
hotpath = False
+ pyjitpl = False
+ exceptiontransform = True
- def __init__(self, novirtualcontainer = None,
- oopspec = None,
- entrypoint_returns_red = None,
- hotpath = None):
- if novirtualcontainer is not None:
- self.novirtualcontainer = novirtualcontainer
- if oopspec is not None:
- self.oopspec = oopspec
- if entrypoint_returns_red is not None:
- self.entrypoint_returns_red = entrypoint_returns_red
- if hotpath is not None:
- self.hotpath = hotpath
+ def __init__(self, **kwds):
+ for key, value in kwds.items():
+ assert hasattr(self, key), "no such option: %r" % (key,)
+ setattr(self, key, value)
def copy(self, **kwds):
new = instantiate(self.__class__)
Modified: pypy/branch/oo-jit/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/lltypesystem/rclass.py (original)
+++ pypy/branch/oo-jit/pypy/rpython/lltypesystem/rclass.py Tue Oct 21 12:21:02 2008
@@ -58,7 +58,8 @@
OBJECT_VTABLE = lltype.ForwardReference()
CLASSTYPE = Ptr(OBJECT_VTABLE)
OBJECT = GcStruct('object', ('typeptr', CLASSTYPE),
- hints = {'immutable': True, 'shouldntbenull': True})
+ hints = {'immutable': True, 'shouldntbenull': True,
+ 'typeptr': True})
OBJECTPTR = Ptr(OBJECT)
OBJECT_VTABLE.become(Struct('object_vtable',
#('parenttypeptr', CLASSTYPE),
Modified: pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py (original)
+++ pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py Tue Oct 21 12:21:02 2008
@@ -393,6 +393,7 @@
class AbstractString(BuiltinADTType):
+ oopspec_name = 'str'
immutable = True
def __init__(self):
More information about the Pypy-commit
mailing list