[m-dev.] for review: more RTTI restructuring
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Apr 17 16:15:30 AEST 2000
Here's a relative diff addressing Zoltan's review comments.
I'll go ahead and commit this now.
--- old/CHANGES6 Mon Apr 17 16:10:50 2000
+++ ./CHANGES6 Mon Apr 17 16:13:15 2000
@@ -25,10 +25,12 @@
compiler/code_util.m:
Add new procedure `make_entry_label_from_rtti', for use by rtti_out.m.
Restructure the implementation of the predicates make_entry_label,
make_local_entry_label, and make_proc_label so that they work by first
calling rtti__make_proc_label.
+ Also update the documentation for code_util__compiler_generated,
+ adding an XXX comment saying that the name is misleading.
--- old/code_util.m Mon Apr 17 14:58:02 2000
+++ code_util.m Mon Apr 17 15:38:47 2000
@@ -97,6 +97,18 @@
:- pred code_util__negate_the_test(list(instruction), list(instruction)).
:- mode code_util__negate_the_test(in, out) is det.
+ % code_util__compiler_generated(PredInfo) succeeds iff
+ % the PredInfo is for a compiler generated instance of a
+ % type-specific special_pred (i.e. one of the __Unify__,
+ % __Index__, or __Compare__ predicates generated as a
+ % type-specific instance of unify/2, index/2, or compare/3).
+ %
+ % XXX The name of this predicate is misleading, because there
+ % are other kinds of compiler-generated predicates, e.g. those
+ % for lambda expressions, those generated by higher-order
+ % specialization, ordinary type specialization, deforestation,
+ % etc., for which this predicate does not succeed.
+
:- pred code_util__compiler_generated(pred_info).
:- mode code_util__compiler_generated(in) is semidet.
@@ -256,9 +268,10 @@
code_util__make_proc_label_from_rtti(RttiProcLabel, ProcLabel) :-
RttiProcLabel = rtti_proc_label(PredOrFunc, ThisModule,
PredModule, PredName, Arity, ArgTypes, _PredId, ProcId,
- IsImported, _IsPseudoImported, _IsExported),
+ IsImported, _IsPseudoImported, _IsExported,
+ IsSpecialPredInstance),
(
- special_pred_name_arity(_, _, PredName, Arity)
+ IsSpecialPredInstance = yes
->
(
special_pred_get_type(PredName, ArgTypes, Type),
@@ -377,9 +390,8 @@
%-----------------------------------------------------------------------------%
- % code_util__compiler_generated(PredInfo) should succeed iff
- % the PredInfo is for a compiler generated predicate.
-
+ % XXX The name of this predicate is misleading -- see the comment
+ % in the declaration.
code_util__compiler_generated(PredInfo) :-
pred_info_name(PredInfo, PredName),
pred_info_arity(PredInfo, PredArity),
--- old/ml_code_util.m Mon Apr 17 14:58:03 2000
+++ ml_code_util.m Mon Apr 17 15:39:58 2000
@@ -755,9 +755,9 @@
ml_gen_pred_label_from_rtti(RttiProcLabel, MLDS_PredLabel, MLDS_Module) :-
RttiProcLabel = rtti_proc_label(PredOrFunc, ThisModule, PredModule,
PredName, Arity, ArgTypes, _PredId, ProcId, IsImported,
- _IsPseudoImported, _IsExported),
+ _IsPseudoImported, _IsExported, IsSpecialPredInstance),
(
- special_pred_name_arity(_, _, PredName, Arity)
+ IsSpecialPredInstance = yes
->
(
special_pred_get_type(PredName, ArgTypes, Type),
--- old/rtti.m Mon Apr 17 14:58:03 2000
+++ rtti.m Mon Apr 17 16:07:05 2000
@@ -330,9 +330,27 @@
arg_types :: list(type),
pred_id :: pred_id,
proc_id :: proc_id,
- is_imported :: bool,
- is_pseudo_imported :: bool,
- is_exported :: bool
+ %
+ % The following booleans hold values computed from the
+ % pred_info, using procedures
+ % pred_info_is_imported/1,
+ % pred_info_is_pseudo_imported/1,
+ % pred_info_is_exported/1, and
+ % pred_info_is_compiler_generated/1
+ % respectively.
+ % We store booleans here, rather than storing the
+ % pred_info, to avoid retaining a reference to the
+ % parts of the pred_info that we aren't interested in,
+ % so that those parts can be garbage collected.
+ % We use booleans rather than an import_status
+ % so that we can continue to use the above-mentioned
+ % abstract interfaces rather than hard-coding tests
+ % on the import_status.
+ %
+ is_imported :: bool,
+ is_pseudo_imported :: bool,
+ is_exported :: bool,
+ is_special_pred_instance :: bool
).
% Construct an rtti_proc_label for a given procedure.
@@ -358,7 +376,10 @@
:- implementation.
-:- import_module llds_out, hlds_data, type_util.
+:- import_module code_util. % for code_util__compiler_defined
+:- import_module llds_out. % for name_mangle and sym_name_mangle
+:- import_module hlds_data, type_util.
+
:- import_module string, require.
rtti__make_proc_label(ModuleInfo, PredId, ProcId) = ProcLabel :-
@@ -372,9 +393,11 @@
IsImported = (pred_info_is_imported(PredInfo) -> yes ; no),
IsPseudoImp = (pred_info_is_pseudo_imported(PredInfo) -> yes ; no),
IsExported = (pred_info_is_exported(PredInfo) -> yes ; no),
+ IsSpecialPredInstance =
+ (code_util__compiler_generated(PredInfo) -> yes ; no),
ProcLabel = rtti_proc_label(PredOrFunc, ThisModule, PredModule,
- PredName, Arity, ArgTypes, PredId, ProcId,
- IsImported, IsPseudoImp, IsExported).
+ PredName, Arity, ArgTypes, PredId, ProcId,
+ IsImported, IsPseudoImp, IsExported, IsSpecialPredInstance).
rtti__addr_to_string(RttiTypeId, RttiName, Str) :-
rtti__mangle_rtti_type_id(RttiTypeId, ModuleName, TypeName, A_str),
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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