[pypy-svn] r69627 - in pypy/trunk/virtual-forcing/pypy/jit: backend backend/test metainterp

pedronis at codespeak.net pedronis at codespeak.net
Wed Nov 25 11:48:05 CET 2009


Author: pedronis
Date: Wed Nov 25 11:48:05 2009
New Revision: 69627

Modified:
   pypy/trunk/virtual-forcing/pypy/jit/backend/model.py
   pypy/trunk/virtual-forcing/pypy/jit/backend/test/runner_test.py
   pypy/trunk/virtual-forcing/pypy/jit/metainterp/resoperation.py
Log:
(fijal, pedronis) start sketching a test for the backend interface required to implement forcing 
virtual(lizable) objects



Modified: pypy/trunk/virtual-forcing/pypy/jit/backend/model.py
==============================================================================
--- pypy/trunk/virtual-forcing/pypy/jit/backend/model.py	(original)
+++ pypy/trunk/virtual-forcing/pypy/jit/backend/model.py	Wed Nov 25 11:48:05 2009
@@ -205,6 +205,12 @@
     def do_cast_ptr_to_int(self, ptrbox):
         raise NotImplementedError
 
+    def do_force_token(self):
+    	raise NotImplementedError
+
+    def do_call_may_force(self, args, calldescr):
+    	raise NotImplementedError
+
     # ootype specific operations
     # --------------------------
 

Modified: pypy/trunk/virtual-forcing/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/trunk/virtual-forcing/pypy/jit/backend/test/runner_test.py	(original)
+++ pypy/trunk/virtual-forcing/pypy/jit/backend/test/runner_test.py	Wed Nov 25 11:48:05 2009
@@ -1221,6 +1221,47 @@
             else:
                 assert record == []
 
+    def test_force_operations(self):
+    	values = []
+	def maybe_force(token, flag):
+            if flag:
+	       self.cpu.force(token)
+	       values.append(self.cpu.get_latest_value_int(0))
+	       values.append(self.cpu.get_latest_value_int(1))
+
+        FUNC = self.FuncType([llmemory.Address, lltype.Signed], lltype.Void)
+	func_ptr = llhelper(lltype.Ptr(FUNC), maybe_force)
+        funcbox = self.get_funcbox(self.cpu, func_ptr).constbox()
+	calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
+      	cpu = self.cpu
+	i0 = BoxInt()
+	i1 = BoxInt()
+	tok = BoxInt()
+	ops = [
+    	ResOperation(rop.FORCE_TOKEN, [], tok),
+	ResOperation(rop.CALL_MAY_FORCE, [funcbox, tok, i1], None, descr=calldescr),
+	ResOperation(rop.GUARD_NOT_FORCED, [], None, descr=BasicFailDescr(1)),
+	ResOperation(rop.FINISH, [i0], None, descr=BasicFailDescr(0))
+	]
+	ops[2].fail_args = [i1, i0]
+	looptoken = LoopToken()
+	self.cpu.compile_loop([i0, i1], ops, looptoken)
+	self.cpu.set_future_value_int(0, 20)
+	self.cpu.set_future_value_int(1, 0)
+        fail = self.cpu.execute_token(looptoken)
+	assert fail.identifier == 0
+	assert self.cpu.get_latest_value_int(0) == 20
+	assert values == []
+
+	self.cpu.set_future_value_int(0, 10)
+	self.cpu.set_future_value_int(1, 1)
+        fail = self.cpu.execute_token(looptoken)
+	assert fail.identifier == 1
+	assert self.cpu.get_latest_value_int(0) == 1
+	assert self.cpu.get_latest_value_int(1) == 10
+	assert values == [1, 10]
+
+
     # pure do_ / descr features
 
     def test_do_operations(self):

Modified: pypy/trunk/virtual-forcing/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/trunk/virtual-forcing/pypy/jit/metainterp/resoperation.py	(original)
+++ pypy/trunk/virtual-forcing/pypy/jit/metainterp/resoperation.py	Wed Nov 25 11:48:05 2009
@@ -125,6 +125,7 @@
     'GUARD_EXCEPTION',
     'GUARD_NO_OVERFLOW',
     'GUARD_OVERFLOW',
+    'GUARD_NOT_FORCED',
     '_GUARD_LAST', # ----- end of guard operations -----
 
     '_NOSIDEEFFECT_FIRST', # ----- start of no_side_effect operations -----
@@ -220,9 +221,11 @@
     'COND_CALL_GC_MALLOC',  # [a, b, if_(a<=b)_result, if_(a>b)_call, args...]
                             #        => result          (for mallocs)
     'DEBUG_MERGE_POINT/1',      # debugging only
+    'FORCE_TOKEN',
 
     '_CANRAISE_FIRST', # ----- start of can_raise operations -----
     'CALL',
+    'CALL_MAY_FORCE',
     'OOSEND',                     # ootype operation
     '_CANRAISE_LAST', # ----- end of can_raise operations -----
 



More information about the Pypy-commit mailing list