Skip to content

Use extcalls for bound errors#168

Merged
Gbury merged 8 commits intoflambda2.0-stablefrom
bound_error
Jun 26, 2020
Merged

Use extcalls for bound errors#168
Gbury merged 8 commits intoflambda2.0-stablefrom
bound_error

Conversation

@Gbury
Copy link

@Gbury Gbury commented Jun 16, 2020

This replaces the code for out of bounds error: previously it raise manually an exception (and had to create the exn). Now it can call the dedicated c function to raise the exception. This change could probably be dependant on a compiler option ?

Additionally to the primitive translation part of the changes, 2 additional changes are present:

  • in flambda2, function call continuation can now never return, which implied a log of code changes. The current PR works, but duplicates code sometimes unecesarily, so it is expected that some modifications to these changes will be needed (but this PR can help converge on what these should look like)
  • some code was added to linearize.ml to eliminate the deadcode present after a call to caml_ml_array_bound_error in the same way as tailcalls.

@Gbury Gbury force-pushed the bound_error branch 2 times, most recently from 43a5e90 to 38c1613 Compare June 24, 2020 12:37
@Gbury
Copy link
Author

Gbury commented Jun 24, 2020

History has been cleaned up, better reviewed commit by commit.

Note that the if true in lambda_to_flambda_primitives_helpers.ml should probably be turned into an option ? Or are the extcalls always better ?

@lthls
Copy link

lthls commented Jun 24, 2020

The explicit raise can give slightly better backtraces, although not much as long as the caml_ml_array_bound_error calls are not merged into a single one.
I'd keep the if true for now, so that the raising code keeps compiling in case we decide do use it again.

Also remove deadcode after a call to caml_ml_array_bound_error
@Gbury Gbury merged commit 16acbd4 into flambda2.0-stable Jun 26, 2020
lthls added a commit that referenced this pull request Sep 29, 2020
* Allow application that never return + shorten out_of_bound raise

* Turn cmm.extcall tuple into a record

* Properly handle never returning functions in the backend

Also remove deadcode after a call to caml_ml_array_bound_error

* Review

* Bettre code factorization

* Refactor back some duplicated code

* Update apply_expr.ml

* typo

Co-authored-by: Vincent Laviron <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants