1995-12-20 02:41:22 -08:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
2011-07-27 07:17:02 -07:00
|
|
|
/* OCaml */
|
1995-12-20 02:41:22 -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-12-20 02:41:22 -08:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
1997-11-20 07:31:10 -08:00
|
|
|
/* Machine-dependent interface with the asm code */
|
1995-12-20 02:41:22 -08:00
|
|
|
|
2003-12-16 10:09:44 -08:00
|
|
|
#ifndef CAML_STACK_H
|
|
|
|
#define CAML_STACK_H
|
1995-12-20 02:41:22 -08:00
|
|
|
|
1997-11-20 07:31:10 -08:00
|
|
|
/* Macros to access the stack frame */
|
1995-12-20 02:41:22 -08:00
|
|
|
|
|
|
|
#ifdef TARGET_sparc
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) + 92))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 104))
|
1995-12-20 02:41:22 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_i386
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - 4))
|
2014-06-02 10:11:40 -07:00
|
|
|
#ifndef SYS_win32
|
2006-04-16 16:28:22 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 16))
|
|
|
|
#else
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 8))
|
1995-12-20 02:41:22 -08:00
|
|
|
#endif
|
2006-04-16 16:28:22 -07:00
|
|
|
#endif
|
1995-12-20 02:41:22 -08:00
|
|
|
|
1996-01-06 10:56:39 -08:00
|
|
|
#ifdef TARGET_power
|
2006-05-31 01:16:34 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - SIZEOF_PTR))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Already_scanned(sp, retaddr) ((retaddr) & 1)
|
2013-03-09 14:38:52 -08:00
|
|
|
#define Mark_scanned(sp, retaddr) \
|
|
|
|
(*((intnat *)((sp) - SIZEOF_PTR)) = (retaddr) | 1)
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Mask_already_scanned(retaddr) ((retaddr) & ~1)
|
1996-07-03 11:39:36 -07:00
|
|
|
#ifdef SYS_aix
|
2003-06-20 08:17:52 -07:00
|
|
|
#define Trap_frame_size 32
|
1996-07-03 11:39:36 -07:00
|
|
|
#else
|
2003-06-20 08:17:52 -07:00
|
|
|
#define Trap_frame_size 16
|
1996-07-03 11:39:36 -07:00
|
|
|
#endif
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + Trap_frame_size))
|
1996-01-06 10:56:39 -08:00
|
|
|
#endif
|
1995-12-20 02:41:22 -08:00
|
|
|
|
1998-10-15 09:10:53 -07:00
|
|
|
#ifdef TARGET_arm
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - 4))
|
2001-08-13 06:53:51 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 8))
|
1998-10-15 09:10:53 -07:00
|
|
|
#endif
|
|
|
|
|
2003-06-30 01:28:48 -07:00
|
|
|
#ifdef TARGET_amd64
|
2005-09-22 07:21:50 -07:00
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - 8))
|
2003-06-30 01:28:48 -07:00
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 16))
|
|
|
|
#endif
|
|
|
|
|
2013-07-18 09:09:20 -07:00
|
|
|
#ifdef TARGET_arm64
|
|
|
|
#define Saved_return_address(sp) *((intnat *)((sp) - 8))
|
|
|
|
#define Callback_link(sp) ((struct caml_context *)((sp) + 16))
|
|
|
|
#endif
|
|
|
|
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Structure of OCaml callback contexts */
|
1997-11-21 05:46:23 -08:00
|
|
|
|
|
|
|
struct caml_context {
|
2012-02-10 08:15:24 -08:00
|
|
|
char * bottom_of_stack; /* beginning of OCaml stack chunk */
|
|
|
|
uintnat last_retaddr; /* last return address in OCaml code */
|
1997-11-27 08:28:40 -08:00
|
|
|
value * gc_regs; /* pointer to register block */
|
1997-11-21 05:46:23 -08:00
|
|
|
};
|
|
|
|
|
2007-01-29 04:11:18 -08:00
|
|
|
/* Structure of frame descriptors */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uintnat retaddr;
|
|
|
|
unsigned short frame_size;
|
|
|
|
unsigned short num_live;
|
|
|
|
unsigned short live_ofs[1];
|
|
|
|
} frame_descr;
|
|
|
|
|
|
|
|
/* Hash table of frame descriptors */
|
|
|
|
|
|
|
|
extern frame_descr ** caml_frame_descriptors;
|
|
|
|
extern int caml_frame_descriptors_mask;
|
|
|
|
|
|
|
|
#define Hash_retaddr(addr) \
|
|
|
|
(((uintnat)(addr) >> 3) & caml_frame_descriptors_mask)
|
|
|
|
|
|
|
|
extern void caml_init_frame_descriptors(void);
|
2007-11-06 07:16:56 -08:00
|
|
|
extern void caml_register_frametable(intnat *);
|
|
|
|
extern void caml_register_dyn_global(void *);
|
2007-01-29 04:11:18 -08:00
|
|
|
|
2010-04-27 00:55:08 -07:00
|
|
|
extern uintnat caml_stack_usage (void);
|
|
|
|
extern uintnat (*caml_stack_usage_hook)(void);
|
|
|
|
|
1997-11-27 08:28:40 -08:00
|
|
|
/* Declaration of variables used in the asm code */
|
2010-04-27 00:55:08 -07:00
|
|
|
extern char * caml_top_of_stack;
|
1997-11-27 08:28:40 -08:00
|
|
|
extern char * caml_bottom_of_stack;
|
2005-09-22 07:21:50 -07:00
|
|
|
extern uintnat caml_last_return_address;
|
1997-11-27 08:28:40 -08:00
|
|
|
extern value * caml_gc_regs;
|
1997-11-21 05:46:23 -08:00
|
|
|
extern char * caml_exception_pointer;
|
|
|
|
extern value caml_globals[];
|
2005-09-22 07:21:50 -07:00
|
|
|
extern intnat caml_globals_inited;
|
|
|
|
extern intnat * caml_frametable[];
|
1997-11-21 05:46:23 -08:00
|
|
|
|
2003-12-16 10:09:44 -08:00
|
|
|
#endif /* CAML_STACK_H */
|