[pypy-svn] r37951 - pypy/branch/jit-virtual-world/pypy/jit/timeshifter

pedronis at codespeak.net pedronis at codespeak.net
Mon Feb 5 02:59:41 CET 2007


Author: pedronis
Date: Mon Feb  5 02:59:39 2007
New Revision: 37951

Modified:
   pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py
   pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py
   pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py
Log:
start reorganizing such that there's always possibly a promote after oopspec calls that can raise.
For now oopspec_was_residual == False so that the promote path is not used/reached.

Next step is to have after residual call code that promote whether there was an exception or not from runtime.



Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/hrtyper.py	Mon Feb  5 02:59:39 2007
@@ -1265,6 +1265,9 @@
 
     # handling of the various kinds of calls
 
+    def translate_op_oopspec_was_residual(self, hop):
+        return hop.inputconst(lltype.Bool, False)
+
     def translate_op_oopspec_call(self, hop):
         # special-cased call, for things like list methods
         from pypy.jit.timeshifter.oop import OopSpecDesc, Index
@@ -1410,15 +1413,23 @@
     def translate_op_after_residual_call(self, hop):
         dopts = hop.args_v[0].value
         withexc = dopts['withexc']
+        oop = dopts['oop']
         v_jitstate = hop.llops.getjitstate()
         if withexc:
             hop.llops.genmixlevelhelpercall(self.fetch_global_excdata,
                                             [self.s_JITState], [v_jitstate],
                                             annmodel.s_None)
-        return hop.llops.genmixlevelhelpercall(rtimeshift.after_residual_call,
-                                               [self.s_JITState],
-                                               [v_jitstate],
-                                               self.s_RedBox)
+        if not oop:
+            v_after = hop.llops.genmixlevelhelpercall(
+                            rtimeshift.after_residual_call,
+                            [self.s_JITState],
+                            [v_jitstate],
+                            self.s_RedBox)
+        else: # xxx
+            v_after = hop.inputconst(self.getredrepr(lltype.Signed), 0)
+
+        return v_after
+        
     def translate_op_reshape(self, hop):
         v_jitstate = hop.llops.getjitstate()                
         v_shape, = hop.inputargs(self.getredrepr(lltype.Signed))

Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/rtimeshift.py	Mon Feb  5 02:59:39 2007
@@ -889,6 +889,17 @@
 
 
 class JITState(object):
+    _attrs_ = """curbuilder frame
+                 exc_type_box exc_value_box
+                 greens
+                 returnbox
+                 promotion_path
+                 resumepoint resuming
+                 next
+                 virtualizables
+                 shape_place
+              """.split()
+
     returnbox = None
     next      = None   # for linked lists
     promotion_path = None

Modified: pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py
==============================================================================
--- pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py	(original)
+++ pypy/branch/jit-virtual-world/pypy/jit/timeshifter/transform.py	Mon Feb  5 02:59:39 2007
@@ -502,7 +502,7 @@
                 self.hannotator.policy.oopspec):
                 if fnobj._callable.oopspec.startswith('vable.'):
                     return 'vable', None
-                return 'oopspec', None
+                return 'oopspec', self.can_raise(spaceop)
         if self.hannotator.bookkeeper.is_green_call(spaceop):
             return 'green', None
         withexc = self.can_raise(spaceop)
@@ -669,11 +669,32 @@
     def handle_gray_call(self, block, pos, withexc):
         self.handle_red_call(block, pos, color='gray', withexc=withexc)
 
-    def handle_oopspec_call(self, block, pos):
+    def handle_oopspec_call(self, block, pos, withexc):
         op = block.operations[pos]
         assert op.opname == 'direct_call'
         op.opname = 'oopspec_call'
-
+        if withexc:
+            link = split_block(self.hannotator, block, pos+1)
+            nextblock = link.target
+            linkargs = link.args
+            v_residual  =self.genop(block, 'oopspec_was_residual', [],
+                                    resulttype = lltype.Bool)
+            residualblock = Block([])
+            self.genswitch(block, v_residual, true = residualblock,
+                                              false = None)
+            link_f = block.exits[0]
+            link_f.args = linkargs
+            link_f.target = nextblock
+            residualblock.closeblock(Link(linkargs, nextblock))
+            residualblock2 = self.handle_after_residual_call_details(
+                                  residualblock, 0, [], oop=True,
+                                  withexc=True)
+
+            blockset = { block: True, nextblock: False,
+                        residualblock: False,
+                        residualblock2: False }
+            SSA_to_SSI(blockset, self.hannotator)
+        
     def handle_vable_call(self, block, pos):
         op = block.operations[pos]
         assert op.opname == 'direct_call'
@@ -731,8 +752,18 @@
         call_index = len(newops)
         v_res = self.genop(newops, 'residual_%s_call' % (color,),
                            [op.args[0]], result_like = op.result)
+        if preserve_res:
+            v_res = newops[call_index].result = op.result
+
+        nextblock = self.handle_after_residual_call_details(block, pos,
+                                                            newops, withexc)
+        
+        return v_res, nextblock
 
-        dopts = {'withexc': withexc}
+
+    def handle_after_residual_call_details(self, block, pos, newops, withexc,
+                                           oop = False):
+        dopts = {'withexc': withexc, 'oop': oop }
         copts = Constant(dopts, lltype.Void)
         v_shape = self.genop(newops, 'after_residual_call', [copts],
                              resulttype=lltype.Signed, red=True)
@@ -740,8 +771,6 @@
         self.genop(newops, 'reshape', [v_shape])
         reshape_pos = pos+reshape_index
         block.operations[pos:pos+1] = newops
-        if preserve_res:
-            v_res = newops[call_index].result = op.result
 
         link = split_block(self.hannotator, block, reshape_pos)
         nextblock = link.target
@@ -752,8 +781,7 @@
                                      resulttype = lltype.Bool)
         self.go_to_dispatcher_if(block, v_finished_flag)
 
-            
-        return v_res, nextblock
+        return nextblock
 
 
     # __________ hints __________



More information about the Pypy-commit mailing list