[m-rev.] For post-commit review: Some improvements for RBMM
Quan Phan
quan.phan at cs.kuleuven.be
Sat Dec 22 01:24:10 AEDT 2007
Hi,
For post-commit review by Zoltan.
Estimated hours taken: 2
Branch: main
- Fix some format errors.
- Move the field to collect memory allocated into a region from
MR_RegionPage
to MR_RegionHeader
- Use conversion macros to cast between MR_RegionPage and
MR_RegionHeader.
- Use MR_REGION_PAGE_SPACE_SIZE = 255.
runtime/mercury_region.h
runtime/mercury_region.c
Implement the above things.
Regards,
Quan.
-------------- next part --------------
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
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.7
diff -u -r1.7 mercury_region.c
--- runtime/mercury_region.c 20 Dec 2007 07:43:16 -0000 1.7
+++ runtime/mercury_region.c 21 Dec 2007 14:06:10 -0000
@@ -155,7 +155,7 @@
** word_sizeof(MR_RegionHeader) words from the start of the data area
** of the page.
*/
- region = (MR_RegionHeader *) (page->MR_regionpage_space);
+ region = MR_regionpage_to_region(page);
region->MR_region_next_available_word = (MR_Word *)
(page->MR_regionpage_space + word_sizeof(MR_RegionHeader));
region->MR_region_last_page = page;
@@ -178,7 +178,7 @@
#if defined(MR_RBMM_PROFILING)
MR_region_update_profiling_unit(&MR_rbmmp_regions_used, 1);
- ((MR_RegionPage *) region)->MR_regionpage_allocated_size = 0;
+ region->MR_region_allocated_size = 0;
#endif
return region;
@@ -271,7 +271,7 @@
}
/* Return the page list of the region to the free page list. */
- MR_region_return_page_list((MR_RegionPage *) region,
+ MR_region_return_page_list(MR_region_to_first_regionpage(region),
region->MR_region_last_page);
/* Collect profiling information. */
@@ -281,28 +281,20 @@
/*
** This method is to be called at the start of the then part of an ite with
** semidet condition (most of the times).
-** XXX At that point we will only check if the region is disj-protected or not.
-** At that point we do not have to check whether this ite-protected region is
-** disj-protected or not. It is because the region is protected for this ite
-** only if it has not been protected before the ite and from the start of
-** this ite to the point when this method is called, i.e., the condition, the
-** region cannot be disj-protected by any disjunctions because this condition
-** is semidet.
+** At this point, we do not have to check whether this ite-protected region is
+** disj-protected or not because we know for sure that it is not:
+** - the region is protected for this ite only if it has not been protected
+** before the ite, which means that it is not disj-protected before the ite
+** - from the start of this ite to this point (i.e., during the condition) it
+** cannot be disj-protected by any disjunctions. This is because this
+** condition is semidet and cannot contain nondet disjuncitons. If it contains
+** semidet disjunctions, at this point they must succeed and therefore the
+** region is not disj-protected for them.
*/
void
MR_remove_undisjprotected_region_ite_then_semidet(MR_RegionHeader *region)
{
- /*
- MR_region_debug_try_remove_region(region);
- if ( !MR_region_is_disj_protected(region) ) {
- MR_region_destroy_region(region);
- MR_region_debug_destroy_region(region);
- } else {
- region->MR_region_logical_removed = 1;
- MR_region_debug_logically_remove_region(region);
- }
- */
MR_region_destroy_region(region);
MR_region_debug_destroy_region(region);
}
@@ -376,7 +368,7 @@
region->MR_region_next_available_word += words;
#if defined(MR_RBMM_PROFILING)
MR_region_update_profiling_unit(&MR_rbmmp_words_used, words);
- ((MR_RegionPage *) region)->MR_regionpage_allocated_size += words;
+ region->MR_region_allocated_size += words;
#endif
return allocated_cell;
@@ -843,10 +835,9 @@
MR_region_update_profiling_unit(&MR_rbmmp_regions_used, -1);
MR_region_update_profiling_unit(&MR_rbmmp_pages_used,
- -MR_region_get_number_of_pages((MR_RegionPage *) region,
+ -MR_region_get_number_of_pages(MR_region_to_first_regionpage(region),
region->MR_region_last_page));
- allocated_size_of_region =
- ((MR_RegionPage *) region)->MR_regionpage_allocated_size;
+ allocated_size_of_region = region->MR_region_allocated_size;
MR_region_update_profiling_unit(&MR_rbmmp_words_used,
-allocated_size_of_region);
if (allocated_size_of_region > MR_rbmmp_biggest_region_size) {
@@ -864,7 +855,7 @@
MR_region_get_new_pages_and_new_words(snapshot, &new_pages, &new_words);
MR_region_update_profiling_unit(&MR_rbmmp_pages_used, -new_pages);
restoring_region = snapshot->MR_snapshot_region;
- ((MR_RegionPage *) restoring_region)->MR_regionpage_allocated_size
+ restoring_region->MR_region_allocated_size
-= new_words;
MR_region_update_profiling_unit(&MR_rbmmp_words_used, -new_words);
MR_rbmmp_pages_snapshot_instant_reclaimed += new_pages;
Index: runtime/mercury_region.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_region.h,v
retrieving revision 1.8
diff -u -r1.8 mercury_region.h
--- runtime/mercury_region.h 20 Dec 2007 07:43:16 -0000 1.8
+++ runtime/mercury_region.h 21 Dec 2007 14:06:11 -0000
@@ -37,7 +37,7 @@
/* XXX This should be made configurable when compiling a program. */
#define MR_REGION_NUM_PAGES_TO_REQUEST 100
-#define MR_REGION_PAGE_SPACE_SIZE 256
+#define MR_REGION_PAGE_SPACE_SIZE 255
/*
** NOTE: The following constants *must match* the values of the Mercury
@@ -61,22 +61,17 @@
/*
** 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.
+** Note:
+** We use conversion macros to cast between MR_RegionPage and
+** MR_RegionHeader. We likely will need to update these macros when the
+** structure of MR_RegionPage changes.
*/
struct MR_RegionPage_Struct {
- /* The space to store program data. */
- MR_Word MR_regionpage_space[MR_REGION_PAGE_SPACE_SIZE];
-
/* Pointer to the next page to form the linked list. */
MR_RegionPage *MR_regionpage_next;
-#ifdef MR_RBMM_PROFILING
- /*
- ** This is to count the number of words which are currently allocated into
- ** the region. It means that it will be reset at backtracking if the region
- ** is restored from its snapshot.
- */
- int MR_regionpage_allocated_size;
-#endif
+ /* The space to store program data. */
+ MR_Word MR_regionpage_space[MR_REGION_PAGE_SPACE_SIZE];
};
/*
@@ -131,6 +126,15 @@
MR_RegionHeader *MR_region_previous_region;
MR_RegionHeader *MR_region_next_region;
+
+#ifdef MR_RBMM_PROFILING
+ /*
+ ** This is to count the number of words which are currently allocated into
+ ** the region. It means that it will be reset at backtracking if the region
+ ** is restored from its snapshot.
+ */
+ int MR_region_allocated_size;
+#endif
};
/*---------------------------------------------------------------------------*/
@@ -238,6 +242,13 @@
MR_region_alloc((MR_RegionHeader *) (region), (num))); \
} while (0)
+#define MR_regionpage_to_region(region_page) \
+ ( (MR_RegionHeader *) (region_page->MR_regionpage_space) )
+
+/* Minus one due to the MR_regionpage_next field */
+#define MR_region_to_first_regionpage(region) \
+ ( (MR_RegionPage *) ( ( (MR_Word *)region ) - 1 ) )
+
#define MR_region_page_end(region_page) \
((region_page)->MR_regionpage_space + MR_REGION_PAGE_SPACE_SIZE)
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