[pypy-svn] r40579 - in pypy/branch/jit-virtual-world/pypy: jit/hintannotator objspace/flow rlib
pedronis at codespeak.net
pedronis at codespeak.net
Fri Mar 16 13:26:13 CET 2007
Author: pedronis
Date: Fri Mar 16 13:26:04 2007
New Revision: 40579
Modified:
pypy/branch/jit-virtual-world/pypy/jit/hintannotator/bookkeeper.py
pypy/branch/jit-virtual-world/pypy/objspace/flow/model.py
pypy/branch/jit-virtual-world/pypy/rlib/objectmodel.py
Log:
(arre, arigo, pedronis)
- we_are_jitted() special function, it evaluates usually to false, but timeshifts
to true. with test.
- support for constant/variable substitution in copygraph by passing in a varmap mapping
Modified: pypy/branch/jit-virtual-world/pypy/jit/hintannotator/bookkeeper.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/hintannotator/bookkeeper.py (original)
+++ pypy/branch/jit-virtual-world/pypy/jit/hintannotator/bookkeeper.py Fri Mar 16 13:26:04 2007
@@ -1,6 +1,7 @@
import py
from pypy.tool.tls import tlsobject
from pypy.tool.ansi_print import ansi_log
+from pypy.rlib import objectmodel
from pypy.objspace.flow.model import copygraph, SpaceOperation, Constant
from pypy.objspace.flow.model import Variable, Block, Link, FunctionGraph
from pypy.annotation import model as annmodel
@@ -14,6 +15,8 @@
log = py.log.Producer("hintannotate")
py.log.setconsumer("hintannotate", ansi_log)
+TIMESHIFTMAP = {Constant(objectmodel._we_are_jitted):
+ Constant(1, lltype.Signed)}
class GraphDesc(object):
@@ -45,7 +48,7 @@
except KeyError:
bk = self.bookkeeper
if bk.annotator.policy.look_inside_graph(self.origgraph):
- graph = copygraph(self.origgraph)
+ graph = copygraph(self.origgraph, varmap=TIMESHIFTMAP)
log(str(graph))
else:
graph = self.build_callback_graph(self.origgraph)
Modified: pypy/branch/jit-virtual-world/pypy/objspace/flow/model.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/objspace/flow/model.py (original)
+++ pypy/branch/jit-virtual-world/pypy/objspace/flow/model.py Fri Mar 16 13:26:04 2007
@@ -507,24 +507,24 @@
lst.append(link)
return result
-def copygraph(graph, shallow=False):
+def copygraph(graph, shallow=False, varmap={}):
"Make a copy of a flow graph."
blockmap = {}
- varmap = {}
+ varmap = varmap.copy()
def copyvar(v):
if shallow:
return v
- if isinstance(v, Variable):
- try:
- return varmap[v]
- except KeyError:
+ try:
+ return varmap[v]
+ except KeyError:
+ if isinstance(v, Variable):
v2 = varmap[v] = Variable(v)
if hasattr(v, 'concretetype'):
v2.concretetype = v.concretetype
return v2
- else:
- return v
+ else:
+ return v
def copyblock(block):
newblock = Block([copyvar(v) for v in block.inputargs])
Modified: pypy/branch/jit-virtual-world/pypy/rlib/objectmodel.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/rlib/objectmodel.py (original)
+++ pypy/branch/jit-virtual-world/pypy/rlib/objectmodel.py Fri Mar 16 13:26:04 2007
@@ -109,9 +109,7 @@
def keepalive_until_here(*values):
pass
-def hint(x, **kwds):
- return x
-
+# ____________________________________________________________
class FREED_OBJECT(object):
def __getattribute__(self, attr):
@@ -189,6 +187,28 @@
return hop.genop('cast_weakadr_to_int', vlist,
resulttype = hop.r_result.lowleveltype)
+# ____________________________________________________________
+
+def hint(x, **kwds):
+ return x
+
+def we_are_jitted():
+ return False
+# timeshifts to True
+
+_we_are_jitted = CDefinedIntSymbolic('0 /* we are not jitted here */',
+ default=0)
+
+class Entry(ExtRegistryEntry):
+ _about_ = we_are_jitted
+
+ def compute_result_annotation(self):
+ from pypy.annotation import model as annmodel
+ return annmodel.SomeInteger(nonneg=True)
+
+ def specialize_call(self, hop):
+ from pypy.rpython.lltypesystem import lltype
+ return hop.inputconst(lltype.Signed, _we_are_jitted)
def debug_assert(x, msg):
"""After translation to C, this becomes an RPyAssert."""
More information about the Pypy-commit
mailing list