Skip to content

Commit e5c9d45

Browse files
committed
Internal API change: introduce and use Compression.input_value
Under the hood, it's just `Stdlib.input_value`. However, it documents the places in the compiler where we expect to read compressed marshaled data.
1 parent 02b0d07 commit e5c9d45

9 files changed

Lines changed: 29 additions & 12 deletions

File tree

.depend

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,6 +1988,7 @@ bytecomp/bytelink.cmo : \
19881988
bytecomp/dll.cmi \
19891989
utils/consistbl.cmi \
19901990
utils/config.cmi \
1991+
utils/compression.cmi \
19911992
file_formats/cmo_format.cmi \
19921993
utils/clflags.cmi \
19931994
utils/ccomp.cmi \
@@ -2005,6 +2006,7 @@ bytecomp/bytelink.cmx : \
20052006
bytecomp/dll.cmx \
20062007
utils/consistbl.cmx \
20072008
utils/config.cmx \
2009+
utils/compression.cmx \
20082010
file_formats/cmo_format.cmi \
20092011
utils/clflags.cmx \
20102012
utils/ccomp.cmx \
@@ -6937,6 +6939,7 @@ tools/dumpobj.cmo : \
69376939
bytecomp/instruct.cmi \
69386940
typing/ident.cmi \
69396941
utils/config.cmi \
6942+
utils/compression.cmi \
69406943
file_formats/cmo_format.cmi \
69416944
bytecomp/bytesections.cmi \
69426945
tools/dumpobj.cmi
@@ -6949,6 +6952,7 @@ tools/dumpobj.cmx : \
69496952
bytecomp/instruct.cmx \
69506953
typing/ident.cmx \
69516954
utils/config.cmx \
6955+
utils/compression.cmx \
69526956
file_formats/cmo_format.cmi \
69536957
bytecomp/bytesections.cmx \
69546958
tools/dumpobj.cmi

bytecomp/bytelink.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ let link_compunit output_fun currpos_fun inchan file_name compunit =
228228
Symtable.patch_object code_block compunit.cu_reloc;
229229
if !Clflags.debug && compunit.cu_debug > 0 then begin
230230
seek_in inchan compunit.cu_debug;
231-
let debug_event_list : Instruct.debug_event list = input_value inchan in
232-
let debug_dirs : string list = input_value inchan in
231+
let debug_event_list : Instruct.debug_event list =
232+
Compression.input_value inchan in
233+
let debug_dirs : string list =
234+
Compression.input_value inchan in
233235
let file_path = Filename.dirname (Location.absolute_path file_name) in
234236
let debug_dirs =
235237
if List.mem file_path debug_dirs

bytecomp/bytepackager.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ let rename_append_bytecode packagename oc state objfile compunit =
162162
let events, debug_dirs =
163163
if !Clflags.debug && compunit.cu_debug > 0 then begin
164164
seek_in ic compunit.cu_debug;
165-
let unit_events = (input_value ic : debug_event list) in
165+
let unit_events = (Compression.input_value ic : debug_event list) in
166166
let events =
167167
rev_append_map
168168
(relocate_debug state.offset packagename state.subst)
169169
unit_events
170170
state.events in
171-
let unit_debug_dirs = (input_value ic : string list) in
171+
let unit_debug_dirs = (Compression.input_value ic : string list) in
172172
let debug_dirs =
173173
String.Set.union
174174
state.debug_dirs

file_formats/cmi_format.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type cmi_infos = {
4242
}
4343

4444
let input_cmi ic =
45-
let (name, sign) = (input_value ic : header) in
45+
let (name, sign) = (Compression.input_value ic : header) in
4646
let crcs = (input_value ic : crcs) in
4747
let flags = (input_value ic : flags) in
4848
{

file_formats/cmt_format.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ let clear_env binary_annots =
105105

106106
exception Error of error
107107

108-
let input_cmt ic = (input_value ic : cmt_infos)
108+
let input_cmt ic = (Compression.input_value ic : cmt_infos)
109109

110110
let output_cmt oc cmt =
111111
output_string oc Config.cmt_magic_number;

otherlibs/dynlink/byte/dynlink.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ module Bytecode = struct
134134
if compunit.cu_debug = 0 then [| |]
135135
else begin
136136
seek_in ic compunit.cu_debug;
137-
[| input_value ic |]
137+
[| Compression.input_value ic |]
138138
end in
139139
if priv then Symtable.hide_additions old_state;
140140
let _, clos = Meta.reify_bytecode code events (Some digest) in

tools/dumpobj.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,9 @@ let dump_obj ic =
468468
List.iter print_reloc cu.cu_reloc;
469469
if cu.cu_debug > 0 then begin
470470
seek_in ic cu.cu_debug;
471-
let evl = (input_value ic : debug_event list) in
472-
ignore (input_value ic); (* Skip the list of absolute directory names *)
471+
let evl = (Compression.input_value ic : debug_event list) in
472+
ignore (Compression.input_value ic);
473+
(* Skip the list of absolute directory names *)
473474
record_events 0 evl
474475
end;
475476
seek_in ic cu.cu_pos;
@@ -496,9 +497,9 @@ let dump_exe ic =
496497
let num_eventlists = input_binary_int ic in
497498
for _i = 1 to num_eventlists do
498499
let orig = input_binary_int ic in
499-
let evl = (input_value ic : debug_event list) in
500+
let evl = (Compression.input_value ic : debug_event list) in
500501
(* Skip the list of absolute directory names *)
501-
ignore (input_value ic);
502+
ignore (Compression.input_value ic);
502503
record_events orig evl
503504
done
504505
end;

utils/compression.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ external to_channel: out_channel -> 'a -> extern_flags list -> unit
2727
= "caml_output_value"
2828

2929
let output_value ch v = to_channel ch v [Compression]
30+
31+
let input_value = Stdlib.input_value

utils/compression.mli

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@
1414
(**************************************************************************)
1515

1616
val output_value : out_channel -> 'a -> unit
17-
(** [Compression.outpput_value chan v] writes the representation
17+
(** [Compression.output_value chan v] writes the representation
1818
of [v] on channel [chan].
1919
If compression is supported, the marshaled data
2020
representing value [v] is compressed before being written to
2121
channel [chan].
2222
If compression is not supported, this function behaves like
2323
{!Stdlib.output_value}. *)
2424

25+
val input_value : in_channel -> 'a
26+
(** [Compression.input_value chan] reads from channel [chan] the
27+
byte representation of a structured value, as produced by
28+
[Compression.output_value], and reconstructs and
29+
returns the corresponding value.
30+
If compression is not supported, this function behaves like
31+
{!Stdlib.input_value}. *)
32+
2533
val compression_supported : bool
2634
(** Reports whether compression is supported. *)

0 commit comments

Comments
 (0)