Skip to content

Commit

Permalink
flambda-backend: To upstream: fix dependency problem with Instruct
Browse files Browse the repository at this point in the history
  • Loading branch information
mshinwell authored and poechsel committed Jun 25, 2021
1 parent c311155 commit 686d6e3
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 57 deletions.
17 changes: 13 additions & 4 deletions .depend
Expand Up @@ -1875,6 +1875,12 @@ bytecomp/bytesections.cmx : \
utils/config.cmx \
bytecomp/bytesections.cmi
bytecomp/bytesections.cmi :
bytecomp/debug_event.cmi : \
typing/types.cmi \
typing/subst.cmi \
parsing/location.cmi \
typing/ident.cmi \
typing/env.cmi
bytecomp/dll.cmo : \
utils/misc.cmi \
utils/config.cmi \
Expand Down Expand Up @@ -1932,6 +1938,7 @@ bytecomp/instruct.cmo : \
lambda/lambda.cmi \
typing/ident.cmi \
typing/env.cmi \
bytecomp/debug_event.cmi \
bytecomp/instruct.cmi
bytecomp/instruct.cmx : \
typing/types.cmx \
Expand All @@ -1940,22 +1947,24 @@ bytecomp/instruct.cmx : \
lambda/lambda.cmx \
typing/ident.cmx \
typing/env.cmx \
bytecomp/debug_event.cmi \
bytecomp/instruct.cmi
bytecomp/instruct.cmi : \
typing/types.cmi \
typing/subst.cmi \
parsing/location.cmi \
lambda/lambda.cmi \
typing/ident.cmi \
typing/env.cmi
typing/env.cmi \
bytecomp/debug_event.cmi
bytecomp/meta.cmo : \
bytecomp/instruct.cmi \
bytecomp/debug_event.cmi \
bytecomp/meta.cmi
bytecomp/meta.cmx : \
bytecomp/instruct.cmx \
bytecomp/debug_event.cmi \
bytecomp/meta.cmi
bytecomp/meta.cmi : \
bytecomp/instruct.cmi
bytecomp/debug_event.cmi
bytecomp/opcodes.cmo : \
bytecomp/opcodes.cmi
bytecomp/opcodes.cmx : \
Expand Down
63 changes: 63 additions & 0 deletions bytecomp/debug_event.mli
@@ -0,0 +1,63 @@
(**************************************************************************)
(* *)
(* 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 Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)

(* Structure of compilation environments *)

type compilation_env =
{ ce_stack: int Ident.tbl; (* Positions of variables in the stack *)
ce_heap: int Ident.tbl; (* Structure of the heap-allocated env *)
ce_rec: int Ident.tbl } (* Functions bound by the same let rec *)

(* The ce_stack component gives locations of variables residing
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
heap-allocated environment.
The ce_rec component associates 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). *)

(* Debugging events *)

(* Warning: when you change these types, check runtime/backtrace_byt.c *)
type debug_event =
{ mutable ev_pos: int; (* Position in bytecode *)
ev_module: string; (* Name of defining module *)
ev_loc: Location.t; (* Location in source file *)
ev_kind: debug_event_kind; (* Before/after event *)
ev_defname: string; (* Enclosing definition *)
ev_info: debug_event_info; (* Extra information *)
ev_typenv: Env.summary; (* Typing environment *)
ev_typsubst: Subst.t; (* Substitution over types *)
ev_compenv: compilation_env; (* Compilation environment *)
ev_stacksize: int; (* Size of stack frame *)
ev_repr: debug_event_repr } (* Position of the representative *)

and debug_event_kind =
Event_before
| Event_after of Types.type_expr
| Event_pseudo

and debug_event_info =
Event_function
| Event_return of int
| Event_other

and debug_event_repr =
Event_none
| Event_parent of int ref
| Event_child of int ref
32 changes: 16 additions & 16 deletions bytecomp/instruct.ml
Expand Up @@ -15,35 +15,35 @@

open Lambda

type compilation_env =
type compilation_env = Debug_event.compilation_env =
{ ce_stack: int Ident.tbl;
ce_heap: int Ident.tbl;
ce_rec: int Ident.tbl }

type debug_event =
{ mutable ev_pos: int; (* Position in bytecode *)
ev_module: string; (* Name of defining module *)
ev_loc: Location.t; (* Location in source file *)
ev_kind: debug_event_kind; (* Before/after event *)
ev_defname: string; (* Enclosing definition *)
ev_info: debug_event_info; (* Extra information *)
ev_typenv: Env.summary; (* Typing environment *)
ev_typsubst: Subst.t; (* Substitution over types *)
ev_compenv: compilation_env; (* Compilation environment *)
ev_stacksize: int; (* Size of stack frame *)
ev_repr: debug_event_repr } (* Position of the representative *)
type debug_event = Debug_event.debug_event =
{ mutable ev_pos: int;
ev_module: string;
ev_loc: Location.t;
ev_kind: debug_event_kind;
ev_defname: string;
ev_info: debug_event_info;
ev_typenv: Env.summary;
ev_typsubst: Subst.t;
ev_compenv: compilation_env;
ev_stacksize: int;
ev_repr: debug_event_repr }

