Skip to content

Commit

Permalink
Skip isolating cover instructions when native coverage is available
Browse files Browse the repository at this point in the history
If OTP is compiled with native coverage support (OTP 27+ plus JIT),
`cover` does not attempt to inject counters into the code, so
isolating the cover instructions fails. We can skip that step when we
detect native coverage support.
  • Loading branch information
the-mikedavis committed Feb 26, 2024
1 parent 7d75f5f commit 495ae55
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/horus.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1218,8 +1218,16 @@ pass1_process_instructions(
Instructions,
#state{mfa_in_progress = MFA,
asm_in_progress_from = cover} = State) ->
Instructions1 = horus_cover:isolate_cover_instructions(MFA, Instructions),
pass1_process_instructions(Instructions1, State, []);
NativeCoverageSupport = erlang:function_exported(
code, coverage_support, 0) andalso
apply(code, coverage_support, []),
case NativeCoverageSupport of
true ->
pass1_process_instructions(Instructions, State, []);
false ->
Instructions1 = horus_cover:isolate_cover_instructions(MFA, Instructions),
pass1_process_instructions(Instructions1, State, [])
end;
pass1_process_instructions(Instructions, State) ->
pass1_process_instructions(Instructions, State, []).

Expand Down

0 comments on commit 495ae55

Please sign in to comment.