2011-07-27 07:17:02 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* OCaml */
|
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../LICENSE. */
|
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
1998-03-13 05:57:35 -08:00
|
|
|
|
2006-05-31 01:16:34 -07:00
|
|
|
#ifdef __ppc64__
|
|
|
|
#define X(a,b) b
|
|
|
|
#else
|
|
|
|
#define X(a,b) a
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define WORD X(4,8)
|
|
|
|
#define lg X(lwz,ld)
|
|
|
|
#define lgu X(lwzu,ldu)
|
|
|
|
#define stg X(stw,std)
|
|
|
|
#define stgu X(stwu,stdu)
|
|
|
|
#define gdata X(.long,.quad)
|
|
|
|
|
1999-11-29 11:16:30 -08:00
|
|
|
.macro Addrglobal /* reg, glob */
|
1998-03-13 11:31:32 -08:00
|
|
|
addis $0, 0, ha16($1)
|
|
|
|
addi $0, $0, lo16($1)
|
|
|
|
.endmacro
|
1999-11-29 11:16:30 -08:00
|
|
|
.macro Loadglobal /* reg,glob,tmp */
|
1998-03-13 11:31:32 -08:00
|
|
|
addis $2, 0, ha16($1)
|
2006-05-31 01:16:34 -07:00
|
|
|
lg $0, lo16($1)($2)
|
1998-03-13 11:31:32 -08:00
|
|
|
.endmacro
|
1999-11-29 11:16:30 -08:00
|
|
|
.macro Storeglobal /* reg,glob,tmp */
|
1998-03-13 11:31:32 -08:00
|
|
|
addis $2, 0, ha16($1)
|
2006-05-31 01:16:34 -07:00
|
|
|
stg $0, lo16($1)($2)
|
1998-03-13 11:31:32 -08:00
|
|
|
.endmacro
|
1998-03-13 05:57:35 -08:00
|
|
|
|
|
|
|
.text
|
|
|
|
|
2012-02-17 02:12:09 -08:00
|
|
|
.globl _caml_system__code_begin
|
|
|
|
_caml_system__code_begin:
|
2012-07-30 11:04:46 -07:00
|
|
|
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Invoke the garbage collector. */
|
|
|
|
|
|
|
|
.globl _caml_call_gc
|
|
|
|
_caml_call_gc:
|
|
|
|
/* Set up stack frame */
|
2006-05-31 01:16:34 -07:00
|
|
|
#define FRAMESIZE (32*WORD + 32*8 + 32)
|
|
|
|
stwu r1, -FRAMESIZE(r1)
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Record return address into OCaml code */
|
1998-03-13 11:31:32 -08:00
|
|
|
mflr r0
|
|
|
|
Storeglobal r0, _caml_last_return_address, r11
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Record lowest stack address */
|
2006-05-31 01:16:34 -07:00
|
|
|
addi r0, r1, FRAMESIZE
|
1998-03-13 11:31:32 -08:00
|
|
|
Storeglobal r0, _caml_bottom_of_stack, r11
|
2012-02-17 02:12:09 -08:00
|
|
|
/* Touch the stack to trigger a recoverable segfault
|
|
|
|
if insufficient space remains */
|
|
|
|
addi r1, r1, -4096*WORD
|
|
|
|
stg r0, 0(r1)
|
|
|
|
addi r1, r1, 4096*WORD
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Record pointer to register array */
|
1998-03-13 11:31:32 -08:00
|
|
|
addi r0, r1, 8*32 + 32
|
|
|
|
Storeglobal r0, _caml_gc_regs, r11
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Save current allocation pointer for debugging purposes */
|
2003-12-31 06:20:40 -08:00
|
|
|
Storeglobal r31, _caml_young_ptr, r11
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Save exception pointer (if e.g. a sighandler raises) */
|
1998-03-13 11:31:32 -08:00
|
|
|
Storeglobal r29, _caml_exception_pointer, r11
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Save all registers used by the code generator */
|
2006-05-31 01:16:34 -07:00
|
|
|
addi r11, r1, 8*32 + 32 - WORD
|
|
|
|
stgu r3, WORD(r11)
|
|
|
|
stgu r4, WORD(r11)
|
|
|
|
stgu r5, WORD(r11)
|
|
|
|
stgu r6, WORD(r11)
|
|
|
|
stgu r7, WORD(r11)
|
|
|
|
stgu r8, WORD(r11)
|
|
|
|
stgu r9, WORD(r11)
|
|
|
|
stgu r10, WORD(r11)
|
|
|
|
stgu r14, WORD(r11)
|
|
|
|
stgu r15, WORD(r11)
|
|
|
|
stgu r16, WORD(r11)
|
|
|
|
stgu r17, WORD(r11)
|
|
|
|
stgu r18, WORD(r11)
|
|
|
|
stgu r19, WORD(r11)
|
|
|
|
stgu r20, WORD(r11)
|
|
|
|
stgu r21, WORD(r11)
|
|
|
|
stgu r22, WORD(r11)
|
|
|
|
stgu r23, WORD(r11)
|
|
|
|
stgu r24, WORD(r11)
|
|
|
|
stgu r25, WORD(r11)
|
|
|
|
stgu r26, WORD(r11)
|
|
|
|
stgu r27, WORD(r11)
|
|
|
|
stgu r28, WORD(r11)
|
1998-03-13 11:31:32 -08:00
|
|
|
addi r11, r1, 32 - 8
|
|
|
|
stfdu f1, 8(r11)
|
|
|
|
stfdu f2, 8(r11)
|
|
|
|
stfdu f3, 8(r11)
|
|
|
|
stfdu f4, 8(r11)
|
|
|
|
stfdu f5, 8(r11)
|
|
|
|
stfdu f6, 8(r11)
|
|
|
|
stfdu f7, 8(r11)
|
|
|
|
stfdu f8, 8(r11)
|
|
|
|
stfdu f9, 8(r11)
|
|
|
|
stfdu f10, 8(r11)
|
|
|
|
stfdu f11, 8(r11)
|
|
|
|
stfdu f12, 8(r11)
|
|
|
|
stfdu f13, 8(r11)
|
|
|
|
stfdu f14, 8(r11)
|
|
|
|
stfdu f15, 8(r11)
|
|
|
|
stfdu f16, 8(r11)
|
|
|
|
stfdu f17, 8(r11)
|
|
|
|
stfdu f18, 8(r11)
|
|
|
|
stfdu f19, 8(r11)
|
|
|
|
stfdu f20, 8(r11)
|
|
|
|
stfdu f21, 8(r11)
|
|
|
|
stfdu f22, 8(r11)
|
|
|
|
stfdu f23, 8(r11)
|
|
|
|
stfdu f24, 8(r11)
|
|
|
|
stfdu f25, 8(r11)
|
|
|
|
stfdu f26, 8(r11)
|
|
|
|
stfdu f27, 8(r11)
|
|
|
|
stfdu f28, 8(r11)
|
|
|
|
stfdu f29, 8(r11)
|
|
|
|
stfdu f30, 8(r11)
|
|
|
|
stfdu f31, 8(r11)
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Call the GC */
|
2004-01-01 08:42:43 -08:00
|
|
|
bl _caml_garbage_collection
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Reload new allocation pointer and allocation limit */
|
2003-12-31 06:20:40 -08:00
|
|
|
Loadglobal r31, _caml_young_ptr, r11
|
|
|
|
Loadglobal r30, _caml_young_limit, r11
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Restore all regs used by the code generator */
|
2006-05-31 01:16:34 -07:00
|
|
|
addi r11, r1, 8*32 + 32 - WORD
|
|
|
|
lgu r3, WORD(r11)
|
|
|
|
lgu r4, WORD(r11)
|
|
|
|
lgu r5, WORD(r11)
|
|
|
|
lgu r6, WORD(r11)
|
|
|
|
lgu r7, WORD(r11)
|
|
|
|
lgu r8, WORD(r11)
|
|
|
|
lgu r9, WORD(r11)
|
|
|
|
lgu r10, WORD(r11)
|
|
|
|
lgu r14, WORD(r11)
|
|
|
|
lgu r15, WORD(r11)
|
|
|
|
lgu r16, WORD(r11)
|
|
|
|
lgu r17, WORD(r11)
|
|
|
|
lgu r18, WORD(r11)
|
|
|
|
lgu r19, WORD(r11)
|
|
|
|
lgu r20, WORD(r11)
|
|
|
|
lgu r21, WORD(r11)
|
|
|
|
lgu r22, WORD(r11)
|
|
|
|
lgu r23, WORD(r11)
|
|
|
|
lgu r24, WORD(r11)
|
|
|
|
lgu r25, WORD(r11)
|
|
|
|
lgu r26, WORD(r11)
|
|
|
|
lgu r27, WORD(r11)
|
|
|
|
lgu r28, WORD(r11)
|
1998-03-13 11:31:32 -08:00
|
|
|
addi r11, r1, 32 - 8
|
|
|
|
lfdu f1, 8(r11)
|
|
|
|
lfdu f2, 8(r11)
|
|
|
|
lfdu f3, 8(r11)
|
|
|
|
lfdu f4, 8(r11)
|
|
|
|
lfdu f5, 8(r11)
|
|
|
|
lfdu f6, 8(r11)
|
|
|
|
lfdu f7, 8(r11)
|
|
|
|
lfdu f8, 8(r11)
|
|
|
|
lfdu f9, 8(r11)
|
|
|
|
lfdu f10, 8(r11)
|
|
|
|
lfdu f11, 8(r11)
|
|
|
|
lfdu f12, 8(r11)
|
|
|
|
lfdu f13, 8(r11)
|
|
|
|
lfdu f14, 8(r11)
|
|
|
|
lfdu f15, 8(r11)
|
|
|
|
lfdu f16, 8(r11)
|
|
|
|
lfdu f17, 8(r11)
|
|
|
|
lfdu f18, 8(r11)
|
|
|
|
lfdu f19, 8(r11)
|
|
|
|
lfdu f20, 8(r11)
|
|
|
|
lfdu f21, 8(r11)
|
|
|
|
lfdu f22, 8(r11)
|
|
|
|
lfdu f23, 8(r11)
|
|
|
|
lfdu f24, 8(r11)
|
|
|
|
lfdu f25, 8(r11)
|
|
|
|
lfdu f26, 8(r11)
|
|
|
|
lfdu f27, 8(r11)
|
|
|
|
lfdu f28, 8(r11)
|
|
|
|
lfdu f29, 8(r11)
|
|
|
|
lfdu f30, 8(r11)
|
|
|
|
lfdu f31, 8(r11)
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Return to caller, restarting the allocation */
|
1998-03-13 11:31:32 -08:00
|
|
|
Loadglobal r0, _caml_last_return_address, r11
|
|
|
|
addic r0, r0, -16 /* Restart the allocation (4 instructions) */
|
|
|
|
mtlr r0
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Say we are back into OCaml code */
|
1998-03-13 11:31:32 -08:00
|
|
|
li r12, 0
|
|
|
|
Storeglobal r12, _caml_last_return_address, r11
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Deallocate stack frame */
|
2006-05-31 01:16:34 -07:00
|
|
|
addi r1, r1, FRAMESIZE
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Return */
|
|
|
|
blr
|
2006-05-31 01:16:34 -07:00
|
|
|
#undef FRAMESIZE
|
1998-03-13 05:57:35 -08:00
|
|
|
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Call a C function from OCaml */
|
1998-03-13 05:57:35 -08:00
|
|
|
|
|
|
|
.globl _caml_c_call
|
|
|
|
_caml_c_call:
|
|
|
|
/* Save return address */
|
1998-03-13 11:31:32 -08:00
|
|
|
mflr r25
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Get ready to call C function (address in 11) */
|
2004-02-22 06:56:25 -08:00
|
|
|
mtctr r11
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Record lowest stack address and return address */
|
1998-03-13 11:31:32 -08:00
|
|
|
Storeglobal r1, _caml_bottom_of_stack, r12
|
|
|
|
Storeglobal r25, _caml_last_return_address, r12
|
2012-02-17 02:12:09 -08:00
|
|
|
/* Touch the stack to trigger a recoverable segfault
|
|
|
|
if insufficient space remains */
|
|
|
|
addi r1, r1, -4096*WORD
|
|
|
|
stg r0, 0(r1)
|
|
|
|
addi r1, r1, 4096*WORD
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Make the exception handler and alloc ptr available to the C code */
|
2003-12-31 06:20:40 -08:00
|
|
|
Storeglobal r31, _caml_young_ptr, r11
|
1998-03-13 11:31:32 -08:00
|
|
|
Storeglobal r29, _caml_exception_pointer, r11
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Call the function (address in link register) */
|
2004-02-22 06:56:25 -08:00
|
|
|
bctrl
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Restore return address (in 25, preserved by the C function) */
|
1998-03-13 11:31:32 -08:00
|
|
|
mtlr r25
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Reload allocation pointer and allocation limit*/
|
2003-12-31 06:20:40 -08:00
|
|
|
Loadglobal r31, _caml_young_ptr, r11
|
|
|
|
Loadglobal r30, _caml_young_limit, r11
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Say we are back into OCaml code */
|
1998-03-13 11:31:32 -08:00
|
|
|
li r12, 0
|
|
|
|
Storeglobal r12, _caml_last_return_address, r11
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Return to caller */
|
|
|
|
blr
|
1999-11-29 11:16:30 -08:00
|
|
|
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Raise an exception from OCaml */
|
2007-01-29 04:11:18 -08:00
|
|
|
.globl _caml_raise_exn
|
|
|
|
_caml_raise_exn:
|
|
|
|
addis r11, 0, ha16(_caml_backtrace_active)
|
|
|
|
lwz r11, lo16(_caml_backtrace_active)(r11)
|
|
|
|
cmpwi r11, 0
|
|
|
|
bne L110
|
|
|
|
L111:
|
|
|
|
/* Pop trap frame */
|
|
|
|
lg r0, 0(r29)
|
|
|
|
mr r1, r29
|
|
|
|
mtlr r0
|
|
|
|
lg r29, WORD(r1)
|
|
|
|
addi r1, r1, 16
|
|
|
|
/* Branch to handler */
|
|
|
|
blr
|
|
|
|
|
|
|
|
L110:
|
|
|
|
mr r28, r3 /* preserve exn bucket in callee-save */
|
|
|
|
/* arg 1: exception bucket (already in r3) */
|
|
|
|
mflr r4 /* arg 2: PC of raise */
|
|
|
|
mr r5, r1 /* arg 3: SP of raise */
|
|
|
|
mr r6, r29 /* arg 4: SP of handler */
|
|
|
|
addi r1, r1, -(16*WORD) /* reserve stack space for C call */
|
|
|
|
bl _caml_stash_backtrace
|
|
|
|
mr r3, r28
|
|
|
|
b L111
|
|
|
|
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Raise an exception from C */
|
|
|
|
|
2004-01-01 08:42:43 -08:00
|
|
|
.globl _caml_raise_exception
|
|
|
|
_caml_raise_exception:
|
2007-01-29 04:11:18 -08:00
|
|
|
addis r11, 0, ha16(_caml_backtrace_active)
|
|
|
|
lwz r11, lo16(_caml_backtrace_active)(r11)
|
|
|
|
cmpwi r11, 0
|
|
|
|
bne L112
|
|
|
|
L113:
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Reload OCaml global registers */
|
1998-03-13 11:31:32 -08:00
|
|
|
Loadglobal r1, _caml_exception_pointer, r11
|
2003-12-31 06:20:40 -08:00
|
|
|
Loadglobal r31, _caml_young_ptr, r11
|
|
|
|
Loadglobal r30, _caml_young_limit, r11
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Say we are back into OCaml code */
|
1998-03-13 11:31:32 -08:00
|
|
|
li r0, 0
|
|
|
|
Storeglobal r0, _caml_last_return_address, r11
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Pop trap frame */
|
2006-05-31 01:16:34 -07:00
|
|
|
lg r0, 0(r1)
|
|
|
|
lg r29, WORD(r1)
|
1998-03-13 11:31:32 -08:00
|
|
|
mtlr r0
|
2003-06-20 08:17:52 -07:00
|
|
|
addi r1, r1, 16
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Branch to handler */
|
|
|
|
blr
|
2007-01-29 04:11:18 -08:00
|
|
|
L112:
|
|
|
|
mr r28, r3 /* preserve exn bucket in callee-save */
|
|
|
|
/* arg 1: exception bucket (already in r3) */
|
2012-07-30 11:04:46 -07:00
|
|
|
Loadglobal r4, _caml_last_return_address, r11 /* arg 2: PC of raise */
|
|
|
|
Loadglobal r5, _caml_bottom_of_stack, r11 /* arg 3: SP of raise */
|
2007-01-29 04:11:18 -08:00
|
|
|
Loadglobal r6, _caml_exception_pointer, r11 /* arg 4: SP of handler */
|
|
|
|
addi r1, r1, -(16*WORD) /* reserve stack space for C call */
|
|
|
|
bl _caml_stash_backtrace
|
|
|
|
mr r3, r28
|
|
|
|
b L113
|
1998-03-13 05:57:35 -08:00
|
|
|
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Start the OCaml program */
|
1998-03-13 05:57:35 -08:00
|
|
|
|
|
|
|
.globl _caml_start_program
|
|
|
|
_caml_start_program:
|
1998-03-13 11:31:32 -08:00
|
|
|
Addrglobal r12, _caml_program
|
1998-03-13 05:57:35 -08:00
|
|
|
|
2003-12-31 06:20:40 -08:00
|
|
|
/* Code shared between caml_start_program and caml_callback */
|
1998-03-13 05:57:35 -08:00
|
|
|
L102:
|
|
|
|
/* Allocate and link stack frame */
|
2006-05-31 01:16:34 -07:00
|
|
|
#define FRAMESIZE (16 + 20*WORD + 18*8)
|
|
|
|
stgu r1, -FRAMESIZE(r1)
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Save return address */
|
1998-03-13 11:31:32 -08:00
|
|
|
mflr r0
|
2006-05-31 01:16:34 -07:00
|
|
|
stg r0, WORD(r1)
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Save all callee-save registers */
|
2006-05-31 01:16:34 -07:00
|
|
|
/* GPR14 ... GPR31, then FPR14 ... FPR31 starting at sp+16 */
|
|
|
|
addi r11, r1, 16-WORD
|
|
|
|
stgu r14, WORD(r11)
|
|
|
|
stgu r15, WORD(r11)
|
|
|
|
stgu r16, WORD(r11)
|
|
|
|
stgu r17, WORD(r11)
|
|
|
|
stgu r18, WORD(r11)
|
|
|
|
stgu r19, WORD(r11)
|
|
|
|
stgu r20, WORD(r11)
|
|
|
|
stgu r21, WORD(r11)
|
|
|
|
stgu r22, WORD(r11)
|
|
|
|
stgu r23, WORD(r11)
|
|
|
|
stgu r24, WORD(r11)
|
|
|
|
stgu r25, WORD(r11)
|
|
|
|
stgu r26, WORD(r11)
|
|
|
|
stgu r27, WORD(r11)
|
|
|
|
stgu r28, WORD(r11)
|
|
|
|
stgu r29, WORD(r11)
|
|
|
|
stgu r30, WORD(r11)
|
|
|
|
stgu r31, WORD(r11)
|
1998-03-13 11:31:32 -08:00
|
|
|
stfdu f14, 8(r11)
|
|
|
|
stfdu f15, 8(r11)
|
|
|
|
stfdu f16, 8(r11)
|
|
|
|
stfdu f17, 8(r11)
|
|
|
|
stfdu f18, 8(r11)
|
|
|
|
stfdu f19, 8(r11)
|
|
|
|
stfdu f20, 8(r11)
|
|
|
|
stfdu f21, 8(r11)
|
|
|
|
stfdu f22, 8(r11)
|
|
|
|
stfdu f23, 8(r11)
|
|
|
|
stfdu f24, 8(r11)
|
|
|
|
stfdu f25, 8(r11)
|
|
|
|
stfdu f26, 8(r11)
|
|
|
|
stfdu f27, 8(r11)
|
|
|
|
stfdu f28, 8(r11)
|
|
|
|
stfdu f29, 8(r11)
|
|
|
|
stfdu f30, 8(r11)
|
|
|
|
stfdu f31, 8(r11)
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Set up a callback link */
|
2006-05-31 01:16:34 -07:00
|
|
|
addi r1, r1, -32
|
1998-03-13 11:31:32 -08:00
|
|
|
Loadglobal r9, _caml_bottom_of_stack, r11
|
|
|
|
Loadglobal r10, _caml_last_return_address, r11
|
|
|
|
Loadglobal r11, _caml_gc_regs, r11
|
2006-05-31 01:16:34 -07:00
|
|
|
stg r9, 0(r1)
|
|
|
|
stg r10, WORD(r1)
|
|
|
|
stg r11, 2*WORD(r1)
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Build an exception handler to catch exceptions escaping out of OCaml */
|
1998-03-13 05:57:35 -08:00
|
|
|
bl L103
|
|
|
|
b L104
|
|
|
|
L103:
|
2003-06-20 08:17:52 -07:00
|
|
|
addi r1, r1, -16
|
1998-03-13 11:31:32 -08:00
|
|
|
mflr r0
|
2006-05-31 01:16:34 -07:00
|
|
|
stg r0, 0(r1)
|
1998-03-13 11:31:32 -08:00
|
|
|
Loadglobal r11, _caml_exception_pointer, r11
|
2006-05-31 01:16:34 -07:00
|
|
|
stg r11, WORD(r1)
|
1998-03-13 11:31:32 -08:00
|
|
|
mr r29, r1
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Reload allocation pointers */
|
2003-12-31 06:20:40 -08:00
|
|
|
Loadglobal r31, _caml_young_ptr, r11
|
|
|
|
Loadglobal r30, _caml_young_limit, r11
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Say we are back into OCaml code */
|
1998-03-13 11:31:32 -08:00
|
|
|
li r0, 0
|
|
|
|
Storeglobal r0, _caml_last_return_address, r11
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Call the OCaml code */
|
2004-02-22 06:56:25 -08:00
|
|
|
mtctr r12
|
1998-03-13 05:57:35 -08:00
|
|
|
L105:
|
2004-02-22 06:56:25 -08:00
|
|
|
bctrl
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Pop the trap frame, restoring caml_exception_pointer */
|
2006-05-31 01:16:34 -07:00
|
|
|
lg r9, WORD(r1)
|
1998-03-13 11:31:32 -08:00
|
|
|
Storeglobal r9, _caml_exception_pointer, r11
|
2003-06-20 08:17:52 -07:00
|
|
|
addi r1, r1, 16
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Pop the callback link, restoring the global variables */
|
1999-02-14 08:48:25 -08:00
|
|
|
L106:
|
2006-05-31 01:16:34 -07:00
|
|
|
lg r9, 0(r1)
|
|
|
|
lg r10, WORD(r1)
|
|
|
|
lg r11, 2*WORD(r1)
|
1999-11-29 11:16:30 -08:00
|
|
|
Storeglobal r9, _caml_bottom_of_stack, r12
|
|
|
|
Storeglobal r10, _caml_last_return_address, r12
|
|
|
|
Storeglobal r11, _caml_gc_regs, r12
|
2006-05-31 01:16:34 -07:00
|
|
|
addi r1, r1, 32
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Update allocation pointer */
|
2003-12-31 06:20:40 -08:00
|
|
|
Storeglobal r31, _caml_young_ptr, r11
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Restore callee-save registers */
|
2006-05-31 01:16:34 -07:00
|
|
|
addi r11, r1, 16-WORD
|
|
|
|
lgu r14, WORD(r11)
|
|
|
|
lgu r15, WORD(r11)
|
|
|
|
lgu r16, WORD(r11)
|
|
|
|
lgu r17, WORD(r11)
|
|
|
|
lgu r18, WORD(r11)
|
|
|
|
lgu r19, WORD(r11)
|
|
|
|
lgu r20, WORD(r11)
|
|
|
|
lgu r21, WORD(r11)
|
|
|
|
lgu r22, WORD(r11)
|
|
|
|
lgu r23, WORD(r11)
|
|
|
|
lgu r24, WORD(r11)
|
|
|
|
lgu r25, WORD(r11)
|
|
|
|
lgu r26, WORD(r11)
|
|
|
|
lgu r27, WORD(r11)
|
|
|
|
lgu r28, WORD(r11)
|
|
|
|
lgu r29, WORD(r11)
|
|
|
|
lgu r30, WORD(r11)
|
|
|
|
lgu r31, WORD(r11)
|
1998-03-13 11:31:32 -08:00
|
|
|
lfdu f14, 8(r11)
|
|
|
|
lfdu f15, 8(r11)
|
|
|
|
lfdu f16, 8(r11)
|
|
|
|
lfdu f17, 8(r11)
|
|
|
|
lfdu f18, 8(r11)
|
|
|
|
lfdu f19, 8(r11)
|
|
|
|
lfdu f20, 8(r11)
|
|
|
|
lfdu f21, 8(r11)
|
|
|
|
lfdu f22, 8(r11)
|
|
|
|
lfdu f23, 8(r11)
|
|
|
|
lfdu f24, 8(r11)
|
|
|
|
lfdu f25, 8(r11)
|
|
|
|
lfdu f26, 8(r11)
|
|
|
|
lfdu f27, 8(r11)
|
|
|
|
lfdu f28, 8(r11)
|
|
|
|
lfdu f29, 8(r11)
|
|
|
|
lfdu f30, 8(r11)
|
|
|
|
lfdu f31, 8(r11)
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Reload return address */
|
2006-05-31 01:16:34 -07:00
|
|
|
lg r0, WORD(r1)
|
1998-03-13 11:31:32 -08:00
|
|
|
mtlr r0
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Return */
|
2006-05-31 01:16:34 -07:00
|
|
|
addi r1, r1, FRAMESIZE
|
1998-03-13 05:57:35 -08:00
|
|
|
blr
|
|
|
|
|
|
|
|
/* The trap handler: */
|
|
|
|
L104:
|
1999-02-14 08:48:25 -08:00
|
|
|
/* Update caml_exception_pointer */
|
1998-03-13 11:31:32 -08:00
|
|
|
Storeglobal r29, _caml_exception_pointer, r11
|
1999-02-14 08:48:25 -08:00
|
|
|
/* Encode exception bucket as an exception result and return it */
|
1999-11-15 12:04:30 -08:00
|
|
|
ori r3, r3, 2
|
1999-02-14 08:48:25 -08:00
|
|
|
b L106
|
2006-05-31 01:16:34 -07:00
|
|
|
#undef FRAMESIZE
|
1998-03-13 05:57:35 -08:00
|
|
|
|
2012-02-10 08:15:24 -08:00
|
|
|
/* Callback from C to OCaml */
|
1998-03-13 05:57:35 -08:00
|
|
|
|
2003-12-31 06:20:40 -08:00
|
|
|
.globl _caml_callback_exn
|
|
|
|
_caml_callback_exn:
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Initial shuffling of arguments */
|
1998-03-13 11:31:32 -08:00
|
|
|
mr r0, r3 /* Closure */
|
|
|
|
mr r3, r4 /* Argument */
|
|
|
|
mr r4, r0
|
2006-05-31 01:16:34 -07:00
|
|
|
lg r12, 0(r4) /* Code pointer */
|
1998-03-13 05:57:35 -08:00
|
|
|
b L102
|
|
|
|
|
2003-12-31 06:20:40 -08:00
|
|
|
.globl _caml_callback2_exn
|
|
|
|
_caml_callback2_exn:
|
1998-03-13 11:31:32 -08:00
|
|
|
mr r0, r3 /* Closure */
|
|
|
|
mr r3, r4 /* First argument */
|
|
|
|
mr r4, r5 /* Second argument */
|
|
|
|
mr r5, r0
|
|
|
|
Addrglobal r12, _caml_apply2
|
1998-03-13 05:57:35 -08:00
|
|
|
b L102
|
1999-11-29 11:16:30 -08:00
|
|
|
|
2003-12-31 06:20:40 -08:00
|
|
|
.globl _caml_callback3_exn
|
|
|
|
_caml_callback3_exn:
|
1998-03-13 11:31:32 -08:00
|
|
|
mr r0, r3 /* Closure */
|
|
|
|
mr r3, r4 /* First argument */
|
|
|
|
mr r4, r5 /* Second argument */
|
|
|
|
mr r5, r6 /* Third argument */
|
|
|
|
mr r6, r0
|
|
|
|
Addrglobal r12, _caml_apply3
|
1998-03-13 05:57:35 -08:00
|
|
|
b L102
|
|
|
|
|
2012-02-17 02:12:09 -08:00
|
|
|
.globl _caml_system__code_end
|
|
|
|
_caml_system__code_end:
|
|
|
|
|
1998-03-13 05:57:35 -08:00
|
|
|
/* Frame table */
|
|
|
|
|
1998-03-13 11:31:32 -08:00
|
|
|
.const
|
2004-01-03 04:51:20 -08:00
|
|
|
.globl _caml_system__frametable
|
|
|
|
_caml_system__frametable:
|
2006-05-31 01:16:34 -07:00
|
|
|
gdata 1 /* one descriptor */
|
|
|
|
gdata L105 + 4 /* return address into callback */
|
1998-03-13 05:57:35 -08:00
|
|
|
.short -1 /* negative size count => use callback link */
|
|
|
|
.short 0 /* no roots here */
|
2012-07-30 11:04:46 -07:00
|
|
|
.align X(2,3)
|