Skip to content

Commit

Permalink
Fix Parse_bytecode types
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierNicole committed Oct 2, 2024
1 parent b16557e commit a6c1ee5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
1 change: 0 additions & 1 deletion compiler/bin-wasm_of_ocaml/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ let run
let t1 = Timer.make () in
let code =
Parse_bytecode.from_exe
~target:`Wasm
~includes:include_dirs
~include_cmis:false
~link_info:false
Expand Down
8 changes: 1 addition & 7 deletions compiler/lib/link_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,7 @@ let link ~output ~linkall ~mklib ~toplevel ~files ~resolve_sourcemap_url ~source
List.fold_left units ~init:StringSet.empty ~f:(fun acc (u : Unit_info.t) ->
StringSet.union acc (StringSet.of_list u.primitives))
in
let code =
Parse_bytecode.link_info
~target:`JavaScript
~symtable:!sym
~primitives
~crcs:[]
in
let code = Parse_bytecode.link_info ~symtable:!sym ~primitives ~crcs:[] in
let b = Buffer.create 100 in
let fmt = Pretty_print.to_buffer b in
Driver.configure fmt;
Expand Down
18 changes: 7 additions & 11 deletions compiler/lib/parse_bytecode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ end

(* Parse constants *)
module Constants : sig
val parse : target:[ `JavaScript | `Wasm ] -> Obj.t -> Code.constant
val parse : Obj.t -> Code.constant

val inlined : Code.constant -> bool
end = struct
Expand Down Expand Up @@ -452,7 +452,7 @@ end = struct

let ident_native = ident_of_custom (Obj.repr 0n)

let rec parse ~target x =
let rec parse x =
if Obj.is_block x
then
let tag = Obj.tag x in
Expand Down Expand Up @@ -485,10 +485,7 @@ end = struct
| None -> assert false
else if tag < Obj.no_scan_tag
then
Tuple
( tag
, Array.init (Obj.size x) ~f:(fun i -> parse ~target (Obj.field x i))
, Unknown )
Tuple (tag, Array.init (Obj.size x) ~f:(fun i -> parse (Obj.field x i)), Unknown)
else assert false
else
let i : int = Obj.magic x in
Expand Down Expand Up @@ -2613,7 +2610,6 @@ let read_primitives toc ic =
String.split_char ~sep:'\000' (String.sub prim ~pos:0 ~len:(String.length prim - 1))

let from_exe
~target
?(includes = [])
~linkall
~link_info
Expand All @@ -2627,7 +2623,7 @@ let from_exe
let primitive_table = Array.of_list primitives in
let code = Toc.read_code toc ic in
let init_data = Toc.read_data toc ic in
let init_data = Array.map ~f:(Constants.parse ~target) init_data in
let init_data = Array.map ~f:Constants.parse init_data in
let orig_symbols = Toc.read_symb toc ic in
let orig_crcs = Toc.read_crcs toc ic in
let keeps =
Expand Down Expand Up @@ -2720,7 +2716,7 @@ let from_exe
let gdata = Var.fresh () in
let need_gdata = ref false in
let infos =
[ "toc", Constants.parse ~target (Obj.repr toc)
[ "toc", Constants.parse (Obj.repr toc)
; "prim_count", Int (Int32.of_int (Array.length globals.primitives))
]
in
Expand Down Expand Up @@ -3141,7 +3137,7 @@ let predefined_exceptions () =
in
{ start = 0; blocks = Addr.Map.singleton 0 block; free_pc = 1 }, unit_info

let link_info ~target ~symtable ~primitives ~crcs =
let link_info ~symtable ~primitives ~crcs =
let gdata = Code.Var.fresh_n "global_data" in
let symtable_js =
Ocaml_compiler.Symtable.GlobalMap.fold
Expand All @@ -3165,7 +3161,7 @@ let link_info ~target ~symtable ~primitives ~crcs =
]
in
let infos =
[ "toc", Constants.parse ~target (Obj.repr toc)
[ "toc", Constants.parse (Obj.repr toc)
; "prim_count", Int (Int32.of_int (List.length primitives))
]
in
Expand Down
6 changes: 2 additions & 4 deletions compiler/lib/parse_bytecode.mli
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ end
val read_primitives : Toc.t -> in_channel -> string list

val from_exe :
target:[ `JavaScript | `Wasm ]
-> ?includes:string list
?includes:string list
-> linkall:bool
-> link_info:bool
-> include_cmis:bool
Expand Down Expand Up @@ -91,8 +90,7 @@ val from_string :
val predefined_exceptions : unit -> Code.program * Unit_info.t

val link_info :
target:[ `JavaScript | `Wasm ]
-> symtable:Ocaml_compiler.Symtable.GlobalMap.t
symtable:Ocaml_compiler.Symtable.GlobalMap.t
-> primitives:StringSet.t
-> crcs:(string * Digest.t option) list
-> Code.program

0 comments on commit a6c1ee5

Please sign in to comment.