Skip to content

Commit af9b98f

Browse files
committed
Ajout de pseudo-registres supplementaires pour le passage de plus de 6 arguments
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6593 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
1 parent 6e98231 commit af9b98f

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

asmcomp/i386/emit.mlp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ let frame_size () = (* includes return address *)
3737

3838
let slot_offset loc cl =
3939
match loc with
40-
Incoming n -> frame_size() + n
40+
Incoming n ->
41+
assert (n >= 0);
42+
frame_size() + n
4143
| Local n ->
4244
if cl = 0
4345
then !stack_offset + n * 4
4446
else !stack_offset + num_stack_slots.(0) * 4 + n * 8
45-
| Outgoing n -> n
47+
| Outgoing n ->
48+
assert (n >= 0);
49+
n
4650

4751
(* Prefixing of symbols with "_" *)
4852

@@ -107,6 +111,8 @@ let emit_Llabel fallthrough lbl =
107111
let emit_reg = function
108112
{ loc = Reg r } ->
109113
emit_string (register_name r)
114+
| { loc = Stack(Incoming n | Outgoing n) } when n < 0 ->
115+
`caml_extra_params + {emit_int (n + 64)}`
110116
| { loc = Stack s } as r ->
111117
let ofs = slot_offset s (register_class r) in
112118
`{emit_int ofs}(%esp)`

asmcomp/i386/proc.ml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,23 @@ let word_addressed = false
8888

8989
(* Calling conventions *)
9090

91+
(* To supplement the processor's meagre supply of registers, we also
92+
use some global memory locations to pass arguments beyond the 6th.
93+
These globals are denoted by Incoming and Outgoing stack locations
94+
with negative offsets, starting at -64.
95+
Unlike arguments passed on stack, arguments passed in globals
96+
do not prevent tail-call elimination. The caller stores arguments
97+
in these globals immediately before the call, and the first thing the
98+
callee does is copy them to registers or stack locations.
99+
Neither GC nor thread context switches can occur between these two
100+
times. *)
101+
91102
let calling_conventions first_int last_int first_float last_float make_stack
92103
arg =
93104
let loc = Array.create (Array.length arg) Reg.dummy in
94105
let int = ref first_int in
95106
let float = ref first_float in
96-
let ofs = ref 0 in
107+
let ofs = ref (-64) in
97108
for i = 0 to Array.length arg - 1 do
98109
match arg.(i).typ with
99110
Int | Addr as ty ->
@@ -113,7 +124,7 @@ let calling_conventions first_int last_int first_float last_float make_stack
113124
ofs := !ofs + size_float
114125
end
115126
done;
116-
(loc, !ofs)
127+
(loc, max 0 !ofs)
117128

118129
let incoming ofs = Incoming ofs
119130
let outgoing ofs = Outgoing ofs

asmrun/i386.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,11 @@ G(caml_system__frametable):
324324
.value -1 /* negative frame size => use callback link */
325325
.value 0 /* no roots here */
326326
#endif
327+
328+
.globl G(caml_extra_params)
329+
G(caml_extra_params):
330+
#ifndef SYS_solaris
331+
.space 64
332+
#else
333+
.zero 64
334+
#endif

0 commit comments

Comments
 (0)