[m-rev.] For review: Protecting backward live regions for disjunctions.
Quan Phan
quan.phan at cs.kuleuven.be
Mon Oct 15 08:17:11 AEST 2007
Hi,
For review by Zoltan (The change is proposed in a previous email to
you.)
I will update the advanced_support document soon.
Regards,
Quan.
-------------- next part --------------
Estimated hours taken: 10
Branch: main
Modify the mechanism of protecting backward live regions for a disjunction.
The reason for this is because generally we do not locally know what regions
will be needed when the program backtracks to the disjunction. Details of
this modification will be in a separate document.
Change to use structs instead of pointer arithmetic in mercury_region.{c,h}.
Fix some bugs, debug messages.
runtime/mercury_region.c:
runtime/mercury_region.h:
Implement the modifications.
runtime/mercury_types.h:
Add type definitions for the new structs.
compiler/options.m:
Change to be consistent with the main modification.
-------------- next part --------------
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bench
cvs diff: Diffing bench/progs
cvs diff: Diffing bench/progs/compress
cvs diff: Diffing bench/progs/icfp2000
cvs diff: Diffing bench/progs/icfp2001
cvs diff: Diffing bench/progs/nuc
cvs diff: Diffing bench/progs/ray
cvs diff: Diffing bench/progs/tree234
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/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
cvs diff: Diffing browser/test
cvs diff: Diffing bytecode
cvs diff: Diffing bytecode/test
cvs diff: Diffing compiler
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.589
diff -u -r1.589 options.m
--- compiler/options.m 10 Oct 2007 07:18:13 -0000 1.589
+++ compiler/options.m 14 Oct 2007 21:55:31 -0000
@@ -1205,10 +1205,10 @@
% The values here must be consistent with those in mercury_region.h.
size_region_ite_fixed - int(4),
size_region_disj_fixed - int(4),
- size_region_commit_fixed - int(3),
+ size_region_commit_fixed - int(4),
size_region_ite_protect - int(1),
size_region_ite_snapshot - int(4),
- size_region_disj_protect - int(1),
+ size_region_disj_protect - int(0),
size_region_disj_snapshot - int(4),
size_region_commit_entry - int(1)
]).
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing detail
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/base64
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/concurrency
cvs diff: Diffing extras/concurrency/samples
cvs diff: Diffing extras/concurrency/samples/midi
cvs diff: Diffing extras/concurrency/tests
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/exceptions
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_glut
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/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lazy_evaluation/examples
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
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/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/opium_m
cvs diff: Diffing extras/opium_m/non-regression-tests
cvs diff: Diffing extras/opium_m/scripts
cvs diff: Diffing extras/opium_m/source
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/stream/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing lp_solve
cvs diff: Diffing lp_solve/lp_examples
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing quickcheck
cvs diff: Diffing quickcheck/tutes
cvs diff: Diffing readline
cvs diff: Diffing readline/doc
cvs diff: Diffing readline/examples
cvs diff: Diffing readline/shlib
cvs diff: Diffing readline/support
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_region.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_region.c,v
retrieving revision 1.2
diff -u -r1.2 mercury_region.c
--- runtime/mercury_region.c 11 Oct 2007 15:29:24 -0000 1.2
+++ runtime/mercury_region.c 14 Oct 2007 21:55:32 -0000
@@ -22,9 +22,9 @@
MR_RegionPage *MR_region_free_page_list;
MR_Region *MR_live_region_list;
-MR_Word *MR_region_ite_sp = NULL;
-MR_Word *MR_region_disj_sp = NULL;
-MR_Word *MR_region_commit_sp = NULL;
+MR_RegionIteFixedFrame *MR_region_ite_sp = NULL;
+MR_RegionDisjFixedFrame *MR_region_disj_sp = NULL;
+MR_RegionCommitFixedFrame *MR_region_commit_sp = NULL;
MR_Word MR_region_sequence_number = 1;
@@ -52,7 +52,8 @@
static void MR_region_nullify_entries_in_commit_stack(
MR_Region *region);
-static void MR_region_nullify_in_commit_frame(MR_Word *frame,
+static void MR_region_nullify_in_commit_frame(
+ MR_RegionCommitFixedFrame *frame,
MR_Region *region);
static void MR_region_nullify_in_ite_frame(MR_Region *region);
@@ -150,7 +151,6 @@
region->MR_region_sequence_number = MR_region_sequence_number++;
region->MR_region_logical_removed = 0;
region->MR_region_ite_protected = NULL;
- region->MR_region_disj_protected = NULL;
region->MR_region_commit_frame = NULL;
region->MR_region_destroy_at_commit = 0;
@@ -177,35 +177,36 @@
static void
MR_region_nullify_entries_in_commit_stack(MR_Region *region)
{
- MR_Word *frame;
+ MR_RegionCommitFixedFrame *frame;
frame = region->MR_region_commit_frame;
while (frame != NULL) {
MR_region_nullify_in_commit_frame(frame, region);
- frame = (MR_Word *) *frame;
+ frame = frame->MR_rcff_previous_commit_frame;
}
}
static void
-MR_region_nullify_in_commit_frame(MR_Word *frame, MR_Region *region)
+MR_region_nullify_in_commit_frame(MR_RegionCommitFixedFrame *commit_frame,
+ MR_Region *region)
{
- MR_Word *saved_region;
- int num_saved_regions;
+ MR_RegionCommitSave *commit_save;
int i;
- num_saved_regions = *(frame + MR_REGION_COMMIT_FRAME_NUMBER_SAVED_REGIONS);
- saved_region = frame + MR_REGION_COMMIT_FRAME_FIRST_SAVED_REGION;
+ commit_save = ( MR_RegionCommitSave *) (
+ ( MR_Word *) commit_frame + MR_REGION_COMMIT_FRAME_FIXED_SIZE);
/*
** Loop through the saved regions and nullify the entry of the input
** region if found.
*/
- for (i = 0; i < num_saved_regions; i++) {
- if ((MR_Region *) (*saved_region) == region) {
- (*saved_region) = (MR_Word) NULL;
+ for (i = 0; i < commit_frame->MR_rcff_num_saved_regions; i++) {
+ if (commit_save != NULL &&
+ commit_save->MR_commit_save_region == region) {
+ commit_save->MR_commit_save_region = NULL;
break;
} else {
- saved_region += 1;
+ commit_save += 1;
}
}
}
@@ -213,26 +214,26 @@
static void
MR_region_nullify_in_ite_frame(MR_Region *region)
{
- MR_Word *ite_frame;
- MR_Word *protected_region;
- int num_protected_regions;
- int i;
+ MR_RegionIteFixedFrame *ite_frame;
+ MR_RegionIteProtect *ite_prot;
+ MR_Word *protected_region;
+ int num_protected_regions;
+ int i;
ite_frame = region->MR_region_ite_protected;
- num_protected_regions = * ((MR_Word *)
- (ite_frame + MR_REGION_FRAME_NUMBER_PROTECTED_REGIONS));
- protected_region = ite_frame + MR_REGION_FRAME_FIXED_SIZE;
+ ite_prot = (MR_RegionIteProtect *) ( (MR_Word *) ite_frame +
+ MR_REGION_ITE_FRAME_FIXED_SIZE );
/*
** Loop through the protected regions and nullify the entry of the input
** region if found.
*/
for (i = 0; i < num_protected_regions; i++) {
- if ((MR_Region *) (*protected_region) == region) {
- (*protected_region) = (MR_Word) NULL;
+ if (ite_prot != NULL && ite_prot->MR_ite_prot_region == region) {
+ ite_prot->MR_ite_prot_region = NULL;
break;
} else {
- protected_region += 1;
+ ite_prot += 1;
}
}
}
@@ -278,7 +279,7 @@
MR_remove_undisjprotected_region_ite_then_semidet(MR_Region *region)
{
MR_region_debug_try_remove_region(region);
- if (region->MR_region_disj_protected == NULL) {
+ if ( !MR_region_is_disj_protected(region) ) {
MR_region_destroy_region(region);
} else {
region->MR_region_logical_removed = 1;
@@ -301,7 +302,7 @@
{
MR_region_debug_try_remove_region(region);
- if (region->MR_region_disj_protected == NULL) {
+ if ( !MR_region_is_disj_protected(region) ) {
MR_region_nullify_in_ite_frame(region);
MR_region_destroy_region(region);
} else {
@@ -318,28 +319,18 @@
{
MR_region_debug_try_remove_region(region);
- if (region->MR_region_ite_protected == NULL &&
- region->MR_region_disj_protected == NULL)
+ if ( region->MR_region_ite_protected == NULL &&
+ !(MR_region_is_disj_protected(region)) )
{
MR_region_destroy_region(region);
} else {
region->MR_region_logical_removed = 1;
/*
- ** This means this logical removal happens in the condition of an
- ** if-then-else and this region is protected by the if-then-else, so
- ** we "ite-unprotect" it.
- if (region->ite_protected != NULL) {
- region->ite_protected = (MR_Word *) (*MR_region_ite_sp);
- } else {}
- */
-
- /*
- ** The region is saved at a commit frame, and this logical removal
- ** happens in the commit context. So we can and need to destroy the
- ** region at commit point.
+ ** This logical removal happens in a commit operation. Therefore we
+ ** mark the region so that it will be destroyed at the commit point.
*/
- if (region->MR_region_commit_frame != NULL) {
+ if (MR_region_commit_sp != NULL) {
region->MR_region_destroy_at_commit = 1;
}
@@ -378,23 +369,22 @@
page = MR_region_get_free_page();
region->MR_region_last_page->MR_regionpage_next = page;
region->MR_region_last_page = page;
- /* XXX Why the cast? */
- region->MR_region_next_available_word = (MR_Word *)
- page->MR_regionpage_space;
+ region->MR_region_next_available_word = page->MR_regionpage_space;
region->MR_region_available_space = MR_REGION_PAGE_SPACE_SIZE;
}
/* Destroy any marked regions allocated before scope entry. */
void
-MR_destroy_marked_old_regions_at_commit(MR_Word number_of_saved_regions,
- MR_Word *first_saved_region_slot)
+MR_commit_success_destroy_marked_saved_regions(MR_Word num_saved_regions,
+ MR_RegionCommitSave *first_commit_save)
{
- MR_Region *region;
- int i;
-
- for (i = 0; i < number_of_saved_regions; i++) {
- region = (MR_Region *)
- *(first_saved_region_slot + i * MR_REGION_COMMIT_ENTRY_SIZE);
+ MR_RegionCommitSave *commit_save;
+ MR_Region *region;
+ int i;
+
+ commit_save = first_commit_save;
+ for (i = 0; i < num_saved_regions; i++, commit_save++) {
+ region = commit_save->MR_commit_save_region;
if (region != NULL) {
/*
** The region is saved here and has not been destroyed.
@@ -411,19 +401,8 @@
*/
MR_region_destroy_region(region);
} else {
- /*
- ** The saved region is not removed in this commit context.
- ** We need to update the commit context that R may be saved
- ** after this frame is discarded.
- ** The reason here is that if R is saved at this
- ** current frame and also saved at any other frames, it must
- ** be saved at the previous frame of this frame.
- */
- /*
- region->MR_region_commit_frame =
- (MR_Word *) (*(region->MR_region_commit_frame));
- */
- MR_fatal_error("MR_destroy_marked_old_regions_at_commit: "
+ MR_fatal_error(
+ "MR_commit_success_destroy_marked_saved_regions: "
"need to rethink.");
}
}
@@ -432,7 +411,7 @@
/* Destroy any marked regions allocated since scope entry. */
void
-MR_destroy_marked_new_regions_at_commit(MR_Word saved_region_seq_number)
+MR_commit_success_destroy_marked_new_regions(MR_Word saved_region_seq_number)
{
MR_Region *region;
@@ -442,53 +421,35 @@
{
if (region->MR_region_destroy_at_commit) {
MR_region_destroy_region(region);
- } else {
- region = region->MR_region_next_region;
}
+ /*
+ ** XXX It is fine to destroy the region and then still use it to find
+ ** the next one because destroying a region is just returning
+ ** its pages, the "region" is still there in memory.
+ */
+ region = region->MR_region_next_region;
}
}
-#if 0
-static void restore_region(MR_Snapshot *);
-static void shrink_region(MR_Region *);
-
-/*
-** Shrink the region to the size which has been saved to the
-** snapshot list of the topmost nondet frame (maxfr).
-*/
+int
+MR_region_is_disj_protected(MR_Region *region)
+{
+ MR_RegionDisjFixedFrame *disj_frame;
-static void
-shrink_region(MR_Region *region) {
- if (region->nondet_frame_of_newest_snapshot == nondet_maxfr) {
- MR_Snapshot *snapshot = (MR_Snapshot *) region->newest_snapshot;
- restore_region(snapshot);
+ disj_frame = MR_region_disj_sp;
+ while (disj_frame != NULL)
+ {
+ if (disj_frame->MR_rdff_disj_prot_seq_number !=
+ MR_REGION_DISJ_FRAME_DUMMY_SEQ_NUMBER &&
+ disj_frame->MR_rdff_disj_prot_seq_number <
+ region->MR_region_sequence_number) {
+ return MR_TRUE;
+ }
+ disj_frame = disj_frame->MR_rdff_previous_disj_frame;
}
+ return MR_FALSE;
}
-/* Restore a region to a state saved in the snapshot. */
-static void
-restore_region(MR_Snapshot *snapshot) {
- MR_Region *region = snapshot->MR_snapshot_region;
- /* Return the list of pages added since the save to the global free
- ** page list.
- */
- region->last_page->MR_regionpage_next = MR_region_free_page_list;
- MR_region_free_page_list =
- snapshot->MR_snapshot_saved_last_page->MR_regionpage_next;
-
- /* Disconnect the saved last page (i.e., the last page of the restored
- ** region) from the free list.
- */
- snapshot->MR_snapshot_saved_last_page->MR_regionpage_next = NULL;
-
- /* Restore the saved region. */
- region->last_page = snapshot->MR_snapshot_saved_last_page;
- region->next_available_word =
- snapshot->MR_snapshot_saved_next_available_word;
- region->available_space = snapshot->MR_snapshot_saved_available_space;
- region->removal_counter = snapshot->MR_snapshot_saved_removal_counter;
-}
-#endif
/*---------------------------------------------------------------------------*/
/* Debugging messages for RBMM. */
@@ -498,7 +459,7 @@
static int
MR_region_get_frame_number(MR_Word *frame)
{
- int frame_number;
+ int frame_number;
frame_number = 0;
while (frame != NULL) {
@@ -544,255 +505,222 @@
printf("\tHandle: %d\n", region);
printf("\tLogically removed: %d\n", region->MR_region_logical_removed);
printf("\tProtected by ite frame #%d: %d\n",
- MR_region_get_frame_number(region->MR_region_ite_protected),
+ MR_region_get_frame_number((MR_Word *)region->MR_region_ite_protected),
region->MR_region_ite_protected);
- printf("\tProtected by disj frame #%d: %d\n",
- MR_region_get_frame_number(region->MR_region_disj_protected),
- region->MR_region_disj_protected);
+ if ( MR_region_is_disj_protected(region) ) {
+ printf("\tProtected by a disj frame.\n");
+ } else {
+ printf("\tNot disj-protected.\n");
+ }
printf("\tSaved in commit frame #%d: %d\n",
- MR_region_get_frame_number(region->MR_region_commit_frame),
+ MR_region_get_frame_number((MR_Word *)region->MR_region_commit_frame),
region->MR_region_commit_frame);
printf("\tBe destroyed at commit: %d\n",
region->MR_region_destroy_at_commit);
}
void
-MR_region_push_ite_frame_msg(MR_Word *ite_frame)
+MR_region_push_ite_frame_msg(MR_RegionIteFixedFrame *ite_frame)
{
- int frame_number;
+ int frame_number;
- frame_number = MR_region_get_frame_number(ite_frame);
+ frame_number = MR_region_get_frame_number( (MR_Word *) ite_frame);
printf("Push ite frame #%d: %d\n", frame_number, ite_frame);
printf("\tPrevious frame at push #%d: %d\n",
- MR_region_get_frame_number((MR_Word *) (*ite_frame)), *ite_frame);
+ MR_region_get_frame_number(
+ (MR_Word *) (ite_frame->MR_riff_previous_ite_frame)),
+ ite_frame->MR_riff_previous_ite_frame);
printf("\tSaved most recent region at push: %d\n",
- *(ite_frame + MR_REGION_FRAME_REGION_LIST));
+ ite_frame->MR_riff_saved_region_list);
}
void
-MR_region_ite_frame_msg(MR_Word *ite_frame)
+MR_region_ite_frame_msg(MR_RegionIteFixedFrame *ite_frame)
{
printf("Ite frame #%d: %d\n",
- MR_region_get_frame_number(ite_frame), ite_frame);
+ MR_region_get_frame_number( (MR_Word *) ite_frame), ite_frame);
printf("\tPrevious frame #%d: %d\n",
- MR_region_get_frame_number((MR_Word *) (*ite_frame)), *ite_frame);
- printf("\tSaved most recent: %d\n",
- *(ite_frame + MR_REGION_FRAME_REGION_LIST));
+ MR_region_get_frame_number(
+ (MR_Word *) (ite_frame->MR_riff_previous_ite_frame)),
+ ite_frame->MR_riff_previous_ite_frame);
+ printf("\tSaved most recent: %d\n", ite_frame->MR_riff_saved_region_list);
MR_region_ite_frame_protected_regions_msg(ite_frame);
MR_region_ite_frame_snapshots_msg(ite_frame);
}
void
-MR_region_ite_frame_protected_regions_msg(MR_Word *ite_frame)
+MR_region_ite_frame_protected_regions_msg(MR_RegionIteFixedFrame *ite_frame)
{
- MR_Word *first_protected_region;
- MR_Word *slot;
- int num_protected_regions;
- int i;
-
- num_protected_regions =
- *(ite_frame + MR_REGION_FRAME_NUMBER_PROTECTED_REGIONS);
- first_protected_region = ite_frame + MR_REGION_FRAME_FIXED_SIZE;
+ MR_RegionIteProtect *ite_prot;
+ int i;
/*
** This check is for development, when it becomes more stable,
** the check can be removed. Normally we expect not many regions.
*/
- if (num_protected_regions > 10) {
- printf("Number of protected region: %d\n", num_protected_regions);
+ if (ite_frame->MR_riff_num_prot_regions > 10) {
+ printf("Number of protected region: %d\n",
+ ite_frame->MR_riff_num_prot_regions);
MR_fatal_error("Too many protected regions.");
}
- for (i = 0; i < num_protected_regions; i++) {
- slot = first_protected_region + i * MR_REGION_ITE_PROT_SIZE;
- printf("\tAt slot: %d, ite-protect region: %d\n", slot, *slot);
+ ite_prot = (MR_RegionIteProtect *) (
+ (MR_Word *) ite_frame + MR_REGION_ITE_FRAME_FIXED_SIZE);
+ for (i = 0; i < ite_frame->MR_riff_num_prot_regions; i++, ite_prot++) {
+ printf("\tAt slot: %d, ite-protect region: %d\n",
+ ite_prot, ite_prot->MR_ite_prot_region);
}
}
void
-MR_region_ite_frame_snapshots_msg(MR_Word *ite_frame)
+MR_region_ite_frame_snapshots_msg(MR_RegionIteFixedFrame *ite_frame)
{
- MR_Word *first_snapshot;
- MR_Word *slot;
- int num_snapshots;
- int num_protected_regions;
- int i;
-
- num_snapshots = *(ite_frame + MR_REGION_FRAME_NUMBER_SNAPSHOTS);
- num_protected_regions =
- *(ite_frame + MR_REGION_FRAME_NUMBER_PROTECTED_REGIONS);
- first_snapshot = ite_frame + MR_REGION_FRAME_FIXED_SIZE +
- num_protected_regions * MR_REGION_ITE_PROT_SIZE;
+ MR_RegionSnapshot *snapshot;
+ int protection_size;
+ int i;
- if (num_snapshots > 10) {
- printf("Number of snapshots: %d\n", num_snapshots);
+ if (ite_frame->MR_riff_num_snapshots > 10) {
+ printf("Number of snapshots: %d\n", ite_frame->MR_riff_num_snapshots);
MR_fatal_error("Too many snapshots");
}
- for (i = 0; i < num_snapshots; i++) {
- slot = first_snapshot + i * MR_REGION_SNAPSHOT_SIZE;
- printf("\tAt slot: %d, snapshot of region: %d\n", slot, *slot);
+ protection_size = ite_frame->MR_riff_num_prot_regions *
+ MR_REGION_ITE_PROT_SIZE;
+ snapshot = (MR_RegionSnapshot *) ((MR_Word *) ite_frame +
+ MR_REGION_ITE_FRAME_FIXED_SIZE + protection_size);
+ for (i = 0; i < ite_frame->MR_riff_num_snapshots; i++, snapshot++) {
+ printf("\tAt slot: %d, snapshot of region: %d\n", snapshot,
+ snapshot->MR_snapshot_region);
}
}
void
-MR_region_push_disj_frame_msg(MR_Word *disj_frame)
+MR_region_push_disj_frame_msg(MR_RegionDisjFixedFrame *disj_frame)
{
printf("Push disj frame #%d: %d\n",
- MR_region_get_frame_number(disj_frame), disj_frame);
+ MR_region_get_frame_number((MR_Word *) disj_frame), disj_frame);
printf("\tPrevious frame at push #%d: %d\n",
- MR_region_get_frame_number((MR_Word *) (*disj_frame)), *disj_frame);
+ MR_region_get_frame_number(
+ (MR_Word *) (disj_frame->MR_rdff_previous_disj_frame)),
+ disj_frame->MR_rdff_previous_disj_frame);
printf("\tSaved most recent region at push: %d\n",
- *(disj_frame + MR_REGION_FRAME_REGION_LIST));
+ disj_frame->MR_rdff_saved_region_list);
}
void
-MR_region_disj_frame_msg(MR_Word *disj_frame)
+MR_region_disj_frame_msg(MR_RegionDisjFixedFrame *disj_frame)
{
printf("Disj frame #%d: %d\n",
- MR_region_get_frame_number(disj_frame), disj_frame);
+ MR_region_get_frame_number((MR_Word *) disj_frame), disj_frame);
printf("\tPrevious frame #%d: %d\n",
- MR_region_get_frame_number((MR_Word *) (*disj_frame)), *disj_frame);
+ MR_region_get_frame_number(
+ (MR_Word *) disj_frame->MR_rdff_previous_disj_frame),
+ disj_frame->MR_rdff_previous_disj_frame);
printf("\tSaved most recent region: %d\n",
- *(disj_frame + MR_REGION_FRAME_REGION_LIST));
+ disj_frame->MR_rdff_saved_region_list);
}
void
-MR_region_disj_frame_protected_regions_msg(MR_Word *disj_frame)
+MR_region_disj_frame_snapshots_msg(MR_RegionDisjFixedFrame *disj_frame)
{
- MR_Word *first_protected_region;
- MR_Word *slot;
- int num_protected_regions;
+ MR_RegionSnapshot *snapshot;
int i;
- num_protected_regions =
- *(disj_frame + MR_REGION_FRAME_NUMBER_PROTECTED_REGIONS);
- first_protected_region = disj_frame + MR_REGION_FRAME_FIXED_SIZE;
-
- /*
- ** This check is for development, when it becomes more stable,
- ** the check can be removed.
- */
- if (num_protected_regions > 10) {
- printf("Number of protected region: %d\n", num_protected_regions);
- MR_fatal_error("Too many protected regions.");
- }
-
- for (i = 0; i < num_protected_regions; i++) {
- slot = first_protected_region + i * MR_REGION_DISJ_PROT_SIZE;
- printf("\tAt slot: %d, disj-protect region: %d\n", slot, *slot);
- }
-
-}
-
-void
-MR_region_disj_frame_snapshots_msg(MR_Word *disj_frame)
-{
- MR_Word *first_snapshot;
- MR_Word *slot;
- int num_snapshots;
- int num_protected_regions;
- int i;
-
- num_snapshots = *(disj_frame + MR_REGION_FRAME_NUMBER_SNAPSHOTS);
- num_protected_regions =
- *(disj_frame + MR_REGION_FRAME_NUMBER_PROTECTED_REGIONS);
- first_snapshot = disj_frame + MR_REGION_FRAME_FIXED_SIZE +
- num_protected_regions * MR_REGION_DISJ_PROT_SIZE;
-
- if (num_snapshots > 10) {
- printf("Number of snapshots: %d\n", num_snapshots);
+ if (disj_frame->MR_rdff_num_snapshots > 10) {
+ printf("Number of snapshots: %d\n", disj_frame->MR_rdff_num_snapshots);
MR_fatal_error("Too many snapshots");
}
- for (i = 0; i < num_snapshots; i++) {
- slot = first_snapshot + i * MR_REGION_SNAPSHOT_SIZE;
- printf("\tAt slot: %d, snapshot of region: %d\n", slot, *slot);
+ snapshot = (MR_RegionSnapshot *) (
+ (MR_Word *) disj_frame + MR_REGION_DISJ_FRAME_FIXED_SIZE);
+ for (i = 0; i < disj_frame->MR_rdff_num_snapshots; i++, snapshot++) {
+ printf("\tAt slot: %d, snapshot of region: %d\n", snapshot,
+ snapshot->MR_snapshot_region);
}
}
void
-MR_region_push_commit_frame_msg(MR_Word *commit_frame)
+MR_region_push_commit_frame_msg(MR_RegionCommitFixedFrame *commit_frame)
{
int i;
printf("Push commit frame #%d: %d\n",
- MR_region_get_frame_number(commit_frame), commit_frame);
+ MR_region_get_frame_number((MR_Word *) commit_frame), commit_frame);
printf("\tPrevious frame at push #%d: %d\n",
- MR_region_get_frame_number((MR_Word *) *commit_frame), *commit_frame);
+ MR_region_get_frame_number(
+ (MR_Word *) commit_frame->MR_rcff_previous_commit_frame),
+ commit_frame->MR_rcff_previous_commit_frame);
printf("\tSequence number at push: %d\n",
- *(commit_frame + MR_REGION_COMMIT_FRAME_SEQUENCE_NUMBER));
+ commit_frame->MR_rcff_saved_sequence_number);
+ printf("\tDisj frame at push #%d: %d\n",
+ MR_region_get_frame_number(
+ (MR_Word *) (commit_frame->MR_rcff_saved_disj_sp)),
+ commit_frame->MR_rcff_saved_disj_sp);
}
void
-MR_region_commit_frame_msg(MR_Word *commit_frame)
+MR_region_commit_frame_msg(MR_RegionCommitFixedFrame *commit_frame)
{
- MR_Word *first_saved_region;
- MR_Word *saved_region;
+ MR_RegionCommitSave *commit_save;
int i;
- int num_saved_regions;
printf("Commit frame #%d: %d\n",
- MR_region_get_frame_number(commit_frame), commit_frame);
+ MR_region_get_frame_number((MR_Word *)commit_frame), commit_frame);
printf("\tPrevious frame #%d: %d\n",
- MR_region_get_frame_number((MR_Word *) (*commit_frame)),
- *commit_frame);
+ MR_region_get_frame_number(
+ (MR_Word *) commit_frame->MR_rcff_previous_commit_frame),
+ commit_frame->MR_rcff_previous_commit_frame);
printf("\tSequence number at push: %d\n",
- *(commit_frame + MR_REGION_COMMIT_FRAME_SEQUENCE_NUMBER));
-
- num_saved_regions =
- *(commit_frame + MR_REGION_COMMIT_FRAME_NUMBER_SAVED_REGIONS);
- first_saved_region = commit_frame +
- MR_REGION_COMMIT_FRAME_FIRST_SAVED_REGION;
-
- printf("\tNumber of saved regions: %d\n", num_saved_regions);
- for (i = 0; i < num_saved_regions; i++) {
- saved_region = first_saved_region + i * MR_REGION_COMMIT_ENTRY_SIZE;
- printf("Slot: %d, region: %d\n", saved_region, *saved_region);
+ commit_frame->MR_rcff_saved_sequence_number);
+ printf("\tDisj frame at push #%d: %d\n",
+ MR_region_get_frame_number(
+ (MR_Word *) (commit_frame->MR_rcff_saved_disj_sp)),
+ commit_frame->MR_rcff_saved_disj_sp);
+ printf("\tCurrent disj frame #%d: %d\n",
+ MR_region_get_frame_number((MR_Word *) MR_region_disj_sp),
+ MR_region_disj_sp);
+
+ commit_save = (MR_RegionCommitSave *) (
+ (MR_Word *) commit_frame + MR_REGION_COMMIT_FRAME_FIXED_SIZE);
+
+ printf("\tNumber of saved regions: %d\n",
+ commit_frame->MR_rcff_num_saved_regions);
+ for (i = 0; i < commit_frame->MR_rcff_num_saved_regions; i++,
+ commit_save++)
+ {
+ printf("Slot: %d, region: %d\n", commit_save,
+ commit_save->MR_commit_save_region);
}
}
void
-MR_region_commit_frame_saved_regions_msg(MR_Word *commit_frame)
+MR_region_commit_frame_saved_regions_msg(
+ MR_RegionCommitFixedFrame *commit_frame)
{
- MR_Word *first_saved_region;
- MR_Word *slot;
- int num_saved_regions;
+ MR_RegionCommitSave *commit_save;
int i;
- num_saved_regions =
- *(commit_frame + MR_REGION_COMMIT_FRAME_NUMBER_SAVED_REGIONS);
- first_saved_region = commit_frame + MR_REGION_COMMIT_FRAME_FIXED_SIZE;
-
/*
** This check is for development, when it becomes more stable, the
** check can be removed.
*/
- if (num_saved_regions > 10) {
- printf("Number of saved region: %d\n", num_saved_regions);
+ if (commit_frame->MR_rcff_num_saved_regions > 10) {
+ printf("Number of saved region: %d\n",
+ commit_frame->MR_rcff_num_saved_regions);
MR_fatal_error("Too many regions were saved.");
}
- for (i = 0; i < num_saved_regions; i++) {
- slot = first_saved_region + i;
- printf("\tAt slot: %d, saved region: %d\n", slot, *slot);
+ commit_save = (MR_RegionCommitSave *) (
+ (MR_Word *) commit_frame + MR_REGION_COMMIT_FRAME_FIXED_SIZE);
+ for (i = 0; i < commit_frame->MR_rcff_num_saved_regions;
+ i++, commit_save++)
+ {
+ printf("\tAt slot: %d, saved region: %d\n", commit_save,
+ commit_save->MR_commit_save_region);
}
}
-void
-MR_region_destroy_marked_regions_at_commit_msg(int saved_seq_number,
- int number_of_saved_regions, MR_Word *first_saved_region_slot)
-{
- printf("Destroy marked regions at commit:\n");
- printf("\tSaved sequence number: %d\n", saved_seq_number);
- printf("\tNumber of saved regions: %d\n", number_of_saved_regions);
-
- if (number_of_saved_regions > 0)
- printf("\tThe first slot of saved regions: %d\n",
- first_saved_region_slot);
-}
-
#endif /* End of MR_RBMM_DEBUG. */
/*---------------------------------------------------------------------------*/
@@ -842,8 +770,8 @@
int new_words;
int new_pages;
- restoring_region = snapshot->region;
- first_new_page = snapshot->saved_last_page->MR_regionpage_next;
+ restoring_region = snapshot->MR_snapshot_region;
+ first_new_page = snapshot->MR_snapshot_saved_last_page->MR_regionpage_next;
if (first_new_page != NULL) {
new_pages = MR_region_get_number_of_pages(first_new_page,
@@ -851,9 +779,9 @@
MR_region_update_profiling_unit(&MR_rbmmp_pages_used, -new_pages);
new_words = (new_pages * MR_REGION_PAGE_SPACE_SIZE -
restoring_region->MR_region_available_space +
- snapshot->saved_available_space);
+ snapshot->MR_snapshot_saved_available_space);
} else {
- new_words = snapshot->saved_available_space -
+ new_words = snapshot->MR_snapshot_saved_available_space -
restoring_region->MR_region_available_space;
}
((MR_RegionPage *) restoring_region)->MR_regionpage_allocated_size
Index: runtime/mercury_region.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_region.h,v
retrieving revision 1.2
diff -u -r1.2 mercury_region.h
--- runtime/mercury_region.h 11 Oct 2007 15:29:24 -0000 1.2
+++ runtime/mercury_region.h 14 Oct 2007 21:55:32 -0000
@@ -18,7 +18,7 @@
#include "mercury_types.h"
#ifdef MR_USE_REGIONS
-
+#define MR_RBMM_DEBUG
/*
** See the documentation of MR_RBMM_DEBUG and MR_RBMM_PROFILING in
** mercury_conf_param.h.
@@ -44,28 +44,18 @@
** options with corresponding names.
*/
-#define MR_REGION_FRAME_FIXED_SIZE 4
-#define MR_REGION_FRAME_PREVIOUS_FRAME 0
-#define MR_REGION_FRAME_REGION_LIST 1
-#define MR_REGION_FRAME_NUMBER_PROTECTED_REGIONS 2
-#define MR_REGION_FRAME_NUMBER_SNAPSHOTS 3
+#define MR_REGION_ITE_FRAME_FIXED_SIZE 4
+
+#define MR_REGION_DISJ_FRAME_FIXED_SIZE 4
+#define MR_REGION_DISJ_FRAME_DUMMY_SEQ_NUMBER 0
#define MR_REGION_COMMIT_FRAME_FIXED_SIZE 4
-#define MR_REGION_COMMIT_FRAME_PREVIOUS_FRAME 0
-#define MR_REGION_COMMIT_FRAME_SEQUENCE_NUMBER 1
-#define MR_REGION_COMMIT_FRAME_DISJ_FRAME 2
-#define MR_REGION_COMMIT_FRAME_NUMBER_SAVED_REGIONS 3
-#define MR_REGION_COMMIT_FRAME_FIRST_SAVED_REGION 4
#define MR_REGION_SNAPSHOT_SIZE 4
-#define MR_REGION_SNAPSHOT_REGION 0
-#define MR_REGION_SNAPSHOT_LAST_PAGE 1
-#define MR_REGION_SNAPSHOT_NEXT_AVAILABLE_WORD 2
-#define MR_REGION_SNAPSHOT_AVAILABLE_SPACE 3
#define MR_REGION_ITE_PROT_SIZE 1
-#define MR_REGION_DISJ_PROT_SIZE 1
-#define MR_REGION_COMMIT_ENTRY_SIZE 1
+#define MR_REGION_DISJ_PROT_SIZE 0
+#define MR_REGION_COMMIT_SAVE_SIZE 1
/*
** A region page contains an array (of MR_Word) to store program data and
@@ -102,60 +92,73 @@
** Pointer to the last page of the region, i.e., the newest or last added
** page. This is needed when we need to enlarge the region.
*/
- MR_RegionPage *MR_region_last_page;
+ MR_RegionPage *MR_region_last_page;
/*
** Pointer to the next available word for allocation. Allocations into
** a region always occur at its last page therefore this pointer always
** points into the last page.
*/
- MR_Word *MR_region_next_available_word;
+ MR_Word *MR_region_next_available_word;
/*
** The current number of words (in the last page) available for allocation
** into the region. When an allocation requires more words than what is
** available the region is extended by adding a new page.
*/
- MR_Word MR_region_available_space;
+ MR_Word MR_region_available_space;
/*
** Currently not used. To be used for implementing conditional removals
** of regions, i.e., the region is only actually removed when the counter
** equals to one.
*/
- unsigned int MR_region_removal_counter;
+ unsigned int MR_region_removal_counter;
/* Sequence number of the region. */
- MR_Word MR_region_sequence_number;
+ MR_Word MR_region_sequence_number;
/* If the region has been removed in forward execution. */
- MR_Word MR_region_logical_removed;
+ MR_Word MR_region_logical_removed;
/*
** NULL if the region is not protected by any if-then-else. Otherwise
** it points to region_ite_stack frame that protects it.
*/
- MR_Word *MR_region_ite_protected;
-
- /*
- ** NULL if the region is not protected by any disj goal. If some disj
- ** frames exist and the region is protected from being destroyed by a
- ** disj goal, this field will point to the top region_disj_stack
- ** frame.
- */
- MR_Word *MR_region_disj_protected;
+ MR_RegionIteFixedFrame *MR_region_ite_protected;
/* If the region is saved at this frame in the region_commit_stack. */
- MR_Word *MR_region_commit_frame;
+ MR_RegionCommitFixedFrame *MR_region_commit_frame;
/*
** True if the region has been removed logically in a commit context and
** therefore needs to be destroyed at commit.
*/
- MR_Word MR_region_destroy_at_commit;
+ MR_Word MR_region_destroy_at_commit;
- MR_Region *MR_region_previous_region;
- MR_Region *MR_region_next_region;
+ MR_Region *MR_region_previous_region;
+ MR_Region *MR_region_next_region;
+};
+
+struct MR_RegionIteFixedFrame_Struct {
+ MR_RegionIteFixedFrame *MR_riff_previous_ite_frame;
+ MR_Region *MR_riff_saved_region_list;
+ int MR_riff_num_prot_regions;
+ int MR_riff_num_snapshots;
+};
+
+struct MR_RegionDisjFixedFrame_Struct {
+ MR_RegionDisjFixedFrame *MR_rdff_previous_disj_frame;
+ MR_Region *MR_rdff_saved_region_list;
+ MR_Word MR_rdff_disj_prot_seq_number;
+ MR_Word MR_rdff_num_snapshots;
+};
+
+struct MR_RegionCommitFixedFrame_Struct {
+ MR_RegionCommitFixedFrame *MR_rcff_previous_commit_frame;
+ MR_Word MR_rcff_saved_sequence_number;
+ MR_RegionDisjFixedFrame *MR_rcff_saved_disj_sp;
+ MR_Word MR_rcff_num_saved_regions;
};
/*
@@ -163,17 +166,25 @@
*/
struct MR_RegionSnapshot_Struct {
- MR_Region *region;
- MR_RegionPage *saved_last_page;
- MR_Word *saved_next_available_word;
- MR_Word saved_available_space;
+ MR_Region *MR_snapshot_region;
+ MR_RegionPage *MR_snapshot_saved_last_page;
+ MR_Word *MR_snapshot_saved_next_available_word;
+ MR_Word MR_snapshot_saved_available_space;
+};
+
+/* Protection information in an ite frame. */
+struct MR_RegionIteProtect_Struct {
+ MR_Region *MR_ite_prot_region;
};
/* Protection information in a disj frame. */
struct MR_RegionDisjProtect_Struct {
- MR_Region *region;
- /* XXX We no longer need to save ite_protected into a disj-frame*/
- /*MR_Word *ite_protected;*/
+ MR_Region *MR_disj_prot_region;
+};
+
+/* Save information in a commit frame */
+struct MR_RegionCommitSave_Struct {
+ MR_Region *MR_commit_save_region;
};
/*
@@ -189,9 +200,9 @@
extern MR_Word MR_region_sequence_number;
/* Pointers to the top frames of ite, disj, and commit stacks. */
-extern MR_Word *MR_region_ite_sp;
-extern MR_Word *MR_region_disj_sp;
-extern MR_Word *MR_region_commit_sp;
+extern MR_RegionIteFixedFrame *MR_region_ite_sp;
+extern MR_RegionDisjFixedFrame *MR_region_disj_sp;
+extern MR_RegionCommitFixedFrame *MR_region_commit_sp;
/*---------------------------------------------------------------------------*/
@@ -225,6 +236,8 @@
MR_region_alloc((MR_Region *) (region), (num))); \
} while (0)
+extern int MR_region_is_disj_protected(MR_Region *region);
+
/*---------------------------------------------------------------------------*/
/*
** push_region_frame
@@ -232,31 +245,45 @@
#define MR_push_region_ite_frame(new_ite_sp) \
do { \
- *(new_ite_sp) = (MR_Word) MR_region_ite_sp; \
- MR_save_live_region_list( \
- *((new_ite_sp) + MR_REGION_FRAME_REGION_LIST)); \
- MR_region_ite_sp = (new_ite_sp); \
- MR_region_debug_push_ite_frame(new_ite_sp); \
+ MR_RegionIteFixedFrame *new_ite_frame; \
+ \
+ new_ite_frame = (MR_RegionIteFixedFrame *) (new_ite_sp); \
+ new_ite_frame->MR_riff_previous_ite_frame = \
+ MR_region_ite_sp; \
+ new_ite_frame->MR_riff_saved_region_list = \
+ MR_live_region_list; \
+ MR_region_ite_sp = new_ite_frame; \
+ MR_region_debug_push_ite_frame(new_ite_frame); \
} while (0)
#define MR_push_region_disj_frame(new_disj_sp) \
do { \
- *(new_disj_sp) = (MR_Word) MR_region_disj_sp; \
- MR_save_live_region_list( \
- *((new_disj_sp) + MR_REGION_FRAME_REGION_LIST)); \
- MR_region_disj_sp = (new_disj_sp); \
- MR_region_debug_push_disj_frame(new_disj_sp); \
+ MR_RegionDisjFixedFrame *new_disj_frame; \
+ \
+ new_disj_frame = (MR_RegionDisjFixedFrame *) (new_disj_sp); \
+ new_disj_frame->MR_rdff_previous_disj_frame = \
+ MR_region_disj_sp; \
+ new_disj_frame->MR_rdff_saved_region_list = \
+ MR_live_region_list; \
+ new_disj_frame->MR_rdff_disj_prot_seq_number = \
+ MR_region_sequence_number; \
+ MR_region_disj_sp = new_disj_frame; \
+ MR_region_debug_push_disj_frame(new_disj_frame); \
} while (0)
#define MR_push_region_commit_frame(new_commit_sp) \
do { \
- *(new_commit_sp) = (MR_Word) MR_region_commit_sp; \
- *(new_commit_sp + MR_REGION_COMMIT_FRAME_SEQUENCE_NUMBER) = \
+ MR_RegionCommitFixedFrame *new_commit_frame; \
+ \
+ new_commit_frame = \
+ (MR_RegionCommitFixedFrame *) (new_commit_sp); \
+ 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_sp + MR_REGION_COMMIT_FRAME_DISJ_FRAME) = \
- (MR_Word) MR_region_disj_sp; \
- MR_region_commit_sp = (new_commit_sp); \
- MR_region_debug_push_commit_frame(new_commit_sp); \
+ new_commit_frame->MR_rcff_saved_disj_sp = MR_region_disj_sp;\
+ MR_region_commit_sp = new_commit_frame; \
+ MR_region_debug_push_commit_frame(new_commit_frame); \
} while (0)
/*---------------------------------------------------------------------------*/
@@ -276,7 +303,7 @@
MR_Region *region; \
\
region = (MR_Region *) (region_ptr); \
- if (region->MR_region_disj_protected == NULL && \
+ if (!MR_region_is_disj_protected(region) && \
region->MR_region_ite_protected == NULL) \
{ \
*((MR_Word *) (region_slot_reg)) = (MR_Word) region; \
@@ -284,7 +311,8 @@
(region_slot_reg) = (MR_Word) \
(((MR_Word *) (region_slot_reg)) + \
MR_REGION_ITE_PROT_SIZE); \
- region->MR_region_ite_protected = (ite_sp); \
+ region->MR_region_ite_protected = \
+ (MR_RegionIteFixedFrame *) (ite_sp); \
} \
} while (0)
@@ -312,7 +340,7 @@
\
region = (MR_Region *) (region_ptr); \
if (region->MR_region_ite_protected != NULL || \
- region->MR_region_disj_protected != NULL) \
+ MR_region_is_disj_protected(region)) \
{ \
MR_save_snapshot(region, snapshot_block); \
MR_next_snapshot_block(snapshot_block); \
@@ -334,15 +362,6 @@
#define MR_region_fill_disj_protect(disj_sp, region_ptr, \
num_protected_regions, protection_block) \
do { \
- MR_Region *region; \
- \
- region = (MR_Region *) (region_ptr); \
- if (region->MR_region_disj_protected == NULL) { \
- MR_save_disj_protection(region, protection_block); \
- (num_protected_regions)++; \
- MR_next_disj_protection_block(protection_block); \
- region->MR_region_disj_protected = (disj_sp); \
- } \
} while (0)
#define MR_region_fill_disj_snapshot(disj_sp, region_ptr, \
@@ -367,15 +386,16 @@
MR_Region *region; \
\
region = (MR_Region *) (region_ptr); \
- if (region->MR_region_disj_protected == NULL && \
+ if (!MR_region_is_disj_protected(region) && \
region->MR_region_ite_protected == NULL) \
{ \
*((MR_Word *) (region_slot_reg)) = (MR_Word) region; \
num_saved_region_reg++; \
(region_slot_reg) = (MR_Word) \
(((MR_Word *) (region_slot_reg)) + \
- MR_REGION_COMMIT_ENTRY_SIZE); \
- (region)->MR_region_commit_frame = (commit_sp); \
+ MR_REGION_COMMIT_SAVE_SIZE); \
+ region->MR_region_commit_frame = \
+ (MR_RegionCommitFixedFrame *) (commit_sp); \
} \
} while (0)
@@ -385,35 +405,44 @@
*/
#define MR_region_set_ite_num_protects(ite_sp, num) \
do { \
- *((ite_sp) + MR_REGION_FRAME_NUMBER_PROTECTED_REGIONS) \
- = (num); \
- MR_region_debug_ite_frame_protected_regions(ite_sp); \
+ MR_RegionIteFixedFrame *top_ite_frame; \
+ \
+ top_ite_frame = (MR_RegionIteFixedFrame *) (ite_sp); \
+ top_ite_frame->MR_riff_num_prot_regions = (num); \
+ MR_region_debug_ite_frame_protected_regions(top_ite_frame); \
} while (0)
#define MR_region_set_ite_num_snapshots(ite_sp, num) \
do { \
- *((ite_sp) + MR_REGION_FRAME_NUMBER_SNAPSHOTS) = (num); \
- MR_region_debug_ite_frame_snapshots(ite_sp); \
+ MR_RegionIteFixedFrame *top_ite_frame; \
+ \
+ top_ite_frame = (MR_RegionIteFixedFrame *) (ite_sp); \
+ top_ite_frame->MR_riff_num_snapshots = (num); \
+ MR_region_debug_ite_frame_snapshots(top_ite_frame); \
} while (0)
#define MR_region_set_disj_num_protects(disj_sp, num) \
do { \
- *((disj_sp) + MR_REGION_FRAME_NUMBER_PROTECTED_REGIONS) \
- = (num); \
- MR_region_debug_disj_frame_protected_regions(disj_sp); \
} while (0)
#define MR_region_set_disj_num_snapshots(disj_sp, num) \
do { \
- *((disj_sp) + MR_REGION_FRAME_NUMBER_SNAPSHOTS) = (num); \
- MR_region_debug_disj_frame_snapshots(disj_sp); \
+ MR_RegionDisjFixedFrame *top_disj_frame; \
+ \
+ top_disj_frame = (MR_RegionDisjFixedFrame *) (disj_sp); \
+ top_disj_frame->MR_rdff_num_snapshots = (num); \
+ MR_region_debug_disj_frame_snapshots(top_disj_frame); \
} while (0)
#define MR_region_set_commit_num_entries(commit_sp, num) \
do { \
- *((commit_sp) + MR_REGION_COMMIT_FRAME_NUMBER_SAVED_REGIONS)\
- = (num); \
- MR_region_debug_commit_frame_saved_regions(commit_sp); \
+ MR_RegionCommitFixedFrame *top_commit_frame; \
+ \
+ top_commit_frame = \
+ (MR_RegionCommitFixedFrame *) (commit_sp); \
+ top_commit_frame->MR_rcff_num_saved_regions = (num); \
+ MR_region_debug_commit_frame_saved_regions( \
+ top_commit_frame); \
} while (0)
/*---------------------------------------------------------------------------*/
@@ -432,53 +461,53 @@
*/
#define MR_use_region_ite_then_semidet(ite_sp) \
do { \
- MR_Word num_protected_regions; \
- MR_Word *first_protected_region; \
- MR_Region *protected_region; \
- int i; \
- \
- num_protected_regions = \
- MR_region_frame_number_protected_regions(ite_sp); \
- first_protected_region = \
- (ite_sp) + MR_REGION_FRAME_FIXED_SIZE; \
- for (i = 0; i < num_protected_regions; i++) { \
- protected_region = (MR_Region *) \
- (*(first_protected_region + i)); \
+ MR_RegionIteFixedFrame *top_ite_frame; \
+ MR_RegionIteProtect *ite_prot; \
+ int i; \
+ \
+ top_ite_frame = (MR_RegionIteFixedFrame *) (ite_sp); \
+ ite_prot = (MR_RegionIteProtect *) ( (ite_sp) + \
+ 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( \
- protected_region); \
+ ite_prot->MR_ite_prot_region); \
} \
- MR_pop_region_ite_frame(ite_sp); \
+ MR_pop_region_ite_frame(top_ite_frame); \
} while (0)
#define MR_use_region_ite_then_nondet(ite_sp) \
do { \
- MR_Word num_protected_regions; \
- MR_Word *first_protected_region; \
- MR_Region *protected_region; \
- int i; \
- \
- num_protected_regions = \
- MR_region_frame_number_protected_regions(ite_sp); \
- first_protected_region = \
- (ite_sp) + MR_REGION_FRAME_FIXED_SIZE; \
- for (i = 0; i < num_protected_regions; i++) { \
- protected_region = (MR_Region *) \
- (*(first_protected_region + i)); \
- if (protected_region != NULL) { \
+ MR_RegionIteFixedFrame *top_ite_frame; \
+ MR_RegionIteProtect *ite_prot; \
+ int i; \
+ \
+ top_ite_frame = (MR_RegionIteFixedFrame *) (ite_sp); \
+ ite_prot = (MR_RegionIteProtect *) ( (ite_sp) + \
+ 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( \
- protected_region); \
+ ite_prot->MR_ite_prot_region); \
} \
} \
} while (0)
#define MR_use_region_ite_else_semidet(ite_sp) \
do { \
- MR_region_process_at_ite_else(ite_sp); \
+ MR_RegionIteFixedFrame *top_ite_frame; \
+ \
+ top_ite_frame = (MR_RegionIteFixedFrame *) (ite_sp); \
+ MR_region_process_at_ite_else(top_ite_frame); \
} while (0)
#define MR_use_region_ite_else_nondet(ite_sp) \
do { \
- MR_region_process_at_ite_else(ite_sp); \
+ MR_RegionIteFixedFrame *top_ite_frame; \
+ \
+ top_ite_frame = (MR_RegionIteFixedFrame *) (ite_sp); \
+ MR_region_process_at_ite_else(top_ite_frame); \
} while (0)
/*
@@ -488,116 +517,109 @@
*/
#define MR_use_region_ite_nondet_cond_fail(ite_sp) \
do { \
- MR_region_process_at_ite_else(ite_sp) \
+ MR_RegionIteFixedFrame *top_ite_frame; \
+ \
+ top_ite_frame = (MR_RegionIteFixedFrame *) (ite_sp); \
+ MR_region_process_at_ite_else(top_ite_frame) \
} while (0)
#define MR_use_region_disj_later(disj_sp) \
do { \
- MR_region_disj_restore_from_snapshots(disj_sp); \
- MR_region_disj_destroy_new_regions(disj_sp); \
+ MR_RegionDisjFixedFrame *top_disj_frame; \
+ \
+ top_disj_frame = (MR_RegionDisjFixedFrame *) (disj_sp); \
+ MR_region_disj_restore_from_snapshots(top_disj_frame); \
+ MR_region_disj_destroy_new_regions(top_disj_frame); \
} while (0)
#define MR_use_region_disj_last(disj_sp) \
do { \
- MR_region_disj_restore_from_snapshots(disj_sp); \
- MR_region_disj_destroy_new_regions(disj_sp); \
- MR_region_disj_unprotect_regions(disj_sp); \
- MR_pop_region_disj_frame(disj_sp); \
+ MR_RegionDisjFixedFrame *top_disj_frame; \
+ \
+ top_disj_frame = (MR_RegionDisjFixedFrame *) (disj_sp); \
+ MR_region_disj_restore_from_snapshots(top_disj_frame); \
+ MR_region_disj_destroy_new_regions(top_disj_frame); \
+ MR_region_disj_unprotect_regions(top_disj_frame); \
+ MR_pop_region_disj_frame(top_disj_frame); \
} while (0)
#define MR_use_region_commit_success(commit_sp) \
do { \
- MR_Word saved_region_seq_number; \
- MR_Word number_of_saved_regions; \
- MR_Word *first_saved_region_slot; \
- \
- saved_region_seq_number = \
- *((commit_sp) + \
- MR_REGION_COMMIT_FRAME_SEQUENCE_NUMBER); \
- number_of_saved_regions = \
- *((commit_sp) + \
- MR_REGION_COMMIT_FRAME_NUMBER_SAVED_REGIONS); \
- first_saved_region_slot = \
- (commit_sp) + MR_REGION_COMMIT_FRAME_FIRST_SAVED_REGION;\
- MR_region_debug_commit_frame(commit_sp); \
- MR_region_debug_destroy_marked_regions_at_commit( \
- saved_region_seq_number, number_of_saved_regions, \
- first_saved_region_slot); \
- MR_destroy_marked_new_regions_at_commit( \
- saved_region_seq_number); \
- MR_destroy_marked_old_regions_at_commit( \
- number_of_saved_regions, first_saved_region_slot); \
- MR_commit_success_undisjprotect_regions(commit_sp); \
- MR_region_disj_sp = ( (MR_Word *) \
- *((commit_sp) + MR_REGION_COMMIT_FRAME_DISJ_FRAME)); \
- MR_pop_region_commit_frame(commit_sp); \
- } while (0)
-
-#define MR_commit_success_undisjprotect_regions(commit_sp) \
- do { \
- MR_Word *saved_disj_frame; \
- MR_Word *disj_frame; \
- \
- saved_disj_frame = ( (MR_Word *) \
- *((commit_sp) + MR_REGION_COMMIT_FRAME_DISJ_FRAME)); \
- disj_frame = MR_region_disj_sp; \
- while (disj_frame != saved_disj_frame) { \
- MR_region_disj_unprotect_regions(disj_frame); \
- disj_frame = (MR_Word *) *disj_frame; \
- } \
+ MR_RegionCommitFixedFrame *top_commit_frame; \
+ MR_RegionCommitSave *first_commit_save; \
+ \
+ top_commit_frame = \
+ (MR_RegionCommitFixedFrame *) (commit_sp); \
+ first_commit_save = (MR_RegionCommitSave *) ( \
+ (commit_sp) + MR_REGION_COMMIT_FRAME_FIXED_SIZE); \
+ \
+ MR_region_debug_commit_frame(top_commit_frame); \
+ \
+ MR_commit_success_destroy_marked_new_regions( \
+ top_commit_frame->MR_rcff_saved_sequence_number); \
+ MR_commit_success_destroy_saved_regions( \
+ top_commit_frame->MR_rcff_num_saved_regions, \
+ first_commit_save); \
+ MR_region_disj_sp = top_commit_frame->MR_rcff_saved_disj_sp;\
+ MR_pop_region_commit_frame(top_commit_frame); \
} while (0)
+
/*
** Commit failure means that the goal in the commit operation has failed.
-** We reset any changes to the commit-related state of saved regions
+** During this execution, all of the regions which are live before and removed
+** inside the commit operation were saved at the commit frame because none of
+** them were protected.
+** We reset any changes to the commit-related state of these saved regions
** i.e., commit_frame and destroy_at_commit, to NULL and false, respectively.
** Then the top commit frame is popped.
*/
#define MR_use_region_commit_failure(commit_sp) \
do { \
- MR_Word number_of_saved_regions; \
- MR_Word *first_saved_region_slot; \
- MR_Region *region; \
- int i; \
- \
- number_of_saved_regions = \
- *((commit_sp) + \
- MR_REGION_COMMIT_FRAME_NUMBER_SAVED_REGIONS); \
- first_saved_region_slot = \
- (commit_sp) + MR_REGION_COMMIT_FRAME_FIRST_SAVED_REGION;\
- for (i = 0; i < number_of_saved_regions; i++) { \
- region = (MR_Region *) \
- *(first_saved_region_slot + \
- i * MR_REGION_COMMIT_ENTRY_SIZE); \
+ MR_RegionCommitFixedFrame *top_commit_frame; \
+ MR_RegionCommitSave *commit_save; \
+ MR_Region *region; \
+ int i; \
+ \
+ top_commit_frame = \
+ (MR_RegionCommitFixedFrame *) (commit_sp); \
+ commit_save = (MR_RegionCommitSave *) ( (commit_sp) + \
+ 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; \
region->MR_region_destroy_at_commit = MR_FALSE; \
} \
} \
- MR_pop_region_commit_frame(commit_sp); \
+ MR_pop_region_commit_frame(top_commit_frame); \
} while (0)
-extern void MR_destroy_marked_old_regions_at_commit(
+extern void MR_commit_success_destroy_marked_saved_regions(
MR_Word number_of_saved_regions,
- MR_Word *first_saved_region_slot);
+ MR_RegionCommitSave *first_commit_save);
-extern void MR_destroy_marked_new_regions_at_commit(
+extern void MR_commit_success_destroy_marked_new_regions(
MR_Word saved_region_seq_number);
/*---------------------------------------------------------------------------*/
-#define MR_pop_region_ite_frame(ite_sp) \
+#define MR_pop_region_ite_frame(top_ite_frame) \
do { \
- MR_region_ite_sp = (MR_Word *) (*ite_sp); \
+ MR_region_ite_sp = \
+ top_ite_frame->MR_riff_previous_ite_frame; \
} while (0)
-#define MR_pop_region_disj_frame(disj_sp) \
+#define MR_pop_region_disj_frame(top_disj_frame) \
do { \
- MR_region_disj_sp = (MR_Word *) (*disj_sp); \
+ MR_region_disj_sp = \
+ top_disj_frame->MR_rdff_previous_disj_frame; \
} while (0)
-#define MR_pop_region_commit_frame(commit_sp) \
+#define MR_pop_region_commit_frame(top_commit_frame) \
do { \
- MR_region_commit_sp = (MR_Word *) (*commit_sp); \
+ MR_region_commit_sp = \
+ top_commit_frame->MR_rcff_previous_commit_frame; \
} while (0)
/*---------------------------------------------------------------------------*/
@@ -610,177 +632,103 @@
** 3. instant reclaiming by destroying new regions created in the condition,
** 4. pop the current ite frame.
*/
-#define MR_region_process_at_ite_else(ite_sp) \
+#define MR_region_process_at_ite_else(top_ite_frame) \
do { \
- MR_region_ite_unprotect(ite_sp); \
- MR_region_ite_restore_from_snapshots(ite_sp); \
- MR_region_ite_destroy_new_regions(ite_sp); \
- MR_pop_region_ite_frame(ite_sp); \
+ 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); \
} while (0)
/*
** Unprotect the protected regions at the beginning of the else part.
*/
-#define MR_region_ite_unprotect(ite_sp) \
+#define MR_region_ite_unprotect(top_ite_frame) \
do { \
- MR_Word num_protected_regions; \
- MR_Region *protected_region; \
- int i; \
- int first_protected_region; \
- \
- MR_region_debug_ite_frame(ite_sp); \
- num_protected_regions = \
- MR_region_frame_number_protected_regions(ite_sp); \
- first_protected_region = MR_REGION_FRAME_FIXED_SIZE; \
- for (i = 0; i < num_protected_regions; i++) { \
- protected_region = (MR_Region *) \
- (*((ite_sp) + first_protected_region + i)); \
+ MR_RegionIteProtect *ite_prot; \
+ MR_Region *protected_region; \
+ int i; \
+ \
+ MR_region_debug_ite_frame(top_ite_frame); \
+ 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; \
/* Try to protect the region by an outer condition. */ \
- protected_region->MR_region_ite_protected = (MR_Word *) \
- (*(ite_sp)); \
+ protected_region->MR_region_ite_protected = \
+ top_ite_frame->MR_riff_previous_ite_frame; \
MR_region_debug_region_struct_removal_info( \
protected_region); \
} \
} while (0)
-#define MR_region_ite_restore_from_snapshots(ite_sp) \
+#define MR_region_ite_restore_from_snapshots(top_ite_frame) \
do { \
- MR_Word num_snapshots; \
- MR_Word first_snapshot_index; \
+ MR_RegionSnapshot *first_snapshot; \
+ MR_Word protection_size; \
\
- num_snapshots = MR_region_frame_number_snapshots(ite_sp); \
- MR_ite_frame_get_first_snapshot_index(ite_sp, \
- first_snapshot_index); \
- MR_restore_snapshots(ite_sp, num_snapshots, \
- first_snapshot_index); \
- } while (0)
-
-#define MR_region_ite_destroy_new_regions(ite_sp) \
- MR_region_frame_destroy_new_regions(ite_sp)
-
-#define MR_ite_frame_get_first_snapshot_index(ite_frame, \
- first_snapshot_index) \
- do { \
- int num_protected_regions; \
- \
- num_protected_regions = \
- MR_region_frame_number_protected_regions((ite_frame)); \
- (first_snapshot_index) = MR_REGION_FRAME_FIXED_SIZE + \
- num_protected_regions * MR_REGION_ITE_PROT_SIZE; \
- } while (0)
+ 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); \
+ } while (0)
+
+#define MR_region_ite_destroy_new_regions(top_ite_frame) \
+ MR_region_frame_destroy_new_regions( \
+ top_ite_frame->MR_riff_saved_region_list)
/*---------------------------------------------------------------------------*/
/* Helpers for nondet disjunction support. */
-/* XXX This macro should no long be used.
-** At any non-first disjunct, reset the ite_protected to the state before
-** the disjunction.
-*/
-#define MR_region_disj_restore_ite_protected(disj_sp) \
- do { \
- MR_RegionDisjProtect *first_block; \
- MR_RegionDisjProtect *block; \
- MR_Word num_protected_regions; \
- MR_Word i; \
- \
- first_block = (MR_RegionDisjProtect *) \
- (disj_sp + MR_REGION_FRAME_FIXED_SIZE); \
- num_protected_regions = \
- MR_region_frame_number_protected_regions(disj_sp); \
- for (i = 0; i < num_protected_regions; i++) { \
- block = first_block + i; \
- block->region->MR_region_ite_protected = \
- block->MR_region_ite_protected; \
- } \
- } while (0)
-
/*
** At any non-first disjunct, try instant reclaiming from snapshots.
*/
-#define MR_region_disj_restore_from_snapshots(disj_sp) \
+#define MR_region_disj_restore_from_snapshots(top_disj_frame) \
do { \
- MR_Word num_snapshots; \
- MR_Word first_snapshot_index; \
+ MR_RegionSnapshot *first_snapshot; \
\
- num_snapshots = MR_region_frame_number_snapshots(disj_sp); \
- MR_disj_frame_get_first_snapshot_index(disj_sp, \
- first_snapshot_index); \
- MR_restore_snapshots(disj_sp, num_snapshots, \
- first_snapshot_index); \
+ first_snapshot = (MR_RegionSnapshot *) ( \
+ (MR_Word *) (top_disj_frame) + \
+ MR_REGION_DISJ_FRAME_FIXED_SIZE); \
+ MR_restore_snapshots(top_disj_frame->MR_rdff_num_snapshots, \
+ first_snapshot); \
} while (0)
/*
** At any non-first disjunct, try instant reclaiming by destroying new
** regions.
*/
-#define MR_region_disj_destroy_new_regions(disj_sp) \
- MR_region_frame_destroy_new_regions(disj_sp)
+#define MR_region_disj_destroy_new_regions(top_disj_frame) \
+ MR_region_frame_destroy_new_regions( \
+ top_disj_frame->MR_rdff_saved_region_list)
/*
** At the last disjunct, we do not disj-protect the regions anymore.
*/
-#define MR_region_disj_unprotect_regions(disj_sp) \
+#define MR_region_disj_unprotect_regions(top_disj_frame) \
do { \
- MR_RegionDisjProtect *first_block; \
- MR_RegionDisjProtect *block; \
- MR_Word num_protected_regions; \
- MR_Word i; \
- \
- first_block = (MR_RegionDisjProtect *) \
- (disj_sp + MR_REGION_FRAME_FIXED_SIZE); \
- num_protected_regions = \
- MR_region_frame_number_protected_regions(disj_sp); \
- for (i = 0; i < num_protected_regions; i++) { \
- block = first_block + i; \
- block->region->MR_region_disj_protected = NULL; \
- } \
- } while (0)
-
-#define MR_disj_frame_get_first_snapshot_index(disj_frame, \
- first_snapshot_index) \
- do { \
- int num_protected_regions; \
- \
- num_protected_regions = \
- MR_region_frame_number_protected_regions(disj_frame); \
- (first_snapshot_index) = MR_REGION_FRAME_FIXED_SIZE + \
- num_protected_regions * MR_REGION_DISJ_PROT_SIZE; \
+ top_disj_frame->MR_rdff_disj_prot_seq_number = \
+ MR_REGION_DISJ_FRAME_DUMMY_SEQ_NUMBER; \
} while (0)
/*---------------------------------------------------------------------------*/
-#define MR_region_frame_number_protected_regions(frame) ( \
- *((frame) + MR_REGION_FRAME_NUMBER_PROTECTED_REGIONS) \
- )
-
-#define MR_save_disj_protection(region, protection_block) \
- do { \
- MR_RegionDisjProtect *disj_prot; \
- \
- disj_prot = (MR_RegionDisjProtect *) (protection_block); \
- disj_prot->region = (region); \
- /* disj_prot->MR_region_ite_protected = \
- (region)->MR_region_ite_protected; */ \
- } while (0)
-
-#define MR_next_disj_protection_block(block) ( \
- (block) = (MR_Word) (((MR_RegionDisjProtect *) (block)) + 1) \
- )
-
-#define MR_region_frame_number_snapshots(frame) ( \
- *((frame) + MR_REGION_FRAME_NUMBER_SNAPSHOTS) \
- )
-
#define MR_save_snapshot(region, snapshot_block) \
do { \
MR_RegionSnapshot *snapshot; \
\
snapshot = (MR_RegionSnapshot *) (snapshot_block); \
- snapshot->region = (region); \
- snapshot->saved_last_page = (region)->MR_region_last_page; \
- snapshot->saved_next_available_word = \
+ 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; \
- snapshot->saved_available_space = \
+ snapshot->MR_snapshot_saved_available_space = \
(region)->MR_region_available_space; \
} while (0)
@@ -799,23 +747,22 @@
** allocated_size sometimes is not realiable.
*/
-#define MR_restore_snapshots(frame, num_snapshots, first_snapshot_index)\
+#define MR_restore_snapshots(num_snapshots, first_snapshot) \
do { \
- MR_RegionSnapshot *first_snapshot; \
MR_RegionSnapshot *snapshot; \
MR_Region *restoring_region; \
MR_RegionPage *saved_last_page; \
MR_RegionPage *first_new_page; \
int i; \
\
- first_snapshot = (MR_RegionSnapshot *) \
- ((frame) + (first_snapshot_index)); \
- for (i = 0; i < (num_snapshots); i++) { \
- snapshot = first_snapshot + i; \
- restoring_region = snapshot->region; \
- saved_last_page = snapshot->saved_last_page; \
+ 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); \
+ \
if (first_new_page != NULL) { \
MR_region_return_page_list(first_new_page, \
restoring_region->MR_region_last_page); \
@@ -823,24 +770,20 @@
saved_last_page; \
} /* else no new page added. */ \
restoring_region->MR_region_next_available_word = \
- snapshot->saved_next_available_word; \
+ snapshot->MR_snapshot_saved_next_available_word; \
restoring_region->MR_region_available_space = \
- snapshot->saved_available_space; \
+ snapshot->MR_snapshot_saved_available_space; \
} \
} while(0)
-#define MR_region_frame_destroy_new_regions(frame) \
+#define MR_region_frame_destroy_new_regions(saved_most_recent_region) \
do { \
- MR_Region *saved_most_recent_region; \
- MR_Region *region; \
- MR_Region *next_region; \
+ MR_Region *region; \
+ MR_Region *next_region; \
\
- saved_most_recent_region = (MR_Region *) \
- (*((frame) + MR_REGION_FRAME_REGION_LIST)); \
region = MR_live_region_list; \
while (region != saved_most_recent_region) { \
next_region = region->MR_region_next_region; \
- MR_region_debug_disj_frame(frame);\
/* We destroy regions upto before the saved one. */ \
MR_region_destroy_region(region); \
region = next_region; \
@@ -855,10 +798,6 @@
MR_region_free_page_list = (from_page); \
} while (0)
-#define MR_save_live_region_list(slot) ( \
- (slot) = (MR_Word) MR_live_region_list \
- )
-
/*---------------------------------------------------------------------------*/
/* Debug RBMM messages. */
@@ -911,13 +850,6 @@
#define MR_region_debug_commit_frame_saved_regions(commit_sp); \
MR_region_commit_frame_saved_regions_msg(commit_sp)
- #define MR_region_debug_destroy_marked_regions_at_commit( \
- saved_region_seq_number, number_of_saved_regions, \
- first_saved_region_slot) \
- MR_region_destroy_marked_regions_at_commit_msg( \
- saved_region_seq_number, number_of_saved_regions, \
- first_saved_region_slot)
-
#else /* MR_RBMM_DEBUG */
#define MR_region_debug_create_region(region) \
((void) 0)
@@ -950,9 +882,6 @@
#define MR_region_debug_disj_frame(frame) \
((void) 0)
- #define MR_region_debug_disj_frame_protected_regions(disj_sp); \
- ((void) 0)
-
#define MR_region_debug_disj_frame_snapshots(disj_sp); \
((void) 0)
@@ -965,10 +894,6 @@
#define MR_region_debug_commit_frame_saved_regions(commit_sp) \
((void) 0)
- #define MR_region_debug_destroy_marked_regions_at_commit( \
- saved_region_seq_number, number_of_saved_regions, \
- first_saved_region_slot) \
- ((void) 0)
#endif /* MR_RBMM_DEBUG */
extern void MR_region_create_region_msg(MR_Region *region);
@@ -977,23 +902,28 @@
extern void MR_region_destroy_region_msg(MR_Region *region);
extern void MR_region_logically_remove_region_msg(MR_Region *region);
-extern void MR_region_push_ite_frame_msg(MR_Word *ite_frame);
-extern void MR_region_ite_frame_msg(MR_Word *ite_frame);
-extern void MR_region_ite_frame_protected_regions_msg(MR_Word *ite_frame);
-extern void MR_region_ite_frame_snapshots_msg(MR_Word *ite_frame);
-
-extern void MR_region_push_disj_frame_msg(MR_Word *disj_frame);
-extern void MR_region_disj_frame_msg(MR_Word *disj_frame);
-extern void MR_region_disj_frame_protected_regions_msg(
- MR_Word *disj_frame);
-extern void MR_region_disj_frame_snapshots_msg(MR_Word *disj_frame);
-
-extern void MR_region_push_commit_frame_msg(MR_Word *commit_frame);
-extern void MR_region_commit_frame_msg(MR_Word *commit_frame);
-extern void MR_region_commit_frame_saved_regions_msg(MR_Word *commit_frame);
-extern void MR_region_destroy_marked_regions_at_commit_msg(
+extern void MR_region_push_ite_frame_msg(MR_RegionIteFixedFrame *ite_frame);
+extern void MR_region_ite_frame_msg(MR_RegionIteFixedFrame *ite_frame);
+extern void MR_region_ite_frame_protected_regions_msg(
+ MR_RegionIteFixedFrame *ite_frame);
+extern void MR_region_ite_frame_snapshots_msg(
+ MR_RegionIteFixedFrame *ite_frame);
+
+extern void MR_region_push_disj_frame_msg(
+ MR_RegionDisjFixedFrame *disj_frame);
+extern void MR_region_disj_frame_msg(MR_RegionDisjFixedFrame *disj_frame);
+extern void MR_region_disj_frame_snapshots_msg(
+ MR_RegionDisjFixedFrame *disj_frame);
+
+extern void MR_region_push_commit_frame_msg(
+ MR_RegionCommitFixedFrame *commit_frame);
+extern void MR_region_commit_frame_msg(
+ MR_RegionCommitFixedFrame *commit_frame);
+extern void MR_region_commit_frame_saved_regions_msg(
+ MR_RegionCommitFixedFrame *commit_frame);
+extern void MR_region_commit_success_destroy_marked_regions_msg(
int saved_seq_number, int number_of_saved_regions,
- MR_Word *commit_frame);
+ MR_RegionCommitFixedFrame *commit_frame);
/*---------------------------------------------------------------------------*/
/* Profiling RBMM. */
Index: runtime/mercury_types.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_types.h,v
retrieving revision 1.52
diff -u -r1.52 mercury_types.h
--- runtime/mercury_types.h 9 Oct 2007 07:59:54 -0000 1.52
+++ runtime/mercury_types.h 14 Oct 2007 21:55:32 -0000
@@ -298,8 +298,12 @@
typedef struct MR_Region_Struct MR_Region;
typedef struct MR_RegionPage_Struct MR_RegionPage;
typedef struct MR_RegionSnapshot_Struct MR_RegionSnapshot;
-typedef struct MR_RegionDisjProtect_Struct MR_RegionDisjProtect;
+typedef struct MR_RegionIteFixedFrame_Struct MR_RegionIteFixedFrame;
+typedef struct MR_RegionDisjFixedFrame_Struct MR_RegionDisjFixedFrame;
+typedef struct MR_RegionCommitFixedFrame_Struct MR_RegionCommitFixedFrame;
typedef struct MR_RegionIteProtect_Struct MR_RegionIteProtect;
+typedef struct MR_RegionDisjProtect_Struct MR_RegionDisjProtect;
+typedef struct MR_RegionCommitSave_Struct MR_RegionCommitSave;
typedef struct MR_RegionProfUnit_Struct MR_RegionProfUnit;
#endif /* not MERCURY_TYPES_H */
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/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing ssdb
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing trax
cvs diff: Diffing trial
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
More information about the reviews
mailing list