[m-dev.] for review: a proper fix for contexts at exception events
Zoltan Somogyi
zs at cs.mu.OZ.AU
Thu Dec 16 18:53:58 AEDT 1999
For review by Fergus or Tyson.
This change is being bootchecked in ~zs/mer/ws6 on ender. If that succeeds,
Fergus may wish to commit this before the nightly checks tonight.
Estimated hours taken: 4
Fix the problem with contexts at exception ports in a way that (unlike Fergus's
fix) does not slow down the speed-critical code path inside the debugger.
compiler/stack_layout.m:
When generating label layouts for return labels, give the two fields
of the layout structure that correspond to arguments of the old
four-argument MR_trace() values that are appropriate for use in
exception events, i.e. port is exception and goal path is empty.
compiler/llds.m:
compiler/llds_out.m:
Add exception to the trace port type, since the compiler now refers
to it.
runtime/mercury_stack_layout.h:
trace/mercury_trace.c:
Undo Fergus's change.
library/exception.m:
Undo Fergus's change, and my change previous to that. Pass the
return layout to MR_trace unchanged, after checking that it indeed
specifies an exception port.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.254
diff -u -b -r1.254 llds.m
--- compiler/llds.m 1999/12/14 04:52:43 1.254
+++ compiler/llds.m 1999/12/16 06:23:56
@@ -512,16 +512,15 @@
; gc
.
- % The kinds of ports for which the code we generate will
- % call MR_trace. The exception port is not on this list, because for
- % that port the code that calls MR_trace is not in compiler-generated
- % code, but in the runtime system. (The same comment applies to the
- % type `external_trace_port' in trace.m.)
+ % The kinds of events with which MR_trace may be called, either
+ % by compiler-generated code, or by code in the standard library
+ % referring to compiler-generated data structures.
:- type trace_port
---> call
; exit
; fail
; redo
+ ; exception
; ite_cond
; ite_then
; ite_else
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.132
diff -u -b -r1.132 llds_out.m
--- compiler/llds_out.m 1999/12/14 04:52:45 1.132
+++ compiler/llds_out.m 1999/12/16 06:24:48
@@ -837,6 +837,7 @@
llds_out__trace_port_to_string(exit, "MR_PORT_EXIT").
llds_out__trace_port_to_string(redo, "MR_PORT_REDO").
llds_out__trace_port_to_string(fail, "MR_PORT_FAIL").
+llds_out__trace_port_to_string(exception, "MR_PORT_EXCEPTION").
llds_out__trace_port_to_string(ite_cond, "MR_PORT_COND").
llds_out__trace_port_to_string(ite_then, "MR_PORT_THEN").
llds_out__trace_port_to_string(ite_else, "MR_PORT_ELSE").
@@ -852,7 +853,8 @@
llds_out__trace_port_to_num(exit, 1).
llds_out__trace_port_to_num(redo, 2).
llds_out__trace_port_to_num(fail, 3).
-llds_out__trace_port_to_num(ite_cond, 5). % exception is 4
+llds_out__trace_port_to_num(exception, 4).
+llds_out__trace_port_to_num(ite_cond, 5).
llds_out__trace_port_to_num(ite_then, 6).
llds_out__trace_port_to_num(ite_else, 7).
llds_out__trace_port_to_num(neg_enter, 8).
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.41
diff -u -b -r1.41 stack_layout.m
--- compiler/stack_layout.m 1999/12/14 04:52:58 1.41
+++ compiler/stack_layout.m 1999/12/16 07:31:22
@@ -838,19 +838,11 @@
(
{ Trace = no },
{ set__init(TraceLiveVarSet) },
- { map__init(TraceTypeVarMap) },
- { TraceRvals = [yes(const(int_const(-1))),
- yes(const(int_const(-1)))] }
+ { map__init(TraceTypeVarMap) }
;
- { Trace = yes(trace_port_layout_info(_, Port, Path,
- TraceLayout)) },
+ { Trace = yes(trace_port_layout_info(_, _, _, TraceLayout)) },
{ TraceLayout = layout_label_info(TraceLiveVarSet,
- TraceTypeVarMap) },
- { llds_out__trace_port_to_num(Port, PortNum) },
- { trace__path_to_string(Path, PathStr) },
- stack_layout__lookup_string_in_table(PathStr, PathNum),
- { TraceRvals = [yes(const(int_const(PortNum))),
- yes(const(int_const(PathNum)))] }
+ TraceTypeVarMap) }
),
{ TraceArgTypes = [2 - yes(int_least16)] },
{
@@ -862,6 +854,31 @@
ResumeLayout = layout_label_info(ResumeLiveVarSet,
ResumeTypeVarMap)
},
+ (
+ { Trace = yes(trace_port_layout_info(_, Port, Path, _)) },
+ { Return = no },
+ { llds_out__trace_port_to_num(Port, PortNum) },
+ { trace__path_to_string(Path, PathStr) },
+ stack_layout__lookup_string_in_table(PathStr, PathNum)
+ ;
+ { Trace = no },
+ { Return = yes(_) },
+ % We only ever use the port and path fields of these
+ % layout structures when we process exception events.
+ { llds_out__trace_port_to_num(exception, PortNum) },
+ { PathNum = 0 }
+ ;
+ { Trace = no },
+ { Return = no },
+ { PortNum = -1 },
+ { PathNum = -1 }
+ ;
+ { Trace = yes(_) },
+ { Return = yes(_) },
+ { error("label has both trace and return layout info") }
+ ),
+ { TraceRvals = [yes(const(int_const(PortNum))),
+ yes(const(int_const(PathNum)))] },
stack_layout__get_agc_stack_layout(AgcStackLayout),
{
Return = no,
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.9
diff -u -b -r1.9 exception.m
--- library/exception.m 1999/12/15 19:15:13 1.9
+++ library/exception.m 1999/12/16 07:41:33
@@ -506,7 +506,6 @@
Code *MR_jumpaddr;
MR_Stack_Walk_Step_Result result;
const char *problem;
- MR_Exception_Layout exception_layout;
/*
** check if we've reached a frame with an exception handler
@@ -520,24 +519,13 @@
}
/*
- ** Note: this is a structure assignment, but we must avoid
- ** using gcc's builtin memcpy, since that causes errors due
- ** to our use of a reserved register.
- **
- ** Note also that the goal path is an index into the
- ** module-wide string table; the string at index 0 will
- ** always be the empty string.
- */
- MR_memcpy(&exception_layout.MR_el_layout, return_label_layout,
- sizeof(exception_layout));
- exception_layout.MR_el_layout.MR_sll_port = MR_PORT_EXCEPTION;
- exception_layout.MR_el_layout.MR_sll_goal_path = 0;
- exception_layout.MR_el_return_layout = return_label_layout;
-
- /*
** invoke MR_trace() to trace the exception
*/
- MR_jumpaddr = MR_trace(&exception_layout.MR_el_layout);
+ if (return_label_layout->MR_sll_port != MR_PORT_EXCEPTION) {
+ fatal_error(""return layout port is not exception"");
+ }
+
+ MR_jumpaddr = MR_trace(return_label_layout);
if (MR_jumpaddr != NULL) {
return MR_jumpaddr;
}
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/mercury_stack_layout.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_layout.h,v
retrieving revision 1.34
diff -u -b -r1.34 mercury_stack_layout.h
--- runtime/mercury_stack_layout.h 1999/12/15 19:15:20 1.34
+++ runtime/mercury_stack_layout.h 1999/12/16 05:16:45
@@ -555,20 +555,6 @@
/*-------------------------------------------------------------------------*/
/*
-** Definitions for MR_Exception_Layout
-**
-** The first field will be a copy of the stack layout for the return label,
-** with the port changed to `MR_PORT_EXCEPTION', and with an empty goal path.
-** The second field will hold the address of the original return label layout.
-*/
-
-typedef struct MR_Exception_Layout_Struct {
- MR_Stack_Layout_Label MR_el_layout;
- MR_Stack_Layout_Label *MR_el_return_layout;
-} MR_Exception_Layout;
-
-/*-------------------------------------------------------------------------*/
-/*
** Definitions for MR_Module_Layout
**
** The layout struct for a module contains three main components.
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.18
diff -u -b -r1.18 mercury_trace.c
--- trace/mercury_trace.c 1999/12/15 19:15:25 1.18
+++ trace/mercury_trace.c 1999/12/16 07:21:57
@@ -216,20 +216,6 @@
*/
port = (MR_Trace_Port) layout->MR_sll_port;
- if (port == MR_PORT_EXCEPTION) {
- /*
- ** `layout' has the correct values, but the wrong
- ** address -- its address won't be in the module
- ** layout table, so MR_event_matches_spy_point()
- ** won't find it. Now that we've already
- ** extracted the port, we can use the return
- ** layout, which does have the correct address
- ** (but the wrong port and path; the path is
- ** not used here).
- */
- layout = ((const MR_Exception_Layout *) layout)
- ->MR_el_return_layout;
- }
match = MR_event_matches_spy_point(layout, port, &action);
if (! match) {
if (MR_trace_ctrl.MR_trace_print_level ==
@@ -279,25 +265,9 @@
event_info.MR_call_seqno = seqno;
event_info.MR_call_depth = depth;
event_info.MR_trace_port = port;
-
+ event_info.MR_event_sll = layout;
event_info.MR_event_path = layout->MR_sll_entry->MR_sle_module_layout
->MR_ml_string_table + layout->MR_sll_goal_path;
-
- if (port == MR_PORT_EXCEPTION) {
- /*
- ** `layout' has the correct values, but the
- ** wrong address -- its address won't be in the
- ** module layout table, so MR_find_context() etc.
- ** won't find it. Now that we've already
- ** extracted the port and path, we can use the return
- ** layout, which does have the correct address
- ** (but the wrong port and path).
- */
- layout = ((const MR_Exception_Layout *) layout)
- ->MR_el_return_layout;
- }
-
- event_info.MR_event_sll = layout;
max_r_num = layout->MR_sll_entry->MR_sle_max_r_num;
if (max_r_num + MR_NUM_SPECIAL_REG > MR_MAX_SPECIAL_REG_MR) {
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
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