[pypy-svn] r73800 - in pypy/trunk/pypy/jit/tl/tinyframe: . test
fijal at codespeak.net
fijal at codespeak.net
Fri Apr 16 01:32:07 CEST 2010
Author: fijal
Date: Fri Apr 16 01:32:05 2010
New Revision: 73800
Modified:
pypy/trunk/pypy/jit/tl/tinyframe/test/test_tinyframe.py
pypy/trunk/pypy/jit/tl/tinyframe/tinyframe.py
Log:
Implement INTROSPECT
Modified: pypy/trunk/pypy/jit/tl/tinyframe/test/test_tinyframe.py
==============================================================================
--- pypy/trunk/pypy/jit/tl/tinyframe/test/test_tinyframe.py (original)
+++ pypy/trunk/pypy/jit/tl/tinyframe/test/test_tinyframe.py Fri Apr 16 01:32:05 2010
@@ -107,3 +107,14 @@
'<function name>',
'<function <function name>(<function name>)>',
]
+
+ def test_introspect(self):
+ code = compile('''
+ main:
+ LOAD 100 => r0
+ LOAD 0 => r1
+ INTROSPECT r1 => r2
+ RETURN r0
+ ''')
+ res = interpret(code)
+ assert res.val == 100
Modified: pypy/trunk/pypy/jit/tl/tinyframe/tinyframe.py
==============================================================================
--- pypy/trunk/pypy/jit/tl/tinyframe/tinyframe.py (original)
+++ pypy/trunk/pypy/jit/tl/tinyframe/tinyframe.py Fri Apr 16 01:32:05 2010
@@ -30,7 +30,7 @@
from pypy.rlib.streamio import open_file_as_stream
from pypy.jit.tl.tinyframe.support import sort
from pypy.rlib.unroll import unrolling_iterable
-from pypy.rlib.jit import JitDriver, hint
+from pypy.rlib.jit import JitDriver, hint, dont_look_inside
opcodes = ['ADD', 'INTROSPECT', 'PRINT', 'CALL', 'LOAD', 'LOAD_FUNCTION',
'RETURN', 'JUMP', 'JUMP_IF_ABOVE']
@@ -144,7 +144,10 @@
self.rint(res.strip(" "))]
def compile_INTROSPECT(self, args):
- raise NotImplementedError
+ arg, res = args.split("=")
+ res = res[1:]
+ self.code += [INTROSPECT, self.rint(arg.strip(" ")),
+ self.rint(res.strip(" "))]
def compile_JUMP(self, args):
raise NotImplementedError
@@ -258,9 +261,18 @@
arg = self.registers[ord(code[i + 1])]
print arg.repr()
i += 2
+ elif opcode == INTROSPECT:
+ self.introspect(ord(code[i + 1]), ord(code[i + 2]))
+ i += 3
else:
raise Exception("unimplemented opcode %s" % opcodes[opcode])
+ @dont_look_inside
+ def introspect(self, rarg, rresult):
+ source = self.registers[rarg]
+ assert isinstance(source, Int)
+ self.registers[rresult] = self.registers[source.val]
+
def interpret(code):
return Frame(code).interpret()
More information about the Pypy-commit
mailing list