[pypy-svn] r36279 - in pypy/branch/jit-codegen-refactor/pypy/jit: codegen codegen/llgraph timeshifter

arigo at codespeak.net arigo at codespeak.net
Mon Jan 8 16:17:39 CET 2007


Author: arigo
Date: Mon Jan  8 16:17:37 2007
New Revision: 36279

Modified:
   pypy/branch/jit-codegen-refactor/pypy/jit/codegen/llgraph/rgenop.py
   pypy/branch/jit-codegen-refactor/pypy/jit/codegen/model.py
   pypy/branch/jit-codegen-refactor/pypy/jit/timeshifter/rtimeshift.py
   pypy/branch/jit-codegen-refactor/pypy/jit/timeshifter/transform.py
Log:
(mwh, arigo)

Finished adapting test_rtimeshift to the new rgenop interface.


Modified: pypy/branch/jit-codegen-refactor/pypy/jit/codegen/llgraph/rgenop.py
==============================================================================
--- pypy/branch/jit-codegen-refactor/pypy/jit/codegen/llgraph/rgenop.py	(original)
+++ pypy/branch/jit-codegen-refactor/pypy/jit/codegen/llgraph/rgenop.py	Mon Jan  8 16:17:37 2007
@@ -211,8 +211,10 @@
     def pause_writing(self, args_gv):
         lnk = llimpl.closeblock1(self.b)
         b2 = llimpl.closelinktofreshblock(lnk, args_gv)
-        self.later_block = b2
         self._close()
+        later_builder = LLBuilder(self.gv_f, llimpl.nullblock)
+        later_builder.later_block = b2
+        return later_builder
 
     def show_incremental_progress(self):
         llimpl.show_incremental_progress(self.gv_f)

Modified: pypy/branch/jit-codegen-refactor/pypy/jit/codegen/model.py
==============================================================================
--- pypy/branch/jit-codegen-refactor/pypy/jit/codegen/model.py	(original)
+++ pypy/branch/jit-codegen-refactor/pypy/jit/codegen/model.py	Mon Jan  8 16:17:37 2007
@@ -156,10 +156,12 @@
         '''
     def pause_writing(self, args_gv):
         '''Optional method: Called when the builder will not be used for a
