[pypy-svn] r63626 - in pypy/branch/pyjitpl5-simplify/pypy/jit: backend/llgraph backend/x86 metainterp metainterp/test
fijal at codespeak.net
fijal at codespeak.net
Sat Apr 4 20:12:53 CEST 2009
Author: fijal
Date: Sat Apr 4 20:12:53 2009
New Revision: 63626
Modified:
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/runner.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_virtual.py
Log:
Support for cast_int_to_ptr and cast_ptr_to_int (only on executor level so far)
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py Sat Apr 4 20:12:53 2009
@@ -332,6 +332,15 @@
else: # calldescr.type == 'v' # void
llimpl.do_call_void(func, self.memo_cast)
+ def do_cast_int_to_ptr(self, args, descr=None):
+ return history.BoxPtr(llmemory.cast_adr_to_ptr(
+ self.cast_int_to_adr(args[0].getint()),
+ llmemory.GCREF))
+
+ def do_cast_ptr_to_int(self, args, descr=None):
+ return history.BoxInt(self.cast_adr_to_int(llmemory.cast_ptr_to_adr(
+ args[0].getptr_base())))
+
# ____________________________________________________________
import pypy.jit.metainterp.executor
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/runner.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/runner.py Sat Apr 4 20:12:53 2009
@@ -514,6 +514,12 @@
return None
return op.args[0]
+ def do_cast_ptr_to_int(self, args, descr=None):
+ return BoxInt(self.cast_gcref_to_int(args[0].getptr_base()))
+
+ def do_cast_int_to_ptr(self, args, descr=None):
+ return BoxPtr(self.cast_int_to_gcref(args[0].getint()))
+
# ------------------- helpers and descriptions --------------------
@staticmethod
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py Sat Apr 4 20:12:53 2009
@@ -254,7 +254,7 @@
''' % (_opimpl, _opimpl.upper())).compile()
for _opimpl in ['int_is_true', 'int_neg', 'int_invert', 'bool_not',
- 'uint_is_true',
+ 'uint_is_true', 'cast_ptr_to_int', 'cast_int_to_ptr',
]:
exec py.code.Source('''
@arguments("box")
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py Sat Apr 4 20:12:53 2009
@@ -103,6 +103,8 @@
_ALWAYS_PURE_FIRST = 20 # ----- start of always_pure operations -----
CALL_PURE = 20
#
+ CAST_INT_TO_PTR = 21
+ CAST_PTR_TO_INT = 22
INT_ADD = 30
INT_SUB = 31
INT_MUL = 32
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py Sat Apr 4 20:12:53 2009
@@ -61,8 +61,8 @@
graph = rtyper.annotator.translator.graphs[0]
maingraph = cw.make_one_bytecode(graph, False)
while cw.unfinished_graphs:
- graph = cw.unfinished_graphs.pop()
- cw.make_one_bytecode(graph, False)
+ graph, called_from = cw.unfinished_graphs.pop()
+ cw.make_one_bytecode(graph, False, called_from)
metainterp.portal_code = maingraph
metainterp.delete_history()
metainterp.warmrunnerdesc = FakeWarmRunnderDesc
@@ -349,6 +349,18 @@
self.meta_interp(f, [20], repeat=7)
self.check_loop_count(3) # the loop, the entry path, the exit path
+ def test_casts(self):
+ from pypy.rpython.lltypesystem import lltype, llmemory
+
+ TP = lltype.GcStruct('x')
+ def f(p):
+ n = lltype.cast_ptr_to_int(p)
+ return lltype.cast_int_to_ptr(lltype.Ptr(TP), n)
+
+ x = lltype.malloc(TP)
+ expected = lltype.cast_opaque_ptr(llmemory.GCREF, x)
+ assert self.interp_operations(f, [x]) == expected
+
class TestOOtype(BasicTests, OOJitMixin):
pass
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_virtual.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_virtual.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_virtual.py Sat Apr 4 20:12:53 2009
@@ -3,6 +3,7 @@
from pypy.jit.metainterp.policy import StopAtXPolicy
from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
from pypy.rpython.lltypesystem import lltype, rclass
+from pypy.rpython.lltypesystem.lloperation import llop
from pypy.jit.metainterp import heaptracker
class VirtualTests:
@@ -104,6 +105,7 @@
def test_two_loops_with_escaping_virtual(self):
myjitdriver = JitDriver(greens = [], reds = ['n', 'node'])
def externfn(node):
+ llop.debug_print(lltype.Void, node)
return node.value * 2
def f(n):
node = self._new()
More information about the Pypy-commit
mailing list