[pypy-svn] r65566 - in pypy/branch/pyjitpl5-experiments/pypy: jit/backend/x86 jit/backend/x86/test rpython/memory/gc

arigo at codespeak.net arigo at codespeak.net
Wed Jun 3 23:09:33 CEST 2009


Author: arigo
Date: Wed Jun  3 23:09:32 2009
New Revision: 65566

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/test/test_zrpy_gc.py
   pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gc/generation.py
Log:
(pedronis, arigo)
Fix the patching of JMPs.
The (only) test about write barriers now passes :-)


Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py	Wed Jun  3 23:09:32 2009
@@ -587,7 +587,7 @@
 
     def patch_jump(self, old_pos, new_pos, oldlocs, newlocs, olddepth, newdepth):
         if len(oldlocs) != len(newlocs):
-            # virtualizable mess
+            assert 0   # virtualizable mess
             return
         for i in range(len(oldlocs)):
             oldloc = oldlocs[i]
@@ -612,8 +612,11 @@
         targetmp = op.jump_target
         if op.jump_target is not self.tree:
             self.jumps_to_look_at.append((op, self.mc.tell()))
-            self.mc.ADD(esp, imm(0))
         self.mc.JMP(rel32(targetmp._x86_compiled))
+        if op.jump_target is not self.tree:
+            # Reserve 6 bytes for a possible later patch by patch_jump().
+            # Put them after the JMP by default, as it's not doing anything.
+            self.mc.SUB(esp, imm32(0))
 
     def genop_guard_guard_true(self, op, ign_1, addr, locs, ign_2):
         loc = locs[0]

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py	Wed Jun  3 23:09:32 2009
@@ -258,9 +258,12 @@
 
         # make a malloc function, with three arguments
         def malloc_basic(size, type_id, has_finalizer):
-            return llop.do_malloc_fixedsize_clear(llmemory.GCREF,
-                                                  type_id, size, True,
-                                                  has_finalizer, False)
+            res = llop.do_malloc_fixedsize_clear(llmemory.GCREF,
+                                                 type_id, size, True,
+                                                 has_finalizer, False)
+            #llop.debug_print(lltype.Void, "\tmalloc_basic", size, type_id,
+            #                 "-->", res)
+            return res
         self.malloc_basic = malloc_basic
         self.GC_MALLOC_BASIC = lltype.Ptr(lltype.FuncType(
             [lltype.Signed, lltype.Signed, lltype.Bool], llmemory.GCREF))

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py	Wed Jun  3 23:09:32 2009
@@ -321,7 +321,10 @@
             self.caught_exception = None
             if verbose:
                 print "Entering: %d" % rffi.cast(lltype.Signed, func)
+            #llop.debug_print(lltype.Void, ">>>> Entering",
+            #                 rffi.cast(lltype.Signed, func))
             res = func()
+            #llop.debug_print(lltype.Void, "<<<< Back")
             if not we_are_translated():
                 del self.keepalives[:]
             self.reraise_caught_exception()

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/test/test_zrpy_gc.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/test/test_zrpy_gc.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/test/test_zrpy_gc.py	Wed Jun  3 23:09:32 2009
@@ -159,7 +159,6 @@
     assert int(res) == 20
 
 def test_compile_hybrid_3():
-    py.test.skip("in-progress")
     # Third version of the test.  Really requires write_barriers.
     myjitdriver = JitDriver(greens = [], reds = ['n', 'x'])
     def main(n, x):

Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gc/generation.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gc/generation.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gc/generation.py	Wed Jun  3 23:09:32 2009
@@ -312,7 +312,9 @@
                          "obtain_free_space failed to do its job")
         if self.nursery:
             if self.config.gcconfig.debugprint:
-                llop.debug_print(lltype.Void, "minor collect")
+                llop.debug_print(lltype.Void, "--- minor collect ---")
+                llop.debug_print(lltype.Void, "nursery:",
+                                 self.nursery, "to", self.nursery_top)
             # a nursery-only collection
             scan = beginning = self.free
             self.collect_oldrefs_to_nursery()
@@ -327,7 +329,9 @@
             # mark the nursery as free and fill it with zeroes again
             llarena.arena_reset(self.nursery, self.nursery_size, True)
             if self.config.gcconfig.debugprint:
-                llop.debug_print(lltype.Void, "percent survived:", float(scan - beginning) / self.nursery_size)
+                llop.debug_print(lltype.Void,
+                                 "survived (fraction of the size):",
+                                 float(scan - beginning) / self.nursery_size)
             #self.debug_check_consistency()   # -- quite expensive
         else:
             # no nursery - this occurs after a full collect, triggered either
@@ -423,6 +427,8 @@
         # Additionally, it makes the code in write_barrier() marginally smaller
         # (which is important because it is inlined *everywhere*).
         def remember_young_pointer(addr_struct, addr):
+            llop.debug_print(lltype.Void, "\tremember_young_pointer",
+                             addr_struct, "<-", addr)
             ll_assert(not self.is_in_nursery(addr_struct),
                          "nursery object with GCFLAG_NO_YOUNG_PTRS")
             if self.is_in_nursery(addr):



More information about the Pypy-commit mailing list