[pypy-svn] r40583 - in pypy/branch/jit-virtual-world/pypy: jit/timeshifter/test rlib rlib/test rpython rpython/lltypesystem
pedronis at codespeak.net
pedronis at codespeak.net
Fri Mar 16 14:04:36 CET 2007
Author: pedronis
Date: Fri Mar 16 14:04:32 2007
New Revision: 40583
Added:
pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_frontend.py (contents, props changed)
Modified:
pypy/branch/jit-virtual-world/pypy/rlib/objectmodel.py
pypy/branch/jit-virtual-world/pypy/rlib/test/test_objectmodel.py
pypy/branch/jit-virtual-world/pypy/rpython/llinterp.py
pypy/branch/jit-virtual-world/pypy/rpython/lltypesystem/lloperation.py
Log:
oops, forgot to add the new test file
Added: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_frontend.py
==============================================================================
--- (empty file)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/test/test_frontend.py Fri Mar 16 14:04:32 2007
@@ -0,0 +1,19 @@
+from pypy.rlib.objectmodel import we_are_jitted, _is_early_constant
+from pypy.rpython.test.test_llinterp import interpret
+from pypy.jit.timeshifter.test.test_timeshift import TimeshiftingTests
+
+class TestFrontend(TimeshiftingTests):
+
+ def test_we_are_jitted(self):
+ def f():
+ if we_are_jitted():
+ return 42
+ return 0
+
+ assert f() == 0
+ res = interpret(f, [])
+ assert res == 0
+
+ res = self.timeshift(f, [])
+ assert res == 42
+
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 14:04:32 2007
@@ -210,6 +210,28 @@
from pypy.rpython.lltypesystem import lltype
return hop.inputconst(lltype.Signed, _we_are_jitted)
+def _is_early_constant(x):
+ return False
+
+class Entry(ExtRegistryEntry):
+ _about_ = _is_early_constant
+
+ def compute_result_annotation(self, s_value):
+ from pypy.annotation import model as annmodel
+ s = annmodel.SomeBool()
+ if s_value.is_constant():
+ s.const = True
+ return s
+
+ def specialize_call(self, hop):
+ from pypy.rpython.lltypesystem import lltype
+ if hop.s_result.is_constant():
+ assert hop.s_result.const
+ return hop.inputconst(lltype.Bool, True)
+ v, = hop.inputargs(hop.args_r[0])
+ return hop.genop('is_early_constant', [v], resulttype=lltype.Bool)
+
+
def debug_assert(x, msg):
"""After translation to C, this becomes an RPyAssert."""
assert x, msg
Modified: pypy/branch/jit-virtual-world/pypy/rlib/test/test_objectmodel.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/rlib/test/test_objectmodel.py (original)
+++ pypy/branch/jit-virtual-world/pypy/rlib/test/test_objectmodel.py Fri Mar 16 14:04:32 2007
@@ -312,6 +312,23 @@
res = self.interpret(f, [])
assert res == 1
+ def test_is_early_constant(self):
+ from pypy.rlib import objectmodel
+ def f(x):
+ if objectmodel._is_early_constant(x):
+ return 42
+ return 0
+
+ assert f(3) == 0
+ res = self.interpret(f, [5])
+ assert res == 0
+
+ def g():
+ return f(88)
+
+ res = self.interpret(g, [])
+ assert res == 42
+
class TestOOtype(BaseTestObjectModel, OORtypeMixin):
pass
Modified: pypy/branch/jit-virtual-world/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/rpython/llinterp.py (original)
+++ pypy/branch/jit-virtual-world/pypy/rpython/llinterp.py Fri Mar 16 14:04:32 2007
@@ -495,6 +495,9 @@
def op_hint(self, x, hints):
return x
+ def op_is_early_constant(self, x):
+ return False
+
def op_resume_point(self, *args):
pass
Modified: pypy/branch/jit-virtual-world/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/rpython/lltypesystem/lloperation.py (original)
+++ pypy/branch/jit-virtual-world/pypy/rpython/lltypesystem/lloperation.py Fri Mar 16 14:04:32 2007
@@ -407,6 +407,7 @@
'keepalive': LLOp(),
'same_as': LLOp(canfold=True),
'hint': LLOp(),
+ 'is_early_constant': LLOp(sideeffects=False),
'check_no_more_arg': LLOp(canraise=(Exception,)),
'check_self_nonzero': LLOp(canraise=(Exception,)),
'decode_arg': LLOp(canraise=(Exception,)),
@@ -444,8 +445,8 @@
'oohash': LLOp(oo=True, sideeffects=False),
# _____ read frame var support ___
- 'get_frame_base': LLOp(),
- 'frame_info': LLOp(),
+ 'get_frame_base': LLOp(sideeffects=False),
+ 'frame_info': LLOp(sideeffects=False),
}
# ***** Run test_lloperation after changes. *****
More information about the Pypy-commit
mailing list