Skip to content

Commit 2c28d27

Browse files
committed
JIT: Improve error reporting in jit_precompile
jit_precompile exception handling was designed to detect unimplemented opcodes, but it would report a badmatch when another error occurred. Signed-off-by: Paul Guyot <[email protected]>
1 parent 151182c commit 2c28d27

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

libs/jit/src/jit_precompile.erl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,20 @@ compile(Target, Dir, Path) ->
8181
ok = file:write_file(UpdatedFile, Binary)
8282
catch
8383
error:function_clause:S ->
84-
[{jit, first_pass, [<<Opcode, _Rest/binary>> | _], _} | _] = S,
85-
io:format("Unimplemented opcode ~p (~s)\n", [Opcode, Path])
84+
case S of
85+
[{jit, first_pass, [<<Opcode, _Rest/binary>> | _], _} | _] ->
86+
io:format("Unimplemented opcode ~p (~s)\n", [Opcode, Path]);
87+
_ ->
88+
io:format("Function clause error in ~s:~n", [Path]),
89+
lists:foreach(
90+
fun(Frame) -> io:format(" ~p~n", [Frame]) end, lists:sublist(S, 5)
91+
),
92+
erlang:raise(error, function_clause, S)
93+
end;
94+
Class:Reason:Stack ->
95+
io:format("Error ~p:~p in ~s:~n", [Class, Reason, Path]),
96+
lists:foreach(fun(Frame) -> io:format(" ~p~n", [Frame]) end, lists:sublist(Stack, 5)),
97+
erlang:raise(Class, Reason, Stack)
8698
end.
8799

88100
atom_resolver(AtomChunk) ->

0 commit comments

Comments
 (0)