[pypy-svn] r65253 - pypy/branch/pyjitpl5/pypy/jit/backend/x86

arigo at codespeak.net arigo at codespeak.net
Tue May 12 18:43:48 CEST 2009


Author: arigo
Date: Tue May 12 18:43:46 2009
New Revision: 65253

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/codebuf.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py
Log:
Minor cleanups.


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py	Tue May 12 18:43:46 2009
@@ -9,7 +9,7 @@
 from pypy.annotation import model as annmodel
 from pypy.tool.uid import fixid
 from pypy.jit.backend.x86.regalloc import (RegAlloc, WORD, REGS, TempBox,
-                                      arg_pos, lower_byte, stack_pos)
+                                           lower_byte, stack_pos)
 from pypy.rlib.objectmodel import we_are_translated, specialize, compute_unique_id
 from pypy.jit.backend.x86 import codebuf
 from pypy.jit.backend.x86.ri386 import *
@@ -291,30 +291,7 @@
         finally:
             Box._extended_display = _prev
 
-#     def assemble_comeback_bootstrap(self, position, arglocs, stacklocs):
-#         return
-#         entry_point_addr = self.mc2.tell()
-#         for i in range(len(arglocs)):
-#             argloc = arglocs[i]
-#             if isinstance(argloc, REG):
-#                 self.mc2.MOV(argloc, stack_pos(stacklocs[i]))
-#             elif not we_are_translated():
-#                 # debug checks
-#                 if not isinstance(argloc, (IMM8, IMM32)):
-#                     assert repr(argloc) == repr(stack_pos(stacklocs[i]))
-#         self.mc2.JMP(rel32(position))
-#         self.mc2.done()
-#         return entry_point_addr
-
-#     def assemble_generic_return(self):
-#         # generate a generic stub that just returns, taking the
-#         # return value from *esp (i.e. stack position 0).
-#         addr = self.mc.tell()
-#         self.mc.MOV(eax, mem(esp, 0))
-#         self.mc.ADD(esp, imm(FRAMESIZE))
-#         self.mc.RET()
-#         self.mc.done()
-#         return addr
+    # ------------------------------------------------------------
 
     def regalloc_load(self, from_loc, to_loc):
         self.mc.MOV(to_loc, from_loc)
@@ -646,7 +623,7 @@
 
     def genop_arraylen_gc(self, op, arglocs, resloc):
         base_loc, ofs_loc = arglocs
-        self.mc.MOV(resloc, addr_add(base_loc, imm(0)))
+        self.mc.MOV(resloc, addr_add_const(base_loc, 0))     # XXX fix this 0
 
     def genop_strgetitem(self, op, arglocs, resloc):
         base_loc, ofs_loc = arglocs
@@ -731,24 +708,6 @@
         mc.JMP(rel32(pos))
         mc.done()
 
-#     def genop_discard_return(self, op, locs):
-#         if op.args:
-#             loc = locs[0]
-#             if loc is not eax:
-#                 self.mc.MOV(eax, loc)
-#         self.mc.ADD(esp, imm(FRAMESIZE))
-#         # copy exception to some safe place and clean the original
-#         # one
-#         self.mc.MOV(ecx, heap(self._exception_addr))
-#         self.mc.MOV(heap(self._exception_bck_addr), ecx)
-#         self.mc.MOV(ecx, addr_add(imm(self._exception_addr), imm(WORD)))
-#         self.mc.MOV(addr_add(imm(self._exception_bck_addr), imm(WORD)),
-#                      ecx)
-#         # clean up the original exception, we don't want
-#         # to enter more rpython code with exc set
-#         self.mc.MOV(heap(self._exception_addr), imm(0))
-#         self.mc.RET()
-
     def genop_discard_jump(self, op, locs):
         targetmp = op.jump_target
         self.jumps_to_look_at.append((op, self.mc.tell()))

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/codebuf.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/codebuf.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/codebuf.py	Tue May 12 18:43:46 2009
@@ -4,8 +4,6 @@
 from pypy.jit.backend.x86.ri386 import I386CodeBuilder
 from pypy.rlib.rmmap import PTR, alloc, free
 
-class CodeBlockOverflow(Exception):
-    pass
 
 class InMemoryCodeBuilder(I386CodeBuilder):
     _last_dump_start = 0
@@ -22,8 +20,7 @@
 
     def write(self, data):
         p = self._pos
-        if p + len(data) > self._size:
-            raise CodeBlockOverflow
+        assert p + len(data) <= self._size
         for c in data:
             self._data[p] = c
             p += 1
@@ -126,48 +123,3 @@
         size = self._size
         assert size >= 0
         free(self._data, size)
-
-# ____________________________________________________________
-
-from pypy.rpython.lltypesystem import lltype
-
-BUF = lltype.GcArray(lltype.Char)
-
-class LLTypeMachineCodeBlock(I386CodeBuilder):
-    # for testing only
-
-    class State:
-        pass
-    state = State()
-    state.base = 1
-
-    def __init__(self, map_size):
-        self._size = map_size
-        self._pos = 0
-        self._base = LLTypeMachineCodeBlock.state.base
-        LLTypeMachineCodeBlock.state.base += map_size
-
-    def write(self, data):
-        p = self._pos
-        if p + len(data) > self._size:
-            raise CodeBlockOverflow
-        self._pos += len(data)
-        return
-
-    def tell(self):
-        return self._base + self._pos
-
-    def seekback(self, count):
-        self._pos -= count
-
-    def done(self):
-        pass
-
-class LLTypeInMemoryCodeBuilder(LLTypeMachineCodeBlock):
-    _last_dump_start = 0
-
-    def __init__(self, start, end):
-        self._size = end - start
-        self._pos = 0
-        self._base = start
-

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py	Tue May 12 18:43:46 2009
@@ -1116,11 +1116,6 @@
         num = getattr(rop, name.upper())
         oplist[num] = value
 
-def arg_pos(i, framesize):
-    res = mem(esp, framesize + WORD * (i + 1))
-    res.position = (i + 1) + framesize // WORD
-    return res
-
 def stack_pos(i):
     res = mem(esp, WORD * i)
     res.position = i



More information about the Pypy-commit mailing list