[m-rev.] for review: mutables and intermodule-optimization (again)

Ralph Becket rafe at cs.mu.OZ.AU
Wed Sep 28 10:59:48 AEST 2005


Julien Fischer, Wednesday, 21 September 2005:
> 
> For review by anyone.
> 
> This is an expanded version of the diff I posted the other day - it
> also resolves the problems with name mangling and mutables.

That looks excellent.

> INDEX: COMPILER/MAKE_HLDS_PASSES.M
> ===================================================================
> @@ -582,17 +582,104 @@
>      % DUPLICATING THE DEFINITION OF THE GLOBAL VARIABLE IN ANY SUBMODULES.
>      %
>      ( STATUS_DEFINED_IN_THIS_MODULE(IMPORTSTATUS, YES) ->
> +        MUTABLE_VAR_MAYBE_FOREIGN_NAMES(ATTRS) = MAYBEFOREIGNNAMES,
> +        (
> +            MAYBEFOREIGNNAMES = NO,
> +            TARGETMUTABLENAME = MUTABLE_C_VAR_NAME(MODULENAME, NAME)
> +        ;
> +            MAYBEFOREIGNNAMES = YES(FOREIGNNAMES),
> +            %
> +            % REPORT ANY ERRORS WITH THE FOREIGN_NAME ATTRIBUTES DURING
> +            % THIS PASS.
> +            %
> +            REPORTERRORS = YES,
> +            GET_GLOBAL_NAME_FROM_FOREIGN_NAMES(REPORTERRORS, CONTEXT,
> +                MODULENAME, NAME, FOREIGNNAMES, TARGETMUTABLENAME, !IO)
> +        ),
>          %
>          % XXX We don't currently support languages other than C.
>          %
> +        module_info_name(!.ModuleInfo, ModuleName),
>          ForeignDecl = pragma(compiler(mutable_decl),
> -            foreign_decl(c, foreign_decl_is_local,
> -                "MR_Word " ++ mutable_c_var_name(Name) ++ ";")),
> -        add_item_decl_pass_2(ForeignDecl, Context, !Status, !ModuleInfo, !IO)
> +            foreign_decl(c, foreign_decl_is_exported,
> +                "extern MR_Word " ++
> +                    TargetMutableName ++ ";")),

You could join these two lines into one.

> +        add_item_decl_pass_2(ForeignDecl, Context, !Status, !ModuleInfo, !IO),
> +        ForeignCode = pragma(compiler(mutable_decl),
> +            foreign_code(c, "MR_Word " ++
> +                TargetMutableName ++ ";")),

And here.

> @@ -906,28 +991,56 @@
>                  [InitTerm], (impure)) - Context),
>          add_item_clause(InitClause, !Status, Context, !ModuleInfo, !QualInfo,
>              !IO),
> +        mutable_var_maybe_foreign_names(MutAttrs) = MaybeForeignNames,
> +        (
> +            MaybeForeignNames = no,
> +            TargetMutableName = mutable_c_var_name(ModuleName, Name)
> +        ;
> +            MaybeForeignNames = yes(ForeignNames),
> +            ReportErrors = no,    % We've already reported them during pass 2.

Why make the mutable_foreign_names field a maybe(list) rather than just
a list with [] meaning "use the default"?


> -            TrailCode =
> -                "MR_trail_current_value(&" ++
> -                mutable_c_var_name(Name) ++
> -                ");\n"
> +            TrailMutableUpdates = trailed,
> +            %
> +            % If we require that the mutable to be trailed then
> +            % we ened to be compiling in a trailing grade.

s/ened/need/

-- Ralph
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list