[m-dev.] for review: type specialization (relative) [1]
Simon Taylor
stayl at cs.mu.OZ.AU
Thu Apr 22 16:27:37 AEST 1999
diff -u --recursive ./compiler/check_typeclass.m /home/pgrad/stayl/mercury0/compiler/check_typeclass.m
--- ./compiler/check_typeclass.m Mon Feb 15 18:13:22 1999
+++ /home/pgrad/stayl/mercury0/compiler/check_typeclass.m Thu Apr 22 12:18:08 1999
@@ -55,6 +55,10 @@
io__state, io__state).
:- mode check_typeclass__check_instance_decls(in, out, out, di, uo) is det.
+ % The prefix added to the class method name for the predicate
+ % used to call a class method for a specific instance.
+:- func check_typeclass__introduced_pred_name_prefix = string.
+
:- implementation.
:- import_module map, list, std_util, hlds_pred, hlds_data, prog_data, require.
@@ -612,13 +616,15 @@
base_typeclass_info__make_instance_string(InstanceTypes,
InstanceString),
string__append_list(
- ["Introduced_pred_for_",
+ [check_typeclass__introduced_pred_name_prefix,
ClassNameString, "__",
InstanceString, "____",
MethodNameString, "_",
PredArityString],
PredNameString),
PredName = unqualified(PredNameString).
+
+check_typeclass__introduced_pred_name_prefix = "Introduced_pred_for_".
%---------------------------------------------------------------------------%
--- compiler/higher_order.m Thu Apr 22 14:42:57 1999
+++ /home/pgrad/stayl/mercury0/compiler/higher_order.m Thu Apr 22 16:22:13 1999
@@ -39,7 +39,7 @@
:- import_module code_util, globals, make_hlds, mode_util, goal_util.
:- import_module type_util, options, prog_data, prog_out, quantification.
:- import_module mercury_to_mercury, inlining, polymorphism, prog_util.
-:- import_module special_pred, passes_aux.
+:- import_module special_pred, passes_aux, check_typeclass.
:- import_module assoc_list, bool, char, int, list, map, require, set.
:- import_module std_util, string, varset, term.
@@ -73,6 +73,7 @@
{ set__list_to_set(PredIds0, PredIdSet0) },
{ set__difference(PredIdSet0, UserSpecPreds, PredIdSet) },
{ set__to_sorted_list(PredIdSet, PredIds) },
+
{ set__init(Requests0) },
{ set__to_sorted_list(UserSpecPreds, UserSpecPredList) },
{ get_specialization_requests(Params, UserSpecPredList, NewPreds0,
@@ -731,7 +732,7 @@
ExtractArgPredId = ExtractArgPredId0
;
error(
- "higher_order.m: can't find `instance-constraint_from_typeclass_info'")
+ "higher_order.m: can't find `instance_constraint_from_typeclass_info'")
),
hlds_pred__initial_proc_id(ExtractArgProcId),
get_arg_typeclass_infos(PredVar, ExtractArgPredId,
@@ -794,7 +795,7 @@
% Build calls to
% `private_builtin:instance_constraint_from_typeclass_info/3'
% to extract the typeclass_infos for the constraints on an instance.
- % This simulates the action of `do_call_*_class_method' in
+ % This simulates the action of `do_call_class_method' in
% runtime/mercury_ho_call.c.
:- pred get_arg_typeclass_infos(prog_var::in, pred_id::in, proc_id::in,
sym_name::in, list(class_constraint)::in, int::in,
@@ -1135,10 +1136,11 @@
CalledPred, CalledPredInfo),
\+ pred_info_is_imported(CalledPredInfo),
(
- % This handles the introduced predicates
- % which call class methods. Without this,
- % user-specified specialized versions of
- % class methods won't be called.
+ % This handles the predicates introduced
+ % by check_typeclass.m to call the class
+ % methods for a specific instance.
+ % Without this, user-specified specialized
+ % versions of class methods won't be called.
UserTypeSpec = yes,
(
pred_info_get_markers(CalledPredInfo,
@@ -1148,7 +1150,7 @@
pred_info_name(CalledPredInfo,
CalledPredName),
string__prefix(CalledPredName,
- "Introduced_")
+ check_typeclass__introduced_pred_name_prefix)
)
;
HigherOrder = yes,
@@ -1615,12 +1617,12 @@
;
{ FilteredRequests1 = FilteredRequests0 },
maybe_write_string(VeryVerbose,
- "% Not specializing (recursive specialization):\n")
+ "% Not specializing (recursive specialization).\n")
)
;
{ FilteredRequests1 = FilteredRequests0 },
maybe_write_string(VeryVerbose,
- "% Not specializing (goal too large):\n")
+ "% Not specializing (goal too large).\n")
),
filter_requests_2(Params, ModuleInfo, Requests0, GoalSizes,
FilteredRequests1, FilteredRequests).
--- compiler/hlds_goal.m Thu Apr 22 14:42:57 1999
+++ /home/pgrad/stayl/mercury0/compiler/hlds_goal.m Thu Apr 22 16:26:10 1999
@@ -717,6 +717,10 @@
%
% Produce a goal to construct a given constant.
+ % These predicates all fill in the non-locals, instmap_delta
+ % and determinism fields of the goal_info of the returned goal.
+ % With alias tracking, the instmap_delta will be correct
+ % only if the variable being assigned to has no aliases.
%
:- pred make_int_const_construction(prog_var, int, hlds_goal).
diff -u --recursive ./compiler/make_hlds.m /home/pgrad/stayl/mercury0/compiler/make_hlds.m
--- ./compiler/make_hlds.m Thu Apr 22 14:42:57 1999
+++ /home/pgrad/stayl/mercury0/compiler/make_hlds.m Wed Apr 21 15:25:59 1999
@@ -920,7 +920,9 @@
% A type substitution is invalid if:
% - it substitutes unknown type variables
% - it substitutes existentially quantified type variables
- % - the replacement types are not ground
+ % Type substitutions are also invalid if the replacement types are
+ % not ground, however this is a (hopefully temporary) limitation
+ % of the current implementation, so it only results in a warning.
:- pred handle_pragma_type_spec_subst(prog_context, assoc_list(tvar, type),
tvarset, pred_info, tvarset, list(type), existq_tvars,
class_constraints, bool, module_info, module_info,
@@ -1052,7 +1054,11 @@
io__write_string(
" warning: the substitution does not make the substituted\n"),
prog_out__write_context(Context),
- io__write_string(" types ground. The declaration will be ignored.\n").
+ io__write_string(" types ground. The declaration will be ignored.\n"),
+ prog_out__write_context(Context),
+ io__write_string(
+ " This is a limitation of the current implementation\n"),
+ prog_out__write_context(Context),
+ io__write_string(" which may be removed in a future release.\n").
:- pred report_unknown_vars_to_subst(pred_info, prog_context, tvarset,
list(tvar), io__state, io__state).
diff -u --recursive ./compiler/options.m /home/pgrad/stayl/mercury0/compiler/options.m
--- ./compiler/options.m Thu Apr 22 14:42:57 1999
+++ /home/pgrad/stayl/mercury0/compiler/options.m Thu Apr 22 11:43:56 1999
@@ -1217,6 +1217,8 @@
inline_single_use - bool(yes),
inline_compound_threshold - int(10),
common_struct - bool(yes),
+ user_guided_type_specialization
+ - bool(yes),
/****
% XXX optimize_duplicate_calls is broken --
% it doesn't take type information into account.
@@ -1236,8 +1238,6 @@
optimize_saved_vars - bool(yes),
optimize_unused_args - bool(yes),
optimize_higher_order - bool(yes),
- user_guided_type_specialization
- - bool(yes),
deforestation - bool(yes),
constant_propagation - bool(yes),
optimize_repeat - int(4)
diff -u --recursive ./compiler/prog_io_pragma.m /home/pgrad/stayl/mercury0/compiler/prog_io_pragma.m
--- ./compiler/prog_io_pragma.m Thu Apr 22 14:42:57 1999
+++ /home/pgrad/stayl/mercury0/compiler/prog_io_pragma.m Wed Apr 21 11:14:41 1999
@@ -614,7 +614,8 @@
->
Result = Result0
;
- Result = error("syntax error in `:- pragma termination_info'",
+ Result = error(
+ "syntax error in `:- pragma termination_info' declaration",
ErrorTerm)
).
--- tests/invalid/type_spec.err_exp Thu Apr 22 16:17:39 1999
+++ /home/pgrad/stayl/mercury0/tests/invalid/type_spec.err_exp Thu Apr 22 14:45:36 1999
@@ -5,6 +5,8 @@
type_spec.m:012: In `:- pragma type_spec' declaration for predicate `type_spec:type_spec1/1':
type_spec.m:012: warning: the substitution does not make the substituted
type_spec.m:012: types ground. The declaration will be ignored.
+type_spec.m:012: This is a limitation of the current implementation
+type_spec.m:012: which may be removed in a future release.
type_spec.m:013: Error: `:- pragma type_spec' declaration for type_spec:type_spec1/2
type_spec.m:013: without corresponding `pred' or `func' declaration.
type_spec.m:024: In `:- pragma type_spec' declaration for predicate `type_spec:type_spec2/1':
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list