[m-dev.] for review: bootstrap hlc.gc.memprof grade
Peter Ross
peter.ross at miscrit.be
Thu Aug 3 00:04:06 AEST 2000
Here is the complete diff for reference.
===================================================================
Estimated hours taken: 24
Bootstrap in the grade hlc.gc.memprof.
To analyse the generated Prof.* files you need to supply the option
--no-demangle to the profiler.
compiler/ml_code_gen.m:
Define MR_PROC_LABEL in pragma c_code.
compiler/mlds.m:
Add a new alternative to the type target_code_component which
records a mlds_entity_name. This information is needed when
outputing the MR_PROC_LABEL #define.
compiler/ml_elim_nested.m:
Changes due to the change to the type target_code_component.
compiler/mlds_to_c.m:
Define a new predicate mlds_maybe_output_init_fn which outputs an
initialisation function, if necessary. This body of the
initialisation function consists of calls to init_entry for each
function in the src module.
If profiling is turned on at each function call: call
MR_prof_call_profile(callee, caller) to record the arc in the call
graph.
If profiling is turned on each heap allocation call
MR_maybe_record_allocation().
Changes due to the change to the type target_code_component.
library/array.m:
library/builtin.m:
library/exception.m:
library/private_builtin.m:
library/std_util.m:
As c2init doesn't understand preprocessor directives we need to
define some empty initialisation functions.
trace/mercury_trace_vars.c:
Avoid a linking problem with MR_trace_ignored_type_ctors.
Add a dummy member to MR_trace_ignored_type_ctors so that the array
is never empty.
runtime/mercury.c:
Call MR_init_entry for each hand defined procedure.
runtime/mercury.h:
If profiling is turned on include the relevant header files.
runtime/mercury_goto.h:
Define MR_init_entry.
runtime/mercury_prof.c:
runtime/mercury_prof.h:
Make decl_fptr an extern global pointer so that mercury_wrapper.c
can call fclose on it.
runtime/mercury_wrapper.c:
Call fclose on decl_fptr.
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.55
diff -u -r1.55 ml_code_gen.m
--- compiler/ml_code_gen.m 2000/07/20 11:24:07 1.55
+++ compiler/ml_code_gen.m 2000/08/02 13:51:15
@@ -1581,6 +1581,7 @@
% For model_non pragma c_code,
% we generate code of the following form:
%
+ % #define MR_PROC_LABEL <procedure name>
% <declaration of locals needed for boxing/unboxing>
% {
% <declaration of one local variable for each arg>
@@ -1617,9 +1618,19 @@
% #undef SUCCEED_LAST
% #undef LOCALS
% }
+ % #undef MR_PROC_LABEL
+ %
+ % We insert a #define for MR_PROC_LABEL, so that the C code in
+ % the Mercury standard library that allocates memory manually
+ % can use MR_PROC_LABEL as the procname argument to
+ % incr_hp_msg(), for memory profiling. Hard-coding the procname
+ % argument in the C code would be wrong, since it wouldn't
+ % handle the case where the original pragma c_code procedure
+ % gets inlined and optimized away. Of course we also need to
+ % #undef it afterwards.
%
ml_gen_nondet_pragma_c_code(CodeModel, Attributes,
- PredId, _ProcId, ArgVars, ArgDatas, OrigArgTypes, Context,
+ PredId, ProcId, ArgVars, ArgDatas, OrigArgTypes, Context,
LocalVarsDecls, LocalVarsContext, FirstCode, FirstContext,
LaterCode, LaterContext, SharedCode, SharedContext,
MLDS_Decls, MLDS_Statements) -->
@@ -1670,10 +1681,16 @@
ObtainLock, ReleaseLock),
%
+ % Generate the MR_PROC_LABEL #define
+ %
+ ml_gen_hash_define_mr_proc_label(PredId, ProcId, HashDefine),
+
+ %
% Put it all together
%
{ Starting_C_Code = list__condense([
[raw_target_code("{\n")],
+ HashDefine,
ArgDeclsList,
[raw_target_code("\tstruct {\n"),
user_target_code(LocalVarsDecls, LocalVarsContext),
@@ -1693,6 +1710,7 @@
raw_target_code("\t\t{\n"),
user_target_code(SharedCode, SharedContext),
raw_target_code("\n\t\t;}\n"),
+ raw_target_code("#undef MR_PROC_LABEL\n"),
raw_target_code(ReleaseLock),
raw_target_code("\t\tif (MR_succeeded) {\n")],
AssignOutputsList
@@ -1741,6 +1759,7 @@
%
% model_det pragma_c_code:
%
+ % #define MR_PROC_LABEL <procedure name>
% <declaration of locals needed for boxing/unboxing>
% {
% <declaration of one local variable for each arg>
@@ -1752,9 +1771,11 @@
% <release global lock>
% <assign output args>
% }
+ % #undef MR_PROC_LABEL
%
% model_semi pragma_c_code:
%
+ % #define MR_PROC_LABEL <procedure name>
% <declaration of locals needed for boxing/unboxing>
% {
% <declaration of one local variable for each arg>
@@ -1771,6 +1792,16 @@
%
% <succeeded> = SUCCESS_INDICATOR;
% }
+ % #undef MR_PROC_LABEL
+ %
+ % We insert a #define for MR_PROC_LABEL, so that the C code in
+ % the Mercury standard library that allocates memory manually
+ % can use MR_PROC_LABEL as the procname argument to
+ % incr_hp_msg(), for memory profiling. Hard-coding the procname
+ % argument in the C code would be wrong, since it wouldn't
+ % handle the case where the original pragma c_code procedure
+ % gets inlined and optimized away. Of course we also need to
+ % #undef it afterwards.
%
% Note that we generate this code directly as
% `target_code(lang_C, <string>)' instructions in the MLDS.
@@ -1782,7 +1813,7 @@
% Java.
%
ml_gen_ordinary_pragma_c_code(CodeModel, Attributes,
- PredId, _ProcId, ArgVars, ArgDatas, OrigArgTypes,
+ PredId, ProcId, ArgVars, ArgDatas, OrigArgTypes,
C_Code, Context, MLDS_Decls, MLDS_Statements) -->
%
% Combine all the information about the each arg
@@ -1814,11 +1845,17 @@
ObtainLock, ReleaseLock),
%
+ % Generate the MR_PROC_LABEL #define
+ %
+ ml_gen_hash_define_mr_proc_label(PredId, ProcId, HashDefine),
+
+ %
% Put it all together
%
( { CodeModel = model_det } ->
{ Starting_C_Code = list__condense([
[raw_target_code("{\n")],
+ HashDefine,
ArgDeclsList,
[raw_target_code("\n")],
AssignInputsList,
@@ -1826,6 +1863,7 @@
raw_target_code("\t\t{\n"),
user_target_code(C_Code, yes(Context)),
raw_target_code("\n\t\t;}\n"),
+ raw_target_code("#undef MR_PROC_LABEL\n"),
raw_target_code(ReleaseLock)],
AssignOutputsList
]) },
@@ -1834,6 +1872,7 @@
ml_success_lval(SucceededLval),
{ Starting_C_Code = list__condense([
[raw_target_code("{\n")],
+ HashDefine,
ArgDeclsList,
[raw_target_code("\tbool SUCCESS_INDICATOR;\n"),
raw_target_code("\n")],
@@ -1842,6 +1881,7 @@
raw_target_code("\t\t{\n"),
user_target_code(C_Code, yes(Context)),
raw_target_code("\n\t\t;}\n"),
+ raw_target_code("#undef MR_PROC_LABEL\n"),
raw_target_code(ReleaseLock),
raw_target_code("\tif (SUCCESS_INDICATOR) {\n")],
AssignOutputsList
@@ -1897,6 +1937,18 @@
ObtainLock = "",
ReleaseLock = ""
}.
+
+:- pred ml_gen_hash_define_mr_proc_label(pred_id::in, proc_id::in,
+ list(target_code_component)::out,
+ ml_gen_info::in, ml_gen_info::out) is det.
+
+ml_gen_hash_define_mr_proc_label(PredId, ProcId, HashDefine) -->
+ =(MLDSGenInfo),
+ { ml_gen_info_get_module_info(MLDSGenInfo, ModuleInfo) },
+ { HashDefine = [raw_target_code("#define MR_PROC_LABEL "),
+ name(ml_gen_proc_label(ModuleInfo, PredId, ProcId)),
+ raw_target_code("\n")] }.
+
%---------------------------------------------------------------------------%
Index: compiler/ml_elim_nested.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_elim_nested.m,v
retrieving revision 1.10
diff -u -r1.10 ml_elim_nested.m
--- compiler/ml_elim_nested.m 2000/07/20 10:39:30 1.10
+++ compiler/ml_elim_nested.m 2000/08/02 13:51:16
@@ -779,6 +779,7 @@
fixup_target_code_component(target_code_output(Lval0),
target_code_output(Lval)) -->
fixup_lval(Lval0, Lval).
+fixup_target_code_component(name(Name), name(Name)) --> [].
:- pred fixup_trail_op(trail_op, trail_op, elim_info, elim_info).
:- mode fixup_trail_op(in, out, in, out) is det.
Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.28
diff -u -r1.28 mlds.m
--- compiler/mlds.m 2000/07/20 10:39:30 1.28
+++ compiler/mlds.m 2000/08/02 13:51:18
@@ -925,6 +925,7 @@
% end in `\n' (or `\n' followed by whitespace).
; target_code_input(mlds__rval)
; target_code_output(mlds__lval)
+ ; name(mlds__entity_name)
.
% XXX I'm not sure what representation we should use here
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.46
diff -u -r1.46 mlds_to_c.m
--- compiler/mlds_to_c.m 2000/08/01 09:04:18 1.46
+++ compiler/mlds_to_c.m 2000/08/02 13:51:20
@@ -146,6 +146,7 @@
{ MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName) },
mlds_output_defns(Indent, MLDS_ModuleName, PublicTypeDefns), io__nl,
mlds_output_decls(Indent, MLDS_ModuleName, PublicNonTypeDefns), io__nl,
+ mlds_maybe_output_init_fn_decl(MLDS_ModuleName), io__nl,
mlds_output_hdr_end(Indent, ModuleName).
:- pred defn_is_public(mlds__defn).
@@ -240,6 +241,7 @@
mlds_output_c_defns(MLDS_ModuleName, Indent, ForeignCode), io__nl,
mlds_output_defns(Indent, MLDS_ModuleName, NonTypeDefns), io__nl,
+ mlds_maybe_output_init_fn_defn(MLDS_ModuleName, NonTypeDefns), io__nl,
mlds_output_src_end(Indent, ModuleName).
:- pred mlds_output_hdr_start(indent, mercury_module_name,
@@ -280,7 +282,6 @@
io__write_string(". */\n"),
mlds_indent(Indent),
io__write_string("/* :- implementation. */\n"),
- io__nl,
mlds_output_src_import(Indent,
mercury_module_name_to_mlds(ModuleName)),
io__nl.
@@ -311,6 +312,98 @@
io__write_string(". */\n").
%-----------------------------------------------------------------------------%
+
+ %
+ % Maybe output the function `mercury__<modulename>__init()'.
+ % The body of the function consists of calls
+ % MR_init_entry(<function>) for each function defined in the
+ % module.
+ %
+:- pred mlds_maybe_output_init_fn_decl(mlds_module_name::in,
+ io__state::di, io__state::uo) is det.
+
+mlds_maybe_output_init_fn_decl(ModuleName) -->
+ io_get_globals(Globals),
+ (
+ { output_init_fn(Globals) }
+ ->
+ output_init_fn_name(ModuleName),
+ io__write_string(";\n")
+ ;
+ []
+ ).
+
+:- pred mlds_maybe_output_init_fn_defn(mlds_module_name::in, mlds__defns::in,
+ io__state::di, io__state::uo) is det.
+
+mlds_maybe_output_init_fn_defn(ModuleName, Defns) -->
+ io_get_globals(Globals),
+ (
+ { output_init_fn(Globals) }
+ ->
+ output_init_fn_name(ModuleName),
+ io__write_string("\n{\n"),
+ io__write_strings(["\tstatic int initialised = 0;\n",
+ "\tif (initialised) return;\n",
+ "\tinitialised = 1;\n\n"]),
+ mlds_output_init_fn_2(ModuleName, Defns),
+ io__write_string("\n}\n")
+ ;
+ []
+ ).
+
+ %
+ % Do we need an init function?
+ %
+:- pred output_init_fn(globals::in) is semidet.
+
+output_init_fn(Globals) :-
+ ( Option = profile_calls
+ ; Option = profile_time
+ ; Option = profile_memory
+ ),
+ globals__lookup_bool_option(Globals, Option, yes).
+
+:- pred output_init_fn_name(mlds_module_name::in,
+ io__state::di, io__state::uo) is det.
+
+output_init_fn_name(ModuleName) -->
+ % Here we ensure that we only get one "mercury__" at the
+ % start of the function name.
+ { prog_out__sym_name_to_string(
+ mlds_module_name_to_sym_name(ModuleName), "__",
+ ModuleNameString0) },
+ {
+ string__prefix(ModuleNameString0, "mercury__")
+ ->
+ ModuleNameString = ModuleNameString0
+ ;
+ string__append("mercury__", ModuleNameString0,
+ ModuleNameString)
+ },
+ io__write_string("void "),
+ io__write_string(ModuleNameString),
+ io__write_string("__init(void)").
+
+:- pred mlds_output_init_fn_2(mlds_module_name::in, mlds__defns::in,
+ io__state::di, io__state::uo) is det.
+
+mlds_output_init_fn_2(_ModuleName, []) --> [].
+mlds_output_init_fn_2(ModuleName, [Defn | Defns]) -->
+ { Defn = mlds__defn(EntityName, _Context, _Flags, _EntityDefn) },
+ (
+ { EntityName = function(_, _, _, _) }
+ ->
+ { QualName = qual(ModuleName, EntityName) },
+ io__write_string("\tMR_init_entry("),
+ mlds_output_fully_qualified_name(QualName),
+ io__write_string(");\n")
+ ;
+ []
+ ),
+ mlds_output_init_fn_2(ModuleName, Defns).
+
+%-----------------------------------------------------------------------------%
%
% C interface stuff
%
@@ -1851,13 +1944,15 @@
% is e.g. inside an if-then-else.
%
mlds_indent(Indent),
- ( { IsTailCall = tail_call } ->
- ( { Results \= [] } ->
- io__write_string("return ")
- ;
- io__write_string("{\n"),
- mlds_indent(Context, Indent + 1)
- )
+ io__write_string("{\n"),
+
+ mlds_maybe_output_call_profile_instr(Context,
+ Indent + 1, FuncRval, Name),
+
+ mlds_indent(Context, Indent + 1),
+
+ ( { IsTailCall = tail_call, Results \= [] } ->
+ io__write_string("return ")
;
[]
),
@@ -1882,12 +1977,12 @@
( { IsTailCall = tail_call, Results = [] } ->
mlds_indent(Context, Indent + 1),
- io__write_string("return;\n"),
- mlds_indent(Context, Indent),
- io__write_string("}\n")
+ io__write_string("return;\n")
;
[]
- )
+ ),
+ mlds_indent(Indent),
+ io__write_string("}\n")
).
mlds_output_stmt(Indent, _FuncInfo, return(Results), _) -->
@@ -1995,6 +2090,82 @@
mlds_output_statement(Indent + 1, FuncInfo, Handler)
).
+ %
+ % If memory profiling is turned on output an instruction to
+ % record the heap allocation.
+ %
+:- pred mlds_maybe_output_heap_profile_instr(mlds__context::in,
+ indent::in, list(mlds__rval)::in,
+ mlds__qualified_entity_name::in, maybe(ctor_name)::in,
+ io__state::di, io__state::uo) is det.
+
+mlds_maybe_output_heap_profile_instr(Context, Indent, Args, FuncName,
+ MaybeCtorName) -->
+ globals__io_lookup_bool_option(profile_memory, ProfileMem),
+ (
+ { ProfileMem = yes }
+ ->
+ mlds_indent(Context, Indent),
+ io__write_string("MR_record_allocation("),
+ io__write_int(list__length(Args)),
+ io__write_string(", "),
+ mlds_output_fully_qualified_name(FuncName),
+ io__write_string(", """),
+ mlds_output_fully_qualified_name(FuncName),
+ io__write_string(""", "),
+ ( { MaybeCtorName = yes(CtorName) } ->
+ io__write_char('"'),
+ c_util__output_quoted_string(CtorName),
+ io__write_char('"')
+ ;
+ io__write_string("NULL")
+ ),
+ io__write_string(");\n")
+ ;
+ []
+ ).
+
+ %
+ % If call profiling is turned on output an instruction to record
+ % an arc in the call profile between the callee and caller.
+ %
+:- pred mlds_maybe_output_call_profile_instr(mlds__context::in,
+ indent::in, mlds__rval::in, mlds__qualified_entity_name::in,
+ io__state::di, io__state::uo) is det.
+
+mlds_maybe_output_call_profile_instr(Context, Indent,
+ CalleeFuncRval, CallerName) -->
+ globals__io_lookup_bool_option(profile_calls, ProfileCalls),
+ (
+ {
+ ProfileCalls = yes,
+
+ % Some functions don't have a
+ % code_addr so we can't record the arc.
+ \+ no_code_address(CalleeFuncRval)
+ }
+ ->
+ mlds_indent(Context, Indent),
+ io__write_string("MR_prof_call_profile("),
+ mlds_output_bracketed_rval(CalleeFuncRval),
+ io__write_string(", "),
+ mlds_output_fully_qualified_name(CallerName),
+ io__write_string(");\n")
+ ;
+ []
+ ).
+
+ %
+ % Does the rval represent a special procedure for which a
+ % code address doesn't exist.
+ %
+:- pred no_code_address(mlds__rval::in) is semidet.
+
+no_code_address(const(code_addr_const(proc(qual(Module, PredLabel - _), _)))) :-
+ SymName = mlds_module_name_to_sym_name(Module),
+ SymName = qualified(unqualified("mercury"), "private_builtin"),
+ PredLabel = pred(predicate, _, "unsafe_type_cast", 2).
+
% return `true' if the statement is a tail call which
% can be optimized into a jump back to the start of the
% function
@@ -2108,8 +2279,8 @@
%
% atomic statements
%
-mlds_output_stmt(Indent, _FuncInfo, atomic(AtomicStatement), Context) -->
- mlds_output_atomic_stmt(Indent, AtomicStatement, Context).
+mlds_output_stmt(Indent, FuncInfo, atomic(AtomicStatement), Context) -->
+ mlds_output_atomic_stmt(Indent, FuncInfo, AtomicStatement, Context).
:- pred mlds_output_label_name(mlds__label, io__state, io__state).
:- mode mlds_output_label_name(in, di, uo) is det.
@@ -2117,14 +2288,14 @@
mlds_output_label_name(LabelName) -->
mlds_output_mangled_name(LabelName).
-:- pred mlds_output_atomic_stmt(indent, mlds__atomic_statement, mlds__context,
- io__state, io__state).
-:- mode mlds_output_atomic_stmt(in, in, in, di, uo) is det.
+:- pred mlds_output_atomic_stmt(indent, func_info,
+ mlds__atomic_statement, mlds__context, io__state, io__state).
+:- mode mlds_output_atomic_stmt(in, in, in, in, di, uo) is det.
%
% comments
%
-mlds_output_atomic_stmt(Indent, comment(Comment), _) -->
+mlds_output_atomic_stmt(Indent, _FuncInfo, comment(Comment), _) -->
% XXX we should escape any "*/"'s in the Comment.
% we should also split the comment into lines and indent
% each line appropriately.
@@ -2136,7 +2307,7 @@
%
% assignment
%
-mlds_output_atomic_stmt(Indent, assign(Lval, Rval), _) -->
+mlds_output_atomic_stmt(Indent, _FuncInfo, assign(Lval, Rval), _) -->
mlds_indent(Indent),
mlds_output_lval(Lval),
io__write_string(" = "),
@@ -2146,11 +2317,16 @@
%
% heap management
%
-mlds_output_atomic_stmt(Indent, NewObject, Context) -->
+mlds_output_atomic_stmt(Indent, FuncInfo, NewObject, Context) -->
{ NewObject = new_object(Target, MaybeTag, Type, MaybeSize,
MaybeCtorName, Args, ArgTypes) },
mlds_indent(Indent),
io__write_string("{\n"),
+
+ { FuncInfo = func_info(FuncName, _) },
+ mlds_maybe_output_heap_profile_instr(Context, Indent + 1, Args,
+ FuncName, MaybeCtorName),
+
mlds_indent(Context, Indent + 1),
mlds_output_lval(Target),
io__write_string(" = "),
@@ -2201,13 +2377,13 @@
mlds_indent(Context, Indent),
io__write_string("}\n").
-mlds_output_atomic_stmt(Indent, mark_hp(Lval), _) -->
+mlds_output_atomic_stmt(Indent, _FuncInfo, mark_hp(Lval), _) -->
mlds_indent(Indent),
io__write_string("MR_mark_hp("),
mlds_output_lval(Lval),
io__write_string(");\n").
-mlds_output_atomic_stmt(Indent, restore_hp(Rval), _) -->
+mlds_output_atomic_stmt(Indent, _FuncInfo, restore_hp(Rval), _) -->
mlds_indent(Indent),
io__write_string("MR_mark_hp("),
mlds_output_rval(Rval),
@@ -2216,26 +2392,28 @@
%
% trail management
%
-mlds_output_atomic_stmt(_Indent, trail_op(_TrailOp), _) -->
+mlds_output_atomic_stmt(_Indent, _FuncInfo, trail_op(_TrailOp), _) -->
{ error("mlds_to_c.m: sorry, trail_ops not implemented") }.
%
% foreign language interfacing
%
-mlds_output_atomic_stmt(_Indent, target_code(TargetLang, Components),
+mlds_output_atomic_stmt(_Indent, FuncInfo, target_code(TargetLang, Components),
Context) -->
( { TargetLang = lang_C } ->
- list__foldl(mlds_output_target_code_component(Context),
+ { FuncInfo = func_info(qual(ModuleName, _), _FuncParams) },
+ list__foldl(
+ mlds_output_target_code_component(ModuleName, Context),
Components)
;
{ error("mlds_to_c.m: sorry, target_code only works for lang_C") }
).
-:- pred mlds_output_target_code_component(mlds__context, target_code_component,
- io__state, io__state).
-:- mode mlds_output_target_code_component(in, in, di, uo) is det.
+:- pred mlds_output_target_code_component(mlds_module_name, mlds__context,
+ target_code_component, io__state, io__state).
+:- mode mlds_output_target_code_component(in, in, in, di, uo) is det.
-mlds_output_target_code_component(Context,
+mlds_output_target_code_component(_ModuleName, Context,
user_target_code(CodeString, MaybeUserContext)) -->
( { MaybeUserContext = yes(UserContext) } ->
mlds_output_context(mlds__make_context(UserContext))
@@ -2244,17 +2422,23 @@
),
io__write_string(CodeString),
io__write_string("\n").
-mlds_output_target_code_component(Context, raw_target_code(CodeString)) -->
+mlds_output_target_code_component(_ModuleName, Context,
+ raw_target_code(CodeString)) -->
mlds_output_context(Context),
io__write_string(CodeString).
-mlds_output_target_code_component(Context, target_code_input(Rval)) -->
+mlds_output_target_code_component(_ModuleName, Context,
+ target_code_input(Rval)) -->
mlds_output_context(Context),
mlds_output_rval(Rval),
io__write_string("\n").
-mlds_output_target_code_component(Context, target_code_output(Lval)) -->
+mlds_output_target_code_component(_ModuleName, Context,
+ target_code_output(Lval)) -->
mlds_output_context(Context),
mlds_output_lval(Lval),
io__write_string("\n").
+mlds_output_target_code_component(ModuleName, _Context, name(Name)) -->
+ mlds_output_fully_qualified_name(qual(ModuleName, Name)).
+
:- pred mlds_output_init_args(list(mlds__rval), list(mlds__type), mlds__context,
int, mlds__lval, mlds__tag, indent, io__state, io__state).
Index: library/array.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.71
diff -u -r1.71 array.m
--- library/array.m 2000/05/08 13:48:33 1.71
+++ library/array.m 2000/08/02 13:51:39
@@ -271,7 +271,12 @@
:- pragma c_code("
-#ifndef MR_HIGHLEVEL_CODE
+#ifdef MR_HIGHLEVEL_CODE
+void sys_init_array_module_builtins(void);
+void sys_init_array_module_builtins(void) {
+ return;
+}
+#else
MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(array, array, 1, MR_TYPECTOR_REP_ARRAY);
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.37
diff -u -r1.37 builtin.m
--- library/builtin.m 2000/07/12 13:54:40 1.37
+++ library/builtin.m 2000/08/02 13:51:39
@@ -234,7 +234,10 @@
:- pragma c_code("
-#ifndef MR_HIGHLEVEL_CODE
+#ifdef MR_HIGHLEVEL_CODE
+void sys_init_builtin_types_module(void); /* suppress gcc warning */
+void sys_init_builtin_types_module(void) { return; }
+#else
MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM(builtin, int, 0,
MR_TYPECTOR_REP_INT,
@@ -388,6 +391,13 @@
mercury__builtin__copy_2_p_0(type_info, x, y);
}
+void sys_init_copy_module(void);
+void sys_init_copy_module(void)
+{
+ MR_init_entry(mercury__builtin__copy_2_p_0);
+ MR_init_entry(mercury__builtin__copy_2_p_1);
+}
+
#else /* ! MR_HIGHLEVEL_CODE */
Define_extern_entry(mercury__copy_2_0);
@@ -443,7 +453,10 @@
:- pragma c_code("
-#ifndef MR_HIGHLEVEL_CODE
+#ifdef MR_HIGHLEVEL_CODE
+void sys_init_unify_c_pointer_module(void);
+void sys_init_unify_c_pointer_module(void) { return; }
+#else
MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_PRED(builtin, c_pointer, 0,
MR_TYPECTOR_REP_C_POINTER,
Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.27
diff -u -r1.27 exception.m
--- library/exception.m 2000/08/01 05:33:33 1.27
+++ library/exception.m 2000/08/02 13:51:40
@@ -893,7 +893,10 @@
").
:- pragma c_code("
-#ifndef MR_HIGHLEVEL_CODE
+#ifdef MR_HIGHLEVEL_CODE
+void mercury_sys_init_exceptions(void);
+void mercury_sys_init_exceptions(void) { return; }
+#else
/*
** MR_trace_throw():
Index: library/private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.52
diff -u -r1.52 private_builtin.m
--- library/private_builtin.m 2000/05/08 16:10:59 1.52
+++ library/private_builtin.m 2000/08/02 13:51:44
@@ -279,7 +279,10 @@
:- pragma c_code("
-#ifndef MR_HIGHLEVEL_CODE
+#ifdef MR_HIGHLEVEL_CODE
+void sys_init_type_info_module(void); /* suppress gcc -Wmissing-decl warning */
+void sys_init_type_info_module(void) { return; }
+#else
/*
** For most purposes, type_ctor_info can be treated just like
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.194
diff -u -r1.194 std_util.m
--- library/std_util.m 2000/07/18 00:46:19 1.194
+++ library/std_util.m 2000/08/02 13:51:48
@@ -1040,7 +1040,10 @@
:- pragma c_code("
-#ifndef MR_HIGHLEVEL_CODE
+#ifdef MR_HIGHLEVEL_CODE
+void sys_init_unify_univ_module(void); /* suppress gcc -Wmissing-decl warning */
+void sys_init_unify_univ_module(void) { return; }
+#else
MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(std_util, type_desc, 0,
MR_TYPECTOR_REP_C_POINTER);
Index: runtime/mercury.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.c,v
retrieving revision 1.8
diff -u -r1.8 mercury.c
--- runtime/mercury.c 2000/07/20 10:39:35 1.8
+++ runtime/mercury.c 2000/08/02 13:51:49
@@ -842,4 +842,55 @@
/*---------------------------------------------------------------------------*/
+/*
+INIT mercury_sys_init_mercury_hlc
+ENDINIT
+*/
+void mercury_sys_init_mercury_hlc(void);
+void mercury_sys_init_mercury_hlc(void)
+{
+ MR_init_entry(mercury__builtin__unify_2_p_0);
+ MR_init_entry(mercury__builtin__compare_3_p_0);
+ MR_init_entry(mercury__builtin__compare_3_p_1);
+ MR_init_entry(mercury__builtin__compare_3_p_2);
+ MR_init_entry(mercury__builtin__compare_3_p_3);
+
+ MR_init_entry(mercury__builtin____Unify____int_0_0);
+ MR_init_entry(mercury__builtin____Unify____string_0_0);
+ MR_init_entry(mercury__builtin____Unify____float_0_0);
+ MR_init_entry(mercury__builtin____Unify____character_0_0);
+ MR_init_entry(mercury__builtin____Unify____void_0_0);
+ MR_init_entry(mercury__builtin____Unify____c_pointer_0_0);
+ MR_init_entry(mercury__builtin____Unify____func_0_0);
+ MR_init_entry(mercury__builtin____Unify____pred_0_0);
+ MR_init_entry(mercury__array____Unify____array_1_0);
+ MR_init_entry(mercury__std_util____Unify____univ_0_0);
+ MR_init_entry(mercury__std_util____Unify____type_desc_0_0);
+ MR_init_entry(mercury__private_builtin____Unify____type_ctor_info_1_0);
+ MR_init_entry(mercury__private_builtin____Unify____type_info_1_0);
+ MR_init_entry(mercury__private_builtin____Unify____typeclass_info_1_0);
+ MR_init_entry(mercury__private_builtin____Unify____base_typeclass_info_1_0);
+
+ MR_init_entry(mercury__builtin____Compare____int_0_0);
+ MR_init_entry(mercury__builtin____Compare____string_0_0);
+ MR_init_entry(mercury__builtin____Compare____float_0_0);
+ MR_init_entry(mercury__builtin____Compare____character_0_0);
+ MR_init_entry(mercury__builtin____Compare____void_0_0);
+ MR_init_entry(mercury__builtin____Compare____c_pointer_0_0);
+ MR_init_entry(mercury__builtin____Compare____func_0_0);
+ MR_init_entry(mercury__builtin____Compare____pred_0_0);
+ MR_init_entry(mercury__array____Compare____array_1_0);
+ MR_init_entry(mercury__std_util____Compare____univ_0_0);
+ MR_init_entry(mercury__std_util____Compare____type_desc_0_0);
+ MR_init_entry(mercury__private_builtin____Compare____type_ctor_info_1_0);
+ MR_init_entry(mercury__private_builtin____Compare____type_info_1_0);
+ MR_init_entry(mercury__private_builtin____Compare____typeclass_info_1_0);
+ MR_init_entry(mercury__private_builtin____Compare____base_typeclass_info_1_0);
+}
+
+/*---------------------------------------------------------------------------*/
+
+#else
+void mercury_sys_init_mercury_hlc(void);
+void mercury_sys_init_mercury_hlc(void) { return; }
#endif /* MR_HIGHLEVEL_CODE */
Index: runtime/mercury.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.h,v
retrieving revision 1.15
diff -u -r1.15 mercury.h
--- runtime/mercury.h 2000/08/01 09:04:21 1.15
+++ runtime/mercury.h 2000/08/02 13:51:49
@@ -35,6 +35,18 @@
#endif
#endif
+#ifdef PROFILE_CALLS
+ #include "mercury_prof.h" /* for MR_prof_call_profile */
+#endif
+
+#ifdef PROFILE_MEMORY
+ #include "mercury_heap_profile.h" /* for MR_record_allocation */
+#endif
+
+#if defined(PROFILE_CALLS) || defined(PROFILE_MEMORY)
+ #include "mercury_goto.h" /* for MR_init_entry */
+#endif
+
#include <setjmp.h> /* for jmp_buf etc., which are used for commits */
#include <string.h> /* for strcmp(), which is used for =/2 on strings */
@@ -222,7 +234,7 @@
** have a `sizeof' operator.
*/
#ifdef MR_AVOID_MACROS
- enum { mercury__private_builtin__SIZEOF_WORD = sizeof(MR_Word); }
+ enum { mercury__private_builtin__SIZEOF_WORD = sizeof(MR_Word) };
#else
#define mercury__private_builtin__SIZEOF_WORD sizeof(MR_Word)
#endif
Index: runtime/mercury_goto.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_goto.h,v
retrieving revision 1.21
diff -u -r1.21 mercury_goto.h
--- runtime/mercury_goto.h 1999/10/23 06:42:13 1.21
+++ runtime/mercury_goto.h 2000/08/02 13:51:50
@@ -25,6 +25,8 @@
#define MR_INTERNAL_LAYOUT(label) (const MR_Stack_Layout_Label *) (Word) \
&(paste(mercury_data__layout__,label))
+#define MR_init_entry(label) init_entry(label)
+
/*
** Passing the name of a label to MR_insert_{internal,entry}_label
** causes that name to be included in the executable as static readonly data.
Index: runtime/mercury_prof.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_prof.c,v
retrieving revision 1.8
diff -u -r1.8 mercury_prof.c
--- runtime/mercury_prof.c 2000/06/08 07:59:05 1.8
+++ runtime/mercury_prof.c 2000/08/02 13:51:50
@@ -101,7 +101,7 @@
#ifdef PROFILE_CALLS
- static FILE *decl_fptr = NULL;
+ FILE *decl_fptr = NULL;
static prof_call_node *addr_pair_table[CALL_TABLE_SIZE] = {NULL};
#endif
Index: runtime/mercury_prof.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_prof.h,v
retrieving revision 1.3
diff -u -r1.3 mercury_prof.h
--- runtime/mercury_prof.h 1997/12/05 15:56:44 1.3
+++ runtime/mercury_prof.h 2000/08/02 13:51:50
@@ -14,6 +14,8 @@
#include "mercury_types.h" /* for `Code *' */
+#include <stdio.h>
+
/*
** This variable holds the address of the "current" procedure so that
** when a profiling interrupt occurs, the profiler knows where we are,
@@ -21,6 +23,13 @@
*/
extern Code * volatile MR_prof_current_proc;
+
+/*
+** A pointer to the "Prof.Decl" file.
+*/
+#ifdef PROFILE_CALLS
+ extern FILE *decl_fptr;
+#endif
/*
** The following two macros are used to ensure that the profiler can
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.63
diff -u -r1.63 mercury_wrapper.c
--- runtime/mercury_wrapper.c 2000/06/29 09:55:37 1.63
+++ runtime/mercury_wrapper.c 2000/08/02 13:51:54
@@ -423,6 +423,10 @@
(*address_of_init_modules)();
done = TRUE;
}
+
+#ifdef PROFILE_CALLS
+ fclose(decl_fptr);
+#endif
}
/*
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list