[m-rev.] for review: restore hl.gc

Peter Wang novalazy at gmail.com
Mon Oct 5 14:07:38 AEDT 2009


Branches: main

Restore high-level data C grades.

- Earlier, I inadvertently disabled unboxing of foreign input arguments in
  high-level data C grades.

- Earlier, I incorrectly assumed that high-level data structures don't require
  secondary tag initialiser arguments, but that is only true when targetting an
  OOP language where the object constructor sets the secondary tag.

compiler/ml_foreign_proc_gen.m:
        Make `input_arg_assignable_with_cast' fail on foreign type arguments
        without the `can_pass_as_mercury_type' assertion in hl.* grades, so the
        argument will be correctly unboxed.

        Rename HasSecTag variables to ExplicitSecTag.

compiler/ml_type_gen.m:
        Export ml_target_uses_constructors.

compiler/ml_unify_gen.m:
        Use ml_target_uses_constructors to decide if an explicit secondary tag
        argument is required when initialising a new object, not whether
        high-level data is in effect.

        Rename HasSecTag variables to ExplicitSecTag.

compiler/mlds.m:
        Clarify that the `HasSecTag' field of `new_object' means whether an
        explicit secondary tag argument is at the head of the list of
        arguments, not whether objects of that type require secondary tags.

        Rename HasSecTag variables to ExplicitSecTag.

