[m-dev.] Re: diff: MLDS back-end: fix an XXX in ml_code_gen.m
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu May 25 10:58:37 AEST 2000
On 24-May-2000, Fergus Henderson <fjh at cs.mu.oz.au> wrote:
> compiler/ml_code_gen.m:
> Fix an XXX: don't output calls to the
> MR_OBTAIN_GLOBAL_LOCK() and MR_RELEASE_GLOBAL_LOCK()
> macros unless the module was compiled with `--parallel'.
I failed to notice that that code was duplicated in another spot.
Hence the following additional change.
----------
Estimated hours taken: 0.25
compiler/ml_code_gen.m:
Fix an XXX: don't output calls to the
MR_OBTAIN_GLOBAL_LOCK() and MR_RELEASE_GLOBAL_LOCK()
macros unless the module was compiled with `--parallel'.
Also avoid some code duplication.
Workspace: /home/pgrad/fjh/ws/hg
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.46
diff -u -d -r1.46 ml_code_gen.m
--- compiler/ml_code_gen.m 2000/05/24 08:26:39 1.46
+++ compiler/ml_code_gen.m 2000/05/25 00:53:21
@@ -1650,26 +1650,10 @@
%
% Generate code fragments to obtain and release the global lock
- % (this is used for ensuring thread safety in a concurrent
- % implementation)
- % XXX we should only generate these if the `parallel' option
- % was enabled
%
- =(MLDSGenInfo),
{ thread_safe(Attributes, ThreadSafe) },
- { ThreadSafe = thread_safe ->
- ObtainLock = "",
- ReleaseLock = ""
- ;
- ml_gen_info_get_module_info(MLDSGenInfo, ModuleInfo),
- module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_name(PredInfo, Name),
- llds_out__quote_c_string(Name, MangledName),
- string__append_list(["\tMR_OBTAIN_GLOBAL_LOCK(""",
- MangledName, """);\n"], ObtainLock),
- string__append_list(["\tMR_RELEASE_GLOBAL_LOCK(""",
- MangledName, """);\n"], ReleaseLock)
- },
+ ml_gen_obtain_release_global_lock(ThreadSafe, PredId,
+ ObtainLock, ReleaseLock),
%
% Put it all together
@@ -1805,29 +1789,10 @@
%
% Generate code fragments to obtain and release the global lock
- % (this is used for ensuring thread safety in a concurrent
- % implementation)
%
- =(MLDSGenInfo),
- { ml_gen_info_get_module_info(MLDSGenInfo, ModuleInfo) },
- { module_info_globals(ModuleInfo, Globals) },
- { globals__lookup_bool_option(Globals, parallel, Parallel) },
{ thread_safe(Attributes, ThreadSafe) },
- {
- Parallel = no,
- ThreadSafe = not_thread_safe
- ->
- module_info_pred_info(ModuleInfo, PredId, PredInfo),
- pred_info_name(PredInfo, Name),
- llds_out__quote_c_string(Name, MangledName),
- string__append_list(["\tMR_OBTAIN_GLOBAL_LOCK(""",
- MangledName, """);\n"], ObtainLock),
- string__append_list(["\tMR_RELEASE_GLOBAL_LOCK(""",
- MangledName, """);\n"], ReleaseLock)
- ;
- ObtainLock = "",
- ReleaseLock = ""
- },
+ ml_gen_obtain_release_global_lock(ThreadSafe, PredId,
+ ObtainLock, ReleaseLock),
%
% Put it all together
@@ -1882,6 +1847,36 @@
mlds__make_context(Context)) },
{ MLDS_Statements = [C_Code_Statement] },
{ MLDS_Decls = [] }.
+
+ % Generate code fragments to obtain and release the global lock
+ % (this is used for ensuring thread safety in a concurrent
+ % implementation)
+ %
+:- pred ml_gen_obtain_release_global_lock(thread_safe, pred_id,
+ string, string, ml_gen_info, ml_gen_info).
+:- mode ml_gen_obtain_release_global_lock(in, in, out, out, in, out) is det.
+
+ml_gen_obtain_release_global_lock(ThreadSafe, PredId,
+ ObtainLock, ReleaseLock) -->
+ =(MLDSGenInfo),
+ { ml_gen_info_get_module_info(MLDSGenInfo, ModuleInfo) },
+ { module_info_globals(ModuleInfo, Globals) },
+ { globals__lookup_bool_option(Globals, parallel, Parallel) },
+ {
+ Parallel = no,
+ ThreadSafe = not_thread_safe
+ ->
+ module_info_pred_info(ModuleInfo, PredId, PredInfo),
+ pred_info_name(PredInfo, Name),
+ llds_out__quote_c_string(Name, MangledName),
+ string__append_list(["\tMR_OBTAIN_GLOBAL_LOCK(""",
+ MangledName, """);\n"], ObtainLock),
+ string__append_list(["\tMR_RELEASE_GLOBAL_LOCK(""",
+ MangledName, """);\n"], ReleaseLock)
+ ;
+ ObtainLock = "",
+ ReleaseLock = ""
+ }.
%---------------------------------------------------------------------------%
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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