[m-rev.] for review: use trail segments by default in trailing grades

Julien Fischer jfischer at opturion.com
Sun Feb 16 14:02:37 AEDT 2020


For review by Zoltan.

----------------------------------------------

Use trail segments by default in trailing grades.

We currently support two variants of trailing grades, those that use a
fixed-size trail (.tr) and those that use trail segments (.trseg). This change
removes non-developer support for fixed sized trails and renames the .trseg
grade component to .tr. The .trseg grade now acts a synonym for .tr; we will
eventually delete it.

runtime/mercury_conf_param.h:
     Delete the MR_TRAIL_SEGMENTS macro; its now implied by MR_USE_TRAIL.

     Add a new macro, MR_USE_FIXED_SIZE_TRAIL, that developers can use
     to disable trail segments (should the need for doing that arise).

runtime/mercury_grade.h:
     Bump the binary compatibility number; old .tr grades are not compatible
     with the new ones.

runtime/mercury_trail.[ch]:
runtime/mercury_context.h:
     Enable trail segments by default, only disabling the if
     MR_USE_FIXED_SIZE_TRAIL is enabled.

runtime/mercury_wrapper.c:
trace/mercury_trace_cmd_developer.c:
     Conform to the above changes.

compiler/compile_target_code.m:
     Do not pass options for trail segments to the C compiler.

compiler/compute_grade.m:
     Treat trseg as a synonym for tr.

compiler/options.m:
     Deprecate --trail-segments.

grade_lib/grade_spec.m:
grade_lib/grade_string.m:
grade_lib/grade_structure.m:
grade_lib/grade_vars.m:
grade_lib/try_all_grade_structs.m:
grade_lib/var_value_names.m:
     Remove the trseg component.

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
     Remove support for the --trail-segments option.

doc/user_guide.texi:
     Update the documentation for the --trail-segments.

     Comment out the documentation of the --trail-size and --trail-size-kwords
     runtime options; they are no longer useful to non-developers.

NEWS:
     Announce this change.

Julien.

diff --git a/NEWS b/NEWS
index 1a7ed40..2db5839 100644
--- a/NEWS
+++ b/NEWS
@@ -90,6 +90,26 @@ Changes to the Mercury standard library
      - pred `string_hash/2`
      - pred `generic_hash/2`

+Changes to the Mercury compiler
+-------------------------------
+
+### Changes to code model options
+
+* `--trail-segments`
+
+   This option is deprecated and no longer has any effect.  Trail segments
+   are now always use in grades that support trailing (see below).
+
+Changes to the Mercury implementation
+-------------------------------------
+
+* In grades that support trailing, trail segments are now used by default.
+  It is no longer possible to use a fixed size trail. The `trseg` grade
+  component is deprecated and now acts as a synonym for the `tr` component.
+
+  As a consequence of this, the `--trail-size` and `--trail-size-kwords`
+  runtime options are deprecated and no longer have any effect.
+
  NEWS for Mercury 20.01.1
  ========================

diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m
index 4585f36..dc073bc 100644
--- a/compiler/compile_target_code.m
+++ b/compiler/compile_target_code.m
@@ -710,19 +710,10 @@ gather_grade_defines(Globals, GradeDefines) :-
      globals.lookup_bool_option(Globals, use_trail, UseTrail),
      (
          UseTrail = yes,
-        UseTrailOpt = "-DMR_USE_TRAIL ",
-        globals.lookup_bool_option(Globals, trail_segments, TrailSegments),
-        (
-            TrailSegments = yes,
-            TrailSegOpt = "-DMR_TRAIL_SEGMENTS "
-        ;
-            TrailSegments = no,
-            TrailSegOpt = ""
-        )
+        UseTrailOpt = "-DMR_USE_TRAIL "
      ;
          UseTrail = no,
-        UseTrailOpt = "",
-        TrailSegOpt = ""
+        UseTrailOpt = ""
      ),
      globals.lookup_bool_option(Globals, use_minimal_model_stack_copy,
          MinimalModelStackCopy),
@@ -821,7 +812,6 @@ gather_grade_defines(Globals, GradeDefines) :-
          SourceDebugOpt,
          ExecTraceOpt,
          UseTrailOpt,
-        TrailSegOpt,
          MinimalModelOpt,
          PregeneratedDistOpt,
          SinglePrecFloatOpt,
diff --git a/compiler/compute_grade.m b/compiler/compute_grade.m
index d63e56c..bedeec6 100644
--- a/compiler/compute_grade.m
+++ b/compiler/compute_grade.m
@@ -190,10 +190,10 @@ check_grade_component_compatibility(Globals, Target, GC_Method, !Specs) :-
              ; Target = target_csharp
              ; Target = target_erlang
              ),
-            Trailpec =
+            TrailSpec =
                  [words("Trailing is incompatible with"),
                  words("target language"), words(TargetStr), suffix("."), nl],
-            add_error(phase_options, Trailpec, !Specs)
+            add_error(phase_options, TrailSpec, !Specs)
          ;
              Target = target_c
          )
