Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode sourcemap mappings only when necessary #1664

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Misc: yojson is no longer optional
* Compiler: speedup global_flow/global_deadcode pass on large bytecode
* Compiler: speedup json parsing, relying on Yojson.Raw (#1640)
* Compiler: Decode sourcemap mappings only when necessary (#1664)
* Compiler: make indirect call using sequence instead of using the call method
[f.call(null, args)] becomes [(0,f)(args)]
* Runtime: change Sys.os_type on windows (Cygwin -> Win32)
Expand Down
4 changes: 2 additions & 2 deletions compiler/bin-js_of_ocaml/cmd_arg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ let options =
; sources = []
; sources_content = (if sourcemap_don't_inline_content then None else Some [])
; names = []
; mappings = []
; mappings = Source_map.Mappings.empty
} )
else None
in
Expand Down Expand Up @@ -543,7 +543,7 @@ let options_runtime_only =
; sources = []
; sources_content = (if sourcemap_don't_inline_content then None else Some [])
; names = []
; mappings = []
; mappings = Source_map.Mappings.empty
} )
else None
in
Expand Down
2 changes: 1 addition & 1 deletion compiler/bin-js_of_ocaml/link.ml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ let options =
; sources = []
; sources_content = Some []
; names = []
; mappings = []
; mappings = Source_map.Mappings.empty
} )
else None
in
Expand Down
4 changes: 3 additions & 1 deletion compiler/lib/js_output.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1996,8 +1996,9 @@ let program ?(accept_unnamed_var = false) f ?source_map p =
| None -> filename
| Some _ -> Filename.concat "/builtin" filename)
in
let sm_mappings = Source_map.Mappings.decode sm.mappings in
let mappings =
List.rev_append_map !temp_mappings sm.mappings ~f:(fun (pos, m) ->
List.rev_append_map !temp_mappings sm_mappings ~f:(fun (pos, m) ->
let gen_line = pos.PP.p_line + 1 in
let gen_col = pos.PP.p_col in
match m with
Expand All @@ -2012,6 +2013,7 @@ let program ?(accept_unnamed_var = false) f ?source_map p =
Source_map.Gen_Ori_Name
{ gen_line; gen_col; ori_source; ori_line; ori_col; ori_name })
in
let mappings = Source_map.Mappings.encode mappings in
vouillon marked this conversation as resolved.
Show resolved Hide resolved
Some { sm with Source_map.sources; names; sources_content; mappings }
in
PP.check f;
Expand Down
Loading