Browse files

Reflecting commit r14943 on version/4.02:

PR#6082: on x86-32, enforce 16-byte stack alignment for compatibility
with recent GCC and Clang.  Win32/MSVC keeps 4-byte stack alignment.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14944 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information...
1 parent 2c67f4f commit dbea9ee230d321b8eaf717d75adcc874a1e00554 @xavierleroy xavierleroy committed Jun 2, 2014
Showing with 11 additions and 15 deletions.
  1. +3 −0 Changes
  2. +4 −2 asmcomp/i386/arch.ml
  3. +3 −12 asmrun/i386.S
  4. +1 −1 asmrun/stack.h
View
3 Changes
@@ -162,6 +162,9 @@ Bug fixes:
(Damien Doligez)
- PR#5820: Fix camlp4 lexer roll back problem
(Hongbo Zhang)
+- PR#6038: on x86-32, enforce 16-byte stack alignment for compatibility
+ with recent GCC and Clang. Win32/MSVC keeps 4-byte stack alignment.
+ (Xavier Leroy)
- PR#6062: Fix a regression bug caused by commit 13047
(Hongbo Zhang, report by Christophe Troestler)
- PR#6109: Typos in ocamlbuild error messages
View
6 asmcomp/i386/arch.ml
@@ -155,5 +155,7 @@ let print_specific_operation printreg op ppf arg =
let stack_alignment =
match Config.system with
- | "macosx" -> 16
- | _ -> 4
+ | "win32" -> 4 (* MSVC *)
+ | _ -> 16
+(* PR#6038: GCC and Clang seem to require 16-byte alignment nowadays,
+ even if only MacOS X's ABI formally requires it *)
View
15 asmrun/i386.S
@@ -115,13 +115,10 @@
#define PROFILE_C
#endif
-#ifdef SYS_macosx
+/* PR#6038: GCC and Clang seem to require 16-byte alignment nowadays,
+ even if only MacOS X's ABI formally requires it. */
#define ALIGN_STACK(amount) subl $ amount, %esp ; CFI_ADJUST(amount)
#define UNDO_ALIGN_STACK(amount) addl $ amount, %esp ; CFI_ADJUST(-amount)
-#else
-#define ALIGN_STACK(amount)
-#define UNDO_ALIGN_STACK(amount)
-#endif
/* Allocation */
@@ -304,11 +301,7 @@ LBL(106):
LBL(107):
/* Pop the exception handler */
popl G(caml_exception_pointer); CFI_ADJUST(-4)
-#ifdef SYS_macosx
addl $12, %esp ; CFI_ADJUST(-12)
-#else
- addl $4, %esp ; CFI_ADJUST(-4)
-#endif
LBL(109):
/* Pop the callback link, restoring the global variables */
popl G(caml_bottom_of_stack); CFI_ADJUST(-4)
@@ -461,10 +454,8 @@ FUNCTION(caml_ml_array_bound_error)
movl %edx, G(caml_last_return_address)
leal 4(%esp), %edx
movl %edx, G(caml_bottom_of_stack)
- /* For MacOS X: re-align the stack */
-#ifdef SYS_macosx
+ /* Re-align the stack */
andl $-16, %esp
-#endif
/* Branch to [caml_array_bound_error] (never returns) */
call G(caml_array_bound_error)
CFI_ENDPROC
View
2 asmrun/stack.h
@@ -25,7 +25,7 @@
#ifdef TARGET_i386
#define Saved_return_address(sp) *((intnat *)((sp) - 4))
-#ifdef SYS_macosx
+#ifndef SYS_win32
#define Callback_link(sp) ((struct caml_context *)((sp) + 16))
#else
#define Callback_link(sp) ((struct caml_context *)((sp) + 8))

0 comments on commit dbea9ee

Please sign in to comment.