Skip to content

Fix error message printing from Emit#791

Merged
mshinwell merged 1 commit intooxcaml:mainfrom
gretay-js:fix-emitaux-error-message
Aug 29, 2022
Merged

Fix error message printing from Emit#791
mshinwell merged 1 commit intooxcaml:mainfrom
gretay-js:fix-emitaux-error-message

Conversation

@gretay-js
Copy link
Copy Markdown
Contributor

Correctly handle exceptions raised during Emit.end_assembly and not only during Emit.funcdecl.

When compiling a function that results in a large frame (for the current frametable format), we were getting unhelpful error messages that look like this:

Fatal error: exception Emitaux.Error(_)
Raised at Emitaux.emit_frames.efa_16_checked in file "backend/emitaux.ml", line 190, characters 9-47
Called from Emitaux.emit_frames.emit_frame in file "backend/emitaux.ml", line 205, characters 4-45
Called from Stdlib__List.iter in file "list.ml", line 114, characters 12-15
Called from Emitaux.emit_frames in file "backend/emitaux.ml", line 283, characters 2-41
Called from Emit.end_assembly in file "backend/amd64/emit.mlp", line 1655, characters 2-931
Called from Asmgen.compile_unit.(fun) in file "backend/asmgen.ml", line 450, characters 12-18
...

With this PR, we will get a slightly nicer user error like this:

File "owl_lapacke_bindings.ml", line 1:
    Error: Error producing assembly code for owl_lapacke_bindings.ml: stack frame too large (136785 bytes)
    - exit external/owl/src/owl/bindings bin_prefix_owl_cblas_parser__Owl_lapacke_bindings.cmx, 5.321s, exited with code 2

(when compiling the file with -linscan).

The error handling was introduced in ocaml/ocaml#10085 for emit_frame (which is actually called during Emit.end_assembly), so this PR is also needed upstream.

I'm trying to move the check itself from emit_frame to record_frame_descr, so the user error can include have a function name as intended, but this PR is independently useful, as we may want to have other user error messages in the future.

Correctly handle user errors during Emit.end_assembly and not only
during Emit.funcdecl
@gretay-js gretay-js requested a review from xclerc as a code owner August 26, 2022 11:58
@mshinwell mshinwell merged commit 7d8bd09 into oxcaml:main Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants