[pypy-svn] r76502 - in pypy/trunk/pypy/jit/backend/x86: . test

arigo at codespeak.net arigo at codespeak.net
Fri Aug 6 11:51:42 CEST 2010


Author: arigo
Date: Fri Aug  6 11:51:40 2010
New Revision: 76502

Modified:
   pypy/trunk/pypy/jit/backend/x86/assembler.py
   pypy/trunk/pypy/jit/backend/x86/test/test_assembler.py
Log:
Use a Struct instead of an Array for debug_counter.
Fixes test_ztranslation, which is unhappy about this
being the only array in the translated program.


Modified: pypy/trunk/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/assembler.py	Fri Aug  6 11:51:40 2010
@@ -151,7 +151,7 @@
         # XXX: 32 is pulled out of the air
         return 32 + len(self.desc_bytes)
 
-DEBUG_COUNTER = rffi.CArray(lltype.Signed)
+DEBUG_COUNTER = lltype.Struct('DEBUG_COUNTER', ('i', lltype.Signed))
 
 class Assembler386(object):
     mc = None
@@ -182,7 +182,7 @@
         self.pending_guard_tokens = None
         self.setup_failure_recovery()
         self._debug = False
-        self.debug_counter_descr = cpu.arraydescrof(DEBUG_COUNTER)
+        self.debug_counter_descr = cpu.fielddescrof(DEBUG_COUNTER, 'i')
 
     def leave_jitted_hook(self):
         ptrs = self.fail_boxes_ptr.ar
@@ -240,8 +240,8 @@
             assert output_log is not None
             f = open_file_as_stream(output_log, "w")
             for i in range(len(self.loop_run_counters)):
-                name, arr = self.loop_run_counters[i]
-                f.write(name + ":" + str(arr[0]) + "\n")
+                name, struct = self.loop_run_counters[i]
+                f.write(name + ":" + str(struct.i) + "\n")
             f.close()
 
     def _build_float_constants(self):
@@ -394,9 +394,9 @@
             funcname = "<loop %d>" % len(self.loop_run_counters)
         # invent the counter, so we don't get too confused
         if self._debug:
-            arr = lltype.malloc(DEBUG_COUNTER, 1, flavor='raw')
-            arr[0] = 0
-            self.loop_run_counters.append((funcname, arr))
+            struct = lltype.malloc(DEBUG_COUNTER, flavor='raw')
+            struct.i = 0
+            self.loop_run_counters.append((funcname, struct))
         return funcname
         
     def patch_jump_for_descr(self, faildescr, adr_new_target):
@@ -426,11 +426,10 @@
                                      self.loop_run_counters[-1][1]))
             box = BoxInt()
             box2 = BoxInt()
-            ops = [ResOperation(rop.GETARRAYITEM_RAW, [c_adr, ConstInt(0)],
+            ops = [ResOperation(rop.GETFIELD_RAW, [c_adr],
                                 box, descr=self.debug_counter_descr),
                    ResOperation(rop.INT_ADD, [box, ConstInt(1)], box2),
-                   ResOperation(rop.SETARRAYITEM_RAW, [c_adr, ConstInt(0),
-                                                       box2],
+                   ResOperation(rop.SETFIELD_RAW, [c_adr, box2],
                                 None, descr=self.debug_counter_descr)]
             operations = ops + operations
             # # we need one register free (a bit of a hack, but whatever)

Modified: pypy/trunk/pypy/jit/backend/x86/test/test_assembler.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/x86/test/test_assembler.py	(original)
+++ pypy/trunk/pypy/jit/backend/x86/test/test_assembler.py	Fri Aug  6 11:51:40 2010
@@ -15,7 +15,7 @@
     supports_floats = True
     NUM_REGS = ACTUAL_CPU.NUM_REGS
 
-    def arraydescrof(self, ARR):
+    def fielddescrof(self, STRUCT, name):
         return 42
 
 class FakeMC:



More information about the Pypy-commit mailing list