-        while. This allows the builder to free temporary resources needed
-        during code generation. The next call to the builder will have to be
-        to start_writing().
+        while. This allows the builder to be freed. The pause_writing()
+        method returns the next builder, on which you will have to call
+        start_writing() before you continue.
         '''
+        return self
+
     def start_writing(self):
         '''Start a builder returned by jump_if_xxx(), or resumes a paused
         builder.'''

Modified: pypy/branch/jit-codegen-refactor/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/branch/jit-codegen-refactor/pypy/jit/timeshifter/rtimeshift.py	(original)
+++ pypy/branch/jit-codegen-refactor/pypy/jit/timeshifter/rtimeshift.py	Mon Jan  8 16:17:37 2007
@@ -308,18 +308,12 @@
             resuming.mergesleft -= 1
 
 def guard_global_merge(jitstate, resumepoint):
-    jitstate.curbuilder.pause()
+    jitstate.pause()
     dispatchqueue = jitstate.frame.dispatchqueue
     jitstate.next = dispatchqueue.global_merge_chain
     dispatchqueue.global_merge_chain = jitstate
     jitstate.resumepoint = resumepoint
 
-def enter_block(jitstate):
-    incoming = []
-    memo = rvalue.enter_block_memo()
-    jitstate.enter_block(incoming, memo)
-    enter_next_block(jitstate, incoming)
-
 def split(jitstate, switchredbox, resumepoint, *greens_gv):
     exitgvar = switchredbox.getgenvar(jitstate.curbuilder)
     if exitgvar.is_const:
@@ -340,6 +334,8 @@
         return True
 
 def collect_split(jitstate_chain, resumepoint, *greens_gv):
+    # assumes that the head of the jitstate_chain is ready for writing,
+    # and all the other jitstates in the chain are paused
     greens_gv = list(greens_gv)
     pending = jitstate_chain
     resuming = jitstate_chain.resuming
@@ -389,12 +385,12 @@
     if dispatchqueue.split_chain is not None:
         jitstate = dispatchqueue.split_chain
         dispatchqueue.split_chain = jitstate.next
-        enter_block(jitstate)
+        jitstate.curbuilder.start_writing()
         return jitstate
     elif dispatchqueue.global_merge_chain is not None:
         jitstate = dispatchqueue.global_merge_chain
         dispatchqueue.global_merge_chain = jitstate.next
-        jitstate.curbuilder.resume()
+        jitstate.curbuilder.start_writing()
         return jitstate
     else:
         oldjitstate.resumepoint = -1
@@ -442,7 +438,7 @@
 
 def save_return(jitstate):
     # add 'jitstate' to the chain of return-jitstates
-    jitstate.curbuilder.pause()
+    jitstate.pause()
     dispatchqueue = jitstate.frame.dispatchqueue
     jitstate.next = dispatchqueue.return_chain
     dispatchqueue.return_chain = jitstate
@@ -874,6 +870,10 @@
         locals_gv = [redbox.genvar for redbox in incoming]
         return locals_gv
 
+    def pause(self):
+        locals_gv = self.get_locals_gv()
+        self.curbuilder = self.curbuilder.pause_writing(locals_gv)
+
 
     def residual_ll_exception(self, ll_evalue):
         ll_etype  = ll_evalue.typeptr
@@ -926,13 +926,13 @@
     while return_chain is not None:
         jitstate = return_chain
         return_chain = return_chain.next
-        jitstate.curbuilder.resume()
+        jitstate.curbuilder.start_writing()
         res = retrieve_jitstate_for_merge(return_cache, jitstate, (),
                                           return_marker,
                                           force_merge=force_merge)
         if res is False:    # not finished
             if still_pending:
-                still_pending.curbuilder.pause()
+                still_pending.pause()
             jitstate.next = still_pending
             still_pending = jitstate
     
@@ -942,16 +942,19 @@
     if return_chain is not None:
         return_cache = {}
         still_pending = None
+        was_paused = False
         while return_chain is not None:
             jitstate = return_chain
             return_chain = return_chain.next
-            jitstate.curbuilder.resume()
+            if was_paused:
+                jitstate.curbuilder.start_writing()
+            was_paused = True   # only the head of the list was *not* paused
             res = retrieve_jitstate_for_merge(return_cache, jitstate, (),
                                               return_marker,
                                               force_merge=force_merge)
             if res is False:    # not finished
                 if still_pending:
-                    still_pending.curbuilder.pause()
+                    still_pending.pause()
                 jitstate.next = still_pending
                 still_pending = jitstate
     return still_pending
@@ -1010,4 +1013,7 @@
     while jitstate is not None:
         leave_frame(jitstate)
         jitstate = jitstate.next
-    return return_chain    # a jitstate, which is the head of the chain
+    # return the jitstate which is the head of the chain,
+    # ready for further writing
+    return_chain.curbuilder.start_writing()
+    return return_chain

Modified: pypy/branch/jit-codegen-refactor/pypy/jit/timeshifter/transform.py
==============================================================================
--- pypy/branch/jit-codegen-refactor/pypy/jit/timeshifter/transform.py	(original)
+++ pypy/branch/jit-codegen-refactor/pypy/jit/timeshifter/transform.py	Mon Jan  8 16:17:37 2007
@@ -433,6 +433,7 @@
         if self.graphcolor == 'gray':
             self.genop(block, 'save_locals', [])
         elif self.graphcolor == 'yellow':
+            self.genop(block, 'save_locals', [])
             self.genop(block, 'save_greens', [v_retbox])
         elif self.graphcolor == 'red':
             self.genop(block, 'save_locals', [v_retbox])



More information about the Pypy-commit mailing list