[pypy-svn] r65790 - pypy/branch/pyjitpl5/pypy/jit/backend/x86
arigo at codespeak.net
arigo at codespeak.net
Tue Jun 16 18:17:14 CEST 2009
Author: arigo
Date: Tue Jun 16 18:17:13 2009
New Revision: 65790
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/x86/gc.py
pypy/branch/pyjitpl5/pypy/jit/backend/x86/ri386setup.py
Log:
Simplify gc.py a bit. Generates PUSHAD/POPAD instructions,
which are slow, but that should not be the common case.
This might also fix the fact that it is ill-defined whether
the called function can modify its arguments in-place or not.
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/gc.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/gc.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/gc.py Tue Jun 16 18:17:13 2009
@@ -233,6 +233,7 @@
0]
for loc in gclocs:
assert isinstance(loc, MODRM)
+ assert loc.is_relative_to_ebp()
shape.append(self.LOC_EBP_BASED | (-4 * (1 + loc.position)))
return shape
@@ -427,9 +428,7 @@
def gen_write_barrier(self, assembler, base_reg, value_reg):
from pypy.jit.backend.x86.regalloc import REGS
- SAVE_ME = [reg for reg in REGS
- if reg != base_reg and reg != value_reg]
- bytes_count = 9 + 2 * len(SAVE_ME)
+ bytes_count = 11
#
if isinstance(value_reg, IMM32):
if value_reg.value == 0:
@@ -452,24 +451,16 @@
mc.write('\x74') # JZ label_end
mc.write(chr(bytes_count))
start = mc.tell()
- for reg in SAVE_ME:
- mc.PUSH(reg) # len(SAVE_ME) bytes
+ mc.PUSHAD() # 1 byte
mc.PUSH(value_reg) # 1 or 5 bytes
mc.PUSH(base_reg) # 1 or 5 bytes
funcptr = llop.get_write_barrier_failing_case(self.WB_FUNCPTR)
funcaddr = rffi.cast(lltype.Signed, funcptr)
mc.CALL(rel32(funcaddr)) # 5 bytes
- if isinstance(base_reg, REG):
- mc.POP(base_reg) # 1 byte
- else:
- mc.POP(SAVE_ME[0])
- if isinstance(value_reg, REG):
- mc.POP(value_reg) # 1 byte
- else:
- mc.POP(SAVE_ME[0])
- for i in range(len(SAVE_ME)-1, -1, -1):
- mc.POP(SAVE_ME[i]) # len(SAVE_ME) bytes
- # total: 9+(4?)+(4?)+2*len(SAVE_ME) bytes
+ mc.POP(eax) # 1 byte
+ mc.POP(eax) # 1 byte
+ mc.POPAD() # 1 byte
+ # total: 11+(4?)+(4?) bytes
assert mc.tell() == start + bytes_count
# ____________________________________________________________
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/ri386setup.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/ri386setup.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/ri386setup.py Tue Jun 16 18:17:13 2009
@@ -331,6 +331,9 @@
PUSHF = Instruction()
PUSHF.mode0(['\x9C'])
+PUSHAD = Instruction()
+PUSHAD.mode0(['\x60'])
+
POP = Instruction()
POP.mode1(REG, [register(1), '\x58'])
POP.mode1(MODRM, ['\x8F', orbyte(0<<3), modrm(1)])
@@ -338,6 +341,9 @@
POPF = Instruction()
POPF.mode0(['\x9D'])
+POPAD = Instruction()
+POPAD.mode0(['\x61'])
+
IMUL = Instruction()
IMUL.mode1(MODRM, ['\xF7', orbyte(5<<3), modrm(1)])
IMUL.mode1(MODRM8, ['\xF6', orbyte(5<<3), modrm(1)])
More information about the Pypy-commit
mailing list