1 (**************************************************************************)
2 (* *)
3 (* OCaml *)
4 (* *)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
6 (* *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. *)
9 (* *)
10 (* All rights reserved. This file is distributed under the terms of *)
11 (* the GNU Lesser General Public License version 2.1, with the *)
12 (* special exception on linking described in the file LICENSE. *)
13 (* *)
14 (**************************************************************************)
15
16 open Lambda
17
18 type compilation_env =
19 { ce_stack: int Ident.tbl;
20 ce_heap: int Ident.tbl;
21 ce_rec: int Ident.tbl }
22
23 type debug_event =
24 { mutable ev_pos: int; (* Position in bytecode *)
25 ev_module: string; (* Name of defining module *)
26 ev_loc: Location.t; (* Location in source file *)
27 ev_kind: debug_event_kind; (* Before/after event *)
28 ev_info: debug_event_info; (* Extra information *)
29 ev_typenv: Env.summary; (* Typing environment *)
30 ev_typsubst: Subst.t; (* Substitution over types *)
31 ev_compenv: compilation_env; (* Compilation environment *)
32 ev_stacksize: int; (* Size of stack frame *)
33 ev_repr: debug_event_repr } (* Position of the representative *)
34
35 and debug_event_kind =
36 Event_before
37 | Event_after of Types.type_expr
38 | Event_pseudo
39
40 and debug_event_info =
41 Event_function
42 | Event_return of int
43 | Event_other
44
45 and debug_event_repr =
46 Event_none
47 | Event_parent of int ref
48 | Event_child of int ref
49
50 type label = int (* Symbolic code labels *)
51
52 type instruction =
53 Klabel of label
54 | Kacc of int
55 | Kenvacc of int
56 | Kpush
57 | Kpop of int
58 | Kassign of int
59 | Kpush_retaddr of label
60 | Kapply of int (* number of arguments *)
61 | Kappterm of int * int (* number of arguments, slot size *)
62 | Kreturn of int (* slot size *)
63 | Krestart
64 | Kgrab of int (* number of arguments *)
65 | Kclosure of label * int
66 | Kclosurerec of label list * int
67 | Koffsetclosure of int
68 | Kgetglobal of Ident.t
69 | Ksetglobal of Ident.t
70 | Kconst of structured_constant
71 | Kmakeblock of int * int (* size, tag *)
72 | Kmakefloatblock of int
73 | Kgetfield of int
74 | Ksetfield of int
75 | Kgetfloatfield of int
76 | Ksetfloatfield of int
77 | Kvectlength
78 | Kgetvectitem
79 | Ksetvectitem
80 | Kgetstringchar
81 | Kgetbyteschar
82 | Ksetbyteschar
83 | Kbranch of label
84 | Kbranchif of label
85 | Kbranchifnot of label
86 | Kstrictbranchif of label
87 | Kstrictbranchifnot of label
88 | Kswitch of label array * label array
89 | Kboolnot
90 | Kpushtrap of label
91 | Kpoptrap
92 | Kraise of raise_kind
93 | Kcheck_signals
94 | Kccall of string * int
95 | Knegint | Kaddint | Ksubint | Kmulint | Kdivint | Kmodint
96 | Kandint | Korint | Kxorint | Klslint | Klsrint | Kasrint
97 | Kintcomp of integer_comparison
98 | Koffsetint of int
99 | Koffsetref of int
100 | Kisint
101 | Kisout
102 | Kgetmethod
103 | Kgetpubmet of int
104 | Kgetdynmet
105 | Kevent of debug_event
106 | Kstop
107
108 let immed_min = -0x40000000
109 and immed_max = 0x3FFFFFFF
110
111 (* Actually the abstract machine accommodates -0x80000000 to 0x7FFFFFFF,
112 but these numbers overflow the OCaml type int if the compiler runs on
113 a 32-bit processor. *)
114