[m-rev.] for review: redefining the meaning of MR_sp
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Nov 20 17:07:29 AEDT 2002
The diff is small, and I have already bootchecked it in a bunch of grades.
Does anyone know of any part of the system that could be affected by this
change that I don't know about? I'll commit this on friday if noone objects
by then.
Zoltan.
runtime/mercury_stacks.h:
Make the MR_based_stackvar and MR_stackvar macros treat MR_sp as
pointing not to the first free word on the det stack, but to the last
used word. MR_maxfr already points to the last used word on the nondet
stack. Eliminating this unnecessary difference between them should
make it easier to write code to perform surgery on stack segments.
(The existing code working with stack segments is already flawed;
it will be fixed in other changes.)
Note that neither the code in mercury_context.[ch] that initializes
MR_sp (and the context structure field that holds saved values of MR_sp)
to point to the bottom of the detstack zone nor the code in
mercury_overflow.h that compares MR_sp against the top of the detstack
zone required changes after this. To avoid cache collisions, we don't
use the bottom part of the detstack zone anyway; it doesn't matter
exactly how many words we leave unused there. The overflow check code
(which usually isn't enabled) was overly conservative; it is now
exactly right.
runtime/mercury_grade.h:
Since the change to mercury_stacks.h affects how the C compiler treats
.c files generated by mmc in all LLDS grades, increment the binary
compatility version number.
cvs diff: Diffing runtime
Index: runtime/mercury_grade.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_grade.h,v
retrieving revision 1.43
diff -u -b -r1.43 mercury_grade.h
--- runtime/mercury_grade.h 15 Nov 2002 04:50:39 -0000 1.43
+++ runtime/mercury_grade.h 18 Nov 2002 11:22:44 -0000
@@ -52,7 +52,7 @@
** RTTI version number.
*/
-#define MR_GRADE_PART_0 v8_
+#define MR_GRADE_PART_0 v9_
#ifdef MR_HIGHLEVEL_CODE
Index: runtime/mercury_stacks.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_stacks.h,v
retrieving revision 1.36
diff -u -b -r1.36 mercury_stacks.h
--- runtime/mercury_stacks.h 6 Nov 2002 06:54:11 -0000 1.36
+++ runtime/mercury_stacks.h 20 Nov 2002 05:49:25 -0000
@@ -68,8 +68,18 @@
/* DEFINITIONS FOR MANIPULATING THE DET STACK */
-/* Stack slots start numbering at 1 */
-#define MR_based_stackvar(base_sp, n) ((base_sp)[-(n)])
+/*
+** The first stack slot in each stack frame is MR_stackvar(1) while MR_sp
+** points to the topmost used word on the stack: this is why we need to add 1.
+** In compiler-generated code, the value of n is always known, so the C
+** compiler will be able to compute 1-n at compile time. The debugger will
+** need to perform the addition at runtime after it gets the value of n from
+** a layout structure, but this is not performance critical. It is useful
+** to have MR_sp and MR_maxfr both point to the topmost used words on their
+** stacks when moving stack segments around in minimal model tabling.
+*/
+
+#define MR_based_stackvar(base_sp, n) ((base_sp)[1 - (n)])
#define MR_stackvar(n) MR_based_stackvar(MR_sp, (n))
#define MR_incr_sp_push_msg(n, msg) \
--------------------------------------------------------------------------
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