[m-rev.] for review: MR_table_detfr_slot
Zoltan Somogyi
zs at cs.mu.OZ.AU
Sun Aug 18 16:36:58 AEST 2002
For review by anyone. The following diff uses -b; all the weird formatting
in the diff is because of this.
Zoltan.
In minimal model grades, add an extra slot to nondet stack frames containing
the value of MR_sp when the stack frame is created. This will be necessary
in future changes that manipulate stack segments.
runtime/mercury_stacks.h:
Add the extra slot in nondet stack frames in minimal model grades.
Rename the similar slot in temp frames from MR_detfr_slot to
MR_tmp_detfr_slot; the new slot is MR_table_detfr_slot.
Decrease the level of indentation of macro bodies where this was
becoming a problem.
runtime/mercury_agc_debug.c:
runtime/mercury_stack_trace.c:
Conform to the changes in mercury_stacks.h.
runtime/mercury_stack_trace.c:
Switch to four-space indentation to cope with the increased demands on
indentation.
cvs diff: Diffing .
Index: mercury_accurate_gc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_accurate_gc.c,v
retrieving revision 1.22
diff -u -b -r1.22 mercury_accurate_gc.c
--- mercury_accurate_gc.c 2002/08/02 08:13:33 1.22
+++ mercury_accurate_gc.c 2002/08/16 08:04:18
@@ -587,7 +587,7 @@
printlabel(MR_redoip_slot(max_frame));
fflush(NULL);
}
- stack_pointer = MR_detfr_slot(max_frame); /* XXX ??? */
+ stack_pointer = MR_tmp_detfr_slot(max_frame); /* XXX ??? */
} else {
if (MR_agc_debug) {
printlabel(MR_redoip_slot(max_frame));
Index: mercury_agc_debug.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_agc_debug.c,v
retrieving revision 1.20
diff -u -b -r1.20 mercury_agc_debug.c
--- mercury_agc_debug.c 2002/03/27 07:35:33 1.20
+++ mercury_agc_debug.c 2002/08/16 08:04:18
@@ -109,7 +109,7 @@
fprintf(stderr, " redofr: %p\n",
MR_redofr_slot(max_frame));
fprintf(stderr, " detfr: %p\n",
- MR_detfr_slot(max_frame));
+ MR_tmp_detfr_slot(max_frame));
label = MR_lookup_internal_by_addr(MR_redoip_slot(
max_frame));
@@ -117,7 +117,8 @@
if (label && label->i_layout) {
dump_live_variables(label->i_layout, heap_zone,
registers_valid,
- MR_detfr_slot(max_frame), max_frame);
+ MR_tmp_detfr_slot(max_frame),
+ max_frame);
/*
** XXX should max_frame above be
** MR_redoip_slot(max_frame) instead?
Index: mercury_stack_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.47
diff -u -b -r1.47 mercury_stack_trace.c
--- mercury_stack_trace.c 2002/02/24 11:53:34 1.47
+++ mercury_stack_trace.c 2002/08/16 08:01:12
@@ -1,4 +1,7 @@
/*
+** vim: ts=4 sw=4 expandtab
+*/
+/*
** Copyright (C) 1998-2002 The University of Melbourne.
** This file may only be copied under the terms of the GNU Library General
** Public License - see the file COPYING.LIB in the Mercury distribution.
@@ -42,8 +45,9 @@
static void MR_maybe_print_context(FILE *fp,
const char *filename, int lineno);
-static void MR_maybe_print_parent_context(FILE *fp, MR_bool print_parent,
- MR_bool verbose, const char *filename, int lineno);
+static void MR_maybe_print_parent_context(FILE *fp,
+ MR_bool print_parent, MR_bool verbose,
+ const char *filename, int lineno);
/* see comments in mercury_stack_trace.h */
MR_Code *MR_stack_trace_bottom;
@@ -118,15 +122,13 @@
return problem;
} else if (result == MR_STEP_ERROR_AFTER) {
MR_dump_stack_record_frame(fp, prev_label_layout,
- old_trace_sp, old_trace_curfr,
- print_stack_record);
+ old_trace_sp, old_trace_curfr, print_stack_record);
MR_dump_stack_record_flush(fp, print_stack_record);
return problem;
} else {
MR_dump_stack_record_frame(fp, prev_label_layout,
- old_trace_sp, old_trace_curfr,
- print_stack_record);
+ old_trace_sp, old_trace_curfr, print_stack_record);
}
} while (cur_label_layout != NULL);
@@ -152,8 +154,8 @@
*problem = NULL;
for (i = 0; i < ancestor_level && label_layout != NULL; i++) {
result = MR_stack_walk_step(label_layout->MR_sll_entry,
- &return_label_layout,
- stack_trace_sp, stack_trace_curfr, problem);
+ &return_label_layout, stack_trace_sp,
+ stack_trace_curfr, problem);
if (result != MR_STEP_OK) {
/* *problem has already been filled in */
@@ -206,8 +208,7 @@
return MR_STEP_ERROR_AFTER;
}
- success = (MR_Code *) MR_based_stackvar(*stack_trace_sp_ptr,
- number);
+ success = (MR_Code *) MR_based_stackvar(*stack_trace_sp_ptr, number);
*stack_trace_sp_ptr = *stack_trace_sp_ptr -
entry_layout->MR_sle_stack_slots;
} else {
@@ -240,9 +241,13 @@
MR_dump_nondet_stack(FILE *fp, MR_Word *base_maxfr)
{
#ifndef MR_HIGHLEVEL_CODE
+
MR_dump_nondet_stack_from_layout(fp, base_maxfr, NULL, NULL, NULL);
+
#else /* !MR_HIGHLEVEL_CODE */
+
MR_fatal_error("MR_dump_nondet_stack in high level C grade");
+
#endif /* !MR_HIGHLEVEL_CODE */
}
@@ -250,8 +255,7 @@
void
MR_dump_nondet_stack_from_layout(FILE *fp, MR_Word *base_maxfr,
- const MR_Label_Layout *top_layout,
- MR_Word *base_sp, MR_Word *base_curfr)
+ const MR_Label_Layout *top_layout, MR_Word *base_sp, MR_Word *base_curfr)
{
MR_fatal_error("MR_dump_nondet_stack_from_layout in high level grade");
}
@@ -324,8 +328,7 @@
void
MR_dump_nondet_stack_from_layout(FILE *fp, MR_Word *base_maxfr,
- const MR_Label_Layout *top_layout,
- MR_Word *base_sp, MR_Word *base_curfr)
+ const MR_Label_Layout *top_layout, MR_Word *base_sp, MR_Word *base_curfr)
{
int frame_size;
int level_number;
@@ -339,8 +342,7 @@
&& MR_address_of_trace_browse_all_on_level != NULL)
{
print_vars = MR_TRUE;
- MR_ensure_room_for_next(MR_nondet_branch_info,
- MR_Nondet_Branch_Info,
+ MR_ensure_room_for_next(MR_nondet_branch_info, MR_Nondet_Branch_Info,
MR_INIT_NONDET_BRANCH_ARRAY_SIZE);
MR_nondet_branch_infos[0].branch_sp = base_sp;
MR_nondet_branch_infos[0].branch_curfr = base_curfr;
@@ -383,12 +385,11 @@
MR_print_nondstackptr(fp, MR_redofr_slot(base_maxfr));
fprintf(fp, " \n");
fprintf(fp, " detfr: ");
- MR_print_detstackptr(fp, MR_detfr_slot(base_maxfr));
+ MR_print_detstackptr(fp, MR_tmp_detfr_slot(base_maxfr));
fprintf(fp, " \n");
} else {
MR_print_nondstackptr(fp, base_maxfr);
- fprintf(fp, ": ordinary, %d words\n",
- frame_size);
+ fprintf(fp, ": ordinary, %d words\n", frame_size);
fprintf(fp, " redoip: ");
MR_printlabel(fp, MR_redoip_slot(base_maxfr));
fprintf(fp, " redofr: ");
@@ -401,11 +402,9 @@
fprintf(fp, " \n");
level_number++;
- if (print_vars &&
- base_maxfr > MR_nondet_stack_trace_bottom)
- {
- problem = MR_step_over_nondet_frame(fp,
- level_number, base_maxfr);
+ if (print_vars && base_maxfr > MR_nondet_stack_trace_bottom) {
+ problem = MR_step_over_nondet_frame(fp, level_number,
+ base_maxfr);
if (problem != NULL) {
fprintf(fp, "%s\n", problem);
return;
@@ -563,8 +562,7 @@
}
if (! MR_find_matching_branch(base_curfr, &branch)) {
- MR_ensure_room_for_next(MR_nondet_branch_info,
- MR_Nondet_Branch_Info,
+ MR_ensure_room_for_next(MR_nondet_branch_info, MR_Nondet_Branch_Info,
MR_INIT_NONDET_BRANCH_ARRAY_SIZE);
last = MR_nondet_branch_info_next;
MR_nondet_branch_infos[last].branch_layout = label_layout;
@@ -575,8 +573,7 @@
} else if (base_sp != NULL &&
MR_nondet_branch_infos[last].branch_sp == NULL)
{
- MR_fatal_error("common ancestor reached from "
- "non-main branch first");
+ MR_fatal_error("common ancestor reached from non-main branch first");
}
return NULL;
@@ -721,15 +718,10 @@
linenumber = 0;
}
- must_flush =
/*
** We cannot merge two calls if they are to different
** procedures.
- */
-
- (entry_layout != prev_entry_layout) ||
-
- /*
+ **
** We cannot merge two calls even to the same procedure
** if we are printing trace data, since this will differ
** between the calls.
@@ -738,8 +730,7 @@
** procedure to differ on whether the procedure has trace
** layout data or not.
*/
-
- trace_data_enabled;
+ must_flush = (entry_layout != prev_entry_layout) || trace_data_enabled;
if (must_flush) {
MR_dump_stack_record_flush(fp, print_stack_record);
@@ -870,8 +861,7 @@
}
if (MR_PROC_LAYOUT_HAS_EXEC_TRACE(entry)) {
- MR_Integer maybe_from_full =
- entry->MR_sle_maybe_from_full;
+ MR_Integer maybe_from_full = entry->MR_sle_maybe_from_full;
if (maybe_from_full > 0) {
/*
** For procedures compiled with shallow
@@ -880,11 +870,9 @@
** the appropriate stack slot was MR_TRUE.
*/
if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
- print_details = MR_based_stackvar(
- base_sp, maybe_from_full);
+ print_details = MR_based_stackvar(base_sp, maybe_from_full);
} else {
- print_details = MR_based_framevar(
- base_curfr, maybe_from_full);
+ print_details = MR_based_framevar(base_curfr, maybe_from_full);
}
} else {
/*
@@ -900,20 +888,14 @@
if (print_details) {
if (MR_DETISM_DET_STACK(entry->MR_sle_detism)) {
fprintf(fp, "%7lu %7lu %4lu ",
- (unsigned long)
- MR_event_num_stackvar(base_sp) + 1,
- (unsigned long)
- MR_call_num_stackvar(base_sp),
- (unsigned long)
- MR_call_depth_stackvar(base_sp));
+ (unsigned long) MR_event_num_stackvar(base_sp) + 1,
+ (unsigned long) MR_call_num_stackvar(base_sp),
+ (unsigned long) MR_call_depth_stackvar(base_sp));
} else {
fprintf(fp, "%7lu %7lu %4lu ",
- (unsigned long)
- MR_event_num_framevar(base_curfr) + 1,
- (unsigned long)
- MR_call_num_framevar(base_curfr),
- (unsigned long)
- MR_call_depth_framevar(base_curfr));
+ (unsigned long) MR_event_num_framevar(base_curfr) + 1,
+ (unsigned long) MR_call_num_framevar(base_curfr),
+ (unsigned long) MR_call_depth_framevar(base_curfr));
}
} else {
/* ensure that the remaining columns line up */
@@ -934,8 +916,7 @@
}
static void
-MR_print_proc_id_internal(FILE *fp, const MR_Proc_Layout *entry,
- MR_bool spec)
+MR_print_proc_id_internal(FILE *fp, const MR_Proc_Layout *entry, MR_bool spec)
{
if (! MR_PROC_LAYOUT_HAS_PROC_ID(entry)) {
MR_fatal_error("cannot print procedure id without layout");
@@ -957,15 +938,12 @@
if (strcmp(entry->MR_sle_comp.MR_comp_type_module,
entry->MR_sle_comp.MR_comp_def_module) != 0)
{
- fprintf(fp, " {%s}",
- entry->MR_sle_comp.MR_comp_def_module);
+ fprintf(fp, " {%s}", entry->MR_sle_comp.MR_comp_def_module);
}
} else {
if (entry->MR_sle_user.MR_user_pred_or_func == MR_PREDICATE) {
fprintf(fp, "pred");
- } else if (entry->MR_sle_user.MR_user_pred_or_func ==
- MR_FUNCTION)
- {
+ } else if (entry->MR_sle_user.MR_user_pred_or_func == MR_FUNCTION) {
fprintf(fp, "func");
} else {
MR_fatal_error("procedure is not pred or func");
@@ -986,8 +964,7 @@
if (!spec && strcmp(entry->MR_sle_user.MR_user_decl_module,
entry->MR_sle_user.MR_user_def_module) != 0)
{
- fprintf(fp, " {%s}",
- entry->MR_sle_user.MR_user_def_module);
+ fprintf(fp, " {%s}", entry->MR_sle_user.MR_user_def_module);
}
}
@@ -998,18 +975,16 @@
void
MR_print_proc_id_trace_and_context(FILE *fp, MR_bool include_trace_data,
- MR_Context_Position pos, const MR_Proc_Layout *entry,
- MR_Word *base_sp, MR_Word *base_curfr,
- const char *path, const char *filename, int lineno,
- MR_bool print_parent, const char *parent_filename,
- int parent_lineno, int indent)
+ MR_Context_Position pos, const MR_Proc_Layout *entry, MR_Word *base_sp,
+ MR_Word *base_curfr, const char *path, const char *filename, int lineno,
+ MR_bool print_parent, const char *parent_filename, int parent_lineno,
+ int indent)
{
-
switch (pos) {
case MR_CONTEXT_NOWHERE:
fprintf(fp, " ");
- MR_maybe_print_call_trace_info(fp, include_trace_data,
- entry, base_sp, base_curfr);
+ MR_maybe_print_call_trace_info(fp, include_trace_data, entry,
+ base_sp, base_curfr);
MR_print_proc_id(fp, entry);
if (strlen(path) > 0) {
fprintf(fp, " %s", path);
@@ -1019,8 +994,8 @@
case MR_CONTEXT_BEFORE:
MR_maybe_print_context(fp, filename, lineno);
- MR_maybe_print_parent_context(fp, print_parent,
- MR_FALSE, parent_filename, parent_lineno);
+ MR_maybe_print_parent_context(fp, print_parent, MR_FALSE,
+ parent_filename, parent_lineno);
fprintf(fp, " ");
MR_maybe_print_call_trace_info(fp, include_trace_data,
entry, base_sp, base_curfr);
@@ -1040,18 +1015,18 @@
fprintf(fp, " %s", path);
}
MR_maybe_print_context(fp, filename, lineno);
- MR_maybe_print_parent_context(fp, print_parent,
- MR_FALSE, parent_filename, parent_lineno);
+ MR_maybe_print_parent_context(fp, print_parent, MR_FALSE,
+ parent_filename, parent_lineno);
fprintf(fp, "\n");
break;
case MR_CONTEXT_PREVLINE:
MR_maybe_print_context(fp, filename, lineno);
- MR_maybe_print_parent_context(fp, print_parent,
- MR_TRUE, parent_filename, parent_lineno);
+ MR_maybe_print_parent_context(fp, print_parent, MR_TRUE,
+ parent_filename, parent_lineno);
fprintf(fp, "\n%*s ", indent, "");
- MR_maybe_print_call_trace_info(fp, include_trace_data,
- entry, base_sp, base_curfr);
+ MR_maybe_print_call_trace_info(fp, include_trace_data, entry,
+ base_sp, base_curfr);
MR_print_proc_id(fp, entry);
if (strlen(path) > 0) {
fprintf(fp, " %s", path);
@@ -1061,16 +1036,16 @@
case MR_CONTEXT_NEXTLINE:
fprintf(fp, " ");
- MR_maybe_print_call_trace_info(fp, include_trace_data,
- entry, base_sp, base_curfr);
+ MR_maybe_print_call_trace_info(fp, include_trace_data, entry,
+ base_sp, base_curfr);
MR_print_proc_id(fp, entry);
if (strlen(path) > 0) {
fprintf(fp, " %s", path);
}
fprintf(fp, "\n%*s", indent, "");
MR_maybe_print_context(fp, filename, lineno);
- MR_maybe_print_parent_context(fp, print_parent,
- MR_TRUE, parent_filename, parent_lineno);
+ MR_maybe_print_parent_context(fp, print_parent, MR_TRUE,
+ parent_filename, parent_lineno);
fprintf(fp, "\n");
break;
Index: mercury_stacks.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stacks.h,v
retrieving revision 1.32
diff -u -b -r1.32 mercury_stacks.h
--- mercury_stacks.h 2002/02/13 09:56:42 1.32
+++ mercury_stacks.h 2002/08/16 08:04:18
@@ -1,5 +1,5 @@
/*
-** Copyright (C) 1995-2001 The University of Melbourne.
+** Copyright (C) 1995-2002 The University of Melbourne.
** This file may only be copied under the terms of the GNU Library General
** Public License - see the file COPYING.LIB in the Mercury distribution.
*/
@@ -113,7 +113,8 @@
#define MR_REDOFR (-2) /* value for curfr on backtracking */
#define MR_SUCCIP (-3) /* in caller proc, set up at call */
#define MR_SUCCFR (-4) /* frame of caller proc, set up at call */
-#define MR_DETFR (-3) /* sp, in model_det temp frames only */
+#define MR_TMP_DETFR (-3) /* sp, in model_det temp frames only */
+#define MR_TABLE_DETFR (-5) /* sp, in minimal model main frames only */
/*
** MR_Code that traverses the nondet stack depends on the relationship
@@ -123,7 +124,12 @@
#define MR_NONDET_TEMP_SIZE 3 /* prevfr, redoip, redofr */
#define MR_DET_TEMP_SIZE 4 /* prevfr, redoip, redofr, detfr */
+#ifdef MR_USE_MINIMAL_MODEL
+#define MR_NONDET_FIXED_SIZE 6 /* prevfr, redoip, redofr, succip, succfr,
+ sp */
+#else
#define MR_NONDET_FIXED_SIZE 5 /* prevfr, redoip, redofr, succip, succfr */
+#endif
#define MR_SAVEVAL (-MR_NONDET_FIXED_SIZE)
/* saved values start at this offset */
@@ -133,7 +139,8 @@
#define MR_redofr_addr(fr) (&((MR_Word *) (fr))[MR_REDOFR])
#define MR_succip_addr(fr) (&((MR_Word *) (fr))[MR_SUCCIP])
#define MR_succfr_addr(fr) (&((MR_Word *) (fr))[MR_SUCCFR])
-#define MR_detfr_addr(fr) (&((MR_Word *) (fr))[MR_DETFR])
+#define MR_tmp_detfr_addr(fr) (&((MR_Word *) (fr))[MR_TMP_DETFR])
+#define MR_table_detfr_addr(fr) (&((MR_Word *) (fr))[MR_TABLE_DETFR])
#define MR_based_framevar_addr(fr, n) \
(&(((MR_Word *) (fr))[MR_SAVEVAL + 1 - (n)]))
@@ -147,8 +154,10 @@
((MR_Word *) (fr))[MR_SUCCIP])
#define MR_succfr_slot(fr) MR_LVALUE_CAST(MR_Word *, \
((MR_Word *) (fr))[MR_SUCCFR])
-#define MR_detfr_slot(fr) MR_LVALUE_CAST(MR_Word *, \
- ((MR_Word *) (fr))[MR_DETFR])
+#define MR_tmp_detfr_slot(fr) MR_LVALUE_CAST(MR_Word *, \
+ ((MR_Word *) (fr))[MR_TMP_DETFR])
+#define MR_table_detfr_slot(fr) MR_LVALUE_CAST(MR_Word *, \
+ ((MR_Word *) (fr))[MR_TABLE_DETFR])
#define MR_based_framevar(fr, n) (((MR_Word *) (fr))[MR_SAVEVAL + 1 - (n)])
#define MR_framevar(n) MR_based_framevar(MR_curfr, n)
@@ -157,6 +166,14 @@
/* DEFINITIONS FOR MANIPULATING THE NONDET STACK */
+#ifdef MR_USE_MINIMAL_MODEL
+ #define MR_maybe_fill_table_detfr_slot() \
+ MR_table_detfr_slot(MR_curfr) = MR_sp
+#else
+ #define MR_maybe_fill_table_detfr_slot() \
+ ((void) 0)
+#endif
+
#define MR_mkframe(predname, numslots, redoip) \
do { \
MR_Word *prevfr; \
@@ -164,18 +181,22 @@
\
prevfr = MR_maxfr; \
succfr = MR_curfr; \
- MR_maxfr += (MR_NONDET_FIXED_SIZE + numslots);\
+ MR_maxfr += (MR_NONDET_FIXED_SIZE + numslots); \
MR_curfr = MR_maxfr; \
MR_redoip_slot(MR_curfr) = redoip; \
MR_prevfr_slot(MR_curfr) = prevfr; \
MR_succip_slot(MR_curfr) = MR_succip; \
MR_succfr_slot(MR_curfr) = succfr; \
MR_redofr_slot(MR_curfr) = MR_curfr; \
+ MR_maybe_fill_table_detfr_slot(); \
MR_debugmkframe(predname); \
MR_nondstack_overflow_check(); \
MR_collect_non_frame_stats(numslots); \
} while (0)
+/* convert a size in bytes to a size in words, rounding up if necessary */
+#define MR_bytes_to_words(x) (((x) + sizeof(MR_Word) - 1) / sizeof(MR_Word))
+
/* just like mkframe, but also reserves space for a struct */
/* with the given tag at the bottom of the nondet stack frame */
#define MR_mkpragmaframe(predname, numslots, structname, redoip) \
@@ -193,6 +214,7 @@
MR_succip_slot(MR_curfr) = MR_succip; \
MR_succfr_slot(MR_curfr) = succfr; \
MR_redofr_slot(MR_curfr) = MR_curfr; \
+ MR_maybe_fill_table_detfr_slot(); \
MR_debugmkframe(predname); \
MR_nondstack_overflow_check(); \
MR_collect_non_frame_stats(numslots); \
@@ -219,11 +241,12 @@
MR_prevfr_slot(MR_maxfr) = prevfr; \
MR_redoip_slot(MR_maxfr) = redoip; \
MR_redofr_slot(MR_maxfr) = MR_curfr; \
- MR_detfr_slot(MR_maxfr) = MR_sp; \
+ MR_tmp_detfr_slot(MR_maxfr) = MR_sp; \
MR_nondstack_overflow_check(); \
} while (0)
-#define MR_succeed() do { \
+#define MR_succeed() \
+ do { \
MR_Word *childfr; \
\
MR_debugsucceed(); \
@@ -244,7 +267,8 @@
} while (0)
-#define MR_fail() do { \
+#define MR_fail() \
+ do { \
MR_debugfail(); \
MR_maxfr = MR_prevfr_slot(MR_maxfr); \
MR_nondstack_underflow_check(); \
@@ -253,7 +277,8 @@
} while (0)
-#define MR_redo() do { \
+#define MR_redo() \
+ do { \
MR_debugredo(); \
MR_curfr = MR_redofr_slot(MR_maxfr); \
MR_GOTO(MR_redoip_slot(MR_maxfr)); \
cvs diff: Diffing GETOPT
cvs diff: Diffing machdeps
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list