Skip to content

Convert raise_notrace non-escaping exceptions into jumps#451

Merged
mshinwell merged 3 commits intoocaml-flambda:flambda2.0-stablefrom
mshinwell:flambda2-local-exns-to-jumps
May 18, 2021
Merged

Convert raise_notrace non-escaping exceptions into jumps#451
mshinwell merged 3 commits intoocaml-flambda:flambda2.0-stablefrom
mshinwell:flambda2-local-exns-to-jumps

Conversation

@mshinwell
Copy link
Copy Markdown

I was discussing this with @gretay-js today and decided to write the code down. I thought it would take one hour but it took two, even so, not too bad. This exercise was quite useful for code review purposes, as there are some tricky details in this area.

There are no doubt still problems with this patch. However some small examples work. Example number 4 in the new test file even correctly unboxes the two arguments to the exception constructor.

In the future we should write some code to add to the backtrace buffer. Then this could be used for regular exception raises too, not just notrace ones.

@mshinwell mshinwell force-pushed the flambda2-local-exns-to-jumps branch from 60cea36 to b98e083 Compare May 17, 2021 17:49
@mshinwell
Copy link
Copy Markdown
Author

@lthls Would you be able to look at this one? It shouldn't take too long.

Copy link
Copy Markdown

@lthls lthls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. A few comments:

  • A number of calls to Continuation.create ~sort:Exn have been converted to Continuation.create ~sort:Normal_or_exn, but Normal_or_exn is the default value so the optional sort argument could be omitted.
  • During Cmm generation, if Clflags.debug is set to false then all raises will be compiled in notrace mode (see Cmm_helpers.raise_prim). We could do the same here.

@mshinwell
Copy link
Copy Markdown
Author

@lthls Comments addressed, thanks -- please merge once CI passes if you are happy.

@lthls
Copy link
Copy Markdown

lthls commented May 18, 2021

A small question: what's the meaning of a Pop action with raise_kind set to None ? I assumed it corresponded to normal exits out of trywith bodies, but I think it can sometimes correspond to a raise too (see inlining_transforms.ml, line 134 for an example).
Should we try to be more consistent about this ?

@mshinwell
Copy link
Copy Markdown
Author

Funnily enough I wondered the same thing this morning. I'll make a separate PR.

@mshinwell mshinwell merged commit d0d2a4b into ocaml-flambda:flambda2.0-stable May 18, 2021
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