Skip to content

Commit

Permalink
Source maps: emit annotations to indicate code with no debug location
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Jun 3, 2024
1 parent 33f1577 commit ef56d39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
9 changes: 2 additions & 7 deletions compiler/lib/wasm/wa_generate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -635,13 +635,8 @@ module Generate (Target : Wa_target_sig.S) = struct
| (Not | Lt | Le | Eq | Neq | Ult | Array_get | IsInt | Vectlength), _ ->
assert false))

and emit_location loc instrs =
match loc with
| No -> instrs
| Before _ | After _ -> with_location loc instrs

and translate_instr ctx stack_ctx context (i, loc) =
emit_location
with_location
loc
(match i with
| Assign (x, y) ->
Expand Down Expand Up @@ -877,7 +872,7 @@ module Generate (Target : Wa_target_sig.S) = struct
let* () = Stack.perform_reloads stack_ctx (`Branch (fst block.branch)) in
let* () = Stack.perform_spilling stack_ctx (`Block pc) in
let branch, loc = block.branch in
emit_location
with_location
loc
(match branch with
| Branch cont ->
Expand Down
3 changes: 2 additions & 1 deletion compiler/lib/wasm/wa_wat_output.ml
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ let expression_or_instructions ctx st in_function =
| Location (loc, i) -> (
let loc = Generate.source_location ctx.debug loc in
match loc with
| Javascript.N | U | Pi Parse_info.{ src = None; _ } -> instruction i
| Javascript.N | U | Pi Parse_info.{ src = None; _ } ->
Comment "@" :: instruction i
| Pi Parse_info.{ src = Some src; col; line; _ } ->
let loc = Format.sprintf "%s:%d:%d" src line col in
Comment ("@ " ^ loc) :: instruction i)
Expand Down

0 comments on commit ef56d39

Please sign in to comment.