@@ -654,9 +654,11 @@ grade_component_table("tsc", comp_term_size,

      % Trailing components.
  grade_component_table("tr", comp_trail,
-    [use_trail - bool(yes), trail_segments - bool(no)], no, yes).
-grade_component_table("trseg", comp_trail,
      [use_trail - bool(yes), trail_segments - bool(yes)], no, yes).
+    % NOTE: we do no include `.trseg' in grades strings because it
+    % it is just a synonym for `.tr'.
+grade_component_table("trseg", comp_trail,
+    [use_trail - bool(yes), trail_segments - bool(yes)], no, no).

      % Minimal model tabling components.
      % NOTE: we do not include `.mm' and `.dmm' in grade strings
diff --git a/compiler/options.m b/compiler/options.m
index d2cb6cd..b31009f 100644
--- a/compiler/options.m
+++ b/compiler/options.m
@@ -4939,9 +4939,8 @@ options_help_compilation_model -->
          "\tThis option is not yet supported for the C#, Java",
          "\tor Erlang back-ends.",
          "--trail-segments\t\t\t(grade modifier: `.trseg')",
-        "\tAs above, but use a dynamically sized trail that is composed",
-        "\tof small segments. This can help to avoid trail exhaustion",
-        "\tat the cost of increased execution time.",
+        "\tThis option is deprecated as trail segments are now used by",
+        "\tdefault. The `.trseg' grade modifier is a synonym for `.tr'.",
          "--parallel\t\t(grade modifier: `.par')",
          "\tEnable parallel execution support for the low-level C grades.",
          "\tEnable concurrency (via pthreads) for the high-level C grades.",
diff --git a/doc/user_guide.texi b/doc/user_guide.texi
index 6d2468f..55637dd 100644
--- a/doc/user_guide.texi
+++ b/doc/user_guide.texi
@@ -7973,7 +7973,8 @@ The set of aspects and their alternatives are:
  (the default is no profiling).

  @item Whether to enable the trail:
- at samp{tr} and @samp{trseg} (the default is no trailing).
+ at samp{tr} (the default is no trailing).  @samp{trseg} is currently
+accepted as synonym for @samp{tr}.

  @item Whether to use single-precision representation of floating point values:
  @samp{spf} (the default is to use double-precision floats)
@@ -8470,10 +8471,8 @@ This option is only supported by the C back-ends.
  @cindex Constraint solving
  @cindex Backtrackable destructive update
  @cindex Destructive update, backtrackable
-Enable the use of a dynamically sized trail that is composed of small segments.
-This can help to avoid trail exhaustion at the cost of increased execution
-time.
-This option is only supported by the C back-ends.
+This option is deprecated as trail segments are now used by default.
+The @samp{.trseg} grade modifier is a synonym for @samp{.tr}.

  @sp 1
  @item @code{--parallel}
@@ -10701,27 +10700,30 @@ Sets the size of the solutions heap to @var{size} kilobytes.
  Sets the size of the solutions heap to @var{size} kilobytes
  multiplied by the word size in bytes.

- at sp 1
- at item --trail-size @var{size}
- at findex --trail-size (runtime option)
- at cindex Trail size
-Sets the size of the trail to @var{size} kilobytes.
-This option is ignored in grades that use trail segments.
+ at c These two options are commented out as we only support a fixed size tail
+ at c for developers.
+ at c
+ at c @sp 1
+ at c @item --trail-size @var{size}
+ at c @findex --trail-size (runtime option)
+ at c @cindex Trail size
+ at c Sets the size of the trail to @var{size} kilobytes.
+ at c This option is ignored in grades that use trail segments.

- at sp 1
- at item --trail-size-kwords @var{size}
- at findex --trail-size-kwords (runtime option)
- at cindex Trail size
-Sets the size of the trail to @var{size} kilobytes
-multiplied by the word size in bytes.
-This option is ignored in grades that use trail segments.
+ at c @sp 1
+ at c @item --trail-size-kwords @var{size}
+ at c @findex --trail-size-kwords (runtime option)
+ at c @cindex Trail size
+ at c Sets the size of the trail to @var{size} kilobytes
+ at c multiplied by the word size in bytes.
+ at c This option is ignored in grades that use trail segments.

  @sp 1
  @item --trail-segment-size @var{size}
  @findex --trail-segment-size (runtime option)
  @cindex Trail size
  Sets the size of each trail segment to be @var{size} kilobytes.
-This option is ignored in grades that do not use trail segments.
+This option is ignored in grades that do not use a trail.

  @sp 1
  @item --trail-segment-size-kwords @var{size}
@@ -10729,7 +10731,7 @@ This option is ignored in grades that do not use trail segments.
  @cindex Trail size
  Set the size of each trail segment to be @var{size} kilobytes multiplied by the
  words size in bytes.
-This option is ignored in grades that do not use trail segments.
+This option is ignored in grades that do not use trail.

  @sp 1
  @item --genstack-size @var{size}
diff --git a/grade_lib/grade_spec.m b/grade_lib/grade_spec.m
index 99706bb..47c6c94 100644
--- a/grade_lib/grade_spec.m
+++ b/grade_lib/grade_spec.m
@@ -46,7 +46,6 @@
      ;       svar_low_tag_bits_use
      ;       svar_stack_len
      ;       svar_trail
-    ;       svar_trail_segments
      ;       svar_minmodel
      ;       svar_thread_safe
      ;       svar_gc
@@ -138,9 +137,6 @@
      ;       svalue_trail_no
      ;       svalue_trail_yes

-    ;       svalue_trail_segments_no
-    ;       svalue_trail_segments_yes
-
      ;       svalue_minmodel_no
      ;       svalue_minmodel_stack_copy
      ;       svalue_minmodel_stack_copy_debug
@@ -363,8 +359,6 @@ init_solver_var_specs(SpecsVersion) = Specs :-
              StackLenPrefOrder),
          solver_var_spec(svar_trail,
              [svalue_trail_no, svalue_trail_yes]),
