[m-dev.] trivial diff: save memory in mode_checkpoint and typecheck__checkpoint
Simon Taylor
stayl at cs.mu.OZ.AU
Wed Nov 15 11:50:04 AEDT 2000
Estimated hours taken: 0.1
compiler/mode_debug.m:
compiler/typecheck.m
Use the globals stored in the module_info rather than in the
io__state to look up the --debug-modes or --debug-types options.
This saves memory by avoiding updating the io__state in the
mode_info or typecheck_info.
Index: mode_debug.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mode_debug.m,v
retrieving revision 1.12
diff -u -u -r1.12 mode_debug.m
--- mode_debug.m 1998/11/20 04:08:25 1.12
+++ mode_debug.m 2000/11/15 00:28:55
@@ -33,30 +33,30 @@
%-----------------------------------------------------------------------------%
:- implementation.
-:- import_module globals, std_util, list, assoc_list, io, bool, map.
+:- import_module std_util, list, assoc_list, io, bool, map.
:- import_module term, varset.
-:- import_module modes, options, mercury_to_mercury, passes_aux.
-:- import_module hlds_goal, instmap, prog_data, (inst).
+:- import_module modes, globals, options, mercury_to_mercury, passes_aux.
+:- import_module hlds_goal, hlds_module, instmap, prog_data, (inst).
%-----------------------------------------------------------------------------%
% This code is used to trace the actions of the mode checker.
mode_checkpoint(Port, Msg, ModeInfo0, ModeInfo) :-
- mode_info_get_io_state(ModeInfo0, IOState0),
- globals__io_lookup_bool_option(debug_modes, DoCheckPoint,
- IOState0, IOState1),
+ mode_info_get_module_info(ModeInfo0, ModuleInfo),
+ module_info_globals(ModuleInfo, Globals),
+ globals__lookup_bool_option(Globals, debug_modes, DoCheckPoint),
( DoCheckPoint = yes ->
+ mode_info_get_io_state(ModeInfo0, IOState0),
mode_info_get_last_checkpoint_insts(ModeInfo0, OldInsts),
mode_checkpoint_2(Port, Msg, OldInsts, NewInsts, ModeInfo0,
- IOState1, IOState),
+ IOState0, IOState),
mode_info_set_last_checkpoint_insts(NewInsts, ModeInfo0,
- ModeInfo1)
+ ModeInfo1),
+ mode_info_set_io_state(ModeInfo1, IOState, ModeInfo)
;
- ModeInfo1 = ModeInfo0,
- IOState = IOState1
- ),
- mode_info_set_io_state(ModeInfo1, IOState, ModeInfo).
+ ModeInfo = ModeInfo0
+ ).
:- pred mode_checkpoint_2(port, string, assoc_list(prog_var, inst),
assoc_list(prog_var, inst), mode_info, io__state, io__state).
Index: typecheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.292
diff -u -u -r1.292 typecheck.m
--- typecheck.m 2000/11/06 04:09:06 1.292
+++ typecheck.m 2000/11/15 00:27:15
@@ -2033,14 +2033,16 @@
:- mode checkpoint(in, typecheck_info_di, typecheck_info_uo) is det.
checkpoint(Msg, T0, T) :-
- typecheck_info_get_io_state(T0, I0),
- globals__io_lookup_bool_option(debug_types, DoCheckPoint, I0, I1),
+ typecheck_info_get_module_info(T0, ModuleInfo),
+ module_info_globals(ModuleInfo, Globals),
+ globals__lookup_bool_option(Globals, debug_types, DoCheckPoint),
( DoCheckPoint = yes ->
- checkpoint_2(Msg, T0, I1, I)
+ typecheck_info_get_io_state(T0, I0),
+ checkpoint_2(Msg, T0, I0, I),
+ typecheck_info_set_io_state(T0, I, T)
;
- I = I1
- ),
- typecheck_info_set_io_state(T0, I, T).
+ T = T0
+ ).
:- pred checkpoint_2(string, typecheck_info, io__state, io__state).
:- mode checkpoint_2(in, typecheck_info_no_io, di, uo) is det.
--------------------------------------------------------------------------
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