[m-rev.] For (postcommit) review: Runtime support for RBMM using functions.
Quan Phan
quan.phan at cs.kuleuven.be
Mon Apr 27 22:40:22 AEST 2009
Hi,
I committed this diff and will deal with any comments, if any, later.
Regards,
Quan.
-------------- next part --------------
Estimated hours taken: 10
Branch: main
Convert the parts of the runtime support for RBMM that have been implemented
fully using macros to macros that finally are expanded to function calls.
Using pure macros may improve the performance of small programs but not what
we want in general.
The function version is the default while the macros are kept for experimental
purposes. The macros can be turned on by specifying the C flag
MR_RBMM_USE_MACROS when compiling programs.
This change is the completion of Zoltan's unfinished work before.
runtime/mercury_conf_param.h:
Add MR_RBMM_USE_MACROS flag as an experimental option.
runtime/mercury_region.h:
runtime/mercury_region.c:
Implement the functions corresponding to the old macros. There is no
change in terms of algorithm.
-------------- next part --------------
Index: mercury_conf_param.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.107
diff -u -r1.107 mercury_conf_param.h
--- mercury_conf_param.h 5 Sep 2008 11:19:33 -0000 1.107
+++ mercury_conf_param.h 27 Apr 2009 12:30:02 -0000
@@ -485,6 +485,15 @@
** MR_UNCONDITIONAL_STRUCTURE_REUSE
** Enable this to bypass the check that a cell was allocated by Boehm GC
** before reusing it.
+**
+** MR_RBMM_USE_MACROS
+** By default, all RBMM operations are implemented by functions, but if
+** this macro is enabled, we implement this with macros. Macros avoid the
+** overhead of function calls, but in large programs, having lots of copies
+** of the macro body will have a negative impact on locality, because we can
+** expect many copies to not be in the instruction cache, while function
+** bodies called from all over the place definitely should stay in the
+** instruction cache.
*/
#if defined(MR_THREAD_SAFE) && defined(MR_TRACE_HISTOGRAM)
Index: mercury_region.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_region.c,v
retrieving revision 1.9
diff -u -r1.9 mercury_region.c
--- mercury_region.c 23 Jan 2008 11:44:48 -0000 1.9
+++ mercury_region.c 27 Apr 2009 12:30:03 -0000
@@ -499,6 +499,459 @@
}
return MR_FALSE;
}
+
+#if !defined(MR_RBMM_USE_MACROS)
+
+/*---------------------------------------------------------------------------*/
+/*
+** push_region_frame
+*/
+
+void
+MR_push_region_ite_frame_proc(MR_RegionIteFixedFrame *new_ite_frame)
+{
+ new_ite_frame->MR_riff_previous_ite_frame = MR_region_ite_sp;
+ new_ite_frame->MR_riff_saved_sequence_number = MR_region_sequence_number;
+ MR_region_ite_sp = new_ite_frame;
+ MR_region_profile_push_ite_frame;
+ MR_region_debug_push_ite_frame(new_ite_frame);
+}
+
+void
+MR_push_region_disj_frame_proc(MR_RegionDisjFixedFrame *new_disj_frame)
+{
+ new_disj_frame->MR_rdff_previous_disj_frame = MR_region_disj_sp;
+ new_disj_frame->MR_rdff_saved_sequence_number = MR_region_sequence_number;
+ new_disj_frame->MR_rdff_num_prot_regions = 0;
+ MR_region_disj_sp = new_disj_frame;
+ MR_region_profile_push_disj_frame;
+ MR_region_debug_push_disj_frame(new_disj_frame);
+}
+
+void
+MR_push_region_commit_frame_proc(MR_RegionCommitFixedFrame *new_commit_frame)
+{
+ new_commit_frame->MR_rcff_previous_commit_frame = MR_region_commit_sp;
+ new_commit_frame->MR_rcff_saved_sequence_number =
+ MR_region_sequence_number;
+ new_commit_frame->MR_rcff_saved_disj_sp = MR_region_disj_sp;
+ MR_region_commit_sp = new_commit_frame;
+ MR_region_profile_push_commit_frame;
+ MR_region_debug_push_commit_frame(new_commit_frame);
+}
+
+/*---------------------------------------------------------------------------*/
+
+int
+MR_region_fill_ite_protect_func(MR_RegionIteFixedFrame *ite_sp,
+ MR_RegionHeader *region, MR_RegionIteProtect *ite_prot)
+{
+ int incr;
+
+ MR_region_debug_start("fill_ite_protect");
+ if (!MR_region_is_disj_protected(region) &&
+ region->MR_region_ite_protected == NULL)
+ {
+ ite_prot->MR_ite_prot_region = region;
+ region->MR_region_ite_protected = ite_sp;
+ MR_region_profile_fill_ite_protect;
+ MR_region_debug_fill_ite_protect(ite_prot, region);
+ incr = 1;
+ } else {
+ MR_region_debug_fill_ite_protect(NULL, region);
+ incr = 0;
+ }
+ MR_region_debug_end("fill_ite_protect");
+
+ return incr;
+}
+
+int
+MR_region_fill_ite_snapshot_removed_func(MR_RegionHeader *region,
+ MR_RegionSnapshot *snapshot)
+{
+ int incr;
+
+ MR_region_debug_start("fill_ite_snapshot_removed");
+ if ((region->MR_region_ite_protected != NULL &&
+ region->MR_region_ite_protected != MR_region_ite_sp) ||
+ MR_region_is_disj_protected(region))
+ {
+ MR_save_snapshot(region, snapshot);
+ MR_region_profile_fill_ite_snapshot;
+ MR_region_debug_fill_ite_snapshot_removed(snapshot, region);
+ incr = 1;
+ } else {
+ /* Else the region is not protected. */
+ MR_region_debug_fill_ite_snapshot_removed(NULL, region);
+ incr = 0;
+ }
+ MR_region_debug_end("fill_ite_snapshot_removed");
+
+ return incr;
+}
+
+void
+MR_region_fill_ite_snapshot_not_removed_proc(MR_RegionHeader *region,
+ MR_RegionSnapshot *snapshot)
+{
+ MR_region_debug_start("fill_ite_snapshot_not_removed");
+ MR_save_snapshot(region, snapshot);
+ MR_region_profile_fill_ite_snapshot;
+ MR_region_debug_fill_ite_snapshot_not_removed(snapshot, region);
+ MR_region_debug_end("fill_ite_snapshot_not_removed");
+}
+
+int
+MR_region_fill_semi_disj_protect_func(MR_RegionHeader *region,
+ MR_RegionSemiDisjProtect *semi_disj_prot)
+{
+ int incr;
+
+ MR_region_debug_start("fill_semi_disj_protect");
+ if (!MR_region_is_disj_protected(region) &&
+ region->MR_region_ite_protected == NULL)
+ {
+ semi_disj_prot->MR_semi_disj_prot_region = region;
+ MR_region_profile_fill_semi_disj_protect;
+ MR_region_debug_fill_semi_disj_protect(semi_disj_prot, region);
+ incr = 1;
+ } else {
+ MR_region_debug_fill_semi_disj_protect(NULL, region);
+ incr = 0;
+ }
+ MR_region_debug_end("fill_ite_protect");
+
+ return incr;
+}
+
+void
+MR_region_fill_disj_snapshot_proc(MR_RegionHeader *region,
+ MR_RegionSnapshot *snapshot)
+{
+ MR_region_debug_start("fill_disj_snapshot");
+ MR_save_snapshot(region, snapshot);
+ MR_region_profile_fill_disj_snapshot;
+ MR_region_debug_fill_disj_snapshot(snapshot, region);
+ MR_region_debug_end("fill_disj_snapshot");
+}
+
+int
+MR_region_fill_commit_func(MR_RegionCommitFixedFrame *top_commit_frame,
+ MR_RegionHeader *region, MR_RegionCommitSave *commit_save)
+{
+ int incr;
+
+ MR_region_debug_start("fill_commit");
+ if (!MR_region_is_disj_protected(region) &&
+ region->MR_region_ite_protected == NULL)
+ {
+ commit_save->MR_commit_save_region = region;
+ region->MR_region_commit_frame = top_commit_frame;
+ MR_region_profile_fill_commit;
+ MR_region_debug_fill_commit(commit_save, region);
+ incr = 1;
+ } else {
+ MR_region_debug_fill_commit(NULL, region);
+ incr = 0;
+ }
+ MR_region_debug_end("fill_commit");
+
+ return incr;
+}
+
+void
+MR_use_region_ite_then_semidet_proc(MR_RegionIteFixedFrame *top_ite_frame)
+{
+ int i;
+ MR_RegionIteProtect *ite_prot;
+
+ MR_region_debug_start("use_region_ite_then_semidet");
+ ite_prot = (MR_RegionIteProtect *) ( ( (MR_Word *) top_ite_frame ) +
+ MR_REGION_ITE_FRAME_FIXED_SIZE);
+ for (i = 0; i < top_ite_frame->MR_riff_num_prot_regions;
+ i++, ite_prot++) {
+ MR_remove_undisjprotected_region_ite_then_semidet(
+ ite_prot->MR_ite_prot_region);
+ }
+ MR_pop_region_ite_frame(top_ite_frame);
+ MR_region_debug_end("use_region_ite_then_semidet");
+}
+
+void
+MR_use_region_ite_then_nondet_proc(MR_RegionIteFixedFrame *top_ite_frame)
+{
+ int i;
+ MR_RegionIteProtect *ite_prot;
+
+ MR_region_debug_start("use_region_ite_then_nondet");
+ ite_prot = (MR_RegionIteProtect *) ( ( (MR_Word *) top_ite_frame ) +
+ MR_REGION_ITE_FRAME_FIXED_SIZE);
+ for (i = 0; i < top_ite_frame->MR_riff_num_prot_regions;
+ i++, ite_prot++) {
+ if (ite_prot->MR_ite_prot_region != NULL) {
+ MR_remove_undisjprotected_region_ite_then_nondet(
+ ite_prot->MR_ite_prot_region);
+ }
+ }
+ MR_region_debug_end("use_region_ite_then_nondet");
+}
+
+void
+MR_use_region_ite_else_semidet_proc(MR_RegionIteFixedFrame *top_ite_frame)
+{
+ MR_region_debug_start("use_region_ite_else_semidet");
+ MR_region_process_at_ite_else_proc(top_ite_frame);
+ MR_region_debug_end("use_region_ite_else_semidet");
+}
+
+void
+MR_use_region_ite_else_nondet_proc(MR_RegionIteFixedFrame *top_ite_frame)
+{
+ MR_region_debug_start("use_region_ite_else_nondet");
+ MR_region_process_at_ite_else(top_ite_frame);
+ MR_region_debug_end("use_region_ite_else_nondet");
+}
+
+void
+MR_use_region_ite_nondet_cond_fail_proc(MR_RegionIteFixedFrame *top_ite_frame)
+{
+ MR_region_debug_start("use_region_ite_nondet_cond_fail");
+ MR_region_ite_restore_from_snapshots(top_ite_frame);
+ MR_pop_region_ite_frame(top_ite_frame);
+ MR_region_debug_end("use_region_ite_nondet_cond_fail");
+}
+
+void
+MR_use_region_disj_later_proc(MR_RegionDisjFixedFrame *top_disj_frame)
+{
+ MR_region_debug_start("use_region_disj_later");
+ MR_region_disj_restore_from_snapshots(top_disj_frame);
+ MR_region_disj_destroy_new_regions(top_disj_frame);
+ MR_region_debug_end("use_region_disj_later");
+}
+
+void
+MR_use_region_disj_nonlast_semi_commit_proc(
+ MR_RegionDisjFixedFrame *top_disj_frame)
+{
+ int i;
+ MR_RegionSemiDisjProtect *semi_disj_prot;
+
+ MR_region_debug_start("use_region_disj_nonlast_semi_commit");
+ /* Destroy any regions protected by the disj frame */
+ semi_disj_prot = (MR_RegionSemiDisjProtect *) (
+ ( (MR_Word *) top_disj_frame ) + MR_REGION_DISJ_FRAME_FIXED_SIZE);
+ for (i = 0; i < top_disj_frame->MR_rdff_num_prot_regions;
+ i++, semi_disj_prot++) {
+ MR_region_destroy_region(
+ semi_disj_prot->MR_semi_disj_prot_region);
+ }
+ MR_pop_region_disj_frame(top_disj_frame);
+ MR_region_debug_end("use_region_disj_nonlast_semi_commit");
+}
+
+void
+MR_use_region_disj_last_proc(MR_RegionDisjFixedFrame *top_disj_frame)
+{
+ MR_region_debug_start("use_region_disj_last");
+ MR_region_disj_restore_from_snapshots(top_disj_frame);
+ MR_region_disj_destroy_new_regions(top_disj_frame);
+ MR_pop_region_disj_frame(top_disj_frame);
+ MR_region_debug_end("use_region_disj_last");
+}
+
+void
+MR_use_region_commit_success_proc(
+ MR_RegionCommitFixedFrame *top_commit_frame)
+{
+ MR_RegionCommitSave *first_commit_save;
+
+ MR_region_debug_start("use_region_commit_success");
+ first_commit_save = (MR_RegionCommitSave *) (
+ ( (MR_Word *) top_commit_frame ) + MR_REGION_COMMIT_FRAME_FIXED_SIZE);
+ MR_commit_success_destroy_marked_new_regions(
+ top_commit_frame->MR_rcff_saved_sequence_number);
+ MR_commit_success_destroy_marked_saved_regions(
+ top_commit_frame->MR_rcff_num_saved_regions, first_commit_save);
+ MR_region_profile_pop_disj_frame(MR_region_disj_sp,
+ top_commit_frame->MR_rcff_saved_disj_sp);
+ MR_region_disj_sp = top_commit_frame->MR_rcff_saved_disj_sp;
+ MR_pop_region_commit_frame(top_commit_frame);
+ MR_region_debug_end("use_region_commit_success");
+}
+
+void
+MR_use_region_commit_failure_proc(MR_RegionCommitFixedFrame *top_commit_frame)
+{
+ int i;
+ MR_RegionCommitSave *commit_save;
+ MR_RegionHeader *region;
+
+ MR_region_debug_start("use_region_commit_failure");
+ commit_save = (MR_RegionCommitSave *) (
+ ( (MR_Word *) top_commit_frame ) + MR_REGION_COMMIT_FRAME_FIXED_SIZE);
+ for (i = 0; i < top_commit_frame->MR_rcff_num_saved_regions;
+ i++, commit_save++) {
+ region = commit_save->MR_commit_save_region;
+ if (region != NULL) {
+ region->MR_region_commit_frame = NULL;
+ }
+ }
+ MR_pop_region_commit_frame(top_commit_frame);
+ MR_region_debug_end("use_region_commit_failure");
+}
+
+/*---------------------------------------------------------------------------*/
+/* Helper procedures for ite support. */
+
+void
+MR_region_process_at_ite_else_proc(MR_RegionIteFixedFrame *top_ite_frame)
+{
+ MR_region_ite_unprotect(top_ite_frame);
+ MR_region_ite_restore_from_snapshots(top_ite_frame);
+ MR_region_ite_destroy_new_regions(top_ite_frame);
+ MR_pop_region_ite_frame(top_ite_frame);
+}
+
+void
+MR_region_ite_unprotect_proc(MR_RegionIteFixedFrame *top_ite_frame)
+{
+ MR_RegionIteProtect *ite_prot;
+ MR_RegionHeader *protected_region;
+ int i;
+
+ MR_region_debug_start("ite_unprotect");
+ ite_prot = (MR_RegionIteProtect *) (
+ ( (MR_Word *) top_ite_frame ) + MR_REGION_ITE_FRAME_FIXED_SIZE);
+ for (i = 0; i < top_ite_frame->MR_riff_num_prot_regions;
+ i++, ite_prot++) {
+ protected_region = ite_prot->MR_ite_prot_region;
+ MR_region_debug_ite_unprotect(protected_region);
+ /* Try to protect the region by an outer condition. */
+ protected_region->MR_region_ite_protected = NULL;
+ }
+ MR_region_debug_end("ite_unprotect");
+}
+
+void
+MR_region_ite_restore_from_snapshots_proc(
+ MR_RegionIteFixedFrame *top_ite_frame)
+{
+ MR_RegionSnapshot *first_snapshot;
+ MR_Word protection_size;
+
+ MR_region_debug_start("ite_restore_from_snapshot");
+ protection_size = top_ite_frame->MR_riff_num_prot_regions *
+ MR_REGION_ITE_PROT_SIZE;
+ first_snapshot = (MR_RegionSnapshot *) (
+ ( (MR_Word *) top_ite_frame ) +
+ MR_REGION_ITE_FRAME_FIXED_SIZE + protection_size);
+ MR_restore_snapshots(top_ite_frame->MR_riff_num_snapshots,
+ first_snapshot);
+ MR_region_debug_end("ite_restore_from_snapshot");
+}
+
+void
+MR_region_ite_destroy_new_regions_proc(MR_RegionIteFixedFrame *top_ite_frame)
+{
+ MR_region_debug_start("ite_destroy_new_regions");
+ MR_region_frame_destroy_new_regions(
+ top_ite_frame->MR_riff_saved_sequence_number,
+ MR_REGION_ITE_FRAME_TYPE);
+ MR_region_debug_end("ite_destroy_new_regions");
+}
+
+/*---------------------------------------------------------------------------*/
+/* Helpers for nondet disjunction support. */
+
+void
+MR_region_disj_restore_from_snapshots_proc(
+ MR_RegionDisjFixedFrame *top_disj_frame)
+{
+ MR_RegionSnapshot *first_snapshot;
+
+ MR_region_debug_start("disj_restore_from_snapshots");
+ first_snapshot = (MR_RegionSnapshot *) (
+ (MR_Word *) top_disj_frame + MR_REGION_DISJ_FRAME_FIXED_SIZE +
+ MR_REGION_SEMI_DISJ_PROT_SIZE *
+ top_disj_frame->MR_rdff_num_prot_regions);
+ MR_restore_snapshots(top_disj_frame->MR_rdff_num_snapshots,
+ first_snapshot);
+ MR_region_debug_end("disj_restore_from_snapshots");
+}
+
+void
+MR_region_disj_destroy_new_regions_proc(
+ MR_RegionDisjFixedFrame *top_disj_frame)
+{
+ MR_region_debug_start("disj_destroy_new_regions");
+ MR_region_frame_destroy_new_regions(
+ top_disj_frame->MR_rdff_saved_sequence_number,
+ MR_REGION_DISJ_FRAME_TYPE);
+ MR_region_debug_end("disj_destroy_new_regions");
+}
+
+/*---------------------------------------------------------------------------*/
+
+void
+MR_save_snapshot_proc(MR_RegionHeader *region, MR_RegionSnapshot *snapshot)
+{
+ snapshot->MR_snapshot_region = region;
+ snapshot->MR_snapshot_saved_last_page = region->MR_region_last_page;
+ snapshot->MR_snapshot_saved_next_available_word =
+ region->MR_region_next_available_word;
+}
+
+void
+MR_restore_snapshots_proc(int num_snapshots,
+ MR_RegionSnapshot *first_snapshot)
+{
+ MR_RegionSnapshot *snapshot;
+ MR_RegionHeader *restoring_region;
+ MR_RegionPage *saved_last_page;
+ MR_RegionPage *first_new_page;
+ int i;
+
+ snapshot = first_snapshot;
+ for (i = 0; i < (num_snapshots); i++, snapshot++) {
+ restoring_region = snapshot->MR_snapshot_region;
+ saved_last_page = snapshot->MR_snapshot_saved_last_page;
+ first_new_page = saved_last_page->MR_regionpage_next;
+ /* Collect profiling information. */
+ MR_region_profile_restore_from_snapshot(snapshot);
+ MR_region_debug_restore_from_snapshot(snapshot);
+
+ if (first_new_page != NULL) {
+ MR_region_return_page_list(first_new_page,
+ restoring_region->MR_region_last_page);
+ restoring_region->MR_region_last_page = saved_last_page;
+ } /* else no new page added. */
+ restoring_region->MR_region_next_available_word =
+ snapshot->MR_snapshot_saved_next_available_word;
+ }
+}
+
+void
+MR_region_frame_destroy_new_regions_proc(int saved_sequence_number,
+ int frame_type)
+{
+ MR_RegionHeader *region;
+
+ region = MR_live_region_list;
+ while (region != NULL &&
+ region->MR_region_sequence_number >= saved_sequence_number)
+ {
+ MR_region_destroy_region(region);
+ MR_region_debug_destroy_region(region);
+ MR_region_profile_frame_destroy_region(region, frame_type);
+ region = region->MR_region_next_region;
+ }
+ MR_live_region_list = region;
+}
+
+#endif /* not defined MR_RBMM_USE_MACROS */
+
/*---------------------------------------------------------------------------*/
/* Debugging messages for RBMM. */
@@ -793,6 +1246,14 @@
}
void
+MR_region_fill_ite_snapshot_not_removed_msg(MR_RegionSnapshot *snapshot,
+ MR_RegionHeader *region)
+{
+ printf("\tAt slot: %d, save snapshot of region #%d.\n", snapshot,
+ region->MR_region_sequence_number);
+}
+
+void
MR_region_fill_ite_snapshot_removed_msg(MR_RegionSnapshot *snapshot,
MR_RegionHeader *region)
{
@@ -806,14 +1267,6 @@
}
void
-MR_region_fill_ite_snapshot_not_removed_msg(MR_RegionSnapshot *snapshot,
- MR_RegionHeader *region)
-{
- printf("\tAt slot: %d, save snapshot of region #%d.\n", snapshot,
- region->MR_region_sequence_number);
-}
-
-void
MR_region_fill_semi_disj_protect_msg(MR_RegionSemiDisjProtect *semi_disj_prot,
MR_RegionHeader *region)
{
Index: mercury_region.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_region.h,v
retrieving revision 1.12
diff -u -r1.12 mercury_region.h
--- mercury_region.h 17 Mar 2008 07:11:09 -0000 1.12
+++ mercury_region.h 27 Apr 2009 12:30:03 -0000
@@ -25,11 +25,6 @@
*/
/*
-** XXX: Many of these macros would be more efficient if they updated the
-** pointer processed in each loop iteration using pointer increment operations
-** instead of recomputing it each time from the pointer to the first element,
-** and the loop variable i.
-**
** XXX Many of these macros would be more readable if they used array notation.
** For example, stack_pointer[offset] instead *(stack_pointer + offset),
** and &stack_pointer[offset] instead (stack_pointer + offset).
@@ -53,6 +48,9 @@
#define MR_REGION_DISJ_SNAPSHOT_SIZE 3
#define MR_REGION_COMMIT_SAVE_SIZE 1
+#define MR_REGION_DISJ_FRAME_TYPE 0
+#define MR_REGION_ITE_FRAME_TYPE 1
+
/*
** A region page contains an array (of MR_Word) to store program data and
** a pointer to the next to form a single-linked-list.
@@ -128,7 +126,7 @@
** the region. It means that it will be reset at backtracking if the region
** is restored from its snapshot.
*/
- int MR_region_allocated_size;
+ int MR_region_allocated_size;
#endif
};
@@ -258,7 +256,9 @@
** push_region_frame
*/
-#define MR_push_region_ite_frame(new_ite_sp) \
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_push_region_ite_frame(new_ite_sp) \
do { \
MR_RegionIteFixedFrame *new_ite_frame; \
\
@@ -272,7 +272,7 @@
MR_region_debug_push_ite_frame(new_ite_frame); \
} while (0)
-#define MR_push_region_disj_frame(new_disj_sp) \
+ #define MR_push_region_disj_frame(new_disj_sp) \
do { \
MR_RegionDisjFixedFrame *new_disj_frame; \
\
@@ -287,7 +287,7 @@
MR_region_debug_push_disj_frame(new_disj_frame); \
} while (0)
-#define MR_push_region_commit_frame(new_commit_sp) \
+ #define MR_push_region_commit_frame(new_commit_sp) \
do { \
MR_RegionCommitFixedFrame *new_commit_frame; \
\
@@ -303,6 +303,37 @@
MR_region_debug_push_commit_frame(new_commit_frame); \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_push_region_ite_frame(new_ite_sp) \
+ do { \
+ MR_push_region_ite_frame_proc( \
+ (MR_RegionIteFixedFrame *) (new_ite_sp) ); \
+ } while (0)
+
+ #define MR_push_region_disj_frame(new_disj_sp) \
+ do { \
+ MR_push_region_disj_frame_proc( \
+ (MR_RegionDisjFixedFrame *) (new_disj_sp) ); \
+ } while (0)
+
+ #define MR_push_region_commit_frame(new_commit_sp) \
+ do { \
+ MR_push_region_commit_frame_proc( \
+ (MR_RegionCommitFixedFrame *) (new_commit_sp) ); \
+ } while (0)
+
+ extern void MR_push_region_ite_frame_proc(
+ MR_RegionIteFixedFrame *new_ite_frame);
+
+ extern void MR_push_region_disj_frame_proc(
+ MR_RegionDisjFixedFrame *new_disj_frame);
+
+ extern void MR_push_region_commit_frame_proc(
+ MR_RegionCommitFixedFrame *new_commit_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/*---------------------------------------------------------------------------*/
/*
** region_fill_frame
@@ -314,7 +345,10 @@
** If save the region, then set the ite_protected field in these regions
** to point to the frame.
*/
-#define MR_region_fill_ite_protect(ite_sp, region_ptr, \
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_fill_ite_protect(ite_sp, region_ptr, \
num_protected_regions, region_slot_reg) \
do { \
MR_RegionHeader *region; \
@@ -328,7 +362,7 @@
ite_prot = (MR_RegionIteProtect *) (region_slot_reg); \
ite_prot->MR_ite_prot_region = region; \
(num_protected_regions)++; \
- (region_slot_reg) = (MR_Word)(ite_prot + 1); \
+ (region_slot_reg) = (MR_Word) (ite_prot + 1); \
region->MR_region_ite_protected = \
(MR_RegionIteFixedFrame *) (ite_sp); \
MR_region_profile_fill_ite_protect; \
@@ -339,6 +373,31 @@
MR_region_debug_end("fill_ite_protect"); \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_fill_ite_protect(ite_sp, region_ptr, \
+ num_protected_regions, region_slot_reg) \
+ do { \
+ int incr; \
+ MR_RegionIteProtect *ite_prot; \
+ \
+ ite_prot = (MR_RegionIteProtect *) (region_slot_reg); \
+ incr = MR_region_fill_ite_protect_func( \
+ (MR_RegionIteFixedFrame *) (ite_sp), \
+ (MR_RegionHeader *) (region_ptr), \
+ ite_prot); \
+ (num_protected_regions) += incr; \
+ ite_prot += incr; \
+ (region_slot_reg) = ( (MR_Word) ite_prot ); \
+ } while (0)
+
+ extern int MR_region_fill_ite_protect_func(
+ MR_RegionIteFixedFrame *ite_sp,
+ MR_RegionHeader *region,
+ MR_RegionIteProtect *ite_prot);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/*
** This is to prepare for instant reclaiming at the start of else. For instant
** reclaiming a region we save its current size by taking a snapshot of it. The
@@ -355,14 +414,16 @@
/*
** XXX ite_sp is not used here.
*/
-#define MR_region_fill_ite_snapshot_removed(ite_sp, region_ptr, \
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_fill_ite_snapshot_removed(ite_sp, region_ptr, \
num_snapshots, snapshot_block) \
do { \
MR_RegionHeader *region; \
MR_RegionSnapshot *snapshot; \
\
- MR_region_debug_start( \
- "fill_ite_snapshot_removed"); \
+ MR_region_debug_start("fill_ite_snapshot_removed"); \
region = (MR_RegionHeader *) (region_ptr); \
snapshot = (MR_RegionSnapshot *) (snapshot_block); \
if ((region->MR_region_ite_protected != NULL && \
@@ -382,15 +443,40 @@
MR_region_debug_end("fill_ite_snapshot_removed"); \
} while (0)
-/* XXX: This can be made more efficient because we will save them all */
-#define MR_region_fill_ite_snapshot_not_removed(ite_sp, region_ptr, \
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_fill_ite_snapshot_removed(ite_sp, region_ptr, \
+ num_snapshots, snapshot_block) \
+ do { \
+ int incr; \
+ MR_RegionSnapshot *snapshot; \
+ \
+ snapshot = (MR_RegionSnapshot *) (snapshot_block); \
+ incr = MR_region_fill_ite_snapshot_removed_func( \
+ (MR_RegionHeader *) (region_ptr), \
+ snapshot); \
+ (num_snapshots) += incr; \
+ snapshot += incr; \
+ (snapshot_block) = ( (MR_Word) snapshot ); \
+ } while (0)
+
+ extern int MR_region_fill_ite_snapshot_removed_func(
+ MR_RegionHeader *region,
+ MR_RegionSnapshot *snapshot);
+
+#endif /* MR_RBMM_USE_MACROS */
+
+/* XXX: This can be made more efficient because we will save them all. */
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_fill_ite_snapshot_not_removed(ite_sp, region_ptr, \
num_snapshots, snapshot_block) \
do { \
MR_RegionHeader *region; \
MR_RegionSnapshot *snapshot; \
\
- MR_region_debug_start( \
- "fill_ite_snapshot_not_removed"); \
+ MR_region_debug_start("fill_ite_snapshot_not_removed"); \
region = (MR_RegionHeader *) (region_ptr); \
snapshot = (MR_RegionSnapshot *) (snapshot_block); \
MR_save_snapshot(region, snapshot); \
@@ -399,11 +485,37 @@
(num_snapshots)++; \
MR_region_debug_fill_ite_snapshot_not_removed(snapshot, \
region); \
- MR_region_debug_end( \
- "fill_ite_snapshot_not_removed"); \
+ MR_region_debug_end("fill_ite_snapshot_not_removed"); \
+ } while (0)
+
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_fill_ite_snapshot_not_removed(ite_sp, region_ptr, \
+ num_snapshots, snapshot_block) \
+ do { \
+ MR_RegionSnapshot *snapshot; \
+ \
+ snapshot = (MR_RegionSnapshot *) (snapshot_block); \
+ MR_region_fill_ite_snapshot_not_removed_proc( \
+ (MR_RegionHeader *) (region_ptr), \
+ snapshot); \
+ (snapshot_block) = (MR_Word) (snapshot + 1); \
+ (num_snapshots)++; \
} while (0)
+
+ extern void MR_region_fill_ite_snapshot_not_removed_proc(
+ MR_RegionHeader *region,
+ MR_RegionSnapshot *snapshot);
+
+#endif /* MR_RBMM_USE_MACROS */
+
+/*
+** XXX disj_sp is actually not needed here.
+*/
+
+#ifdef MR_RBMM_USE_MACROS
-#define MR_region_fill_semi_disj_protect(disj_sp, region_ptr, \
+ #define MR_region_fill_semi_disj_protect(disj_sp, region_ptr, \
num_protected_regions, protection_block) \
do { \
MR_RegionHeader *region; \
@@ -428,8 +540,36 @@
MR_region_debug_end("fill_ite_protect"); \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_fill_semi_disj_protect(disj_sp, region_ptr, \
+ num_protected_regions, protection_block) \
+ do { \
+ MR_RegionHeader *region; \
+ MR_RegionSemiDisjProtect *semi_disj_prot; \
+ \
+ semi_disj_prot = \
+ (MR_RegionSemiDisjProtect *) (protection_block); \
+ incr = MR_region_fill_semi_disj_protect_func( \
+ (MR_RegionHeader *) (region_ptr), \
+ semi_disj_prot); \
+ (num_protected_regions) += incr; \
+ semi_disj_prot += incr; \
+ (protection_block) = ( (MR_Word)semi_disj_prot ); \
+ } while (0)
+
+ extern int MR_region_fill_semi_disj_protect_func(
+ MR_RegionHeader *region,
+ MR_RegionSemiDisjProtect *semi_disj_prot);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/* XXX: This can be made more efficient because we will save them all */
-#define MR_region_fill_disj_snapshot(disj_sp, region_ptr, \
+/* XXX: disj_sp is actually not needed. */
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_fill_disj_snapshot(disj_sp, region_ptr, \
num_snapshots, snapshot_block) \
do { \
MR_RegionHeader *region; \
@@ -446,12 +586,36 @@
MR_region_debug_end("fill_disj_snapshot"); \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_fill_disj_snapshot(disj_sp, region_ptr, \
+ num_snapshots, snapshot_block) \
+ do { \
+ MR_RegionSnapshot *snapshot; \
+ \
+ snapshot = (MR_RegionSnapshot *) (snapshot_block); \
+ MR_region_fill_disj_snapshot_proc( \
+ (MR_RegionHeader *) (region_ptr), \
+ snapshot); \
+ (snapshot_block) = (MR_Word) (snapshot + 1); \
+ (num_snapshots)++; \
+ } while (0)
+
+ extern void MR_region_fill_disj_snapshot_proc(
+ MR_RegionHeader *region,
+ MR_RegionSnapshot *snapshot);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/*
** Save the live and unprotected regions which are input to the commit goal
** into the top commit stack frame.
** Set the commit_frame field in these regions to point to the frame.
*/
-#define MR_region_fill_commit(commit_sp, region_ptr, \
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_fill_commit(commit_sp, region_ptr, \
num_saved_region_reg, region_slot_reg) \
do { \
MR_RegionHeader *region; \
@@ -464,7 +628,7 @@
{ \
commit_save = (MR_RegionCommitSave *) (region_slot_reg);\
commit_save->MR_commit_save_region = region; \
- num_saved_region_reg++; \
+ (num_saved_region_reg)++; \
(region_slot_reg) = (MR_Word) (commit_save + 1); \
region->MR_region_commit_frame = \
(MR_RegionCommitFixedFrame *) (commit_sp); \
@@ -476,6 +640,31 @@
MR_region_debug_end("fill_commit"); \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_fill_commit(commit_sp, region_ptr, \
+ num_saved_region_reg, region_slot_reg) \
+ do { \
+ int incr; \
+ MR_RegionCommitSave *commit_save; \
+ \
+ commit_save = (MR_RegionCommitSave *) (region_slot_reg); \
+ incr = MR_region_fill_commit_func( \
+ (MR_RegionCommitFixedFrame *) (commit_sp), \
+ (MR_RegionHeader *) (region_ptr), \
+ commit_save); \
+ (num_saved_region_reg) += incr; \
+ commit_save += incr; \
+ (region_slot_reg) = ( (MR_Word) commit_save ); \
+ } while (0)
+
+ extern int MR_region_fill_commit_func(
+ MR_RegionCommitFixedFrame *commit_sp,
+ MR_RegionHeader *region,
+ MR_RegionCommitSave *commit_save);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/*---------------------------------------------------------------------------*/
/*
** region_set_fixed_slot
@@ -535,7 +724,10 @@
** + 2. if we destroy a protected region, we have to nullify its
** corresponding entry in the ite frame.
*/
-#define MR_use_region_ite_then_semidet(ite_sp) \
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_use_region_ite_then_semidet(ite_sp) \
do { \
MR_RegionIteFixedFrame *top_ite_frame; \
MR_RegionIteProtect *ite_prot; \
@@ -554,7 +746,7 @@
MR_region_debug_end("use_region_ite_then_semidet"); \
} while (0)
-#define MR_use_region_ite_then_nondet(ite_sp) \
+ #define MR_use_region_ite_then_nondet(ite_sp) \
do { \
MR_RegionIteFixedFrame *top_ite_frame; \
MR_RegionIteProtect *ite_prot; \
@@ -574,7 +766,32 @@
MR_region_debug_end("use_region_ite_then_nondet"); \
} while (0)
-#define MR_use_region_ite_else_semidet(ite_sp) \
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_use_region_ite_then_semidet(ite_sp) \
+ do { \
+ MR_use_region_ite_then_semidet_proc( \
+ (MR_RegionIteFixedFrame *) (ite_sp)); \
+ } while (0)
+
+ extern void MR_use_region_ite_then_semidet_proc(
+ MR_RegionIteFixedFrame *top_ite_frame);
+
+ #define MR_use_region_ite_then_nondet(ite_sp) \
+ do { \
+ top_ite_frame = (MR_RegionIteFixedFrame *) (ite_sp); \
+ MR_use_region_ite_then_nondet_proc( \
+ (MR_RegionIteFixedFrame *) (ite_sp)); \
+ } while (0)
+
+ extern void MR_use_region_ite_then_nondet_proc(
+ MR_RegionIteFixedFrame *top_ite_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_use_region_ite_else_semidet(ite_sp) \
do { \
MR_RegionIteFixedFrame *top_ite_frame; \
\
@@ -584,7 +801,7 @@
MR_region_debug_end("use_region_ite_else_semidet"); \
} while (0)
-#define MR_use_region_ite_else_nondet(ite_sp) \
+ #define MR_use_region_ite_else_nondet(ite_sp) \
do { \
MR_RegionIteFixedFrame *top_ite_frame; \
\
@@ -594,6 +811,28 @@
MR_region_debug_end("use_region_ite_else_nondet"); \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_use_region_ite_else_semidet(ite_sp) \
+ do { \
+ MR_use_region_ite_else_semidet_proc( \
+ (MR_RegionIteFixedFrame *) (ite_sp)); \
+ } while (0)
+
+ extern void MR_use_region_ite_else_semidet_proc(
+ MR_RegionIteFixedFrame *top_ite_frame);
+
+ #define MR_use_region_ite_else_nondet(ite_sp) \
+ do { \
+ MR_use_region_ite_else_nondet_proc( \
+ (MR_RegionIteFixedFrame *) (ite_sp)); \
+ } while (0)
+
+ extern void MR_use_region_ite_else_nondet_proc(
+ MR_RegionIteFixedFrame *top_ite_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/*
** This is to handle the post-success failure of the condition in an
** if-then-else with nondet condition.
@@ -615,7 +854,10 @@
** suboptimal but the cost seems negligible.
** After that the frame is discarded.
*/
-#define MR_use_region_ite_nondet_cond_fail(ite_sp) \
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_use_region_ite_nondet_cond_fail(ite_sp) \
do { \
MR_RegionIteFixedFrame *top_ite_frame; \
\
@@ -626,7 +868,22 @@
MR_region_debug_end("use_region_ite_nondet_cond_fail"); \
} while (0)
-#define MR_use_region_disj_later(disj_sp) \
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_use_region_ite_nondet_cond_fail(ite_sp) \
+ do { \
+ MR_use_region_ite_nondet_cond_fail( \
+ (MR_RegionIteFixedFrame *) (ite_sp)); \
+ } while (0)
+
+ extern void MR_use_region_ite_nondet_cond_fail_proc(
+ MR_RegionIteFixedFrame *top_ite_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_use_region_disj_later(disj_sp) \
do { \
MR_RegionDisjFixedFrame *top_disj_frame; \
\
@@ -637,7 +894,22 @@
MR_region_debug_end("use_region_disj_later"); \
} while (0)
-#define MR_use_region_disj_nonlast_semi_commit(disj_sp) \
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_use_region_disj_later(disj_sp) \
+ do { \
+ MR_use_region_disj_later_proc( \
+ (MR_RegionDisjFixedFrame *) (disj_sp)); \
+ } while (0)
+
+ extern void MR_use_region_disj_later_proc(
+ MR_RegionDisjFixedFrame *top_disj_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_use_region_disj_nonlast_semi_commit(disj_sp) \
do { \
MR_RegionDisjFixedFrame *top_disj_frame; \
MR_RegionSemiDisjProtect *semi_disj_prot; \
@@ -646,7 +918,7 @@
MR_region_debug_start( \
"use_region_disj_nonlast_semi_commit"); \
top_disj_frame = (MR_RegionDisjFixedFrame *) (disj_sp); \
- /* XXX destroy any regions protected by the disj frame */ \
+ /* Destroy any regions protected by the disj frame */ \
semi_disj_prot = (MR_RegionSemiDisjProtect *) ( (disj_sp) + \
MR_REGION_DISJ_FRAME_FIXED_SIZE); \
for (i = 0; i < top_disj_frame->MR_rdff_num_prot_regions; \
@@ -658,7 +930,26 @@
MR_region_debug_end("use_region_disj_nonlast_semi_commit"); \
} while (0)
-#define MR_use_region_disj_last(disj_sp) \
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_use_region_disj_nonlast_semi_commit(disj_sp) \
+ do { \
+ MR_RegionDisjFixedFrame *top_disj_frame; \
+ MR_RegionSemiDisjProtect *semi_disj_prot; \
+ int i; \
+ \
+ MR_use_region_disj_nonlast_semi_commit_proc( \
+ (MR_RegionDisjFixedFrame *) (disj_sp)); \
+ } while (0)
+
+ extern void MR_use_region_disj_nonlast_semi_commit_proc(
+ MR_RegionDisjFixedFrame *top_disj_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_use_region_disj_last(disj_sp) \
do { \
MR_RegionDisjFixedFrame *top_disj_frame; \
\
@@ -670,7 +961,22 @@
MR_region_debug_end("use_region_disj_last"); \
} while (0)
-#define MR_use_region_commit_success(commit_sp) \
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_use_region_disj_last(disj_sp) \
+ do { \
+ MR_use_region_disj_last_proc( \
+ (MR_RegionDisjFixedFrame *) (disj_sp) ); \
+ } while (0)
+
+ extern void MR_use_region_disj_last_proc(
+ MR_RegionDisjFixedFrame *top_disj_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_use_region_commit_success(commit_sp) \
do { \
MR_RegionCommitFixedFrame *top_commit_frame; \
MR_RegionCommitSave *first_commit_save; \
@@ -692,12 +998,28 @@
MR_region_debug_end("use_region_commit_success"); \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_use_region_commit_success(commit_sp) \
+ do { \
+ MR_use_region_commit_success_proc( \
+ (MR_RegionCommitFixedFrame *) (commit_sp) ); \
+ } while (0)
+
+ extern void MR_use_region_commit_success_proc(
+ MR_RegionCommitFixedFrame *top_commit_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/*
** Commit failure means that the goal in the commit operation has failed.
** We reset the commit_frame field of the saved regions at the commit frame to
** NULL. Then the top commit frame is popped.
*/
-#define MR_use_region_commit_failure(commit_sp) \
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_use_region_commit_failure(commit_sp) \
do { \
MR_RegionCommitFixedFrame *top_commit_frame; \
MR_RegionCommitSave *commit_save; \
@@ -720,6 +1042,19 @@
MR_region_debug_end("use_region_commit_failure"); \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_use_region_commit_failure(commit_sp) \
+ do { \
+ MR_use_region_commit_failure_proc( \
+ (MR_RegionCommitFixedFrame *) (commit_sp) ); \
+ } while (0)
+
+ extern void MR_use_region_commit_failure_proc(
+ MR_RegionCommitFixedFrame *top_commit_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
extern void MR_commit_success_destroy_marked_saved_regions(
MR_Word number_of_saved_regions,
MR_RegionCommitSave *first_commit_save);
@@ -761,7 +1096,10 @@
** 3. instant reclaiming by destroying new regions created in the condition,
** 4. pop the current ite frame.
*/
-#define MR_region_process_at_ite_else(top_ite_frame) \
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_process_at_ite_else(top_ite_frame) \
do { \
MR_region_ite_unprotect(top_ite_frame); \
MR_region_ite_restore_from_snapshots(top_ite_frame); \
@@ -769,10 +1107,25 @@
MR_pop_region_ite_frame(top_ite_frame); \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_process_at_ite_else(top_ite_frame) \
+ do { \
+ MR_region_process_at_ite_else_proc(top_ite_frame); \
+ } while (0)
+
+ extern void MR_region_process_at_ite_else_proc(
+ MR_RegionIteFixedFrame *top_ite_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/*
** Unprotect the protected regions at the beginning of the else part.
*/
-#define MR_region_ite_unprotect(top_ite_frame) \
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_ite_unprotect(top_ite_frame) \
do { \
MR_RegionIteProtect *ite_prot; \
MR_RegionHeader *protected_region; \
@@ -792,13 +1145,26 @@
MR_region_debug_end("ite_unprotect"); \
} while (0)
-#define MR_region_ite_restore_from_snapshots(top_ite_frame) \
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_ite_unprotect(top_ite_frame) \
+ do { \
+ MR_region_ite_unprotect_proc(top_ite_frame); \
+ } while (0)
+
+ extern void MR_region_ite_unprotect_proc(
+ MR_RegionIteFixedFrame *top_ite_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_ite_restore_from_snapshots(top_ite_frame) \
do { \
MR_RegionSnapshot *first_snapshot; \
MR_Word protection_size; \
\
- MR_region_debug_start( \
- "ite_restore_from_snapshot"); \
+ MR_region_debug_start("ite_restore_from_snapshot"); \
protection_size = top_ite_frame->MR_riff_num_prot_regions * \
MR_REGION_ITE_PROT_SIZE; \
first_snapshot = (MR_RegionSnapshot *) ( \
@@ -806,33 +1172,58 @@
MR_REGION_ITE_FRAME_FIXED_SIZE + protection_size); \
MR_restore_snapshots(top_ite_frame->MR_riff_num_snapshots, \
first_snapshot); \
- MR_region_debug_end( \
- "ite_restore_from_snapshot"); \
+ MR_region_debug_end("ite_restore_from_snapshot"); \
} while (0)
-#define MR_region_ite_destroy_new_regions(top_ite_frame) \
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_ite_restore_from_snapshots(top_ite_frame) \
do { \
- MR_region_debug_start( \
- "ite_destroy_new_regions"); \
+ MR_region_ite_restore_from_snapshots_proc(top_ite_frame); \
+ } while (0)
+
+ extern void MR_region_ite_restore_from_snapshots_proc(
+ MR_RegionIteFixedFrame *top_ite_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_ite_destroy_new_regions(top_ite_frame) \
+ do { \
+ MR_region_debug_start("ite_destroy_new_regions"); \
MR_region_frame_destroy_new_regions( \
top_ite_frame->MR_riff_saved_sequence_number, \
MR_REGION_ITE_FRAME_TYPE); \
- MR_region_debug_end( \
- "ite_destroy_new_regions"); \
+ MR_region_debug_end("ite_destroy_new_regions"); \
+ } while (0)
+
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_ite_destroy_new_regions(top_ite_frame) \
+ do { \
+ MR_region_ite_destroy_new_regions_proc(top_ite_frame); \
} while (0)
+ extern void MR_region_ite_destroy_new_regions_proc(
+ MR_RegionIteFixedFrame *top_ite_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/*---------------------------------------------------------------------------*/
/* Helpers for nondet disjunction support. */
/*
** At any non-first disjunct, try instant reclaiming from snapshots.
*/
-#define MR_region_disj_restore_from_snapshots(top_disj_frame) \
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_disj_restore_from_snapshots(top_disj_frame) \
do { \
MR_RegionSnapshot *first_snapshot; \
\
- MR_region_debug_start( \
- "disj_restore_from_snapshots"); \
+ MR_region_debug_start("disj_restore_from_snapshots"); \
first_snapshot = (MR_RegionSnapshot *) ( \
(MR_Word *) (top_disj_frame) + \
MR_REGION_DISJ_FRAME_FIXED_SIZE + \
@@ -840,37 +1231,74 @@
top_disj_frame->MR_rdff_num_prot_regions); \
MR_restore_snapshots(top_disj_frame->MR_rdff_num_snapshots, \
first_snapshot); \
- MR_region_debug_end( \
- "disj_restore_from_snapshots"); \
+ MR_region_debug_end("disj_restore_from_snapshots"); \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_disj_restore_from_snapshots(top_disj_frame) \
+ do { \
+ MR_region_disj_restore_from_snapshots_proc(top_disj_frame); \
+ } while (0)
+
+ extern void MR_region_disj_restore_from_snapshots_proc(
+ MR_RegionDisjFixedFrame *top_disj_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/*
** At any non-first disjunct, try instant reclaiming by destroying new
** regions.
*/
-#define MR_region_disj_destroy_new_regions(top_disj_frame) \
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_disj_destroy_new_regions(top_disj_frame) \
do { \
- MR_region_debug_start( \
- "disj_destroy_new_regions"); \
+ MR_region_debug_start("disj_destroy_new_regions"); \
MR_region_frame_destroy_new_regions( \
top_disj_frame->MR_rdff_saved_sequence_number, \
MR_REGION_DISJ_FRAME_TYPE); \
- MR_region_debug_end( \
- "disj_destroy_new_regions"); \
+ MR_region_debug_end("disj_destroy_new_regions"); \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_disj_destroy_new_regions(top_disj_frame) \
+ do { \
+ MR_region_disj_destroy_new_regions_proc(top_disj_frame); \
+ } while (0)
+
+ extern void MR_region_disj_destroy_new_regions_proc(
+ MR_RegionDisjFixedFrame *top_disj_frame);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/*---------------------------------------------------------------------------*/
-#define MR_save_snapshot(region, snapshot) \
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_save_snapshot(region, snapshot) \
do { \
- snapshot->MR_snapshot_region = (region); \
- snapshot->MR_snapshot_saved_last_page = \
+ (snapshot)->MR_snapshot_region = (region); \
+ (snapshot)->MR_snapshot_saved_last_page = \
(region)->MR_region_last_page; \
- snapshot->MR_snapshot_saved_next_available_word = \
+ (snapshot)->MR_snapshot_saved_next_available_word = \
(region)->MR_region_next_available_word; \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_save_snapshot(region, snapshot) \
+ do { \
+ MR_save_snapshot_proc(region,snapshot); \
+ } while (0)
+
+ extern void MR_save_snapshot_proc(MR_RegionHeader *region,
+ MR_RegionSnapshot *snapshot);
+#endif /* MR_RBMM_USE_MACROS */
+
/*
** XXX For profiling:
** One correct way to reset the allocated_size is to save it in the snapshot
@@ -881,7 +1309,9 @@
** allocated_size sometimes is not realiable.
*/
-#define MR_restore_snapshots(num_snapshots, first_snapshot) \
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_restore_snapshots(num_snapshots, first_snapshot) \
do { \
MR_RegionSnapshot *snapshot; \
MR_RegionHeader *restoring_region; \
@@ -909,7 +1339,21 @@
} \
} while(0)
-#define MR_region_frame_destroy_new_regions(saved_sequence_number, \
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_restore_snapshots(num_snapshots, first_snapshot) \
+ do { \
+ MR_restore_snapshots_proc(num_snapshots, first_snapshot); \
+ } while(0)
+
+ extern void MR_restore_snapshots_proc(int num_snapshots,
+ MR_RegionSnapshot *first_snapshot);
+
+#endif /* MR_RBMM_USE_MACROS */
+
+#ifdef MR_RBMM_USE_MACROS
+
+ #define MR_region_frame_destroy_new_regions(saved_sequence_number, \
frame_type) \
do { \
MR_RegionHeader *region; \
@@ -928,6 +1372,20 @@
MR_live_region_list = region; \
} while (0)
+#else /* MR_RBMM_USE_MACROS */
+
+ #define MR_region_frame_destroy_new_regions(saved_sequence_number, \
+ frame_type) \
+ do { \
+ MR_region_frame_destroy_new_regions_proc( \
+ saved_sequence_number, frame_type); \
+ } while (0)
+
+ extern void MR_region_frame_destroy_new_regions_proc(
+ int saved_sequence_number, int frame_type);
+
+#endif /* MR_RBMM_USE_MACROS */
+
/* from_page must not be NULL. */
#define MR_region_return_page_list(from_page, to_page) \
do { \
@@ -1142,6 +1600,8 @@
MR_RegionSnapshot *, MR_RegionHeader *);
extern void MR_region_fill_ite_snapshot_removed_msg(MR_RegionSnapshot *,
MR_RegionHeader *);
+extern void MR_region_fill_semi_disj_protect_msg(
+ MR_RegionSemiDisjProtect *, MR_RegionHeader *);
extern void MR_region_fill_disj_snapshot_msg(MR_RegionSnapshot *,
MR_RegionHeader *);
extern void MR_region_fill_commit_msg(MR_RegionCommitSave *,
@@ -1219,9 +1679,6 @@
extern int MR_region_get_disj_frame_size(MR_RegionDisjFixedFrame *);
extern int MR_region_get_commit_frame_size(MR_RegionCommitFixedFrame *);
-#define MR_REGION_DISJ_FRAME_TYPE 0
-#define MR_REGION_ITE_FRAME_TYPE 1
-
#define MR_region_profile_push_ite_frame \
do { \
MR_region_update_profiling_unit(&MR_rbmmp_num_ite_frames, \
More information about the reviews
mailing list