Skip to content

Commit

Permalink
Reflecting commit r14943 on version/4.02:
Browse files Browse the repository at this point in the history
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
xavierleroy committed Jun 2, 2014
1 parent 2c67f4f commit dbea9ee
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions asmcomp/i386/arch.ml
Expand Up @@ -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 *)
15 changes: 3 additions & 12 deletions asmrun/i386.S
Expand Up @@ -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 */

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion asmrun/stack.h
Expand Up @@ -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))
Expand Down

0 comments on commit dbea9ee

Please sign in to comment.