for review: fix stack traces
Tyson Dowd
trd at cs.mu.OZ.AU
Thu Apr 16 17:43:34 AEST 1998
Hi,
Here are some changes needed to get stack traces working again.
Changes are also needed for the runtime -- see my next diff.
Probably best that Zoltan reviews this.
===================================================================
Estimated hours taken: 4
Fix stack traces, which were broken with recent tracing code changes.
compiler/continuation_info.m:
compiler/mercury_compile.m:
Collect continuation label information for stack traces, but
without the liveness information that is needed for agc.
compiler/stack_layout.m:
Add a comment stating that changes in this file may need to be
reflected in runtime/mercury_stack_layout.h
Index: compiler/continuation_info.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/continuation_info.m,v
retrieving revision 1.11
diff -u -r1.11 continuation_info.m
--- continuation_info.m 1998/04/08 11:31:26 1.11
+++ continuation_info.m 1998/04/15 10:37:17
@@ -47,7 +47,7 @@
:- interface.
:- import_module llds, hlds_pred, prog_data, hlds_data.
-:- import_module set, map, list, std_util.
+:- import_module set, map, list, std_util, bool.
%
% Information used by the continuation_info module.
@@ -135,15 +135,15 @@
% Call continuation_info__process_instructions on the code
% of every procedure in the list.
%
-:- pred continuation_info__process_llds(list(c_procedure)::in,
+:- pred continuation_info__process_llds(list(c_procedure)::in, bool::in,
continuation_info::in, continuation_info::out) is det.
%
% Add the information for all the continuation labels within a proc.
%
:- pred continuation_info__process_instructions(pred_proc_id::in,
- list(instruction)::in, continuation_info::in, continuation_info::out)
- is det.
+ list(instruction)::in, bool::in, continuation_info::in,
+ continuation_info::out) is det.
%
% Get the finished list of proc_layout_infos.
@@ -193,18 +193,19 @@
continuation_info__get_all_proc_layouts(ContInfo, Entries) :-
map__values(ContInfo, Entries).
-continuation_info__process_llds([]) --> [].
-continuation_info__process_llds([Proc | Procs]) -->
+continuation_info__process_llds([], _) --> [].
+continuation_info__process_llds([Proc | Procs], WantAgcInfo) -->
{ Proc = c_procedure(_, _, PredProcId, Instrs) },
- continuation_info__process_instructions(PredProcId, Instrs),
- continuation_info__process_llds(Procs).
+ continuation_info__process_instructions(PredProcId, Instrs,
+ WantAgcInfo),
+ continuation_info__process_llds(Procs, WantAgcInfo).
%
% Process the list of instructions for this proc, adding
% all internal label information to the continuation_info.
%
continuation_info__process_instructions(PredProcId, Instructions,
- ContInfo0, ContInfo) :-
+ WantAgcInfo, ContInfo0, ContInfo) :-
% Get all the continuation info from the call instructions.
map__lookup(ContInfo0, PredProcId, ProcLayoutInfo0),
@@ -216,8 +217,8 @@
list__filter_map(GetCallLivevals, Instructions, Calls),
% Process the continuation label info.
- list__foldl(continuation_info__process_continuation, Calls,
- Internals0, Internals),
+ list__foldl(continuation_info__process_continuation(WantAgcInfo),
+ Calls, Internals0, Internals),
ProcLayoutInfo = proc_layout_info(A, B, C, D, E, Internals),
map__det_update(ContInfo0, PredProcId, ProcLayoutInfo, ContInfo).
@@ -228,26 +229,30 @@
% Collect the liveness information from a single label and add
% it to the internals.
%
-:- pred continuation_info__process_continuation(
- pair(label, list(liveinfo))::in,
+:- pred continuation_info__process_continuation(bool::in,
+ pair(label, list(liveinfo))::in,
proc_label_layout_info::in, proc_label_layout_info::out) is det.
-continuation_info__process_continuation(Label - LiveInfoList,
+continuation_info__process_continuation(WantAgcInfo, Label - LiveInfoList,
Internals0, Internals) :-
- GetVarInfo = lambda([LiveLval::in, VarInfo::out] is det, (
- LiveLval = live_lvalue(Lval, LiveValueType, Name, _),
- VarInfo = var_info(Lval, LiveValueType, Name)
- )),
- list__map(GetVarInfo, LiveInfoList, VarInfoList),
- GetTypeInfo = lambda([LiveLval::in, TypeInfos::out] is det, (
- LiveLval = live_lvalue(_, _, _, TypeInfos)
- )),
- list__map(GetTypeInfo, LiveInfoList, TypeInfoListList),
- list__condense(TypeInfoListList, TypeInfoList),
- list__sort_and_remove_dups(TypeInfoList, SortedTypeInfoList),
- set__sorted_list_to_set(SortedTypeInfoList, TypeInfoSet),
- set__list_to_set(VarInfoList, VarInfoSet),
- NewInternal = yes(layout_label_info(VarInfoSet, TypeInfoSet)),
+ ( WantAgcInfo = yes ->
+ GetVarInfo = lambda([LiveLval::in, VarInfo::out] is det, (
+ LiveLval = live_lvalue(Lval, LiveValueType, Name, _),
+ VarInfo = var_info(Lval, LiveValueType, Name)
+ )),
+ list__map(GetVarInfo, LiveInfoList, VarInfoList),
+ GetTypeInfo = lambda([LiveLval::in, TypeInfos::out] is det, (
+ LiveLval = live_lvalue(_, _, _, TypeInfos)
+ )),
+ list__map(GetTypeInfo, LiveInfoList, TypeInfoListList),
+ list__condense(TypeInfoListList, TypeInfoList),
+ list__sort_and_remove_dups(TypeInfoList, SortedTypeInfoList),
+ set__sorted_list_to_set(SortedTypeInfoList, TypeInfoSet),
+ set__list_to_set(VarInfoList, VarInfoSet),
+ NewInternal = yes(layout_label_info(VarInfoSet, TypeInfoSet))
+ ;
+ NewInternal = no
+ ),
continuation_info__add_internal_info(Label, NewInternal,
Internals0, Internals).
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/mercury_compile.m,v
retrieving revision 1.83
diff -u -r1.83 mercury_compile.m
--- mercury_compile.m 1998/04/08 11:32:03 1.83
+++ mercury_compile.m 1998/04/15 10:10:42
@@ -997,16 +997,18 @@
;
{ Proc = Proc0 }
),
- { globals__lookup_bool_option(Globals, agc_stack_layout,
- AgcStackLayout) },
- ( { AgcStackLayout = yes } ->
+ { globals__lookup_bool_option(Globals, basic_stack_layout,
+ BasicStackLayout) },
+ ( { BasicStackLayout = yes } ->
{ Proc = c_procedure(_, _, PredProcId, Instructions) },
{ module_info_get_continuation_info(ModuleInfo5, ContInfo2) },
+ { globals__lookup_bool_option(Globals, agc_stack_layout,
+ AgcStackLayout) },
write_proc_progress_message(
"% Generating call continuation information for ",
PredId, ProcId, ModuleInfo5),
{ continuation_info__process_instructions(PredProcId,
- Instructions, ContInfo2, ContInfo3) },
+ Instructions, AgcStackLayout, ContInfo2, ContInfo3) },
{ module_info_set_continuation_info(ModuleInfo5, ContInfo3,
ModuleInfo) }
;
@@ -1631,13 +1633,15 @@
mercury_compile__maybe_generate_stack_layouts(ModuleInfo0, LLDS0, Verbose,
Stats, ModuleInfo) -->
- globals__io_lookup_bool_option(agc_stack_layout, AgcStackLayout),
- ( { AgcStackLayout = yes } ->
+ globals__io_lookup_bool_option(basic_stack_layout, BasicStackLayout),
+ ( { BasicStackLayout = yes } ->
maybe_write_string(Verbose,
"% Generating call continuation information..."),
maybe_flush_output(Verbose),
+ globals__io_lookup_bool_option(agc_stack_layout,
+ AgcStackLayout),
{ module_info_get_continuation_info(ModuleInfo0, ContInfo0) },
- { continuation_info__process_llds(LLDS0,
+ { continuation_info__process_llds(LLDS0, AgcStackLayout,
ContInfo0, ContInfo) },
{ module_info_set_continuation_info(ModuleInfo0, ContInfo,
ModuleInfo) },
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/stack_layout.m,v
retrieving revision 1.10
diff -u -r1.10 stack_layout.m
--- stack_layout.m 1998/04/08 11:32:17 1.10
+++ stack_layout.m 1998/04/16 06:07:59
@@ -17,6 +17,9 @@
% Main author: trd.
% Modifications by zs.
%
+% NOTE: If you make changes in this file, you may also need to modify
+% runtime/mercury_stack_layout.h
+%
%---------------------------------------------------------------------------%
%
% Data Stucture: stack_layouts
--
Tyson Dowd # There isn't any reason why Linux can't be
# implemented as an enterprise computing solution.
trd at cs.mu.oz.au # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.
More information about the developers
mailing list