[pypy-svn] r38081 - pypy/branch/new-jit-codegen/i386

arigo at codespeak.net arigo at codespeak.net
Wed Feb 7 17:09:28 CET 2007


Author: arigo
Date: Wed Feb  7 17:09:26 2007
New Revision: 38081

Modified:
   pypy/branch/new-jit-codegen/i386/operation.py
   pypy/branch/new-jit-codegen/i386/rgenop.py
Log:
* i386 fixes for places with no initial value.
* fixes in array_item_operand.


Modified: pypy/branch/new-jit-codegen/i386/operation.py
==============================================================================
--- pypy/branch/new-jit-codegen/i386/operation.py	(original)
+++ pypy/branch/new-jit-codegen/i386/operation.py	Wed Feb  7 17:09:26 2007
@@ -23,6 +23,8 @@
     clobbers_cc = True
     side_effects = True
 
+    def mark_used_vars(self, allocator):
+        raise NotImplementedError
     def generate(self, allocator):
         raise NotImplementedError
 
@@ -105,6 +107,8 @@
 class OpWhatever(Operation):
     clobbers_cc = False
     side_effects = False
+    def mark_used_vars(self, allocator):
+        pass
     def generate(self, allocator):
         allocator.create(self)
 
@@ -642,9 +646,9 @@
             allocator.create_exactly_at(self, eax)
 
 
-def field_operand(allocator, base, fieldtoken):
+def field_operand(allocator, gv_base, fieldtoken):
     fieldoffset, fieldsize = fieldtoken
-
+    base = allocator.get_operand(gv_base)
     if isinstance(base, MODRM):
         tmp = allocator.create_scratch_reg(base)
         allocator.end_clobber(tmp)
@@ -652,16 +656,18 @@
     elif isinstance(base, IMM32):
         fieldoffset += base.value
         base = None
+    allocator.release(gv_base)
 
     if fieldsize == 1:
         return mem8(base, fieldoffset)
     else:
         return mem (base, fieldoffset)
 
-def array_item_operand(allocator, base, arraytoken, opindex):
+def array_item_operand(allocator, gv_base, arraytoken, gv_opindex):
     tmp = None
     _, startoffset, itemoffset = arraytoken
 
+    opindex = allocator.get_operand(gv_opindex)
     if isinstance(opindex, IMM32):
         startoffset += itemoffset * opindex.value
         opindex = None
@@ -677,21 +683,27 @@
         opindex = tmp
         indexshift = 0
 
-    if isinstance(base, MODRM):
-        if tmp is None:
-            tmp = allocator.create_scratch_reg(base)
-        else:   # let's avoid using two scratch registers
-            opindex = None
-            if indexshift > 0:
-                allocator.mc.SHL(tmp, imm8(indexshift))
-            allocator.mc.ADD(tmp, base)
-        base = tmp
-    elif isinstance(base, IMM32):
-        startoffset += base.value
+    if gv_base is None:
         base = None
+    else:
+        base = allocator.get_operand(gv_base)
+        if isinstance(base, MODRM):
+            if tmp is None:
+                tmp = allocator.create_scratch_reg(base)
+            else:   # let's avoid using two scratch registers
+                opindex = None
+                if indexshift > 0:
+                    allocator.mc.SHL(tmp, imm8(indexshift))
+                allocator.mc.ADD(tmp, base)
+            base = tmp
+        elif isinstance(base, IMM32):
+            startoffset += base.value
+            base = None
+        allocator.release(gv_base)
 
     if tmp is not None:
         allocator.end_clobber(tmp)
+    allocator.release(gv_opindex)
 
     if itemoffset == 1:
         return memSIB8(base, opindex, indexshift, startoffset)
@@ -707,10 +719,8 @@
     def mark_used_vars(self, allocator):
         allocator.using(self.gv_length)
     def generate(self, allocator):
-        srcop = allocator.get_operand(self.gv_length)
         op_size = array_item_operand(allocator, None,
-                                     self.varsizealloctoken, srcop)
-        allocator.release(self.gv_length)
+                                     self.varsizealloctoken, self.gv_length)
         dstop = allocator.create_reg(self)
         allocator.mc.LEA(dstop, op_size)
 
@@ -763,9 +773,7 @@
     def mark_used_vars(self, allocator):
         allocator.using(self.gv_ptr)
     def generate_opsource(self, allocator):
-        opptr = allocator.get_operand(self.gv_ptr)
-        opsource = field_operand(allocator, opptr, self.fieldtoken)
-        allocator.release(self.gv_ptr)
+        opsource = field_operand(allocator, self.gv_ptr, self.fieldtoken)
         return opsource
 
 class OpSetField(OpSetter):
@@ -781,9 +789,7 @@
         allocator.using(self.gv_ptr)
         allocator.using(self.gv_value)
     def generate_optarget(self, allocator):
-        opptr   = allocator.get_operand(self.gv_ptr)
-        optarget = field_operand(allocator, opptr, self.fieldtoken)
-        allocator.release(self.gv_ptr)
+        optarget = field_operand(allocator, self.gv_ptr, self.fieldtoken)
         allocator.release(self.gv_value)
         return optarget
 
@@ -799,12 +805,8 @@
         allocator.using(self.gv_array)
         allocator.using(self.gv_index)
     def generate_opsource(self, allocator):
-        oparray = allocator.get_operand(self.gv_array)
-        opindex = allocator.get_operand(self.gv_index)
-        opsource = array_item_operand(allocator, oparray,
-                                      self.arraytoken, opindex)
-        allocator.release(self.gv_array)
-        allocator.release(self.gv_index)
+        opsource = array_item_operand(allocator, self.gv_array,
+                                      self.arraytoken, self.gv_index)
         return opsource
 
 class OpGetArraySubstruct(OpGetArrayItem):
@@ -827,12 +829,8 @@
         allocator.using(self.gv_index)
         allocator.using(self.gv_value)
     def generate_optarget(self, allocator):
-        oparray = allocator.get_operand(self.gv_array)
-        opindex = allocator.get_operand(self.gv_index)
-        opsource = array_item_operand(allocator, oparray,
-                                      self.arraytoken, opindex)
-        allocator.release(self.gv_array)
-        allocator.release(self.gv_index)
+        opsource = array_item_operand(allocator, self.gv_array,
+                                      self.arraytoken, self.gv_index)
         allocator.release(self.gv_value)
         return opsource
 

Modified: pypy/branch/new-jit-codegen/i386/rgenop.py
==============================================================================
--- pypy/branch/new-jit-codegen/i386/rgenop.py	(original)
+++ pypy/branch/new-jit-codegen/i386/rgenop.py	Wed Feb  7 17:09:26 2007
@@ -266,7 +266,7 @@
         self.coming_from_cond = insncond
         self.coming_from = mc.tell()
         insnemit = EMIT_JCOND[insncond]
-        insnemit(mc, rel32(0))
+        insnemit(mc, rel32(-1))
         self.coming_from_end = mc.tell()
 
     def start_mc(self):



More information about the Pypy-commit mailing list