compiler/mlds_to_il.m:
        Abort if we see a `new_object' with an explicit secondary tag, instead
        of skipping it.

compiler/ml_accurate_gc.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
compiler/structure_reuse.direct.choose_reuse.m:
        Rename HasSecTag variables to ExplicitSecTag.

diff --git a/compiler/ml_accurate_gc.m b/compiler/ml_accurate_gc.m
index 0426c8d..72c06df 100644
--- a/compiler/ml_accurate_gc.m
+++ b/compiler/ml_accurate_gc.m
@@ -533,9 +533,9 @@ fixup_newobj_in_default(default_case(Statement0), default_case(Statement),
 
 fixup_newobj_in_atomic_statement(AtomicStatement0, Stmt, !Fixup) :-
     (
-        AtomicStatement0 = new_object(Lval, MaybeTag, _HasSecTag, PointerType,
-            _MaybeSizeInWordsRval, _MaybeCtorName, ArgRvals, _ArgTypes,
-            _MayUseAtomic)
+        AtomicStatement0 = new_object(Lval, MaybeTag, _ExplicitSecTag,
+            PointerType, _MaybeSizeInWordsRval, _MaybeCtorName,
+            ArgRvals, _ArgTypes, _MayUseAtomic)
     ->
         % Generate the declaration of the new local variable.
         %
diff --git a/compiler/ml_elim_nested.m b/compiler/ml_elim_nested.m
index ccc43cb..56f32d5 100644
--- a/compiler/ml_elim_nested.m
+++ b/compiler/ml_elim_nested.m
@@ -1855,12 +1855,12 @@ fixup_atomic_stmt(Action, Info, Atomic0, Atomic) :-
         fixup_rval(Action, Info, Rval0, Rval),
         Atomic = delete_object(Rval)
     ;
-        Atomic0 = new_object(Target0, MaybeTag, HasSecTag, Type, MaybeSize,
-            MaybeCtorName, Args0, ArgTypes, MayUseAtomic),
+        Atomic0 = new_object(Target0, MaybeTag, ExplicitSecTag, Type,
+            MaybeSize, MaybeCtorName, Args0, ArgTypes, MayUseAtomic),
         fixup_lval(Action, Info, Target0, Target),
         fixup_rvals(Action, Info, Args0, Args),
-        Atomic = new_object(Target, MaybeTag, HasSecTag, Type, MaybeSize,
-            MaybeCtorName, Args, ArgTypes, MayUseAtomic)
+        Atomic = new_object(Target, MaybeTag, ExplicitSecTag, Type,
+            MaybeSize, MaybeCtorName, Args, ArgTypes, MayUseAtomic)
     ;
         Atomic0 = mark_hp(Lval0),
         fixup_lval(Action, Info, Lval0, Lval),
diff --git a/compiler/ml_foreign_proc_gen.m b/compiler/ml_foreign_proc_gen.m
index d4346f7..2a6f285 100644
--- a/compiler/ml_foreign_proc_gen.m
+++ b/compiler/ml_foreign_proc_gen.m
@@ -1112,6 +1112,13 @@ input_arg_assignable_with_cast(Lang, HighLevelData, OrigType, ExportedType,
     (
         Lang = lang_c,
         HighLevelData = yes,
+        IsForeign = foreign.is_foreign_type(ExportedType),
+        (
+            IsForeign = yes(Assertions),
+            list.member(foreign_type_can_pass_as_mercury_type, Assertions)
+        ;
+            IsForeign = no
+        ),
         % In general, the types used for the C interface are not the same
         % as the types used by --high-level-data, so we always use a cast
         % here. (Strictly speaking the cast is not needed for a few cases
diff --git a/compiler/ml_optimize.m b/compiler/ml_optimize.m
index 8e3a38f..6224fbb 100644
--- a/compiler/ml_optimize.m
+++ b/compiler/ml_optimize.m
@@ -1223,11 +1223,11 @@ eliminate_var_in_atomic_stmt(Stmt0, Stmt, !VarElimInfo) :-
         eliminate_var_in_rval(Rval0, Rval, !VarElimInfo),
         Stmt = delete_object(Rval)
     ;
-        Stmt0 = new_object(Target0, MaybeTag, HasSecTag, Type,
+        Stmt0 = new_object(Target0, MaybeTag, ExplicitSecTag, Type,
             MaybeSize, MaybeCtorName, Args0, ArgTypes, MayUseAtomic),
         eliminate_var_in_lval(Target0, Target, !VarElimInfo),
         eliminate_var_in_rvals(Args0, Args, !VarElimInfo),
-        Stmt = new_object(Target, MaybeTag, HasSecTag, Type,
+        Stmt = new_object(Target, MaybeTag, ExplicitSecTag, Type,
             MaybeSize, MaybeCtorName, Args, ArgTypes, MayUseAtomic)
     ;
         Stmt0 = mark_hp(Lval0),
diff --git a/compiler/ml_type_gen.m b/compiler/ml_type_gen.m
index cea75ed..77fcbb9 100644
--- a/compiler/ml_type_gen.m
+++ b/compiler/ml_type_gen.m
@@ -33,6 +33,7 @@
 :- import_module ml_backend.mlds.
 :- import_module parse_tree.prog_data.
 
+:- import_module bool.
 :- import_module list.
 
 %-----------------------------------------------------------------------------%
@@ -91,6 +92,10 @@
     %
 :- func ml_tag_uses_base_class(cons_tag) = tag_uses_base_class.
 
+    % Return whether this compilation target uses object constructors.
+    %
+:- func ml_target_uses_constructors(compilation_target) = bool.
+
     % Exported enumeration info in the HLDS is converted into an MLDS
     % specific representation.  The target specific code generators may
     % further transform it.
@@ -115,7 +120,6 @@
 :- import_module parse_tree.prog_util.
 
 :- import_module assoc_list.
-:- import_module bool.
 :- import_module int.
 :- import_module list.
 :- import_module map.
@@ -742,7 +746,7 @@ ml_gen_du_ctor_member(ModuleInfo, BaseClassId, BaseClassQualifier,
         % Generate a constructor function to initialize the fields, if needed
         % (not all back-ends use constructor functions).
         MaybeSecTagVal = get_secondary_tag(TagVal),
-        UsesConstructors = target_uses_constructors(Target),
+        UsesConstructors = ml_target_uses_constructors(Target),
         UsesBaseClass = ml_tag_uses_base_class(TagVal),
         (
             UsesConstructors = yes,
@@ -867,15 +871,13 @@ ml_tag_uses_base_class(Tag) = UsesBaseClass :-
         UsesBaseClass = tag_does_not_use_base_class
     ).
 
-:- func target_uses_constructors(compilation_target) = bool.
-
-target_uses_constructors(target_c) = no.
-target_uses_constructors(target_il) = yes.
-target_uses_constructors(target_java) = yes.
-target_uses_constructors(target_asm) = no.
-target_uses_constructors(target_x86_64) =
+ml_target_uses_constructors(target_c) = no.
+ml_target_uses_constructors(target_il) = yes.
+ml_target_uses_constructors(target_java) = yes.
+ml_target_uses_constructors(target_asm) = no.
+ml_target_uses_constructors(target_x86_64) =
     unexpected(this_file, "target_x86_64 and --high-level-code").
-target_uses_constructors(target_erlang) =
+ml_target_uses_constructors(target_erlang) =
     unexpected(this_file, "target erlang").
 
 :- func target_uses_empty_base_classes(compilation_target) = bool.
diff --git a/compiler/ml_unify_gen.m b/compiler/ml_unify_gen.m
index 1226a96..e536adc 100644
--- a/compiler/ml_unify_gen.m
+++ b/compiler/ml_unify_gen.m
@@ -93,7 +93,7 @@
 :- func ml_gen_reserved_address(module_info, reserved_address, mlds_type) =
     mlds_rval.
 
-    % ml_gen_new_object(MaybeConsId, MaybeCtorName, Tag, HasSecTag, Var,
+    % ml_gen_new_object(MaybeConsId, MaybeCtorName, Tag, ExplicitSecTag, Var,
     %   ExtraRvals, ExtraTypes, ArgVars, ArgModes, TakeAddr, HowToConstruct,
     %   Context, Statements, !Info):
     %
@@ -570,13 +570,14 @@ ml_cons_id_to_tag(Info, ConsId, Tag) :-
 
 ml_gen_compound(ConsId, Ptag, MaybeStag, UsesBaseClass, Var, ArgVars, ArgModes,
         TakeAddr, HowToConstruct, Context, Statements, !Info) :-
+    ml_gen_info_get_target(!.Info, CompilationTarget),
+
     % Figure out which class name to construct.
     (
         UsesBaseClass = tag_uses_base_class,
         MaybeCtorName = no
     ;
         UsesBaseClass = tag_does_not_use_base_class,
-        ml_gen_info_get_target(!.Info, CompilationTarget),
         ml_cons_name(CompilationTarget, ConsId, CtorName),
         MaybeCtorName = yes(CtorName)
     ),
@@ -584,10 +585,10 @@ ml_gen_compound(ConsId, Ptag, MaybeStag, UsesBaseClass, Var, ArgVars, ArgModes,
     % If there is a secondary tag, it goes in the first field.
     (
         MaybeStag = yes(Stag),
-        ml_gen_info_get_high_level_data(!.Info, HighLevelData),
+        UsesConstructors = ml_target_uses_constructors(CompilationTarget),
         (
-            HighLevelData = no,
-            HasSecTag = yes,
+            UsesConstructors = no,
+            ExplicitSecTag = yes,
             StagRval0 = ml_const(mlconst_int(Stag)),
             StagType0 = mlds_native_int_type,
             % With the low-level data representation, all fields -- even the
@@ -597,22 +598,23 @@ ml_gen_compound(ConsId, Ptag, MaybeStag, UsesBaseClass, Var, ArgVars, ArgModes,
             ExtraRvals = [StagRval],
             ExtraArgTypes = [StagType]
         ;
-            HighLevelData = yes,
-            HasSecTag = no,
+            UsesConstructors = yes,
+            % Secondary tag is implicitly initialised by the constructor.
+            ExplicitSecTag = no,
             ExtraRvals = [],
             ExtraArgTypes = []
         )
     ;
         MaybeStag = no,
-        HasSecTag = no,
+        ExplicitSecTag = no,
         ExtraRvals = [],
         ExtraArgTypes = []
     ),
-    ml_gen_new_object(yes(ConsId), MaybeCtorName, Ptag, HasSecTag,
+    ml_gen_new_object(yes(ConsId), MaybeCtorName, Ptag, ExplicitSecTag,
         Var, ExtraRvals, ExtraArgTypes, ArgVars, ArgModes, TakeAddr,
         HowToConstruct, Context, Statements, !Info).
 
-ml_gen_new_object(MaybeConsId, MaybeCtorName, Tag, HasSecTag, Var,
+ml_gen_new_object(MaybeConsId, MaybeCtorName, Tag, ExplicitSecTag, Var,
         ExtraRvals, ExtraTypes, ArgVars, ArgModes, TakeAddr, HowToConstruct,
         Context, Statements, !Info) :-
     % Determine the variable's type and lval, the tag to use, and the types
@@ -630,7 +632,7 @@ ml_gen_new_object(MaybeConsId, MaybeCtorName, Tag, HasSecTag, Var,
     (
         HowToConstruct = construct_dynamically,
         ml_gen_new_object_dynamically(MaybeConsId, MaybeCtorName,
-            MaybeTag, HasSecTag, Var, VarLval, VarType, MLDS_Type,
+            MaybeTag, ExplicitSecTag, Var, VarLval, VarType, MLDS_Type,
             ExtraRvals, ExtraTypes, ArgVars, ArgTypes, ArgModes, TakeAddr,
             Context, Statements, !Info)
     ;
@@ -643,7 +645,7 @@ ml_gen_new_object(MaybeConsId, MaybeCtorName, Tag, HasSecTag, Var,
     ;
         HowToConstruct = reuse_cell(CellToReuse),
         ml_gen_new_object_reuse_cell(MaybeConsId, MaybeCtorName, Tag, MaybeTag,
-            HasSecTag, Var, VarLval, VarType, MLDS_Type,
+            ExplicitSecTag, Var, VarLval, VarType, MLDS_Type,
             ExtraRvals, ExtraTypes, ArgVars, ArgTypes, ArgModes, TakeAddr,
             CellToReuse, Context, Statements, !Info)
     ;
@@ -658,7 +660,7 @@ ml_gen_new_object(MaybeConsId, MaybeCtorName, Tag, HasSecTag, Var,
     list(int)::in, prog_context::in, list(statement)::out,
     ml_gen_info::in, ml_gen_info::out) is det.
 
-ml_gen_new_object_dynamically(MaybeConsId, MaybeCtorName, MaybeTag, HasSecTag,
+ml_gen_new_object_dynamically(MaybeConsId, MaybeCtorName, MaybeTag, ExplicitSecTag,
         _Var, VarLval, VarType, MLDS_Type, ExtraRvals, ExtraTypes,
         ArgVars, ArgTypes, ArgModes, TakeAddr, Context, Statements, !Info) :-
     % Find out the types of the constructor arguments and generate rvals
@@ -693,7 +695,7 @@ ml_gen_new_object_dynamically(MaybeConsId, MaybeCtorName, MaybeTag, HasSecTag,
     % Generate a `new_object' statement to dynamically allocate the memory
     % for this term from the heap. The `new_object' statement will also
     % initialize the fields of this term with the specified arguments.
-    MakeNewObject = new_object(VarLval, MaybeTag, HasSecTag, MLDS_Type,
+    MakeNewObject = new_object(VarLval, MaybeTag, ExplicitSecTag, MLDS_Type,
         yes(SizeInWordsRval), MaybeCtorName, ArgRvals, MLDS_ArgTypes,
         MayUseAtomic),
     Stmt = ml_stmt_atomic(MakeNewObject),
@@ -810,9 +812,9 @@ ml_gen_new_object_statically(MaybeConsId, MaybeCtorName, MaybeTag,
     list(statement)::out, ml_gen_info::in, ml_gen_info::out) is det.
 
 ml_gen_new_object_reuse_cell(MaybeConsId, MaybeCtorName, Tag, MaybeTag,
-        HasSecTag, Var, VarLval, VarType, MLDS_Type, ExtraRvals, ExtraTypes,
-        ArgVars, ArgTypes, ArgModes, TakeAddr, CellToReuse, Context,
-        Statements, !Info) :-
+        ExplicitSecTag, Var, VarLval, VarType, MLDS_Type,
+        ExtraRvals, ExtraTypes, ArgVars, ArgTypes, ArgModes, TakeAddr,
+        CellToReuse, Context, Statements, !Info) :-
     CellToReuse = cell_to_reuse(ReuseVar, ReuseConsIds, _),
     (
         MaybeConsId = yes(ConsId0),
@@ -880,7 +882,7 @@ ml_gen_new_object_reuse_cell(MaybeConsId, MaybeCtorName, Tag, MaybeTag,
 
     % If the reassignment isn't possible because the target is statically
     % allocated then fall back to dynamic allocation.
-    ml_gen_new_object(MaybeConsId, MaybeCtorName, Tag, HasSecTag, Var,
+    ml_gen_new_object(MaybeConsId, MaybeCtorName, Tag, ExplicitSecTag, Var,
         ExtraRvals, ExtraTypes, ArgVars, ArgModes, TakeAddr,
         construct_dynamically, Context, DynamicStmts, !Info),
     ElseStmt = ml_stmt_block([], DynamicStmts),
@@ -2160,14 +2162,21 @@ ml_gen_ground_term_conjunct_tag(ModuleInfo, Target, HighLevelData, VarTypes,
             ExtraInitializers = []
         ;
             ConsTag = shared_remote_tag(Ptag, Stag),
+            UsesConstructors = ml_target_uses_constructors(Target),
             (
-                HighLevelData = no,
+                UsesConstructors = no,
                 StagRval0 = ml_const(mlconst_int(Stag)),
-                % XXX why is this cast here?
-                StagRval = ml_unop(box(mlds_native_char_type), StagRval0),
+                (
+                    HighLevelData = no,
+                    % XXX why is this cast here?
+                    StagRval = ml_unop(box(mlds_native_char_type), StagRval0)
+                ;
+                    HighLevelData = yes,
+                    StagRval = StagRval0
+                ),
                 ExtraInitializers = [init_obj(StagRval)]
             ;
-                HighLevelData = yes,
+                UsesConstructors = yes,
                 ExtraInitializers = []
             )
         ),
diff --git a/compiler/ml_util.m b/compiler/ml_util.m
index 8ee3d98..7d54602 100644
--- a/compiler/ml_util.m
+++ b/compiler/ml_util.m
@@ -465,7 +465,7 @@ atomic_stmt_contains_var(AtomicStmt, DataName) = ContainsVar :-
         AtomicStmt = delete_object(Rval),
         ContainsVar = rval_contains_var(Rval, DataName)
     ;
-        AtomicStmt = new_object(Target, _MaybeTag, _HasSecTag, _Type,
+        AtomicStmt = new_object(Target, _MaybeTag, _ExplicitSecTag, _Type,
             _MaybeSize, _MaybeCtorName, Args, _ArgTypes, _MayUseAtomic),
         ( lval_contains_var(Target, DataName) = yes ->
             ContainsVar = yes
diff --git a/compiler/mlds.m b/compiler/mlds.m
index 98d4932..db3064d 100644
--- a/compiler/mlds.m
+++ b/compiler/mlds.m
@@ -1289,9 +1289,10 @@
                 % the result to the target.
                 maybe(mlds_tag),
 
-                % Indicates whether or not there is a secondary tag. If so,
-                % it will be stored as the first argument in the argument list
-                % (see below).
+                % Indicates whether or not the first argument in the list (see
+                % below) is a secondary tag. For target languages with
+                % constructors, secondary tags are implicitly initialised by
+                % the constructor, not passed in.
                 bool,
 
                 % The type of the object being allocated.
diff --git a/compiler/mlds_to_c.m b/compiler/mlds_to_c.m
index 744f5a6..8804675 100644
--- a/compiler/mlds_to_c.m
+++ b/compiler/mlds_to_c.m
@@ -3573,8 +3573,8 @@ mlds_output_atomic_stmt(Opts, Indent, FuncInfo, Statement, Context, !IO) :-
         mlds_output_rval(Opts, Rval, !IO),
         io.write_string(");\n", !IO)
     ;
-        Statement = new_object(Target, MaybeTag, _HasSecTag, Type, MaybeSize,
-            MaybeCtorName, Args, ArgTypes, MayUseAtomic),
+        Statement = new_object(Target, MaybeTag, _ExplicitSecTag, Type,
+            MaybeSize, MaybeCtorName, Args, ArgTypes, MayUseAtomic),
         mlds_indent(Indent, !IO),
         io.write_string("{\n", !IO),
 
diff --git a/compiler/mlds_to_gcc.m b/compiler/mlds_to_gcc.m
index 6426193..3ab11e2 100644
--- a/compiler/mlds_to_gcc.m
+++ b/compiler/mlds_to_gcc.m
@@ -3100,8 +3100,8 @@ gen_atomic_stmt(_DefnInfo, delete_object(_Lval), _) -->
     { sorry(this_file, "delete_object") }.
 
 gen_atomic_stmt(DefnInfo, NewObject, Context) -->
-    { NewObject = new_object(Target, MaybeTag, _HasSecTag, Type, MaybeSize,
-        _MaybeCtorName, Args, ArgTypes, _MayUseAtomic) },
+    { NewObject = new_object(Target, MaybeTag, _ExplicitSecTag, Type,
+        MaybeSize, _MaybeCtorName, Args, ArgTypes, _MayUseAtomic) },
 
     %
     % Calculate the size that we're going to allocate.
diff --git a/compiler/mlds_to_il.m b/compiler/mlds_to_il.m
index d97f9fd..84b643c 100644
--- a/compiler/mlds_to_il.m
+++ b/compiler/mlds_to_il.m
@@ -546,9 +546,9 @@ rename_atomic(comment(S)) = comment(S).
 rename_atomic(assign(L, R)) = assign(rename_lval(L), rename_rval(R)).
 rename_atomic(assign_if_in_heap(L, R)) = assign(rename_lval(L), rename_rval(R)).
 rename_atomic(delete_object(O)) = delete_object(rename_rval(O)).
-rename_atomic(new_object(L, Tag, HasSecTag, Type, MaybeSize, Ctxt, Args,
+rename_atomic(new_object(L, Tag, ExplicitSecTag, Type, MaybeSize, Ctxt, Args,
         Types, MayUseAtomic))
-    = new_object(rename_lval(L), Tag, HasSecTag, Type, MaybeSize,
+    = new_object(rename_lval(L), Tag, ExplicitSecTag, Type, MaybeSize,
         Ctxt, list.map(rename_rval, Args), Types, MayUseAtomic).
 rename_atomic(gc_check) = gc_check.
 rename_atomic(mark_hp(L)) = mark_hp(rename_lval(L)).
@@ -2032,8 +2032,14 @@ atomic_statement_to_il(delete_object(_Target), Instrs, !Info) :-
     % Instrs = LoadInstrs ++ singleton(ldnull) ++ StoreInstrs.
     Instrs = empty.
 
-atomic_statement_to_il(new_object(Target0, _MaybeTag, HasSecTag, Type, Size,
-        MaybeCtorName, Args0, ArgTypes0, _MayUseAtomic), Instrs, !Info) :-
+atomic_statement_to_il(new_object(Target0, _MaybeTag, ExplicitSecTag, Type,
+        Size, MaybeCtorName, Args, ArgTypes, _MayUseAtomic), Instrs, !Info) :-
+    (
+        ExplicitSecTag = yes,
+        unexpected(this_file, "new_object has explicit secondary tag")
+    ;
+        ExplicitSecTag = no
+    ),
     DataRep = !.Info ^ il_data_rep,
     (
         (
@@ -2067,23 +2073,6 @@ atomic_statement_to_il(new_object(Target0, _MaybeTag, HasSecTag, Type, Size,
             MaybeCtorName = no,
             ClassName = ClassName0
         ),
-        % Skip the secondary tag, if any.
-        (
-            HasSecTag = yes,
-            (
-                ArgTypes0 = [_SecondaryTag | ArgTypes1],
-                Args0 = [_SecondaryTagVal | Args1]
-            ->
-                Args = Args1,
-                ArgTypes = ArgTypes1
-            ;
-                unexpected(this_file, "newobj without secondary tag")
-            )
-        ;
-            HasSecTag = no,
-            ArgTypes = ArgTypes0,
-            Args = Args0
-        ),
         ILArgTypes = list.map(mlds_type_to_ilds_type(DataRep), ArgTypes),
         list.map_foldl(load, Args, ArgsLoadInstrsTrees, !Info),
         ArgsLoadInstrs = cord_list_to_cord(ArgsLoadInstrsTrees),
@@ -2163,7 +2152,7 @@ atomic_statement_to_il(new_object(Target0, _MaybeTag, HasSecTag, Type, Size,
                 I = I0 ++ I1 ++ I2 ++ I3,
                 Arg = (Index + 1) - S
             ),
-        list.map_foldl(LoadInArray, Args0, ArgsLoadInstrsTrees,
+        list.map_foldl(LoadInArray, Args, ArgsLoadInstrsTrees,
             0 - !.Info, _ - !:Info),
         ArgsLoadInstrs = cord_list_to_cord(ArgsLoadInstrsTrees),
 
diff --git a/compiler/mlds_to_java.m b/compiler/mlds_to_java.m
index 9baee4a..885511c 100644
--- a/compiler/mlds_to_java.m
+++ b/compiler/mlds_to_java.m
@@ -1432,13 +1432,13 @@ rename_class_names_atomic(Renaming, !Statement) :-
         rename_class_names_rval(Renaming, Rval0, Rval),
         !:Statement = delete_object(Rval)
     ;
-        !.Statement = new_object(TargetLval0, MaybeTag, HasSecTag, Type0,
+        !.Statement = new_object(TargetLval0, MaybeTag, ExplicitSecTag, Type0,
             MaybeSize, MaybeCtorName, Args0, ArgTypes0, MayUseAtomic),
         rename_class_names_lval(Renaming, TargetLval0, TargetLval),
         rename_class_names_type(Renaming, Type0, Type),
         list.map(rename_class_names_rval(Renaming), Args0, Args),
         list.map(rename_class_names_type(Renaming), ArgTypes0, ArgTypes),
-        !:Statement = new_object(TargetLval, MaybeTag, HasSecTag, Type,
+        !:Statement = new_object(TargetLval, MaybeTag, ExplicitSecTag, Type,
             MaybeSize, MaybeCtorName, Args, ArgTypes, MayUseAtomic)
     ;
         ( !.Statement = comment(_)
@@ -3727,13 +3727,13 @@ output_atomic_stmt(_Indent, _, _FuncInfo, delete_object(_Lval), _, _, _) :-
     unexpected(this_file, "delete_object not supported in Java.").
 
 output_atomic_stmt(Indent, ModuleInfo, FuncInfo, NewObject, Context, !IO) :-
-    NewObject = new_object(Target, _MaybeTag, HasSecTag, Type,
+    NewObject = new_object(Target, _MaybeTag, ExplicitSecTag, Type,
         _MaybeSize, MaybeCtorName, Args, ArgTypes, _MayUseAtomic),
     (
-        HasSecTag = yes,
-        unexpected(this_file, "output_atomic_stmt: has secondary tag")
+        ExplicitSecTag = yes,
+        unexpected(this_file, "output_atomic_stmt: explicit secondary tag")
     ;
-        HasSecTag = no
+        ExplicitSecTag = no
     ),
 
     ModuleName = FuncInfo ^ func_info_name ^ mod_name,
diff --git a/compiler/structure_reuse.direct.choose_reuse.m b/compiler/structure_reuse.direct.choose_reuse.m
index 2c042cc..73602e1 100644
--- a/compiler/structure_reuse.direct.choose_reuse.m
+++ b/compiler/structure_reuse.direct.choose_reuse.m
@@ -1045,7 +1045,7 @@ needs_update_and(does_not_need_update, does_not_need_update) =
 
 %-----------------------------------------------------------------------------%
 
-    % has_secondary_tag(Var, ConsId, HasSecTag) returns `yes' iff the
+    % has_secondary_tag(Var, ConsId, ExplicitSecTag) returns `yes' iff the
     % variable, Var, with cons_id, ConsId, requires a remote
     % secondary tag to distinguish between its various functors.
     %
@@ -1066,7 +1066,7 @@ has_secondary_tag(ModuleInfo, VarTypes, Var, ConsId, SecondaryTag) :-
         SecondaryTag = no
     ).
 
-    % already_correct_fields(HasSecTagC, VarsC, HasSecTagR, VarsR)
+    % already_correct_fields(ExplicitSecTagC, VarsC, ExplicitSecTagR, VarsR)
     % takes a list of variables, VarsC, which are the arguments for the cell to
     % be constructed and the list of variables, VarsR, which are the arguments
     % for the cell to be reused and returns a list of 'needs_update' values.
@@ -1078,12 +1078,14 @@ has_secondary_tag(ModuleInfo, VarTypes, Var, ConsId, SecondaryTag) :-
 :- func already_correct_fields(bool, prog_vars, bool, prog_vars) =
     list(needs_update).
 
-already_correct_fields(HasSecTagC, CurrentCellVars, HasSecTagR, ReuseCellVars)
-        = NeedsNoUpdate ++ list.duplicate(LengthC - LengthB, needs_update) :-
-    NeedsNoUpdate = already_correct_fields_2(HasSecTagC, CurrentCellVars,
-        HasSecTagR, ReuseCellVars),
+already_correct_fields(ExplicitSecTagC, CurrentCellVars, ExplicitSecTagR,
+        ReuseCellVars) = ReuseFields :-
+    NeedsNoUpdate = already_correct_fields_2(ExplicitSecTagC, CurrentCellVars,
+        ExplicitSecTagR, ReuseCellVars),
     LengthC = list.length(CurrentCellVars),
-    LengthB = list.length(NeedsNoUpdate).
+    LengthB = list.length(NeedsNoUpdate),
+    NeedsUpdate = list.duplicate(LengthC - LengthB, needs_update),
+    ReuseFields = NeedsNoUpdate ++ NeedsUpdate.
 
 :- func already_correct_fields_2(bool, prog_vars, bool, prog_vars)
     = list(needs_update).

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list