Refactor primitive handling in Lambda_to_flambda#1382
Refactor primitive handling in Lambda_to_flambda#1382mshinwell wants to merge 1 commit intooxcaml:mainfrom
Conversation
Ekdohibs
left a comment
There was a problem hiding this comment.
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.
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.
Is there any reason to do that rather than give dbg as an argument (which is already known in one of the use sites) ?
| | 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.
| | Pccall { prim_native_repr_res = _, Untagged_int; _} ->layout_int | |
| | Pccall { prim_native_repr_res = _, Untagged_int; _} -> layout_int |
| | Paddfloat _ | Psubfloat _ | Pmulfloat _ | Pdivfloat _ | ||
| | Pbox_float _ -> layout_float | ||
| | Punbox_float -> Punboxed_float | ||
| | Pccall _p -> |
There was a problem hiding this comment.
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_kindfunction together with some duplicate code (callingtransform_primitive).