[m-rev.] diff: variable renaming on sharing info for foreign procs
Peter Wang
novalazy at gmail.com
Fri May 9 15:45:16 AEST 2008
Estimated hours taken: 0.5
Branches: main
compiler/structure_sharing.domain.m:
When using the user-annotated structure sharing information from
foreign_procs, we need to rename the variables so that they
refer to the actual variables at the call site instead of formal
parameters. Change add_foreign_proc_sharing to do that.
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.indirect.m:
compiler/structure_sharing.analysis.m:
Update the callers.
Index: compiler/structure_reuse.direct.detect_garbage.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_reuse.direct.detect_garbage.m,v
retrieving revision 1.15
diff -u -r1.15 structure_reuse.direct.detect_garbage.m
--- compiler/structure_reuse.direct.detect_garbage.m 27 Mar 2008 02:29:42 -0000 1.15
+++ compiler/structure_reuse.direct.detect_garbage.m 9 May 2008 05:36:42 -0000
@@ -152,11 +152,11 @@
ThenSharingAs, ElseSharingAs)
;
GoalExpr = call_foreign_proc(Attributes, ForeignPredId, ForeignProcId,
- _Args, _ExtraArgs, _MaybeTraceRuntimeCond, _Impl),
+ Args, _ExtraArgs, _MaybeTraceRuntimeCond, _Impl),
+ ForeignPPId = proc(ForeignPredId, ForeignProcId),
Context = goal_info_get_context(GoalInfo),
- !:SharingAs = add_foreign_proc_sharing(ModuleInfo, ProcInfo,
- proc(ForeignPredId, ForeignProcId), Attributes, Context,
- !.SharingAs)
+ add_foreign_proc_sharing(ModuleInfo, PredInfo, ProcInfo, ForeignPPId,
+ Attributes, Args, Context, !SharingAs)
;
GoalExpr = shorthand(_),
% These should have been expanded out by now.
Index: compiler/structure_reuse.indirect.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_reuse.indirect.m,v
retrieving revision 1.23
diff -u -r1.23 structure_reuse.indirect.m
--- compiler/structure_reuse.indirect.m 7 May 2008 05:05:52 -0000 1.23
+++ compiler/structure_reuse.indirect.m 9 May 2008 04:58:18 -0000
@@ -463,12 +463,13 @@
!:Goal = hlds_goal(GoalExpr, GoalInfo0)
;
GoalExpr0 = call_foreign_proc(Attributes, ForeignPredId, ForeignProcId,
- _Args, _ExtraArgs, _MaybeTraceRuntimeCond, _Impl),
+ Args, _ExtraArgs, _MaybeTraceRuntimeCond, _Impl),
+ ForeignPPId = proc(ForeignPredId, ForeignProcId),
Context = goal_info_get_context(GoalInfo0),
- !IrInfo ^ sharing_as :=
- add_foreign_proc_sharing(ModuleInfo, ProcInfo,
- proc(ForeignPredId, ForeignProcId), Attributes, Context,
- !.IrInfo ^ sharing_as)
+ OldSharing = !.IrInfo ^ sharing_as,
+ add_foreign_proc_sharing(ModuleInfo, PredInfo, ProcInfo,
+ ForeignPPId, Attributes, Args, Context, OldSharing, NewSharing),
+ !IrInfo ^ sharing_as := NewSharing
;
GoalExpr0 = shorthand(_),
% These should have been expanded out by now.
Index: compiler/structure_sharing.analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_sharing.analysis.m,v
retrieving revision 1.32
diff -u -r1.32 structure_sharing.analysis.m
--- compiler/structure_sharing.analysis.m 7 May 2008 05:05:52 -0000 1.32
+++ compiler/structure_sharing.analysis.m 9 May 2008 04:57:47 -0000
@@ -643,11 +643,11 @@
ThenSharingAs, ElseSharingAs)
;
GoalExpr = call_foreign_proc(Attributes, ForeignPredId, ForeignProcId,
- _Args, _ExtraArgs, _MaybeTraceRuntimeCond, _Impl),
+ Args, _ExtraArgs, _MaybeTraceRuntimeCond, _Impl),
Context = goal_info_get_context(GoalInfo),
- !:SharingAs = add_foreign_proc_sharing(ModuleInfo, ProcInfo,
- proc(ForeignPredId, ForeignProcId), Attributes, Context,
- !.SharingAs)
+ ForeignPPId = proc(ForeignPredId, ForeignProcId),
+ add_foreign_proc_sharing(ModuleInfo, PredInfo, ProcInfo, ForeignPPId,
+ Attributes, Args, Context, !SharingAs)
;
GoalExpr = shorthand(_),
% These should have been expanded out by now.
Index: compiler/structure_sharing.domain.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_sharing.domain.m,v
retrieving revision 1.32
diff -u -r1.32 structure_sharing.domain.m
--- compiler/structure_sharing.domain.m 7 May 2008 05:05:52 -0000 1.32
+++ compiler/structure_sharing.domain.m 9 May 2008 05:35:40 -0000
@@ -154,8 +154,10 @@
% foreign code was manually annotated, or can be predicted to
% "bottom", and in the worst case to "top".
%
-:- func add_foreign_proc_sharing(module_info, proc_info, pred_proc_id,
- pragma_foreign_proc_attributes, prog_context, sharing_as) = sharing_as.
+:- pred add_foreign_proc_sharing(module_info::in, pred_info::in, proc_info::in,
+ pred_proc_id::in, pragma_foreign_proc_attributes::in,
+ list(foreign_arg)::in, prog_context::in, sharing_as::in, sharing_as::out)
+ is det.
% Compare two sharing sets. A sharing set Set1 is subsumed by a sharing set
% Set2 iff the total set of sharing represented by Set1 is a subset of the
@@ -611,11 +613,22 @@
set.to_sorted_list(Deaths, DeathsList),
sharing_as_project_with_type(outproject, DeathsList, Sharing0, Sharing).
-add_foreign_proc_sharing(ModuleInfo, ProcInfo, ForeignPPId,
- Attributes, GoalContext, OldSharing) = NewSharing :-
+add_foreign_proc_sharing(ModuleInfo, PredInfo, ProcInfo, ForeignPPId,
+ Attributes, Args, GoalContext, OldSharing, NewSharing) :-
ForeignSharing = sharing_as_for_foreign_proc(ModuleInfo,
Attributes, ForeignPPId, GoalContext),
- NewSharing = sharing_as_comb(ModuleInfo, ProcInfo, ForeignSharing,
+
+ ActualVars = list.map(foreign_arg_var, Args),
+ proc_info_get_vartypes(ProcInfo, VarTypes),
+ map.apply_to_list(ActualVars, VarTypes, ActualTypes),
+ pred_info_get_typevarset(PredInfo, CallerTypeVarSet),
+ pred_info_get_head_type_params(PredInfo, CallerHeadTypeParams),
+
+ sharing_as_rename_using_module_info(ModuleInfo, ForeignPPId,
+ ActualVars, ActualTypes, CallerTypeVarSet,
+ CallerHeadTypeParams, ForeignSharing, ActualSharing),
+
+ NewSharing = sharing_as_comb(ModuleInfo, ProcInfo, ActualSharing,
OldSharing).
:- func sharing_as_for_foreign_proc(module_info,
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list