-        solver_var_spec(svar_trail_segments,
-            [svalue_trail_segments_yes, svalue_trail_segments_no]),

          solver_var_spec(svar_minmodel,
              [svalue_minmodel_no,
@@ -731,13 +725,6 @@ init_requirement_specs = [
          (svar_minmodel `is_one_of` [svalue_minmodel_no])
      ),

-% Requirements of values of svar_trail_segments.
-    requirement_spec(
-        "Trail segments require trailing.",
-        (svar_trail_segments `being` svalue_trail_segments_yes) `implies_that`
-        (svar_trail `is_one_of` [svalue_trail_yes])
-    ),
-
  % Requirements of values of svar_minmodel.
      requirement_spec(
          "Minimal model tabling requires the LLDS backend.",
diff --git a/grade_lib/grade_string.m b/grade_lib/grade_string.m
index 675d8bd..334fed1 100644
--- a/grade_lib/grade_string.m
+++ b/grade_lib/grade_string.m
@@ -350,8 +350,7 @@ gc_to_strs(grade_var_gc_history) = ["hgc"].
  :- func c_trail_to_strs(c_trail) = list(string).

  c_trail_to_strs(c_trail_no) = [].
-c_trail_to_strs(c_trail_yes(grade_var_trail_segments_no)) = ["tr"].
-c_trail_to_strs(c_trail_yes(grade_var_trail_segments_yes)) = ["trseg"].
+c_trail_to_strs(c_trail_yes) = ["tr"].

  :- type thread_safe_backend
      --->    tsb_llds(which_grade_string)
@@ -713,13 +712,11 @@ translate_grade_component(ComponentStr, Setting, Settings) :-
          Setting = svar_term_size_prof - svalue_term_size_prof_words,
          Settings = []
      ;
-        ComponentStr = "tr",
-        Setting = svar_trail - svalue_trail_yes,
-        Settings = [svar_trail_segments - svalue_trail_segments_no]
-    ;
-        ComponentStr = "trseg",
+        ( ComponentStr = "tr"
+        ; ComponentStr = "trseg"
+        ),
          Setting = svar_trail - svalue_trail_yes,
-        Settings = [svar_trail_segments - svalue_trail_segments_yes]
+        Settings = []
      ;
          ( ComponentStr = "mm"
          ; ComponentStr = "mmsc"
diff --git a/grade_lib/grade_structure.m b/grade_lib/grade_structure.m
index da1eaf4..4bf8ebb 100644
--- a/grade_lib/grade_structure.m
+++ b/grade_lib/grade_structure.m
@@ -111,9 +111,7 @@

  :- type c_trail
      --->    c_trail_no
-    ;       c_trail_yes(
-                grade_var_trail_segments
-            ).
+    ;       c_trail_yes.

  :- type llds_minmodel_kind
      --->    lmk_stack_copy
@@ -236,12 +234,12 @@ grade_vars_to_grade_structure(GradeVars) = GradeStructure :-
      % *some* arguments is vulnerable to not picking up some arguments
      % in *either*.
      GradeVars = grade_vars(Pregen, Backend, _, _, _, _, _, _,
-        _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _),
+        _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _),

      (
          Pregen = grade_var_pregen_yes,
          GradeVars = grade_vars(_Pregen, _Backend, Target, DataRep,
-            GccConf, LowTagBitsUse, StackLen, Trail, TrailSegments,
+            GccConf, LowTagBitsUse, StackLen, Trail,
              MinimalModel, ThreadSafe, Gc,
              DeepProf, MprofCall, MprofTime, MprofMemory, TScopeProf,
              TermSizeProf, Debug, SSDebug, TargetDebug,
@@ -259,8 +257,6 @@ grade_vars_to_grade_structure(GradeVars) = GradeStructure :-
              "pregen but StackLen != grade_var_stack_len_std"),
          expect(unify(Trail, grade_var_trail_no), $pred,
              "pregen but Trail != grade_var_trail_no"),
-        expect(unify(TrailSegments, grade_var_trail_segments_no), $pred,
-            "pregen but TrailSegments != grade_var_trail_segments_no"),
          expect(unify(MinimalModel, grade_var_minmodel_no), $pred,
              "pregen but MinimalModel != grade_var_minmodel_no"),
          expect(unify(ThreadSafe, grade_var_thread_safe_c_no), $pred,
@@ -335,7 +331,7 @@ grade_vars_to_grade_structure(GradeVars) = GradeStructure :-
              Backend = grade_var_backend_llds,

              GradeVars = grade_vars(_Pregen, _Backend, Target, DataRep,
-                GccConf, LowTagBitsUse, StackLen, Trail, TrailSegments,
+                GccConf, LowTagBitsUse, StackLen, Trail,
                  MinimalModel, ThreadSafe, Gc,
                  DeepProf, MprofCall, MprofTime, MprofMemory, TScopeProf,
                  TermSizeProf, Debug, SSDebug, TargetDebug,
@@ -355,7 +351,7 @@ grade_vars_to_grade_structure(GradeVars) = GradeStructure :-
                  (
                      MinimalModel = grade_var_minmodel_no,
                      encode_c_gc(Gc, CGc),
-                    encode_c_trail(Trail, TrailSegments, CTrail),
+                    encode_c_trail(Trail, CTrail),
                      (
                          DeepProf = grade_var_deep_prof_no,
                          (
@@ -437,9 +433,6 @@ grade_vars_to_grade_structure(GradeVars) = GradeStructure :-
                      ),
                      expect(unify(Trail, grade_var_trail_no), $pred,
                          "Trail != grade_var_trail_no"),
-                    expect(unify(TrailSegments, grade_var_trail_segments_no),
-                        $pred,
-                        "TrailSegments != grade_var_trail_segments_no"),
                      expect(unify(DeepProf, grade_var_deep_prof_no), $pred,
                          "DeepProf != grade_var_deep_prof_no"),
                      expect(unify(MprofCall, grade_var_mprof_call_no), $pred,
@@ -467,7 +460,7 @@ grade_vars_to_grade_structure(GradeVars) = GradeStructure :-
                      "MinModel != grade_var_minmodel_no"),

                  encode_thread_safe_c_gc(Gc, ThreadSafeCGc),
-                encode_c_trail(Trail, TrailSegments, CTrail),
+                encode_c_trail(Trail, CTrail),
                  expect(unify(DeepProf, grade_var_deep_prof_no), $pred,
                      "DeepProf != grade_var_deep_prof_no"),
                  expect(unify(MprofCall, grade_var_mprof_call_no), $pred,
@@ -496,7 +489,7 @@ grade_vars_to_grade_structure(GradeVars) = GradeStructure :-
              Backend = grade_var_backend_mlds,

              GradeVars = grade_vars(_Pregen, _Backend, Target, DataRep,
-                GccConf, LowTagBitsUse, StackLen, Trail, TrailSegments,
+                GccConf, LowTagBitsUse, StackLen, Trail,
                  MinimalModel, ThreadSafe, Gc,
                  DeepProf, MprofCall, MprofTime, MprofMemory, TScopeProf,
                  TermSizeProf, Debug, SSDebug, TargetDebug,
@@ -575,7 +568,7 @@ grade_vars_to_grade_structure(GradeVars) = GradeStructure :-
                      CTrail = c_trail_no
                  ;
                      Trail = grade_var_trail_yes,
-                    CTrail = c_trail_yes(TrailSegments)
+                    CTrail = c_trail_yes
                  ),
                  TargetC = mlds_target_c(MLDSCDataRep, MLDSCThreadSafe,
                      CTrail, MercFile, LowTagBitsUse, MercFloat),
@@ -593,9 +586,6 @@ grade_vars_to_grade_structure(GradeVars) = GradeStructure :-
                      "Gc != grade_var_gc_target_native"),
                  expect(unify(Trail, grade_var_trail_no), $pred,
                      "Trail != grade_var_trail_no"),
-                expect(unify(TrailSegments, grade_var_trail_segments_no),
-                    $pred,
-                    "TrailSegments != grade_var_trail_segments_no"),
                  expect(unify(MprofCall, grade_var_mprof_call_no), $pred,
                      "MprofCall != grade_var_mprof_call_no"),
                  expect(unify(MprofTime, grade_var_mprof_time_no), $pred,
@@ -635,7 +625,7 @@ grade_vars_to_grade_structure(GradeVars) = GradeStructure :-
              Backend = grade_var_backend_elds,

              GradeVars = grade_vars(_Pregen, _Backend, Target, DataRep,
-                GccConf, _LowTagBitsUse, StackLen, Trail, TrailSegments,
+                GccConf, _LowTagBitsUse, StackLen, Trail,
                  MinimalModel, ThreadSafe, Gc,
                  DeepProf, MprofCall, MprofTime, MprofMemory, TScopeProf,
                  TermSizeProf, Debug, SSDebug, TargetDebug,
@@ -654,8 +644,6 @@ grade_vars_to_grade_structure(GradeVars) = GradeStructure :-
                  "StackLen != grade_var_stack_len_std"),
              expect(unify(Trail, grade_var_trail_no), $pred,
                  "Trail != grade_var_trail_no"),
-            expect(unify(TrailSegments, grade_var_trail_segments_no), $pred,
-                "TrailSegments != grade_var_trail_segments_no"),
              expect(unify(MinimalModel, grade_var_minmodel_no), $pred,
                  "MinimalModel != grade_var_minmodel_no"),
              expect(unify(ThreadSafe, grade_var_thread_safe_target_native),
@@ -747,18 +735,15 @@ encode_thread_safe_c_gc(Gc, ThreadSafeCGc) :-
          unexpected($pred, "thread safe, Gc = history")
      ).

-:- pred encode_c_trail(grade_var_trail::in, grade_var_trail_segments::in,
-    c_trail::out) is det.
+:- pred encode_c_trail(grade_var_trail::in, c_trail::out) is det.

-encode_c_trail(Trail, TrailSegments, CTrail) :-
+encode_c_trail(Trail, CTrail) :-
      (
          Trail = grade_var_trail_no,
-        expect(unify(TrailSegments, grade_var_trail_segments_no), $pred,
-            "Trail = no, TrailSegments = yes"),
          CTrail = c_trail_no
      ;
          Trail = grade_var_trail_yes,
-        CTrail = c_trail_yes(TrailSegments)
+        CTrail = c_trail_yes
      ).

  %---------------------------------------------------------------------------%
diff --git a/grade_lib/grade_vars.m b/grade_lib/grade_vars.m
index 6020906..023d94e 100644
--- a/grade_lib/grade_vars.m
+++ b/grade_lib/grade_vars.m
@@ -54,7 +54,6 @@
                  gv_low_tag_bits_use     :: grade_var_low_tag_bits_use,
                  gv_stack_len            :: grade_var_stack_len,
                  gv_trail                :: grade_var_trail,
-                gv_trail_segments       :: grade_var_trail_segments,
                  gv_minmodel             :: grade_var_minmodel,
                  gv_thread_safe          :: grade_var_thread_safe,
                  gv_gc                   :: grade_var_gc,
@@ -230,7 +229,6 @@ success_map_to_grade_vars(!.SuccMap) = GradeVars :-
      map.det_remove(svar_low_tag_bits_use, LowTagBitsUse, !SuccMap),
      map.det_remove(svar_stack_len, StackLen, !SuccMap),
      map.det_remove(svar_trail, Trail, !SuccMap),
-    map.det_remove(svar_trail_segments, TrailSegments, !SuccMap),
      map.det_remove(svar_minmodel, MinimalModel, !SuccMap),
      map.det_remove(svar_thread_safe, ThreadSafe, !SuccMap),
      map.det_remove(svar_gc, Gc, !SuccMap),
@@ -335,14 +333,6 @@ success_map_to_grade_vars(!.SuccMap) = GradeVars :-
          unexpected($pred, "unexpected value of Trail")
      ),

-    ( if TrailSegments = svalue_trail_segments_no then
-        GradeVarTrailSegments = grade_var_trail_segments_no
-    else if TrailSegments = svalue_trail_segments_yes then
-        GradeVarTrailSegments = grade_var_trail_segments_yes
-    else
-        unexpected($pred, "unexpected value of TrailSegments")
-    ),
-
      ( if MinimalModel = svalue_minmodel_no then
          GradeVarMinimalModel = grade_var_minmodel_no
      else if MinimalModel = svalue_minmodel_stack_copy then
@@ -504,7 +494,7 @@ success_map_to_grade_vars(!.SuccMap) = GradeVars :-
      GradeVars = grade_vars(GradeVarPregen, GradeVarBackend,
          GradeVarTarget, GradeVarDataRep,
          GradeVarGccConf, GradeVarLowTagBitsUse, GradeVarStackLen,
-        GradeVarTrail, GradeVarTrailSegments,
+        GradeVarTrail,
          GradeVarMinimalModel, GradeVarThreadSafe, GradeVarGc,
          GradeVarDeepProf,
          GradeVarMprofCall, GradeVarMprofTime, GradeVarMprofMemory,
diff --git a/grade_lib/try_all_grade_structs.m b/grade_lib/try_all_grade_structs.m
index 8ae5127..9141c78 100644
--- a/grade_lib/try_all_grade_structs.m
+++ b/grade_lib/try_all_grade_structs.m
@@ -106,8 +106,7 @@ generate_llds_tests(GradeStructure) :-
      (
          generate_c_gc(CGc),
          ( CTrail = c_trail_no
-        ; CTrail = c_trail_yes(grade_var_trail_segments_no)
-        ; CTrail = c_trail_yes(grade_var_trail_segments_yes)
+        ; CTrail = c_trail_yes
          ),
          (
              LLDSPerfProf = llds_perf_prof_none
@@ -161,8 +160,7 @@ generate_llds_tests(GradeStructure) :-
      ;
          generate_thread_safe_c_gc(ThreadSafeCGc),
          ( CTrail = c_trail_no
-        ; CTrail = c_trail_yes(grade_var_trail_segments_no)
-        ; CTrail = c_trail_yes(grade_var_trail_segments_yes)
+        ; CTrail = c_trail_yes
          ),
          ( TScopeProf = grade_var_tscope_prof_no
          ; TScopeProf = grade_var_tscope_prof_yes
@@ -220,8 +218,7 @@ generate_mlds_c_target(MLDSCTarget) :-
          MLDSCThreadSafe = mlds_c_thread_safe_yes(ThreadSafeCGc)
      ),
      ( CTrail = c_trail_no
-    ; CTrail = c_trail_yes(grade_var_trail_segments_no)
-    ; CTrail = c_trail_yes(grade_var_trail_segments_yes)
+    ; CTrail = c_trail_yes
      ),
      MercFile = grade_var_merc_file_no,
      generate_grade_var_low_tag_bits_use(LowTagBitsUse),
diff --git a/grade_lib/var_value_names.m b/grade_lib/var_value_names.m
index 64468ae..a25b5a0 100644
--- a/grade_lib/var_value_names.m
+++ b/grade_lib/var_value_names.m
@@ -50,7 +50,6 @@ solver_var_name("gcc_conf",                     svar_gcc_conf).
  solver_var_name("low_tag_bits_use",             svar_low_tag_bits_use).
  solver_var_name("stack_len",                    svar_stack_len).
  solver_var_name("trail",                        svar_trail).
-solver_var_name("trail_segments",               svar_trail_segments).
  solver_var_name("minmodel",                     svar_minmodel).
  solver_var_name("thread_safe",                  svar_thread_safe).
  solver_var_name("gc",                           svar_gc).
@@ -120,9 +119,6 @@ solver_var_value_name("exts",                   svalue_stack_len_extend).
  solver_var_value_name("no_trail",               svalue_trail_no).
  solver_var_value_name("trail",                  svalue_trail_yes).

-solver_var_value_name("trfix",                  svalue_trail_segments_no).
-solver_var_value_name("trseg",                  svalue_trail_segments_yes).
-
  solver_var_value_name("no_mm",                  svalue_minmodel_no).
  solver_var_value_name("mm_stack_copy",
                                      svalue_minmodel_stack_copy).
diff --git a/runtime/mercury_conf_param.h b/runtime/mercury_conf_param.h
index 64c081b..38f6618 100644
--- a/runtime/mercury_conf_param.h
+++ b/runtime/mercury_conf_param.h
@@ -150,7 +150,6 @@
  // MR_USE_SINGLE_PREC_FLOAT
  // MR_EXTEND_STACKS_WHEN_NEEDED
  // MR_STACK_SEGMENTS
-// MR_TRAIL_SEGMENTS
  // MR_INLINE_ALLOC
  // MR_TAGBITS
  // MR_USE_REGIONS
@@ -173,7 +172,6 @@
  //    --single-prec-float
  //    --extend-stacks-when-needed
  //    --stack-segments
-//    --trail-segments
  //    --inline-alloc
  //    --pic-reg
  //    --tags
@@ -394,6 +392,10 @@
  // Enables low-level debugging messages when updating the list of
  // trail segments.
  //
+// MR_USE_FIXED_SIZE_TRAIL
+// Disables the trail segment mechanism; this is sometimes use for
+// developers working on that mechanism.
+//
  // MR_TRACE_CHECK_INTEGRITY
  // Enables the -i and --integrity options on mdb's forward movement
  // commands, which cause the debugger to check the integrity of the
diff --git a/runtime/mercury_context.h b/runtime/mercury_context.h
index 1764da0..9ce2e4e 100644
--- a/runtime/mercury_context.h
+++ b/runtime/mercury_context.h
@@ -329,7 +329,7 @@ struct MR_Context_Struct {

  #ifdef  MR_USE_TRAIL
      MR_MemoryZone       *MR_ctxt_trail_zone;
-  #ifdef MR_TRAIL_SEGMENTS
+  #ifndef MR_USE_FIXED_SIZE_TRAIL
      MR_MemoryZones      *MR_ctxt_prev_trail_zones;
    #endif
      MR_TrailEntry       *MR_ctxt_trail_ptr;
diff --git a/runtime/mercury_grade.h b/runtime/mercury_grade.h
index faeda1b..d5260d4 100644
--- a/runtime/mercury_grade.h
+++ b/runtime/mercury_grade.h
@@ -76,7 +76,7 @@
  // breaks binary backwards compatibility only in debugging, deep profiling
  // and low-level C parallel grades respectively.

-#define MR_GRADE_PART_0 v19_
+#define MR_GRADE_PART_0 v20_
  #define MR_GRADE_EXEC_TRACE_VERSION_NO  12
  #define MR_GRADE_DEEP_PROF_VERSION_NO   4
  #define MR_GRADE_LLC_PAR_VERSION_NO 1
@@ -237,13 +237,8 @@
  #endif

  #ifdef MR_USE_TRAIL
-   #ifdef MR_TRAIL_SEGMENTS
-    #define MR_GRADE_PART_7     MR_PASTE2(MR_GRADE_PART_6, _trseg)
-    #define MR_GRADE_OPT_PART_7 MR_GRADE_OPT_PART_6 ".trseg"
-  #else
-    #define MR_GRADE_PART_7     MR_PASTE2(MR_GRADE_PART_6, _tr)
-    #define MR_GRADE_OPT_PART_7 MR_GRADE_OPT_PART_6 ".tr"
-   #endif // ! MR_TRAIL_SEGMENTS
+  #define MR_GRADE_PART_7     MR_PASTE2(MR_GRADE_PART_6, _tr)
+  #define MR_GRADE_OPT_PART_7 MR_GRADE_OPT_PART_6 ".tr"
  #else
    #define MR_GRADE_PART_7       MR_GRADE_PART_6
    #define MR_GRADE_OPT_PART_7   MR_GRADE_OPT_PART_6
diff --git a/runtime/mercury_trail.c b/runtime/mercury_trail.c
index 9b80c5a..28bf5eb 100644
--- a/runtime/mercury_trail.c
+++ b/runtime/mercury_trail.c
@@ -20,7 +20,7 @@
  MR_MemoryZone   *MR_trail_zone;
  MR_TrailEntry   *MR_trail_ptr_var;

-  #if defined(MR_TRAIL_SEGMENTS)
+  #if !defined(MR_USE_FIXED_SIZE_TRAIL)
      MR_MemoryZones *MR_prev_trail_zones;
    #endif

@@ -28,7 +28,7 @@ MR_Unsigned     MR_ticket_counter_var = 1;
  MR_Unsigned     MR_ticket_high_water_var = 1;
  #endif

-#if defined(MR_TRAIL_SEGMENTS)
+#if !defined(MR_USE_FIXED_SIZE_TRAIL)
  static void
  MR_pop_trail_segment(void);
  #endif
@@ -64,7 +64,7 @@ MR_untrail_to(MR_TrailEntry *old_trail_ptr, MR_untrail_reason reason)
              // We need to walk backwards through all the previous segments
              // (invoking function trail entries as we go) until we find it.

-            #if defined(MR_TRAIL_SEGMENTS)
+            #if !defined(MR_USE_FIXED_SIZE_TRAIL)
                  if (tr_ptr == tr_base
                      && tr_ptr != old_trail_ptr)
                  {
@@ -115,7 +115,7 @@ MR_untrail_to(MR_TrailEntry *old_trail_ptr, MR_untrail_reason reason)
                  *MR_get_trail_entry_address(tr_ptr) =
                      MR_get_trail_entry_value(tr_ptr);
              }
-            #if defined(MR_TRAIL_SEGMENTS)
+            #if !defined(MR_USE_FIXED_SIZE_TRAIL)
                  if (tr_ptr == tr_base
                      && tr_ptr != old_trail_ptr)
                  {
@@ -143,7 +143,7 @@ MR_num_trail_entries(void)
  {
      MR_Unsigned     n_entries = 0;

-#if defined(MR_TRAIL_SEGMENTS)
+#if !defined(MR_USE_FIXED_SIZE_TRAIL)
      MR_MemoryZones  *list;
      MR_MemoryZone   *zone;

@@ -154,7 +154,7 @@ MR_num_trail_entries(void)
              - (MR_TrailEntry *) zone->MR_zone_min;
          list = list->MR_zones_tail;
      }
-#endif // MR_TRAIL_SEGMENTS
+#endif // ! MR_USE_FIXED_SIZE_TRAIL

      n_entries += MR_trail_ptr - MR_TRAIL_BASE;

@@ -166,7 +166,7 @@ MR_num_trail_entries(void)
  void
  MR_reset_trail(void)
  {
-    #if defined(MR_TRAIL_SEGMENTS)
+    #if !defined(MR_FIX_SIZE_TRAIL)
          while (MR_PREV_TRAIL_ZONES != NULL) {
              MR_reset_trail_zone();
              MR_pop_trail_segment();
@@ -204,7 +204,7 @@ MR_reset_trail_zone(void) {

  ////////////////////////////////////////////////////////////////////////////

-#if defined(MR_TRAIL_SEGMENTS)
+#if !defined(MR_USE_FIXED_SIZE_TRAIL)
  void
  MR_new_trail_segment(void)
  {
@@ -280,7 +280,7 @@ MR_num_trail_segments(void)
      return n_segments;
  }

-#endif // MR_TRAIL_SEGMENTS
+#endif // ! MR_USE_FIXED_SIZE_TRAIL

  #endif // MR_USE_TRAIL

diff --git a/runtime/mercury_trail.h b/runtime/mercury_trail.h
index 28bd638..b5423c5 100644
--- a/runtime/mercury_trail.h
+++ b/runtime/mercury_trail.h
@@ -320,7 +320,7 @@ struct MR_TrailEntry_Struct {
      // The Mercury trail.
      extern MR_MemoryZone *MR_trail_zone;

-    #if defined(MR_TRAIL_SEGMENTS)
+    #if !defined(MR_USE_FIXED_SIZE_TRAIL)
          // A list of any previous trail zones.
           extern MR_MemoryZones *MR_prev_trail_zones;
      #endif
@@ -372,7 +372,7 @@ struct MR_TrailEntry_Struct {

      #define MR_TRAIL_ZONE (MR_CONTEXT(MR_ctxt_trail_zone))

-    #if defined(MR_TRAIL_SEGMENTS)
+    #if !defined(MR_USE_FIXED_SIZE_TRAIL)
          #define MR_PREV_TRAIL_ZONES (MR_CONTEXT(MR_ctxt_prev_trail_zones))
      #endif

@@ -381,7 +381,7 @@ struct MR_TrailEntry_Struct {
  #else
      #define MR_TRAIL_ZONE   MR_trail_zone

-    #if defined(MR_TRAIL_SEGMENTS)
+    #if !defined(MR_USE_FIXED_SIZE_TRAIL)
          #define MR_PREV_TRAIL_ZONES MR_prev_trail_zones
      #endif

@@ -397,7 +397,7 @@ struct MR_TrailEntry_Struct {

  ////////////////////////////////////////////////////////////////////////////

-#if defined(MR_TRAIL_SEGMENTS)
+#if !defined(MR_USE_FIXED_SIZE_TRAIL)

  #define MR_trail_extend_and_check()                                         \
      do {                                                                    \
@@ -406,11 +406,11 @@ struct MR_TrailEntry_Struct {
          }                                                                   \
      } while (0)

-#else // ! MR_TRAIL_SEGMENTS
+#else // ! MR_USE_FIXED_SIZE_TRAIL

      #define MR_trail_extend_and_check()     ((void) 0)

-#endif // !MR_TRAIL_SEGMENTS
+#endif // MR_USE_FIXED_SIZE_TRAIL

  // void  MR_trail_value(MR_Word *address, MR_Word value);
  //
@@ -511,7 +511,7 @@ extern MR_Unsigned  MR_num_trail_entries(void);

  extern void         MR_reset_trail(void);

-#if defined(MR_TRAIL_SEGMENTS)
+#if !defined(MR_USE_FIXED_SIZE_TRAIL)

  // Push the current trail segment onto the list of previous segments,
  // allocate a new segment and set MR_trail_ptr to point to beginning
@@ -523,6 +523,6 @@ extern void         MR_new_trail_segment(void);

  extern MR_Unsigned  MR_num_trail_segments(void);

-#endif // MR_TRAIL_SEGMENTS
+#endif // ! MR_USE_FIXED_SIZE_TRAIL

  #endif // not MERCURY_TRAIL_H
diff --git a/runtime/mercury_wrapper.c b/runtime/mercury_wrapper.c
index 5f9cb3b..53ed4b2 100644
--- a/runtime/mercury_wrapper.c
+++ b/runtime/mercury_wrapper.c
@@ -1505,7 +1505,7 @@ MR_process_options(int argc, char **argv)
                      MR_usage();
                  }

-                #if !defined(MR_TRAIL_SEGMENTS)
+                #if defined(MR_USE_FIXED_SIZE_TRAIL)
                      MR_trail_size = size;
                  #endif
                  break;
@@ -1515,7 +1515,7 @@ MR_process_options(int argc, char **argv)
                      MR_usage();
                  }

-                #if !defined(MR_TRAIL_SEGMENTS)
+                #if defined(MR_USE_FIXED_SIZE_TRAIL)
                      MR_trail_size = size * sizeof(MR_Word);
                  #endif
                  break;
@@ -1525,7 +1525,7 @@ MR_process_options(int argc, char **argv)
                      MR_usage();
                  }

-                #if defined(MR_TRAIL_SEGMENTS)
+                #if !defined(MR_USE_FIXED_SIZE_TRAIL)
                      MR_trail_size = size;
                  #endif
                  break;
@@ -1535,7 +1535,7 @@ MR_process_options(int argc, char **argv)
                      MR_usage();
                  }

-                #if defined(MR_TRAIL_SEGMENTS)
+                #if !defined(MR_USE_FIXED_SIZE_TRAIL)
                      MR_trail_size = size * sizeof(MR_Word);
                  #endif
                  break;
diff --git a/scripts/canonical_grade.sh-subr b/scripts/canonical_grade.sh-subr
index ae058c9..cb905fb 100644
--- a/scripts/canonical_grade.sh-subr
+++ b/scripts/canonical_grade.sh-subr
@@ -119,14 +119,9 @@ case $record_term_sizes_as_words,$record_term_sizes_as_cells in
  			;;
  esac

-case $use_trail,$trail_segments in
-	true,false)	GRADE="$GRADE.tr" ;;
-	true,true)	GRADE="$GRADE.trseg" ;;
-	false,false)	;;
-	*)		progname=`basename $0`
-			echo "$progname: error: invalid combination of trailing options." 1>&2
-			exit 1
-			;;
+case $use_trail in
+	true)	GRADE="$GRADE.tr" ;;
+	*)      ;;
  esac

  case $use_minimal_model_stack_copy,$use_minimal_model_own_stacks,$minimal_model_debug in
diff --git a/scripts/init_grade_options.sh-subr b/scripts/init_grade_options.sh-subr
index 0f4a478..b51613d 100644
--- a/scripts/init_grade_options.sh-subr
+++ b/scripts/init_grade_options.sh-subr
@@ -78,7 +78,6 @@ profile_deep=false
  record_term_sizes_as_words=false
  record_term_sizes_as_cells=false
  use_trail=false
-trail_segments=false
  use_minimal_model_stack_copy=false
  use_minimal_model_own_stacks=false
  minimal_model_debug=false
diff --git a/scripts/mgnuc.in b/scripts/mgnuc.in
index 19fa9e9..f2248d9 100755
--- a/scripts/mgnuc.in
+++ b/scripts/mgnuc.in
@@ -390,9 +390,6 @@ esac
  case $use_trail in
      true)
          TRAIL_OPTS="-DMR_USE_TRAIL"
-        case $trail_segments in
-            true) TRAIL_OPTS="$TRAIL_OPTS -DMR_TRAIL_SEGMENTS" ;;
-        esac
          # See the comment in compile_c_file/7 in compiler/compile_target_code.m
          # for an explanation of this.
          case $COMPILER in
@@ -402,15 +399,7 @@ case $use_trail in
          ;;

      false)
-        TRAIL_OPTS=""
-        case $trail_segments in
-            true)
-                    progname`basename $0`
-                    echo "$progname: cannot use trail segments without trailing"
-                    exit 1;;
-        esac
-        FN_ALIGN_OPTS=""
-    ;;
+        TRAIL_OPTS="" ;;
  esac

  case $use_minimal_model_stack_copy,$use_minimal_model_own_stacks in
diff --git a/scripts/parse_grade_options.sh-subr b/scripts/parse_grade_options.sh-subr
index 87d375a..e094f2c 100644
--- a/scripts/parse_grade_options.sh-subr
+++ b/scripts/parse_grade_options.sh-subr
@@ -143,11 +143,6 @@
      --no-use-trail)
          use_trail=false ;;

-    --trail-segments)
-        trail_segments=true ;;
-    --no-trail-segments)
-        trail_segments=false ;;
-
      --use-minimal-model-stack-copy)
          use_minimal_model_stack_copy=true ;;
      --no-use-minimal-model-stack-copy)
@@ -243,7 +238,6 @@
          record_term_sizes_as_words=false
          record_term_sizes_as_cells=false
          use_trail=false
-        trail_segments=false
          use_minimal_model_stack_copy=false
          use_minimal_model_own_stacks=false
          minimal_model_debug=false
@@ -423,12 +417,10 @@

                  tr)
                      use_trail=true
-                    trail_segments=false
                      ;;

                  trseg)
                      use_trail=true
-                    trail_segments=true
                      ;;

                  mm)
diff --git a/trace/mercury_trace_cmd_developer.c b/trace/mercury_trace_cmd_developer.c
index cb724f7..3db090a 100644
--- a/trace/mercury_trace_cmd_developer.c
+++ b/trace/mercury_trace_cmd_developer.c
@@ -1344,7 +1344,7 @@ MR_trace_cmd_trail_details(char **words, int word_count,
      fprintf(MR_mdb_out, "number of trail entries: %lu\n",
          (unsigned long) MR_num_trail_entries());

-    #if defined(MR_TRAIL_SEGMENTS)
+    #if !defined(MR_USE_FIXED_SIZE_TRAIL)
          fprintf(MR_mdb_out, "number of trail segments: %lu\n",
              (unsigned long) MR_num_trail_segments());
      #endif




More information about the reviews mailing list