[pypy-svn] r43523 - in pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Mon May 21 13:00:54 CEST 2007
Author: cfbolz
Date: Mon May 21 13:00:53 2007
New Revision: 43523
Modified:
pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/engine.py
pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/portal.py
pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/test/test_jit.py
Log:
more changes
Modified: pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/engine.py
==============================================================================
--- pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/engine.py (original)
+++ pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/engine.py Mon May 21 13:00:53 2007
@@ -137,7 +137,7 @@
hint(j, concrete=True)
hash1 = uh[j]
hash2 = uh2[j]
- if hash1 != 0 and hash2 != 0 and hash2 != hash1:
+ if hash1 != 0 and hash2 * (hash2 - hash1) != 0:
break
j += 1
else:
@@ -269,6 +269,7 @@
hint(where, concrete=True)
hint(rule, concrete=True)
while 1:
+ hint(None, global_merge_point=True)
#print " " * self.depth, where, query
if where == CALL:
next = self._call(query, continuation)
@@ -287,13 +288,6 @@
where, query, continuation, rule = next
where = hint(where, promote=True)
- def _opaque_main_loop(self, where, query, continuation, rule=None):
- return self.portal_main_loop(where, query, continuation, rule)
-
- def portal_main_loop(self, where, query, continuation, rule=None):
- hint(None, global_merge_point=True)
- return self.main_loop(where, query, continuation, rule)
-
def _jit_lookup(self, signature):
signature2function = self.signature2function
function = signature2function.get(signature, None)
@@ -375,11 +369,24 @@
def try_rule(self, rule, query, continuation=DONOTHING, choice_point=True,
inline=False):
- #if not choice_point and inline:
- # return (TRY_RULE, query, continuation, rule)
if not we_are_jitted():
- return self.portal_main_loop(TRY_RULE, query, continuation, rule)
- return self._opaque_main_loop(TRY_RULE, query, continuation, rule)
+ if not choice_point:
+ return (TRY_RULE, query, continuation, rule)
+ return self.portal_try_rule(rule, query, continuation, choice_point)
+ if _is_early_constant(rule):
+ rule = hint(rule, promote=True)
+ return self.portal_try_rule(rule, query, continuation, choice_point)
+ return self._opaque_try_rule(rule, query, continuation, choice_point)
+
+ def _opaque_try_rule(self, rule, query, continuation, choice_point):
+ return self.portal_try_rule(rule, query, continuation, choice_point)
+
+ def portal_try_rule(self, rule, query, continuation, choice_point):
+ hint(None, global_merge_point=True)
+ #hint(choice_point, concrete=True)
+ #if not choice_point:
+ # return self._try_rule(rule, query, continuation)
+ return self.main_loop(TRY_RULE, query, continuation, rule)
def _try_rule(self, rule, query, continuation):
rule = hint(rule, deepfreeze=True)
Modified: pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/portal.py
==============================================================================
--- pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/portal.py (original)
+++ pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/portal.py Mon May 21 13:00:53 2007
@@ -11,7 +11,7 @@
'pypy.lang.prolog.builtin.register': True
}
-PORTAL = engine.Engine.portal_main_loop.im_func
+PORTAL = engine.Engine.portal_try_rule.im_func
class PyrologHintAnnotatorPolicy(HintAnnotatorPolicy):
novirtualcontainer = True
@@ -126,7 +126,6 @@
seegraph(cls.copy)
seegraph(cls.__init__)
seegraph(cls.copy_and_unify)
- seegraph(cls.unify_hash_of_child)
for cls in [term.Term, term.Number, term.Atom]:
seegraph(cls.copy_and_basic_unify)
seegraph(cls.dereference)
@@ -147,6 +146,7 @@
seegraph(pypy.lang.prolog.interpreter.engine.Engine.main_loop)
seegraph(pypy.lang.prolog.interpreter.engine.LinkedRules.find_applicable_rule)
seegraph(pypy.lang.prolog.interpreter.engine.Continuation.call)
+ seegraph(term.Term.unify_hash_of_child)
for cls in [engine.Continuation, engine.LimitedScopeContinuation,
pypy.lang.prolog.builtin.control.AndContinuation]:
seegraph(cls._call)
Modified: pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/test/test_jit.py
==============================================================================
--- pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/test/test_jit.py (original)
+++ pypy/branch/prolog-jit-experiments/pypy/lang/prolog/interpreter/test/test_jit.py Mon May 21 13:00:53 2007
@@ -98,3 +98,24 @@
backendoptimize=True)
assert res == True
+ def test_loop(self):
+ e = get_engine("""
+ f(X) :- h(X).
+ f(a).
+ h(X) :- h(X).
+ """)
+ X = e.heap.newvar()
+
+ def main(n):
+ e.heap.reset()
+ if n == 0:
+ e.call(term.Term("f", [X]))
+ return isinstance(X.dereference(e.heap), term.Atom)
+ else:
+ return False
+
+ res = self.timeshift_from_portal(main, portal.PORTAL,
+ [0], policy=POLICY,
+ backendoptimize=True)
+ assert res == True
+
More information about the Pypy-commit
mailing list