From fb4b5c30a2e352815ef6a606d8683031fa99bd99 Mon Sep 17 00:00:00 2001 From: Zoltan Somogyi Date: Wed, 10 Oct 2007 07:18:16 +0000 Subject: [PATCH] Allow the specification of RBMM debugging and profiling via grades. Estimated hours taken: 2 Branches: main Allow the specification of RBMM debugging and profiling via grades. runtime/mercury_grade.h: Add rbmmd and rbmmp as grade components denoting RBMM with debugging and profiling respectively, while rbmmdp is RBMM with both. compiler/options.m: Add --use-regions-debug and --use-regions-profiling as the Mercury compiler options specifying RBMM debugging and profiling. compiler/handle_options.m: compiler/compile_target_code.m: runtime/mercury_conf_param.h: scripts/canonical_grade.sh-subr: scripts/final_grade_options.sh-subr: scripts/init_grade_options.sh-subr: scripts/mgnuc.in: scripts/parse_grade_options.sh-subr: Handle the new grade components. configure.in: Add the new option --enable-rbmm-grades, for use by Quan and me for now, that causes the installation of all four RBMM grades. Once RBMM is ready for use by non-implementors, we can change this to install only the rbmm grade, and not the rbmmd/rbmmp/rbmmdp grades. --- compiler/compile_target_code.m | 19 ++++++++++++++++- compiler/handle_options.m | 16 +++++++++++++- compiler/options.m | 7 ++++++ configure.in | 17 +++++++++++++++ runtime/mercury_conf_param.h | 12 ++++------- runtime/mercury_grade.h | 19 +++++++++++++++-- scripts/canonical_grade.sh-subr | 14 ++++++++++-- scripts/final_grade_options.sh-subr | 10 +++++++++ scripts/init_grade_options.sh-subr | 4 ++++ scripts/mgnuc.in | 16 ++++++++++++-- scripts/parse_grade_options.sh-subr | 33 +++++++++++++++++++++++++++++ 11 files changed, 151 insertions(+), 16 deletions(-) diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m index 425f20628..1687920bd 100644 --- a/compiler/compile_target_code.m +++ b/compiler/compile_target_code.m @@ -668,7 +668,24 @@ compile_c_file(ErrorStream, PIC, C_File, O_File, Succeeded, !IO) :- globals.io_lookup_bool_option(use_regions, UseRegions, !IO), ( UseRegions = yes, - UseRegionsOpt = "-DMR_USE_REGIONS " + UseRegionsOpt0 = "-DMR_USE_REGIONS ", + globals.io_lookup_bool_option(use_regions_debug, UseRegionsDebug, !IO), + ( + UseRegionsDebug = yes, + UseRegionsOpt1 = UseRegionsOpt0 ++ "-DMR_RBMM_DEBUG " + ; + UseRegionsDebug = no, + UseRegionsOpt1 = UseRegionsOpt0 + ), + globals.io_lookup_bool_option(use_regions_profiling, + UseRegionsProfiling, !IO), + ( + UseRegionsProfiling = yes, + UseRegionsOpt = UseRegionsOpt1 ++ "-DMR_RBMM_PROFILING " + ; + UseRegionsProfiling = no, + UseRegionsOpt = UseRegionsOpt1 + ) ; UseRegions = no, UseRegionsOpt = "" diff --git a/compiler/handle_options.m b/compiler/handle_options.m index 59580c5e9..87a4ef9a5 100644 --- a/compiler/handle_options.m +++ b/compiler/handle_options.m @@ -2509,7 +2509,21 @@ grade_component_table("stseg", comp_stack_extend, no, yes). % Region-based memory managment components -grade_component_table("rbmm", comp_regions, [use_regions - bool(yes)], +grade_component_table("rbmm", comp_regions, + [use_regions - bool(yes), + use_regions_debug - bool(no), use_regions_profiling - bool(no)], + no, yes). +grade_component_table("rbmmd", comp_regions, + [use_regions - bool(yes), + use_regions_debug - bool(yes), use_regions_profiling - bool(no)], + no, yes). +grade_component_table("rbmmp", comp_regions, + [use_regions - bool(yes), + use_regions_debug - bool(no), use_regions_profiling - bool(yes)], + no, yes). +grade_component_table("rbmmdp", comp_regions, + [use_regions - bool(yes), + use_regions_debug - bool(yes), use_regions_profiling - bool(yes)], no, yes). :- pred reset_grade_options(option_table::in, option_table::out) is det. diff --git a/compiler/options.m b/compiler/options.m index 9ae632621..1a8f44c77 100644 --- a/compiler/options.m +++ b/compiler/options.m @@ -312,6 +312,8 @@ ; extend_stacks_when_needed ; stack_segments ; use_regions + ; use_regions_debug + ; use_regions_profiling ; source_to_source_debug % Data representation compilation model options @@ -1116,6 +1118,8 @@ option_defaults_2(compilation_model_option, [ extend_stacks_when_needed - bool(no), stack_segments - bool(no), use_regions - bool(no), + use_regions_debug - bool(no), + use_regions_profiling - bool(no), use_minimal_model_stack_copy - bool(no), use_minimal_model_own_stacks - bool(no), minimal_model_debug - bool(no), @@ -1908,6 +1912,8 @@ long_option("maybe-thread-safe", maybe_thread_safe_opt). long_option("extend-stacks-when-needed", extend_stacks_when_needed). long_option("stack-segments", stack_segments). long_option("use-regions", use_regions). +long_option("use-regions-debug", use_regions_debug). +long_option("use-regions-profiling",use_regions_profiling). long_option("ssdb", source_to_source_debug). long_option("source-to-source-debug", source_to_source_debug). % Data representation options @@ -3816,6 +3822,7 @@ options_help_compilation_model --> "\tSpecify that code that increments a stack pointer must allocate", "\ta new stack segment when the limit on the old one is reached." % RBMM is undocumented since it is still experimental. + % should also document rbmmd rbmmp rbmmdp %"--use-regions\t\t(grade modifier: `.rbmm')", %"\tEnable support for region-based memory managment." ]), diff --git a/configure.in b/configure.in index 180108199..1f4d0e370 100644 --- a/configure.in +++ b/configure.in @@ -2918,6 +2918,11 @@ AC_ARG_ENABLE(hlc-low-level-debug-grades, [install a low level debugging version of the high level C grade]), enable_hlc_ll_debug_grades="$enableval",enable_hlc_ll_debug_grades=no) +AC_ARG_ENABLE(rbmm-grades, + AC_HELP_STRING([--enable-rbmm-grades], + [install experimental region-based memory management versions of the library]), + enable_rbmm_grades="$enableval",enable_rbmm_grades=no) + # We don't enable the .NET grades by default because that may lead to # installation process breaking on Linux systems that have DotGNU or Mono # installed. @@ -2956,6 +2961,7 @@ if test "$enable_most_grades" = no; then enable_dmm_grades=no enable_hlc_prof_grades=no enable_hlc_ll_debug_grades=no + enable_rbmm_grades=no enable_par_grades=no enable_dotnet_grades=no enable_java_grade=no @@ -3131,6 +3137,17 @@ if test "$enable_hlc_ll_debug_grades" = yes; then LIBGRADES="$LIBGRADES hlc.gcd.ll_debug" fi +# Add rbmm grades +if test "$enable_rbmm_grades" = yes; then + # As of Oct 2007, all the users of RBMM grades are implementors + # who may need the debugging and profiling versions. + LIBGRADES="$LIBGRADES \ + $BEST_LLDS_BASE_GRADE.gc.rbmm \ + $BEST_LLDS_BASE_GRADE.gc.rbmmd \ + $BEST_LLDS_BASE_GRADE.gc.rbmmp \ + $BEST_LLDS_BASE_GRADE.gc.rbmmdp" +fi + # Add the .par (thread-safe) grade, if it is supported for this system # Only enable it if this system has pthreads installed. # diff --git a/runtime/mercury_conf_param.h b/runtime/mercury_conf_param.h index d933635e7..8df652cfb 100644 --- a/runtime/mercury_conf_param.h +++ b/runtime/mercury_conf_param.h @@ -63,6 +63,8 @@ ** MR_HIGHTAGS ** MR_TAGBITS ** MR_USE_REGIONS +** MR_RBMM_DEBUG +** MR_RBMM_PROFILING ** See the documentation for ** --high-level-code ** --high-level-data @@ -86,6 +88,8 @@ ** --tags ** --num-tag-bits ** --use-regions +** --use-regions-debug +** --use-regions-profiling ** (respectively) in the mmc help message or the Mercury User's Guide. ** ** MR_PIC @@ -306,14 +310,6 @@ ** MR_STM_DEBUG ** Enables low-level debugging messages from the code that implements ** transactions used by software transactional memory. -** -** MR_RBMM_DEBUG -** Enables low-level debugging messages from the code that implements -** region-based memory management. -** -** MR_RBMM_PROFILING -** Enables low-level profiling messages from the code that implements -** region-based memory management. */ /* diff --git a/runtime/mercury_grade.h b/runtime/mercury_grade.h index bf236bc73..263191bf1 100644 --- a/runtime/mercury_grade.h +++ b/runtime/mercury_grade.h @@ -412,8 +412,23 @@ #endif #if defined(MR_USE_REGIONS) - #define MR_GRADE_PART_17 MR_PASTE2(MR_GRADE_PART_16, _rbmm) - #define MR_GRADE_OPT_PART_17 MR_GRADE_OPT_PART_16 ".rbmm" + #if defined(MR_RBMM_DEBUG) + #if defined(MR_RBMM_PROFILING) + #define MR_GRADE_PART_17 MR_PASTE2(MR_GRADE_PART_16, _rbmmdp) + #define MR_GRADE_OPT_PART_17 MR_GRADE_OPT_PART_16 ".rbmmdp" + #else + #define MR_GRADE_PART_17 MR_PASTE2(MR_GRADE_PART_16, _rbmmd) + #define MR_GRADE_OPT_PART_17 MR_GRADE_OPT_PART_16 ".rbmmd" + #endif + #else + #if defined(MR_RBMM_PROFILING) + #define MR_GRADE_PART_17 MR_PASTE2(MR_GRADE_PART_16, _rbmmp) + #define MR_GRADE_OPT_PART_17 MR_GRADE_OPT_PART_16 ".rbmmp" + #else + #define MR_GRADE_PART_17 MR_PASTE2(MR_GRADE_PART_16, _rbmm) + #define MR_GRADE_OPT_PART_17 MR_GRADE_OPT_PART_16 ".rbmm" + #endif + #endif #else #define MR_GRADE_PART_17 MR_GRADE_PART_16 #define MR_GRADE_OPT_PART_17 MR_GRADE_OPT_PART_16 diff --git a/scripts/canonical_grade.sh-subr b/scripts/canonical_grade.sh-subr index 77ae6454e..a5b1b3d4f 100644 --- a/scripts/canonical_grade.sh-subr +++ b/scripts/canonical_grade.sh-subr @@ -1,4 +1,6 @@ #---------------------------------------------------------------------------# +# vim: ft=sh +#---------------------------------------------------------------------------# # Copyright (C) 2000-2007 The University of Melbourne. # This file may only be copied under the terms of the GNU General # Public License - see the file COPYING in the Mercury distribution. @@ -167,7 +169,15 @@ case $extend_stacks,$stack_segments in esac case $use_regions in - true) GRADE="$GRADE.rbmm" ;; - false) ;; + true) + case $use_regions_debug,$use_regions_profiling in + false,false) GRADE="$GRADE.rbmm" ;; + false,true) GRADE="$GRADE.rbmmp" ;; + true,false) GRADE="$GRADE.rbmmd" ;; + true,true) GRADE="$GRADE.rbmmdp" ;; + esac + ;; + false) + ;; esac diff --git a/scripts/final_grade_options.sh-subr b/scripts/final_grade_options.sh-subr index dbc4a4fa2..ea240a1a4 100644 --- a/scripts/final_grade_options.sh-subr +++ b/scripts/final_grade_options.sh-subr @@ -95,4 +95,14 @@ case $highlevel_code in true) ;; esac +# +# --use-regions-debug and --use-regions-profiling aren't meaningful +# without --use-regions +# +case $use_regions in false) + use_regions_debug=false + use_regions_profiling=false + ;; +esac + #---------------------------------------------------------------------------# diff --git a/scripts/init_grade_options.sh-subr b/scripts/init_grade_options.sh-subr index 4831d31ee..916ed1ba2 100644 --- a/scripts/init_grade_options.sh-subr +++ b/scripts/init_grade_options.sh-subr @@ -59,6 +59,8 @@ Grade options: # --high-level-data is not yet documented because it is not yet implemented # --high-level is not yet documented because --high-level-data is # not yet implemented +# --use-regions-debug and --use-regions-profiling are not yet documented +# since they are not yet stable target=c highlevel_code=false @@ -87,6 +89,8 @@ ll_debug=false extend_stacks=false stack_segments=false use_regions=false +use_regions_debug=false +use_regions_profiling=false case $# in 0) set - --grade "$DEFAULT_GRADE" ;; diff --git a/scripts/mgnuc.in b/scripts/mgnuc.in index 51162021e..d3f7e98a9 100644 --- a/scripts/mgnuc.in +++ b/scripts/mgnuc.in @@ -405,8 +405,20 @@ case $stack_segments in esac case $use_regions in - true) REGION_OPTS="-DMR_USE_REGIONS" ;; - false) REGION_OPTS="" ;; + true) + REGION_OPTS_0="-DMR_USE_REGIONS" + case $use_regions_debug in + true) REGION_OPTS_1="$REGION_OPTS_0 -DMR_RBMM_DEBUG" ;; + false) REGION_OPTS_1="$REGION_OPTS_0" ;; + esac + case $use_regions_profiling in + true) REGION_OPTS="$REGION_OPTS_1 -DMR_RBMM_PROFILING" ;; + false) REGION_OPTS="$REGION_OPTS_1" ;; + esac + ;; + false) + REGION_OPTS="" + ;; esac GCC_OPTS="$NEST_OPTS $ASM_OPTS $GOTO_OPTS $REG_OPTS" diff --git a/scripts/parse_grade_options.sh-subr b/scripts/parse_grade_options.sh-subr index 9d38109de..f2d500c9d 100644 --- a/scripts/parse_grade_options.sh-subr +++ b/scripts/parse_grade_options.sh-subr @@ -205,6 +205,16 @@ --no-use-regions) use_regions=false ;; + --use-regions-debug) + use_regions_debug=true;; + --no-use-regions-debug) + use_regions_debug=false ;; + + --use-regions-profiling) + use_regions_profiling=true;; + --no-use-regions-profiling) + use_regions_profiling=false ;; + -s|--grade) shift grade="$1"; @@ -242,6 +252,8 @@ extend_stacks=false stack_segments=false use_regions=false + use_regions_debug=false + use_regions_profiling=false grade_pieces=`echo $grade | tr '.' ' '` for grade_piece in $grade_pieces @@ -495,7 +507,28 @@ rbmm) use_regions=true + use_regions_debug=false + use_regions_profiling=false ;; + + rbmmd) + use_regions=true + use_regions_debug=true + use_regions_profiling=false + ;; + + rbmmp) + use_regions=true + use_regions_debug=false + use_regions_profiling=true + ;; + + rbmmdp) + use_regions=true + use_regions_debug=true + use_regions_profiling=true + ;; + *) echo "$0: unknown grade component \`$grade_piece'" 1>&2 exit 1