1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-08-09 08:06:35 -07: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 *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* The type of the instructions of the abstract machine *)
|
|
|
|
|
|
|
|
open Lambda
|
|
|
|
|
1996-11-29 10:36:42 -08:00
|
|
|
(* Structure of compilation environments *)
|
|
|
|
|
|
|
|
type compilation_env =
|
|
|
|
{ ce_stack: int Ident.tbl; (* Positions of variables in the stack *)
|
1998-04-06 02:15:55 -07:00
|
|
|
ce_heap: int Ident.tbl; (* Structure of the heap-allocated env *)
|
|
|
|
ce_rec: int Ident.tbl } (* Functions bound by the same let rec *)
|
1996-11-29 10:36:42 -08:00
|
|
|
|
2005-08-25 08:35:16 -07:00
|
|
|
(* The ce_stack component gives locations of variables residing
|
1996-11-29 10:36:42 -08:00
|
|
|
in the stack. The locations are offsets w.r.t. the origin of the
|
|
|
|
stack frame.
|
|
|
|
The ce_heap component gives the positions of variables residing in the
|
1998-04-06 02:15:55 -07:00
|
|
|
heap-allocated environment.
|
|
|
|
The ce_rec component associate offsets to identifiers for functions
|
|
|
|
bound by the same let rec as the current function. The offsets
|
|
|
|
are used by the OFFSETCLOSURE instruction to recover the closure
|
|
|
|
pointer of the desired function from the env register (which
|
|
|
|
points to the closure for the current function). *)
|
1996-11-29 10:36:42 -08:00
|
|
|
|
|
|
|
(* Debugging events *)
|
|
|
|
|
|
|
|
type debug_event =
|
|
|
|
{ mutable ev_pos: int; (* Position in bytecode *)
|
1997-02-19 08:08:05 -08:00
|
|
|
ev_module: string; (* Name of defining module *)
|
2005-08-25 08:35:16 -07:00
|
|
|
ev_loc: Location.t; (* Location in source file *)
|
1996-11-29 10:36:42 -08:00
|
|
|
ev_kind: debug_event_kind; (* Before/after event *)
|
1997-06-16 06:34:34 -07:00
|
|
|
ev_info: debug_event_info; (* Extra information *)
|
1996-11-29 10:36:42 -08:00
|
|
|
ev_typenv: Env.summary; (* Typing environment *)
|
|
|
|
ev_compenv: compilation_env; (* Compilation environment *)
|
1997-03-27 12:53:30 -08:00
|
|
|
ev_stacksize: int; (* Size of stack frame *)
|
1997-06-16 06:34:34 -07:00
|
|
|
ev_repr: debug_event_repr } (* Position of the representative *)
|
1996-11-29 10:36:42 -08:00
|
|
|
|
|
|
|
and debug_event_kind =
|
|
|
|
Event_before
|
1997-06-16 06:34:34 -07:00
|
|
|
| Event_after of Types.type_expr
|
|
|
|
| Event_pseudo
|
|
|
|
|
|
|
|
and debug_event_info =
|
|
|
|
Event_function
|
1997-03-30 11:41:38 -08:00
|
|
|
| Event_return of int
|
1997-06-16 06:34:34 -07:00
|
|
|
| Event_other
|
1997-03-27 12:53:30 -08:00
|
|
|
|
|
|
|
and debug_event_repr =
|
|
|
|
Event_none
|
|
|
|
| Event_parent of int ref
|
|
|
|
| Event_child of int ref
|
1996-11-29 10:36:42 -08:00
|
|
|
|
|
|
|
(* Abstract machine instructions *)
|
|
|
|
|
|
|
|
type label = int (* Symbolic code labels *)
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
type instruction =
|
|
|
|
Klabel of label
|
|
|
|
| Kacc of int
|
|
|
|
| Kenvacc of int
|
|
|
|
| Kpush
|
|
|
|
| Kpop of int
|
|
|
|
| Kassign of int
|
|
|
|
| Kpush_retaddr of label
|
|
|
|
| Kapply of int (* number of arguments *)
|
|
|
|
| Kappterm of int * int (* number of arguments, slot size *)
|
|
|
|
| Kreturn of int (* slot size *)
|
|
|
|
| Krestart
|
|
|
|
| Kgrab of int (* number of arguments *)
|
|
|
|
| Kclosure of label * int
|
1998-04-06 02:15:55 -07:00
|
|
|
| Kclosurerec of label list * int
|
|
|
|
| Koffsetclosure of int
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kgetglobal of Ident.t
|
|
|
|
| Ksetglobal of Ident.t
|
|
|
|
| Kconst of structured_constant
|
|
|
|
| Kmakeblock of int * int (* size, tag *)
|
1998-04-06 02:15:55 -07:00
|
|
|
| Kmakefloatblock of int
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kgetfield of int
|
|
|
|
| Ksetfield of int
|
1998-04-06 02:15:55 -07:00
|
|
|
| Kgetfloatfield of int
|
|
|
|
| Ksetfloatfield of int
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kvectlength
|
|
|
|
| Kgetvectitem
|
|
|
|
| Ksetvectitem
|
|
|
|
| Kgetstringchar
|
|
|
|
| Ksetstringchar
|
|
|
|
| Kbranch of label
|
|
|
|
| Kbranchif of label
|
|
|
|
| Kbranchifnot of label
|
|
|
|
| Kstrictbranchif of label
|
|
|
|
| Kstrictbranchifnot of label
|
1995-06-18 07:44:56 -07:00
|
|
|
| Kswitch of label array * label array
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kboolnot
|
|
|
|
| Kpushtrap of label
|
|
|
|
| Kpoptrap
|
|
|
|
| Kraise
|
|
|
|
| Kcheck_signals
|
|
|
|
| Kccall of string * int
|
|
|
|
| Knegint | Kaddint | Ksubint | Kmulint | Kdivint | Kmodint
|
|
|
|
| Kandint | Korint | Kxorint | Klslint | Klsrint | Kasrint
|
|
|
|
| Kintcomp of comparison
|
|
|
|
| Koffsetint of int
|
|
|
|
| Koffsetref of int
|
1999-12-06 08:59:24 -08:00
|
|
|
| Kisint
|
2000-10-02 07:18:05 -07:00
|
|
|
| Kisout
|
1996-04-22 04:15:41 -07:00
|
|
|
| Kgetmethod
|
2004-05-26 04:10:52 -07:00
|
|
|
| Kgetpubmet of int
|
|
|
|
| Kgetdynmet
|
1996-11-29 10:36:42 -08:00
|
|
|
| Kevent of debug_event
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kstop
|
|
|
|
|
|
|
|
val immed_min: int
|
|
|
|
val immed_max: int
|