1995-10-31 01:27:04 -08:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1995-10-31 01:27:04 -08:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../LICENSE. */
|
1995-10-31 01:27:04 -08:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/* Asm part of the runtime system, Intel 386 processor */
|
|
|
|
/* Must be preprocessed by cpp */
|
|
|
|
|
1999-10-14 06:35:23 -07:00
|
|
|
/* Linux/BSD with ELF binaries and Solaris do not prefix identifiers with _.
|
|
|
|
Linux/BSD with a.out binaries and NextStep do. */
|
1995-10-31 01:27:04 -08:00
|
|
|
|
1998-12-07 04:55:25 -08:00
|
|
|
#if defined(SYS_solaris)
|
|
|
|
#define CONCAT(a,b) a/**/b
|
|
|
|
#else
|
|
|
|
#define CONCAT(a,b) a##b
|
|
|
|
#endif
|
|
|
|
|
1999-10-14 06:35:23 -07:00
|
|
|
#if defined(SYS_linux_elf) || defined(SYS_bsd_elf) \
|
2006-04-16 16:28:22 -07:00
|
|
|
|| defined(SYS_solaris) || defined(SYS_beos) || defined(SYS_gnu)
|
1995-10-31 01:27:04 -08:00
|
|
|
#define G(x) x
|
1998-12-07 04:55:25 -08:00
|
|
|
#define LBL(x) CONCAT(.L,x)
|
1995-10-31 01:27:04 -08:00
|
|
|
#else
|
1998-12-07 04:55:25 -08:00
|
|
|
#define G(x) CONCAT(_,x)
|
|
|
|
#define LBL(x) CONCAT(L,x)
|
2000-08-10 02:58:08 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SYS_linux_elf) || defined(SYS_bsd_elf) \
|
2002-06-07 02:49:45 -07:00
|
|
|
|| defined(SYS_solaris) || defined(SYS_beos) || defined(SYS_cygwin) \
|
2006-04-16 16:28:22 -07:00
|
|
|
|| defined(SYS_mingw) || defined(SYS_gnu)
|
2000-08-10 02:58:08 -07:00
|
|
|
#define FUNCTION_ALIGN 4
|
|
|
|
#else
|
1996-06-25 02:28:17 -07:00
|
|
|
#define FUNCTION_ALIGN 2
|
1995-10-31 01:27:04 -08:00
|
|
|
#endif
|
|
|
|
|
2000-02-29 08:15:59 -08:00
|
|
|
#if defined(PROFILING)
|
2006-04-16 16:28:22 -07:00
|
|
|
#if defined(SYS_linux_elf) || defined(SYS_gnu)
|
1998-08-06 06:27:38 -07:00
|
|
|
#define PROFILE_CAML \
|
1998-10-01 05:21:22 -07:00
|
|
|
pushl %ebp; movl %esp, %ebp; pushl %eax; pushl %ecx; pushl %edx; \
|
1998-08-06 06:27:38 -07:00
|
|
|
call mcount; \
|
1998-10-01 05:21:22 -07:00
|
|
|
popl %edx; popl %ecx; popl %eax; popl %ebp
|
1998-08-06 06:27:38 -07:00
|
|
|
#define PROFILE_C \
|
|
|
|
pushl %ebp; movl %esp, %ebp; call mcount; popl %ebp
|
2000-02-29 08:15:59 -08:00
|
|
|
#elif defined(SYS_bsd_elf)
|
|
|
|
#define PROFILE_CAML \
|
|
|
|
pushl %ebp; movl %esp, %ebp; pushl %eax; pushl %ecx; pushl %edx; \
|
|
|
|
call .mcount; \
|
|
|
|
popl %edx; popl %ecx; popl %eax; popl %ebp
|
|
|
|
#define PROFILE_C \
|
|
|
|
pushl %ebp; movl %esp, %ebp; call .mcount; popl %ebp
|
2006-10-16 01:40:42 -07:00
|
|
|
#elif defined(SYS_macosx)
|
|
|
|
#define PROFILE_CAML \
|
|
|
|
pushl %ebp; movl %esp, %ebp; pushl %eax; pushl %ecx; pushl %edx; \
|
|
|
|
call Lmcount$stub; \
|
|
|
|
popl %edx; popl %ecx; popl %eax; popl %ebp
|
|
|
|
#define PROFILE_C \
|
|
|
|
pushl %ebp; movl %esp, %ebp; call Lmcount$stub; popl %ebp
|
2000-02-29 08:15:59 -08:00
|
|
|
#endif
|
1998-08-06 06:27:38 -07:00
|
|
|
#else
|
|
|
|
#define PROFILE_CAML
|
|
|
|
#define PROFILE_C
|
|
|
|
#endif
|
|
|
|
|
2007-01-29 04:11:18 -08:00
|
|
|
#ifdef SYS_macosx
|
|
|
|
#define ALIGN_STACK(amount) subl $ amount, %esp
|
|
|
|
#define UNDO_ALIGN_STACK(amount) addl $ amount, %esp
|
|
|
|
#else
|
|
|
|
#define ALIGN_STACK(amount)
|
|
|
|
#define UNDO_ALIGN_STACK(amount)
|
|
|
|
#endif
|
|
|
|
|
1995-10-31 01:27:04 -08:00
|
|
|
/* Allocation */
|
|
|
|
|
|
|
|
.text
|
1997-05-19 08:42:21 -07:00
|
|
|
.globl G(caml_call_gc)
|
1995-10-31 01:27:04 -08:00
|
|
|
.globl G(caml_alloc1)
|
|
|
|
.globl G(caml_alloc2)
|
|
|
|
.globl G(caml_alloc3)
|
2004-01-01 08:42:43 -08:00
|
|
|
.globl G(caml_allocN)
|
1996-05-14 09:51:42 -07:00
|
|
|
|
2007-01-29 04:11:18 -08:00
|
|
|
.align FUNCTION_ALIGN
|
1996-05-14 09:51:42 -07:00
|
|
|
G(caml_call_gc):
|
1998-08-06 06:27:38 -07:00
|
|
|
PROFILE_CAML
|
1997-11-27 08:28:40 -08:00
|
|
|
/* Record lowest stack address and return address */
|
|
|
|
movl 0(%esp), %eax
|
|
|
|
movl %eax, G(caml_last_return_address)
|
|
|
|
leal 4(%esp), %eax
|
|
|
|
movl %eax, G(caml_bottom_of_stack)
|
|
|
|
/* Build array of registers, save it into caml_gc_regs */
|
1998-12-03 09:28:53 -08:00
|
|
|
LBL(105):
|
|
|
|
pushl %ebp
|
1997-11-21 05:46:23 -08:00
|
|
|
pushl %edi
|
|
|
|
pushl %esi
|
|
|
|
pushl %edx
|
|
|
|
pushl %ecx
|
|
|
|
pushl %ebx
|
|
|
|
pushl %eax
|
1997-11-27 08:28:40 -08:00
|
|
|
movl %esp, G(caml_gc_regs)
|
2006-09-20 04:14:37 -07:00
|
|
|
/* MacOSX note: 16-alignment of stack preserved at this point */
|
1996-05-14 09:51:42 -07:00
|
|
|
/* Call the garbage collector */
|
2004-01-01 08:42:43 -08:00
|
|
|
call G(caml_garbage_collection)
|
1996-05-14 09:51:42 -07:00
|
|
|
/* Restore all regs used by the code generator */
|
1997-11-21 05:46:23 -08:00
|
|
|
popl %eax
|
|
|
|
popl %ebx
|
|
|
|
popl %ecx
|
|
|
|
popl %edx
|
|
|
|
popl %esi
|
|
|
|
popl %edi
|
|
|
|
popl %ebp
|
1996-05-14 09:51:42 -07:00
|
|
|
/* Return to caller */
|
|
|
|
ret
|
1995-10-31 01:27:04 -08:00
|
|
|
|
1995-11-05 09:32:12 -08:00
|
|
|
.align FUNCTION_ALIGN
|
1995-10-31 01:27:04 -08:00
|
|
|
G(caml_alloc1):
|
1998-08-06 06:27:38 -07:00
|
|
|
PROFILE_CAML
|
2003-12-31 06:20:40 -08:00
|
|
|
movl G(caml_young_ptr), %eax
|
1995-10-31 01:27:04 -08:00
|
|
|
subl $8, %eax
|
2003-12-31 06:20:40 -08:00
|
|
|
movl %eax, G(caml_young_ptr)
|
|
|
|
cmpl G(caml_young_limit), %eax
|
1998-12-03 09:28:53 -08:00
|
|
|
jb LBL(100)
|
1995-10-31 01:27:04 -08:00
|
|
|
ret
|
1998-12-03 09:28:53 -08:00
|
|
|
LBL(100):
|
|
|
|
movl 0(%esp), %eax
|
1997-11-27 08:28:40 -08:00
|
|
|
movl %eax, G(caml_last_return_address)
|
|
|
|
leal 4(%esp), %eax
|
|
|
|
movl %eax, G(caml_bottom_of_stack)
|
2007-01-29 04:11:18 -08:00
|
|
|
ALIGN_STACK(12)
|
1998-12-03 09:28:53 -08:00
|
|
|
call LBL(105)
|
2007-01-29 04:11:18 -08:00
|
|
|
UNDO_ALIGN_STACK(12)
|
1996-05-16 07:19:17 -07:00
|
|
|
jmp G(caml_alloc1)
|
1995-10-31 01:27:04 -08:00
|
|
|
|
1995-11-05 09:32:12 -08:00
|
|
|
.align FUNCTION_ALIGN
|
1995-10-31 01:27:04 -08:00
|
|
|
G(caml_alloc2):
|
1998-08-06 06:27:38 -07:00
|
|
|
PROFILE_CAML
|
2003-12-31 06:20:40 -08:00
|
|
|
movl G(caml_young_ptr), %eax
|
1995-10-31 01:27:04 -08:00
|
|
|
subl $12, %eax
|
2003-12-31 06:20:40 -08:00
|
|
|
movl %eax, G(caml_young_ptr)
|
|
|
|
cmpl G(caml_young_limit), %eax
|
1998-12-03 09:28:53 -08:00
|
|
|
jb LBL(101)
|
1995-10-31 01:27:04 -08:00
|
|
|
ret
|
1998-12-03 09:28:53 -08:00
|
|
|
LBL(101):
|
|
|
|
movl 0(%esp), %eax
|
1997-11-27 08:28:40 -08:00
|
|
|
movl %eax, G(caml_last_return_address)
|
|
|
|
leal 4(%esp), %eax
|
|
|
|
movl %eax, G(caml_bottom_of_stack)
|
2007-01-29 04:11:18 -08:00
|
|
|
ALIGN_STACK(12)
|
1998-12-03 09:28:53 -08:00
|
|
|
call LBL(105)
|
2007-01-29 04:11:18 -08:00
|
|
|
UNDO_ALIGN_STACK(12)
|
1996-05-16 07:19:17 -07:00
|
|
|
jmp G(caml_alloc2)
|
1995-10-31 01:27:04 -08:00
|
|
|
|
1995-11-05 09:32:12 -08:00
|
|
|
.align FUNCTION_ALIGN
|
1995-10-31 01:27:04 -08:00
|
|
|
G(caml_alloc3):
|
1998-08-06 06:27:38 -07:00
|
|
|
PROFILE_CAML
|
2003-12-31 06:20:40 -08:00
|
|
|
movl G(caml_young_ptr), %eax
|
1995-10-31 01:27:04 -08:00
|
|
|
subl $16, %eax
|
2003-12-31 06:20:40 -08:00
|
|
|
movl %eax, G(caml_young_ptr)
|
|
|
|
cmpl G(caml_young_limit), %eax
|
1998-12-03 09:28:53 -08:00
|
|
|
jb LBL(102)
|
1995-10-31 01:27:04 -08:00
|
|
|
ret
|
1998-12-03 09:28:53 -08:00
|
|
|
LBL(102):
|
|
|
|
movl 0(%esp), %eax
|
1997-11-27 08:28:40 -08:00
|
|
|
movl %eax, G(caml_last_return_address)
|
|
|
|
leal 4(%esp), %eax
|
|
|
|
movl %eax, G(caml_bottom_of_stack)
|
2007-01-29 04:11:18 -08:00
|
|
|
ALIGN_STACK(12)
|
1998-12-03 09:28:53 -08:00
|
|
|
call LBL(105)
|
2007-01-29 04:11:18 -08:00
|
|
|
UNDO_ALIGN_STACK(12)
|
1996-05-16 07:19:17 -07:00
|
|
|
jmp G(caml_alloc3)
|
1995-10-31 01:27:04 -08:00
|
|
|
|
1995-11-05 09:32:12 -08:00
|
|
|
.align FUNCTION_ALIGN
|
2004-01-01 08:42:43 -08:00
|
|
|
G(caml_allocN):
|
1998-08-06 06:27:38 -07:00
|
|
|
PROFILE_CAML
|
2003-12-31 06:20:40 -08:00
|
|
|
subl G(caml_young_ptr), %eax /* eax = size - caml_young_ptr */
|
|
|
|
negl %eax /* eax = caml_young_ptr - size */
|
|
|
|
cmpl G(caml_young_limit), %eax
|
1998-12-03 09:28:53 -08:00
|
|
|
jb LBL(103)
|
2003-12-31 06:20:40 -08:00
|
|
|
movl %eax, G(caml_young_ptr)
|
1995-10-31 01:27:04 -08:00
|
|
|
ret
|
1998-12-03 09:28:53 -08:00
|
|
|
LBL(103):
|
2003-12-31 06:20:40 -08:00
|
|
|
subl G(caml_young_ptr), %eax /* eax = - size */
|
1996-05-14 09:51:42 -07:00
|
|
|
negl %eax /* eax = size */
|
1997-11-27 08:28:40 -08:00
|
|
|
pushl %eax /* save desired size */
|
2003-12-31 06:20:40 -08:00
|
|
|
subl %eax, G(caml_young_ptr) /* must update young_ptr */
|
1997-11-27 08:28:40 -08:00
|
|
|
movl 4(%esp), %eax
|
|
|
|
movl %eax, G(caml_last_return_address)
|
|
|
|
leal 8(%esp), %eax
|
|
|
|
movl %eax, G(caml_bottom_of_stack)
|
2007-01-29 04:11:18 -08:00
|
|
|
ALIGN_STACK(8)
|
1998-12-03 09:28:53 -08:00
|
|
|
call LBL(105)
|
2007-01-29 04:11:18 -08:00
|
|
|
UNDO_ALIGN_STACK(8)
|
1997-11-27 08:28:40 -08:00
|
|
|
popl %eax /* recover desired size */
|
2004-01-01 08:42:43 -08:00
|
|
|
jmp G(caml_allocN)
|
1995-10-31 01:27:04 -08:00
|
|
|
|
|
|
|
/* Call a C function from Caml */
|
|
|
|
|
|
|
|
.globl G(caml_c_call)
|
1995-11-05 09:32:12 -08:00
|
|
|
.align FUNCTION_ALIGN
|
1995-10-31 01:27:04 -08:00
|
|
|
G(caml_c_call):
|
1998-08-06 06:27:38 -07:00
|
|
|
PROFILE_CAML
|
1997-11-27 08:28:40 -08:00
|
|
|
/* Record lowest stack address and return address */
|
|
|
|
movl (%esp), %edx
|
|
|
|
movl %edx, G(caml_last_return_address)
|
|
|
|
leal 4(%esp), %edx
|
|
|
|
movl %edx, G(caml_bottom_of_stack)
|
1995-12-10 01:33:09 -08:00
|
|
|
/* Call the function (address in %eax) */
|
1995-11-25 07:37:33 -08:00
|
|
|
jmp *%eax
|
1995-10-31 01:27:04 -08:00
|
|
|
|
|
|
|
/* Start the Caml program */
|
|
|
|
|
|
|
|
.globl G(caml_start_program)
|
1995-11-05 09:32:12 -08:00
|
|
|
.align FUNCTION_ALIGN
|
1995-10-31 01:27:04 -08:00
|
|
|
G(caml_start_program):
|
1998-08-06 06:27:38 -07:00
|
|
|
PROFILE_C
|
1995-10-31 01:27:04 -08:00
|
|
|
/* Save callee-save registers */
|
|
|
|
pushl %ebx
|
|
|
|
pushl %esi
|
|
|
|
pushl %edi
|
|
|
|
pushl %ebp
|
1997-03-17 02:17:32 -08:00
|
|
|
/* Initial entry point is caml_program */
|
|
|
|
movl $ G(caml_program), %esi
|
2003-12-31 06:20:40 -08:00
|
|
|
/* Common code for caml_start_program and caml_callback* */
|
1998-12-03 09:28:53 -08:00
|
|
|
LBL(106):
|
1996-01-07 08:58:44 -08:00
|
|
|
/* Build a callback link */
|
1997-11-27 08:28:40 -08:00
|
|
|
pushl G(caml_gc_regs)
|
|
|
|
pushl G(caml_last_return_address)
|
|
|
|
pushl G(caml_bottom_of_stack)
|
2006-04-16 16:28:22 -07:00
|
|
|
/* Note: 16-alignment preserved on MacOSX at this point */
|
1995-12-20 05:27:16 -08:00
|
|
|
/* Build an exception handler */
|
1998-12-03 09:28:53 -08:00
|
|
|
pushl $ LBL(108)
|
2007-01-29 04:11:18 -08:00
|
|
|
ALIGN_STACK(8)
|
1995-12-20 05:27:16 -08:00
|
|
|
pushl G(caml_exception_pointer)
|
|
|
|
movl %esp, G(caml_exception_pointer)
|
|
|
|
/* Call the Caml code */
|
|
|
|
call *%esi
|
1998-12-03 09:28:53 -08:00
|
|
|
LBL(107):
|
1996-01-07 08:58:44 -08:00
|
|
|
/* Pop the exception handler */
|
|
|
|
popl G(caml_exception_pointer)
|
2006-04-16 16:28:22 -07:00
|
|
|
#ifdef SYS_macosx
|
|
|
|
addl $12, %esp
|
|
|
|
#else
|
|
|
|
addl $4, %esp
|
|
|
|
#endif
|
1999-02-14 08:48:25 -08:00
|
|
|
LBL(109):
|
1997-11-27 08:28:40 -08:00
|
|
|
/* Pop the callback link, restoring the global variables */
|
|
|
|
popl G(caml_bottom_of_stack)
|
|
|
|
popl G(caml_last_return_address)
|
|
|
|
popl G(caml_gc_regs)
|
1996-05-16 12:39:26 -07:00
|
|
|
/* Restore callee-save registers. */
|
1995-12-20 05:27:16 -08:00
|
|
|
popl %ebp
|
|
|
|
popl %edi
|
|
|
|
popl %esi
|
|
|
|
popl %ebx
|
|
|
|
/* Return to caller. */
|
|
|
|
ret
|
1998-12-03 09:28:53 -08:00
|
|
|
LBL(108):
|
1996-01-07 08:58:44 -08:00
|
|
|
/* Exception handler*/
|
1999-02-14 08:48:25 -08:00
|
|
|
/* Mark the bucket as an exception result and return it */
|
|
|
|
orl $2, %eax
|
|
|
|
jmp LBL(109)
|
1995-12-20 05:27:16 -08:00
|
|
|
|
2007-01-29 04:11:18 -08:00
|
|
|
/* Raise an exception from Caml */
|
|
|
|
|
|
|
|
.globl G(caml_raise_exn)
|
|
|
|
.align FUNCTION_ALIGN
|
|
|
|
G(caml_raise_exn):
|
|
|
|
testl $1, G(caml_backtrace_active)
|
|
|
|
jne LBL(110)
|
|
|
|
movl G(caml_exception_pointer), %esp
|
|
|
|
popl G(caml_exception_pointer)
|
|
|
|
UNDO_ALIGN_STACK(8)
|
|
|
|
ret
|
|
|
|
LBL(110):
|
|
|
|
movl %eax, %esi /* Save exception bucket in esi */
|
|
|
|
movl G(caml_exception_pointer), %edi /* SP of handler */
|
|
|
|
movl 0(%esp), %eax /* PC of raise */
|
|
|
|
leal 4(%esp), %edx /* SP of raise */
|
|
|
|
ALIGN_STACK(12)
|
|
|
|
pushl %edi /* arg 4: sp of handler */
|
|
|
|
pushl %edx /* arg 3: sp of raise */
|
|
|
|
pushl %eax /* arg 2: pc of raise */
|
|
|
|
pushl %esi /* arg 1: exception bucket */
|
|
|
|
call G(caml_stash_backtrace)
|
|
|
|
movl %esi, %eax /* Recover exception bucket */
|
|
|
|
movl %edi, %esp
|
|
|
|
popl G(caml_exception_pointer)
|
|
|
|
UNDO_ALIGN_STACK(8)
|
|
|
|
ret
|
|
|
|
|
1997-03-17 02:17:32 -08:00
|
|
|
/* Raise an exception from C */
|
|
|
|
|
2004-01-01 08:42:43 -08:00
|
|
|
.globl G(caml_raise_exception)
|
1997-03-17 02:17:32 -08:00
|
|
|
.align FUNCTION_ALIGN
|
2004-01-01 08:42:43 -08:00
|
|
|
G(caml_raise_exception):
|
1998-08-06 06:27:38 -07:00
|
|
|
PROFILE_C
|
2007-01-29 04:11:18 -08:00
|
|
|
testl $1, G(caml_backtrace_active)
|
|
|
|
jne LBL(111)
|
1997-03-17 02:17:32 -08:00
|
|
|
movl 4(%esp), %eax
|
|
|
|
movl G(caml_exception_pointer), %esp
|
|
|
|
popl G(caml_exception_pointer)
|
2007-01-29 04:11:18 -08:00
|
|
|
UNDO_ALIGN_STACK(8)
|
|
|
|
ret
|
|
|
|
LBL(111):
|
|
|
|
movl 4(%esp), %esi /* Save exception bucket in esi */
|
|
|
|
ALIGN_STACK(12)
|
|
|
|
pushl G(caml_exception_pointer) /* arg 4: sp of handler */
|
|
|
|
pushl G(caml_bottom_of_stack) /* arg 3: sp of raise */
|
|
|
|
pushl G(caml_last_return_address) /* arg 2: pc of raise */
|
|
|
|
pushl %esi /* arg 1: exception bucket */
|
|
|
|
call G(caml_stash_backtrace)
|
|
|
|
movl %esi, %eax /* Recover exception bucket */
|
|
|
|
movl G(caml_exception_pointer), %esp
|
|
|
|
popl G(caml_exception_pointer)
|
|
|
|
UNDO_ALIGN_STACK(8)
|
1997-03-17 02:17:32 -08:00
|
|
|
ret
|
|
|
|
|
|
|
|
/* Callback from C to Caml */
|
|
|
|
|
2003-12-31 06:20:40 -08:00
|
|
|
.globl G(caml_callback_exn)
|
1997-03-17 02:17:32 -08:00
|
|
|
.align FUNCTION_ALIGN
|
2003-12-31 06:20:40 -08:00
|
|
|
G(caml_callback_exn):
|
1998-08-06 06:27:38 -07:00
|
|
|
PROFILE_C
|
1997-03-17 02:17:32 -08:00
|
|
|
/* Save callee-save registers */
|
|
|
|
pushl %ebx
|
|
|
|
pushl %esi
|
|
|
|
pushl %edi
|
|
|
|
pushl %ebp
|
|
|
|
/* Initial loading of arguments */
|
|
|
|
movl 20(%esp), %ebx /* closure */
|
|
|
|
movl 24(%esp), %eax /* argument */
|
|
|
|
movl 0(%ebx), %esi /* code pointer */
|
1998-12-03 09:28:53 -08:00
|
|
|
jmp LBL(106)
|
1997-03-17 02:17:32 -08:00
|
|
|
|
2003-12-31 06:20:40 -08:00
|
|
|
.globl G(caml_callback2_exn)
|
1995-12-20 05:27:16 -08:00
|
|
|
.align FUNCTION_ALIGN
|
2003-12-31 06:20:40 -08:00
|
|
|
G(caml_callback2_exn):
|
1998-08-06 06:27:38 -07:00
|
|
|
PROFILE_C
|
1995-12-20 05:27:16 -08:00
|
|
|
/* Save callee-save registers */
|
|
|
|
pushl %ebx
|
|
|
|
pushl %esi
|
|
|
|
pushl %edi
|
|
|
|
pushl %ebp
|
|
|
|
/* Initial loading of arguments */
|
|
|
|
movl 20(%esp), %ecx /* closure */
|
|
|
|
movl 24(%esp), %eax /* first argument */
|
|
|
|
movl 28(%esp), %ebx /* second argument */
|
|
|
|
movl $ G(caml_apply2), %esi /* code pointer */
|
1998-12-03 09:28:53 -08:00
|
|
|
jmp LBL(106)
|
1995-12-20 05:27:16 -08:00
|
|
|
|
2003-12-31 06:20:40 -08:00
|
|
|
.globl G(caml_callback3_exn)
|
1995-12-20 05:27:16 -08:00
|
|
|
.align FUNCTION_ALIGN
|
2003-12-31 06:20:40 -08:00
|
|
|
G(caml_callback3_exn):
|
1998-08-06 06:27:38 -07:00
|
|
|
PROFILE_C
|
1995-12-20 05:27:16 -08:00
|
|
|
/* Save callee-save registers */
|
|
|
|
pushl %ebx
|
|
|
|
pushl %esi
|
|
|
|
pushl %edi
|
|
|
|
pushl %ebp
|
|
|
|
/* Initial loading of arguments */
|
|
|
|
movl 20(%esp), %edx /* closure */
|
|
|
|
movl 24(%esp), %eax /* first argument */
|
|
|
|
movl 28(%esp), %ebx /* second argument */
|
|
|
|
movl 32(%esp), %ecx /* third argument */
|
|
|
|
movl $ G(caml_apply3), %esi /* code pointer */
|
1998-12-03 09:28:53 -08:00
|
|
|
jmp LBL(106)
|
|
|
|
|
2004-01-01 08:42:43 -08:00
|
|
|
.globl G(caml_ml_array_bound_error)
|
1998-12-03 09:28:53 -08:00
|
|
|
.align FUNCTION_ALIGN
|
2004-01-01 08:42:43 -08:00
|
|
|
G(caml_ml_array_bound_error):
|
1998-12-03 09:28:53 -08:00
|
|
|
/* Empty the floating-point stack */
|
|
|
|
ffree %st(0)
|
|
|
|
ffree %st(1)
|
|
|
|
ffree %st(2)
|
|
|
|
ffree %st(3)
|
|
|
|
ffree %st(4)
|
|
|
|
ffree %st(5)
|
|
|
|
ffree %st(6)
|
|
|
|
ffree %st(7)
|
2008-01-11 08:13:18 -08:00
|
|
|
/* Record lowest stack address and return address */
|
|
|
|
movl (%esp), %edx
|
|
|
|
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
|
|
|
|
andl $-16, %esp
|
|
|
|
#endif
|
|
|
|
/* Branch to [caml_array_bound_error] (never returns) */
|
|
|
|
call G(caml_array_bound_error)
|
1995-12-20 05:27:16 -08:00
|
|
|
|
|
|
|
.data
|
2004-01-03 04:51:20 -08:00
|
|
|
.globl G(caml_system__frametable)
|
|
|
|
G(caml_system__frametable):
|
1995-12-20 05:27:16 -08:00
|
|
|
.long 1 /* one descriptor */
|
1998-12-03 09:28:53 -08:00
|
|
|
.long LBL(107) /* return address into callback */
|
1996-09-18 05:43:46 -07:00
|
|
|
#ifndef SYS_solaris
|
1995-12-20 05:27:16 -08:00
|
|
|
.word -1 /* negative frame size => use callback link */
|
|
|
|
.word 0 /* no roots here */
|
1996-09-18 05:43:46 -07:00
|
|
|
#else
|
|
|
|
.value -1 /* negative frame size => use callback link */
|
|
|
|
.value 0 /* no roots here */
|
|
|
|
#endif
|
2004-08-12 06:37:12 -07:00
|
|
|
|
|
|
|
.globl G(caml_extra_params)
|
|
|
|
G(caml_extra_params):
|
|
|
|
#ifndef SYS_solaris
|
|
|
|
.space 64
|
|
|
|
#else
|
|
|
|
.zero 64
|
|
|
|
#endif
|
2006-10-16 01:40:42 -07:00
|
|
|
|
|
|
|
#if defined(PROFILING) && defined(SYS_macosx)
|
|
|
|
.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5
|
|
|
|
Lmcount$stub:
|
|
|
|
.indirect_symbol mcount
|
|
|
|
hlt ; hlt ; hlt ; hlt ; hlt
|
|
|
|
.subsections_via_symbols
|
|
|
|
#endif
|
2008-08-01 01:04:57 -07:00
|
|
|
|
|
|
|
#if defined(SYS_linux_elf)
|
|
|
|
/* Mark stack as non-executable, PR#4564 */
|
|
|
|
.section .note.GNU-stack,"",%progbits
|
|
|
|
#endif
|