[m-rev.] diff: fix hlc.agc library build failure
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed May 15 18:16:51 AEST 2002
Estimated hours taken: 1
Branches: main
Fix a problem where the library wasn't building in grade `hlc.agc'
anymore after petdr's change to make io_stream a foreign_type.
compiler/ml_code_util.m:
Don't abort for foreign_types if accurate GC is enabled; instead,
just don't generate any GC code for them. In other words, assume
that foreign_types are not allowed to point to the Mercury heap.
doc/reference_manual.texi:
Document that C foreign_types must not point to the Mercury heap.
But leave this documentation commented out for now, since
`--gc accurate' is not yet fully implemented or officially supported.
library/io.m:
Add code to mercury_fclose() to explicitly deallocate the
MercuryFile structure pointed to by the io_stream C foreign_type,
when not using conservative GC.
This avoids a potential memory leak in those grades.
Workspace: /home/ceres/fjh/mercury
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.63
diff -u -d -r1.63 ml_code_util.m
--- compiler/ml_code_util.m 7 May 2002 11:03:03 -0000 1.63
+++ compiler/ml_code_util.m 15 May 2002 07:34:54 -0000
@@ -2160,11 +2160,9 @@
ml_type_might_contain_pointers(mlds__native_float_type) = no.
ml_type_might_contain_pointers(mlds__native_bool_type) = no.
ml_type_might_contain_pointers(mlds__native_char_type) = no.
-ml_type_might_contain_pointers(mlds__foreign_type(_)) = _ :-
- sorry(this_file, "--gc accurate and foreign_type").
- % It might contain pointers, so it's not safe to return `no',
- % but it also might not be word-sized, so it's not safe to
- % return `yes'.
+ml_type_might_contain_pointers(mlds__foreign_type(_)) = no.
+ % We assume that foreign types are not allowed to contain pointers
+ % to the Mercury heap. XXX is this requirement too strict?
ml_type_might_contain_pointers(mlds__class_type(_, _, Category)) =
(if Category = mlds__enum then no else yes).
ml_type_might_contain_pointers(mlds__ptr_type(_)) = yes.
Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.247
diff -u -d -r1.247 reference_manual.texi
--- doc/reference_manual.texi 7 May 2002 11:03:17 -0000 1.247
+++ doc/reference_manual.texi 15 May 2002 07:51:05 -0000
@@ -5503,6 +5503,11 @@
at a later date we plan to lift this restriction and allow enum, struct
and floating point types.
+ at c XXX No point documenting this until `--gc accurate'
+ at c is officially supported.
+ at c With @samp{--gc accurate}, foreign_types which are C pointer types
+ at c must not point to the Mercury heap.
+
If the @var{MercuryTypeName} is the type of a parameter of a procedure
defined using @samp{pragma foreign_proc},
it will be passed to the foreign_proc's foreign language code
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.253
diff -u -d -r1.253 io.m
--- library/io.m 12 May 2002 17:47:47 -0000 1.253
+++ library/io.m 15 May 2002 08:15:23 -0000
@@ -3848,6 +3848,18 @@
#endif /* ! MR_NEW_MERCURYFILE_STRUCT */
+#ifndef MR_CONSERVATIVE_GC
+ /*
+ ** For the accurate GC or no GC cases,
+ ** we need to explicitly deallocate the memory here,
+ ** to avoid a memory leak.
+ ** Note that the accurate collector won't reclaim
+ ** io_streams, since the io__stream type is defined
+ ** as a foreign_type.
+ */
+ MR_GC_FREE(mf);
+#endif /* !MR_CONSERVATIVE_GC */
+
}
}
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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