1 (***********************************************************************)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the Q Public License version 1.0. *)
11 (***********************************************************************)
15 (* The type of the instructions of the abstract machine *)
19 (* Structure of compilation environments *)
21 type compilation_env
=
22 { ce_stack
: int Ident.tbl
; (* Positions of variables in the stack *)
23 ce_heap
: int Ident.tbl
; (* Structure of the heap-allocated env *)
24 ce_rec
: int Ident.tbl
} (* Functions bound by the same let rec *)
26 (* The ce_stack component gives locations of variables residing
27 in the stack. The locations are offsets w.r.t. the origin of the
29 The ce_heap component gives the positions of variables residing in the
30 heap-allocated environment.
31 The ce_rec component associate offsets to identifiers for functions
32 bound by the same let rec as the current function. The offsets
33 are used by the OFFSETCLOSURE instruction to recover the closure
34 pointer of the desired function from the env register (which
35 points to the closure for the current function). *)
37 (* Debugging events *)
39 (* Warning: when you change these types, check byterun/backtrace.c *)
41 { mutable ev_pos
: int; (* Position in bytecode *)
42 ev_module
: string; (* Name of defining module *)
43 ev_loc
: Location.t
; (* Location in source file *)
44 ev_kind
: debug_event_kind
; (* Before/after event *)
45 ev_info
: debug_event_info
; (* Extra information *)
46 ev_typenv
: Env.summary
; (* Typing environment *)
47 ev_compenv
: compilation_env
; (* Compilation environment *)
48 ev_stacksize
: int; (* Size of stack frame *)
49 ev_repr
: debug_event_repr
} (* Position of the representative *)
51 and debug_event_kind
=
53 | Event_after
of Types.type_expr
56 and debug_event_info
=
61 and debug_event_repr
=
63 | Event_parent
of int ref
64 | Event_child
of int ref
66 (* Abstract machine instructions *)
68 type label
= int (* Symbolic code labels *)
77 | Kpush_retaddr
of label
78 | Kapply
of int (* number of arguments *)
79 | Kappterm
of int * int (* number of arguments, slot size *)
80 | Kreturn
of int (* slot size *)
82 | Kgrab
of int (* number of arguments *)
83 | Kclosure
of label
* int
84 | Kclosurerec
of label list
* int
85 | Koffsetclosure
of int
86 | Kgetglobal
of Ident.t
87 | Ksetglobal
of Ident.t
88 | Kconst
of structured_constant
89 | Kmakeblock
of int * int (* size, tag *)
90 | Kmakefloatblock
of int
93 | Kgetfloatfield
of int
94 | Ksetfloatfield
of int
102 | Kbranchifnot
of label
103 | Kstrictbranchif
of label
104 | Kstrictbranchifnot
of label
105 | Kswitch
of label array
* label array
111 | Kccall
of string * int
112 | Knegint
| Kaddint
| Ksubint
| Kmulint
| Kdivint
| Kmodint
113 | Kandint
| Korint
| Kxorint
| Klslint
| Klsrint
| Kasrint
114 | Kintcomp
of comparison
122 | Kevent
of debug_event