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

pedronis at codespeak.net pedronis at codespeak.net
Mon Dec 28 17:43:26 CET 2009


Author: pedronis
Date: Mon Dec 28 17:43:25 2009
New Revision: 70307

Modified:
   pypy/trunk/pypy/jit/backend/detect_cpu.py
   pypy/trunk/pypy/jit/backend/x86/assembler.py
Log:
fix call stack-aligment issues on Mac OS X



Modified: pypy/trunk/pypy/jit/backend/detect_cpu.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/detect_cpu.py	(original)
+++ pypy/trunk/pypy/jit/backend/detect_cpu.py	Mon Dec 28 17:43:25 2009
@@ -9,8 +9,6 @@
     pass
 
 def autodetect_main_model():
-    if sys.platform == 'darwin':
-        raise Exception("JIT not supported on Mac OS/X right now")
     mach = None
     try:
         import platform

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	Mon Dec 28 17:43:25 2009
@@ -28,7 +28,6 @@
 else:
     CALL_ALIGN = 1
 
-
 def align_stack_words(words):
     return (words + CALL_ALIGN - 1) & ~(CALL_ALIGN-1)
 
@@ -226,13 +225,14 @@
 
     def _patch_stackadjust(self, adr_lea, reserved_depth):
         # patch stack adjustment LEA
-        # possibly align, e.g. for Mac OS X        
         mc = codebuf.InMemoryCodeBuilder(adr_lea, adr_lea + 4)
         # Compute the correct offset for the instruction LEA ESP, [EBP-4*words].
         # Given that [EBP] is where we saved EBP, i.e. in the last word
         # of our fixed frame, then the 'words' value is:
         words = (FRAME_FIXED_SIZE - 1) + reserved_depth
-        mc.write(packimm32(-WORD * words))
+        # align, e.g. for Mac OS X        
+        aligned_words = align_stack_words(words+2)-2 # 2 = EIP+EBP
+        mc.write(packimm32(-WORD * aligned_words))
         mc.done()
 
     def _assemble_bootstrap_code(self, inputargs, arglocs):
@@ -404,14 +404,6 @@
                     return self.implement_guard(addr, getattr(self.mc, name))
         return genop_cmp_guard
 
-##    XXX redo me
-##    def align_stack_for_call(self, nargs):
-##        # xxx do something when we don't use push anymore for calls
-##        extra_on_stack = align_stack_words(nargs)
-##        for i in range(extra_on_stack-nargs):
-##            self.mc.PUSH(imm(0))   --- or just use a single SUB(esp, imm)
-##        return extra_on_stack
-
     def _emit_call(self, x, arglocs, start=0, tmp=eax):
         p = 0
         n = len(arglocs)



More information about the Pypy-commit mailing list