[m-dev.] for review: type specialisation
Simon Taylor
stayl at cs.mu.OZ.AU
Thu Sep 3 11:52:03 AEST 1998
> > Added polymorphism__typeclass_info_class_constraint to get the
> > class_constraint from a typeclass_info's type. This isn't used yet.
> > In extract_type_info, an entry in the type_info_var_map
> > was being overwritten using an entry from a dummy typevarset.
>
> Does the last sentence describe a change unrelated to the other stuff?
> If so, it would be helpful to seperate it a bit more clearly in the
> log message, e.g. make it a new paragraph and insert "Also, fix a bug: "
> at the start.
OK.
>
> > compiler/higher_order.m:
> ...
> > Specialize calls to unify/2, index/2 and compare/3.
> > Specialize class_method_calls.
> > Interpret the predicates in private_builtin.m which manipulate
> > typeclass_infos.
>
> "Interpret" is a bit unclear here. Do you mean "Specialize calls to"?
> If so, I think that way of phrasing it would be clearer.
OK.
> The role of higher_order.m seems to be a bit more general now.
> Perhaps higher_order.m should be renamed specialize.m?
If you want, although the name specialize.m suggests something a bit
more general than what higher_order.m does, and there will be other
modules to perform different types of specialization such as constraint
propagation and partial deduction.
>
> > Index: compiler/higher_order.m
> > +:- pred specialize_higher_order(bool::in, bool::in,
> > + module_info::in, module_info::out,
> > + io__state::di, io__state::uo) is det.
>
> You should document the meaning of the `bool' arguments here.
+ % specialize_higher_order(DoHigherOrder, DoTypeInfos, Module0, Module).
+ % DoHigherOrder is the value of `--optimize-higher-order'.
+ % DoTypeInfos is the value of `--type-specialization'
>
> > +traverse_goal_0(Goal0, Goal, Info0, Info) :-
> > + Info0 = info(_, B, NewPreds0, PredProcId, E, F, G, H, I),
> > + NewPreds0 = new_preds(_, PredVarMap),
> > + % Lookup the initial known bindings of the variables if this
> > + % procedure is a specialised version..
>
> s/.././ ?
>
> > @@ -586,63 +653,67 @@
> > ;
> > error("higher_order.m: call expected")
> > ),
> > - module_info_pred_info(Module, CalledPred, PredInfo),
> > + module_info_pred_info(Module, CalledPred, CalleePredInfo),
> > (
> > - pred_info_is_imported(PredInfo)
> > + % Look for calls to unify/2 and compare/3 which can
> > + % be specialized.
> > + specialize_builtin(Info0, CalledPred, CalledProc,
> > + Args0, MaybeContext, Goal1)
>
> The predicates unify/2, compare/3, and index are generally called
> "special preds" rather than "builtins", so I suggest `specialize_builtin'
> be renamed `specialize_special_pred'.
OK.
>
> > + % Interpret a call to `type_info_from_typeclass_info' or
> > + % `superclass_from_typeclass_info'. Currently they both have
> > + % the same definition. This should be kept in sync with
> > + % compiler/polymorphism.m and runtime/mercury_type_info.h.
> > +:- pred interpret_typeclass_info_manipulator(typeclass_info_manipulator::in,
>
> You should put comments in both of those places too,
> saying that they should be kept in sync with this.
>
compiler/polymorphism.m:
%
% IMPORTANT: ANY CHANGES TO THE DOCUMENTATION HERE MUST BE REFLECTED BY
-% SIMILAR CHANGES TO THE #defines IN "runtime/type_info.h"
-% AND VICE VERSA.
+% SIMILAR CHANGES TO THE #defines IN "runtime/mercury_type_info.h" AND
+% TO THE TYPE SPECIALIZATION CODE IN "compiler/higher_order.m".
library/private_builtin.m:
@@ -35,6 +35,8 @@
% The following are used by the compiler, to implement polymorphism.
% They should not be used in programs.
+% Changes here may also require changes in compiler/polymorphism.m,
+% compiler/higher_order.m and runtime/mercury_type_info.{c,h}.
runtime/mercury_type_info.h:
+** Changes here may also require changes in compiler/polymorphism.m,
+** compiler/higher_order.m and library/private_builtin.m.
Simon.
More information about the developers
mailing list