[pypy-svn] r34469 - in pypy/dist/pypy/jit: timeshifter/test tl
pedronis at codespeak.net
pedronis at codespeak.net
Fri Nov 10 16:40:01 CET 2006
Author: pedronis
Date: Fri Nov 10 16:39:58 2006
New Revision: 34469
Modified:
pypy/dist/pypy/jit/timeshifter/test/test_tlc.py
pypy/dist/pypy/jit/tl/tlc.py
Log:
(arre, pedronis)
start porting this test to the portal style. We will need to add more tests and try out inserting promotions in the tlc itself.
Modified: pypy/dist/pypy/jit/timeshifter/test/test_tlc.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_tlc.py (original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_tlc.py Fri Nov 10 16:39:58 2006
@@ -1,6 +1,6 @@
import py
from pypy.rpython.module.support import LLSupport
-from pypy.jit.timeshifter.test.test_timeshift import TimeshiftingTests
+from pypy.jit.timeshifter.test.test_portal import PortalTest
from pypy.jit.timeshifter.test.test_vlist import P_OOPSPEC
from pypy.tool.sourcetools import func_with_new_name
from pypy.jit.conftest import Benchmark
@@ -11,6 +11,8 @@
tlc_interp_without_call = func_with_new_name(
tlc.interp_without_call, "tlc_interp_without_call")
+tlc_interp_eval_without_call = tlc.interp_eval_without_call
+
# to stick attributes on the new function object, not on tlc.interp_wi*
def build_bytecode(s):
result = ''.join([chr(int(t)) for t in s.split(',')])
@@ -18,19 +20,19 @@
tlc_interp_without_call.convert_arguments = [build_bytecode, int, int]
-class TestTLC(TimeshiftingTests):
+class TestTLC(PortalTest):
def test_factorial(self):
code = tlc.compile(FACTORIAL_SOURCE)
bytecode = ','.join([str(ord(c)) for c in code])
- if Benchmark.ENABLED:
- n = 2500
- expected = 0 # far too many powers of 2 to be anything else
- else:
- n = 5
- expected = 120
- res = self.timeshift(tlc_interp_without_call, [bytecode, 0, n],
- [0, 1], policy=P_OOPSPEC)#, backendoptimize=True)
+
+ n = 5
+ expected = 120
+
+ res = self.timeshift_from_portal(tlc_interp_without_call,
+ tlc_interp_eval_without_call,
+ [bytecode, 0, n],
+ policy=P_OOPSPEC)#, backendoptimize=True)
assert res == expected
def test_nth_item(self):
Modified: pypy/dist/pypy/jit/tl/tlc.py
==============================================================================
--- pypy/dist/pypy/jit/tl/tlc.py (original)
+++ pypy/dist/pypy/jit/tl/tlc.py Fri Nov 10 16:39:58 2006
@@ -45,6 +45,8 @@
def lt(self, other): return self.value < other.int_o()
+zero = IntObj(0)
+
class LispObj(Obj):
def div(self, n):
@@ -108,14 +110,19 @@
return t
def make_interp(supports_call):
+
def interp(code='', pc=0, inputarg=0):
if not isinstance(code,str):
raise TypeError("code '%s' should be a string" % str(code))
-
+
+ return interp_eval(code, pc, IntObj(inputarg)).int_o()
+
+ def interp_eval(code, pc, inputarg):
code_len = len(code)
stack = []
while pc < code_len:
+ hint(None, global_merge_point=True)
opcode = ord(code[pc])
opcode = hint(opcode, concrete=True)
pc += 1
@@ -224,22 +231,22 @@
elif supports_call and opcode == CALL:
offset = char2int(code[pc])
pc += 1
- res = interp(code, pc + offset)
- stack.append( IntObj(res) )
+ res = interp_eval(code, pc + offset, zero)
+ stack.append( res )
elif opcode == RETURN:
break
elif opcode == PUSHARG:
- stack.append(IntObj(inputarg))
+ stack.append(inputarg)
else:
raise RuntimeError("unknown opcode: " + str(opcode))
- return stack[-1].int_o()
+ return stack[-1]
- return interp
+ return interp, interp_eval
-interp = make_interp(supports_call = True)
-interp_without_call = make_interp(supports_call = False)
+interp , interp_eval = make_interp(supports_call = True)
+interp_without_call, interp_eval_without_call = make_interp(supports_call = False)
More information about the Pypy-commit
mailing list