lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lightning] Re: Stack frame alignment bug on MacOS


From: Paolo Bonzini
Subject: [Lightning] Re: Stack frame alignment bug on MacOS
Date: Tue, 10 Jun 2008 17:12:23 -0700
User-agent: Thunderbird 2.0.0.14 (Macintosh/20080421)


PS/ My correction aligns on 16 bytes on all architecture. Note that x86_64 requires 16 bytes alignment anyway, so this "wastes" a little bit of space only on Linux i386 and nowhere else. In my case, I don't consider the 12 bytes anything I would loose sleep over, but that's your call.

Can you try this patch instead? (And maybe you have a testcase to include?...) If it works, feel free to write a ChangeLog and push it.

PPS/ I can push the changes to git if you wish but I won't until you say it's ok (don't even know if i have write privileges).

I think so.  You had CVS, so you can access git too.

Paolo
diff --git a/lightning/i386/core-32.h b/lightning/i386/core-32.h
index eba34b9..8e2cc5a 100644
--- a/lightning/i386/core-32.h
+++ b/lightning/i386/core-32.h
@@ -46,8 +46,11 @@ struct jit_local_state {
   int  alloca_slack;
 };
 
-#define jit_base_prolog() (PUSHLr(_EBX), PUSHLr(_ESI), PUSHLr(_EDI), 
PUSHLr(_EBP), MOVLrr(_ESP, _EBP))
-#define jit_prolog(n) (_jitl.framesize = 20, _jitl.alloca_offset = 0, 
jit_base_prolog())
+#define jit_base_prolog() (_jitl.framesize = 20, _jitl.alloca_offset = 0, \
+  PUSHLr(_EBX), PUSHLr(_ESI), PUSHLr(_EDI), PUSHLr(_EBP), MOVLrr(_ESP, _EBP))
+#define jit_base_ret(ofs)                                                \
+  (((ofs) < 0 ? LEAVE_() : POPLr(_EBP)),                                 \
+   POPLr(_EDI), POPLr(_ESI), POPLr(_EBX), RET_())
 
 /* Used internally.  SLACK is used by the Darwin ABI which keeps the stack
    aligned to 16-bytes.  */
@@ -78,11 +81,17 @@ struct jit_local_state {
 #define jit_allocai(n)                                         \
   jit_allocai_internal ((n), (_jitl.alloca_slack - (n)) & 15)
 
+#define jit_prolog(n)          (jit_base_prolog(), jit_subi (JIT_SP, JIT_SP, 
12))
+#define jit_ret()              jit_base_ret (-12)
+
 #else
 # define jit_prepare_i(ni)     (_jitl.argssize += (ni))
 
 #define jit_allocai(n)                                         \
   jit_allocai_internal ((n), 0)
+
+#define jit_prolog(n)          jit_base_prolog()
+#define jit_ret()              jit_base_ret (_jitl.alloca_offset)
 #endif
 
 #define jit_calli(label)       (CALLm( ((unsigned long) (label))), _jit.x.pc)
@@ -105,7 +114,6 @@ struct jit_local_state {
 #define jit_movi_p(d, is)       (jit_movi_l(d, ((long)(is))), _jit.x.pc)
 #define jit_patch_long_at(jump_pc,v)  (*_PSL((jump_pc) - sizeof(long)) = 
_jit_SL((jit_insn *)(v) - (jump_pc)))
 #define jit_patch_at(jump_pc,v)  jit_patch_long_at(jump_pc, v)
-#define jit_ret()              ((_jitl.alloca_offset < 0 ? LEAVE_() : 
POPLr(_EBP)), POPLr(_EDI), POPLr(_ESI), POPLr(_EBX), RET_())
 
 /* Memory */
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]