and debug_event_kind =
and debug_event_kind = Debug_event.debug_event_kind =
Event_before
| Event_after of Types.type_expr
| Event_pseudo

and debug_event_info =
and debug_event_info = Debug_event.debug_event_info =
Event_function
| Event_return of int
| Event_other

and debug_event_repr =
and debug_event_repr = Debug_event.debug_event_repr =
Event_none
| Event_parent of int ref
| Event_child of int ref
Expand Down
50 changes: 19 additions & 31 deletions bytecomp/instruct.mli
Expand Up @@ -19,49 +19,37 @@ open Lambda

(* Structure of compilation environments *)

type compilation_env =
{ ce_stack: int Ident.tbl; (* Positions of variables in the stack *)
ce_heap: int Ident.tbl; (* Structure of the heap-allocated env *)
ce_rec: int Ident.tbl } (* Functions bound by the same let rec *)

(* The ce_stack component gives locations of variables residing
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
heap-allocated environment.
The ce_rec component associates 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). *)
type compilation_env = Debug_event.compilation_env =
{ ce_stack: int Ident.tbl;
ce_heap: int Ident.tbl;
ce_rec: int Ident.tbl }

(* Debugging events *)

(* Warning: when you change these types, check runtime/backtrace_byt.c *)
type debug_event =
{ mutable ev_pos: int; (* Position in bytecode *)
ev_module: string; (* Name of defining module *)
ev_loc: Location.t; (* Location in source file *)
ev_kind: debug_event_kind; (* Before/after event *)
ev_defname: string; (* Enclosing definition *)
ev_info: debug_event_info; (* Extra information *)
ev_typenv: Env.summary; (* Typing environment *)
ev_typsubst: Subst.t; (* Substitution over types *)
ev_compenv: compilation_env; (* Compilation environment *)
ev_stacksize: int; (* Size of stack frame *)
ev_repr: debug_event_repr } (* Position of the representative *)
type debug_event = Debug_event.debug_event =
{ mutable ev_pos: int;
ev_module: string;
ev_loc: Location.t;
ev_kind: debug_event_kind;
ev_defname: string;
ev_info: debug_event_info;
ev_typenv: Env.summary;
ev_typsubst: Subst.t;
ev_compenv: compilation_env;
ev_stacksize: int;
ev_repr: debug_event_repr }

and debug_event_kind =
and debug_event_kind = Debug_event.debug_event_kind =
Event_before
| Event_after of Types.type_expr
| Event_pseudo

and debug_event_info =
and debug_event_info = Debug_event.debug_event_info =
Event_function
| Event_return of int
| Event_other

and debug_event_repr =
and debug_event_repr = Debug_event.debug_event_repr =
Event_none
| Event_parent of int ref
| Event_child of int ref
Expand Down
2 changes: 1 addition & 1 deletion bytecomp/meta.ml
Expand Up @@ -18,7 +18,7 @@ external realloc_global_data : int -> unit = "caml_realloc_global"
type closure = unit -> Obj.t
type bytecode
external reify_bytecode :
bytes array -> Instruct.debug_event list array -> string option ->
bytes array -> Debug_event.debug_event list array -> string option ->
bytecode * closure
= "caml_reify_bytecode"
external release_bytecode : bytecode -> unit
Expand Down
2 changes: 1 addition & 1 deletion bytecomp/meta.mli
Expand Up @@ -20,7 +20,7 @@ external realloc_global_data : int -> unit = "caml_realloc_global"
type closure = unit -> Obj.t
type bytecode
external reify_bytecode :
bytes array -> Instruct.debug_event list array -> string option ->
bytes array -> Debug_event.debug_event list array -> string option ->
bytecode * closure
= "caml_reify_bytecode"
external release_bytecode : bytecode -> unit
Expand Down
5 changes: 2 additions & 3 deletions dune
Expand Up @@ -71,14 +71,12 @@
translattribute translclass translcore translmod translobj translprim

;; bytecomp/
meta opcodes bytesections dll symtable
debug_event meta opcodes bytesections dll symtable

;; some of COMP
pparse main_args compenv compmisc makedepend compile_common
; manual update: mli only files
cmo_format
; manual update: this is required.
instruct
))

(library
Expand All @@ -89,6 +87,7 @@
(modules
;; bytecomp/
bytegen bytelibrarian bytelink bytepackager emitcode printinstr
instruct

;; driver/
errors compile
Expand Down
3 changes: 2 additions & 1 deletion otherlibs/dynlink/Makefile
Expand Up @@ -69,7 +69,8 @@ COMPILERLIBS_INTFS=\
parsing/parsetree.mli \
typing/outcometree.mli \
file_formats/cmo_format.mli \
file_formats/cmxs_format.mli
file_formats/cmxs_format.mli \
bytecomp/debug_event.mli

# .ml files from compilerlibs that have corresponding .mli files.
COMPILERLIBS_SOURCES=\
Expand Down

0 comments on commit 686d6e3

Please sign in to comment.