-
Notifications
You must be signed in to change notification settings - Fork 86
Refactor primitive handling in Lambda_to_flambda #1382
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Refactor primitive handling in Lambda_to_flambda #1382
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good, I wonder what the effect of use-visible lets is however. I think we might need to modify close_raise
to avoid the duplicated constants (see comments).
let close_raise acc env ~raise_kind ~arg loc exn_continuation = | ||
let acc, exn_cont = close_exn_continuation acc env exn_continuation in | ||
let exn_handler = Exn_continuation.exn_handler exn_cont in | ||
let acc, arg = find_simple acc env arg in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we already do let acc, args = find_simples acc env args
in close_primitive
, I think this might duplicate the definition of the constant corresponding to the argument if it is one.
in | ||
let raise_kind = Some (Trap_action.Raise_kind.from_lambda raise_kind) in | ||
let trap_action = Trap_action.Pop { exn_handler; raise_kind } in | ||
let dbg = Debuginfo.from_location loc in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to do that rather than give dbg
as an argument (which is already known in one of the use sites) ?
@@ -1430,9 +1430,12 @@ let primitive_result_layout (p : primitive) = | |||
| Paddfloat _ | Psubfloat _ | Pmulfloat _ | Pdivfloat _ | |||
| Pbox_float _ -> layout_float | |||
| Punbox_float -> Punboxed_float | |||
| Pccall _p -> | |||
(* CR ncourant: use native_repr *) | |||
| Pccall { prim_native_repr_res = _, Untagged_int; _} ->layout_int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Pccall { prim_native_repr_res = _, Untagged_int; _} ->layout_int | |
| Pccall { prim_native_repr_res = _, Untagged_int; _} -> layout_int |
@@ -1430,9 +1430,12 @@ let primitive_result_layout (p : primitive) = | |||
| Paddfloat _ | Psubfloat _ | Pmulfloat _ | Pdivfloat _ | |||
| Pbox_float _ -> layout_float | |||
| Punbox_float -> Punboxed_float | |||
| Pccall _p -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add a case Pccall _ when not !Clflags.native_code -> layout_any_value
?
This is now in #1465 and the comments have been addressed there. |
This allows us to remove the
primitive_result_kind
function together with some duplicate code (callingtransform_primitive
).