Commit Graph

70 Commits

Author SHA1 Message Date
Peter Wang
a70ecd4f91 Implement version arrays for Java. This is a straightforward
Branches: main

library/version_array.m:
        Implement version arrays for Java.  This is a straightforward
        translation of the C code.

library/version_hash_table.m:
        Add a cast predicate implementation for Java.
2009-08-05 05:11:57 +00:00
Peter Wang
cbffae65fd Make version_array.set make a new array if it's not updating the latest version
Branches: main

Make version_array.set make a new array if it's not updating the latest version
of an array.  This avoids unexpected bad performance, where the version array
essentially turns into a linked list with an array at the end, if the user
happens to go back to an older version of an array without an explicit
rewind/copy.

library/version_array.m:
        As above.

compiler/make.dependencies.m:
        Use size doubling when resizing version arrays.
2009-08-05 01:02:20 +00:00
Peter Wang
eeec14a8b1 Replace the implementations of (version) hash tables by separate chaining hash
Branches: main

Replace the implementations of (version) hash tables by separate chaining hash
tables.  The old open addressing scheme was broken in the presence of deletes.
Fixes bug #68.

library/hash_table.m:
library/version_hash_table.m:
	As above.

	We no longer use double hashing in case of a hash collision, so hash
	predicates only need to return one value now.

	Add fold with predicate arguments.

library/array.m:
	Add array.foldl for a predicate argument.

	Add array.foldl2 with a unique state pair.

library/version_array.m:
	Add version_array.foldl for a predicate argument.

compiler/make.m:
compiler/make.program_target.m:
compiler/make.util.m:
library/robdd.m:
	Conform to change in hashing predicates.

deep_profiler/dense_bitset.m:
	Add module qualifier to avoid ambiguity.

tests/hard_coded/Mmakefile:
tests/hard_coded/hash_table_delete.exp:
tests/hard_coded/hash_table_delete.m:
tests/hard_coded/hash_table_test.exp:
tests/hard_coded/hash_table_test.m:
tests/hard_coded/version_hash_table_delete.exp:
tests/hard_coded/version_hash_table_delete.m:
tests/hard_coded/version_hash_table_test2.exp:
tests/hard_coded/version_hash_table_test2.m:
	Add new test cases.

tests/hard_coded/hash_bug.m:
tests/hard_coded/hash_init_bug.m:
tests/hard_coded/version_hash_table_test.m:
	Conform to change in hashing predicates.

NEWS:
	Document additions.
2009-03-26 06:32:19 +00:00
Peter Wang
2736b1a184 Add `may_not_duplicate' attributes on some "C" foreign_procs to prevent
Estimated hours taken: 0.5
Branches: main

library/construct.m:
library/dir.m:
library/io.m:
library/store.m:
library/string.m:
library/term_size_prof_builtin.m:
library/thread.m:
library/version_array.m:
	Add `may_not_duplicate' attributes on some "C" foreign_procs to prevent
	them being written to `.opt' files.

	It works around a problem with opt-exporting `thread.spawn' (which
	happens to be not worth opt-exporting).
2008-08-29 06:13:09 +00:00
Zoltan Somogyi
672f77c4ec Add a new compiler option. --inform-ite-instead-of-switch.
Estimated hours taken: 20
Branches: main

Add a new compiler option. --inform-ite-instead-of-switch. If this is enabled,
the compiler will generate informational messages about if-then-elses that
it thinks should be converted to switches for the sake of program reliability.

Act on the output generated by this option.

compiler/simplify.m:
	Implement the new option.

	Fix an old bug that could cause us to generate warnings about code
	that was OK in one duplicated copy but not in another (where a switch
	arm's code is duplicated due to the case being selected for more than
	one cons_id).

compiler/options.m:
	Add the new option.

	Add a way to test for the bug fix in simplify.

doc/user_guide.texi:
	Document the new option.

NEWS:
	Mention the new option.

library/*.m:
mdbcomp/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
	Convert if-then-elses to switches at most of the sites suggested by the
	new option. At the remaining sites, switching to switches would have
	nontrivial downsides. This typically happens with the switched-on type
	has many functors, and we treat one or two specially (e.g. cons/2 in
	the cons_id type).

	Perform misc cleanups in the vicinity of the if-then-else to switch
	conversions.

	In a few cases, improve the error messages generated.

compiler/accumulator.m:
compiler/hlds_goal.m:
	(Rename and) move insts for particular kinds of goal from
	accumulator.m to hlds_goal.m, to allow them to be used in other
	modules. Using these insts allowed us to eliminate some if-then-elses
	entirely.

compiler/exprn_aux.m:
	Instead of fixing some if-then-elses, delete the predicates containing
	them, since they aren't used, and (as pointed out by the new option)
	would need considerable other fixing if they were ever needed again.

compiler/lp_rational.m:
	Add prefixes to the names of the function symbols on some types,
	since without those prefixes, it was hard to figure out what type
	the switch corresponding to an old if-then-else was switching on.

tests/invalid/reserve_tag.err_exp:
	Expect a new, improved error message.
2007-11-23 07:36:01 +00:00
Simon Taylor
1410facd59 Fix a bug which caused negative indices to be allowed
Estimated hours taken: 0.5
Branches: main

library/version_array.m:
	Fix a bug which caused negative indices to be allowed
	when updating a version_array.

tests/hard_coded/version_array_test.{m,exp}:
	Add test cases.
2007-05-30 02:42:46 +00:00
Simon Taylor
9c650e1d83 Improvements for bitmap.m, to make it useable as a general container
Estimated hours taken: 80
Branches: main

Improvements for bitmap.m, to make it useable as a general container
for binary data.

library/bitmap.m:
runtime/mercury_bitmap.c:
runtime/mercury_bitmap.h:
	Specialize the representation of bitmaps to an array of unsigned
	bytes defined as a foreign type.

	This is better than building on top of array(int) because it:
	- is better for interfacing with foreign code
	- has a more sensible machine-independent comparison order
	  (same as array(bool))
	- avoids storing the size twice
	- has more efficient copying, unification, comparison and tabling
	  (although we should probably specialize the handling of array(int)
	  and isomorphic types as well)
	- uses GC_MALLOC_ATOMIC to avoid problems with bit patterns that look
	  like pointers (although we should do that for array(int) as well)

	XXX The code for the Java and IL backends is untested.
	Building the library in grade Java with Sun JDK 1.6 failed (but
	at least passed error checking), and I don't have access to a
	copy of MSVS.NET.  The foreign code that needs to be tested is
	trivial.

	Add fields `bit', `bits' and `byte' to get/set a single bit,
	multiple bits (from an int) or an 8 bit byte.

	Add functions for converting bitmaps to hex strings and back,
	for use by stream.string_writer.write and deconstruct.functor/4.

	bitmap.intersect was buggy in the case where the input bitmaps
	had a different size.  Given that bitmaps are implemented with
	a fixed domain (lookups out of range throw an exception), it
	makes more sense to throw an exception in that case anyway,
	so all of the set operations do that now.

	The difference operation actually performed xor.  Fix it and
	add an xor function.

library/version_bitmap.m:
	This hasn't been fully updated to be the same as bitmap.m.
	The payoff would be much less because foreign code can't
	really do anything with version_bitmaps.

	Add a `bit' field.

	Deprecate the `get/2' function in favour of the `bit' field.

	Fix the union, difference, intersection and xor functions
	as for bitmap.m.

	Fix comparison of version_arrays so that it uses the same
	method as array.m: compare size then elements in order.
	The old code found version_arrays to be equal if one was
	a suffix of the other.

library/char.m:
	Add predicates for converting between hex digits and integers.

library/io.m:
library/stream.string_writer.m:
library/term.m:
	Read and write bitmaps.

runtime/mercury_type_info.h:
runtime/mercury_deep_copy_body.h:
runtime/mercury_mcpp.h:
runtime/mercury_table_type_body.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_unify_compare_body.h:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_term_size.c:
runtime/mercury_string.h:
library/construct.m:
library/deconstruct.m
compiler/prog_type.m:
compiler/mlds_to_gcc.m:
compiler/rtti.m:
	Add a MR_TypeCtorRep for bitmaps, and handle it in the library
	and runtinme.

library/Mercury.options:
	Compile bitmap.m with `--no-warn-insts-without-matching-type'.

runtime/mercury_type_info.h:
	Bump MR_RTTI_VERSION.

NEWS:
	Document the changes.

tests/hard_coded/Mmakefile:
tests/hard_coded/bitmap_test.m:
tests/hard_coded/bitmap_simple.m:
tests/hard_coded/bitmap_tester.m:
tests/hard_coded/bitmap_test.exp:
tests/tabling/Mmakefile:
tests/tabling/expand_bitmap.m:
tests/tabling/expand_bitmap.exp:
tests/hard_coded/version_array_test.m:
tests/hard_coded/version_array_test.exp:
	Test cases.
2007-02-13 01:59:04 +00:00
Zoltan Somogyi
7b7dabb89a Extend this optimization to handle temporaries being both defined in
Estimated hours taken: 12
Branches: main

compiler/use_local_vars.m:
	Extend this optimization to handle temporaries being both defined in
	and used by foreign_proc_code instructions. This should eliminate
	unnecessary accesses to the MR_fake_reg array, and thus speed up
	programs that use foreign code a lot, including typeclass- and
	tabling-intensive programs, since those features are implemented using
	inline foreign code. I/O intensive should also benefit, but not much,
	since the cost of the I/O itself overwhelms the cost of the
	MR_fake_reg accesses.

	Group together the LLDS instructions that are handled similarly.
	Factor out some common code.

compiler/opt_util.m:
	Allow for the fact that foreign_proc_codes can now refer to
	temporaries.

compiler/opt_debug.m:
	Print more useful information about foreign_proc_code components.

compiler/prog_data.m:
	Rename the types and function symbols of the recently added
	foreign_proc attributes to avoid clashing with the keywords
	representing them in source code.

	Add a new foreign_proc attribute, proc_may_duplicate that governs
	whether the body of foreign code is allowed to be duplicated.

compiler/table_gen.m:
	Include does_not_affect_liveness among the annotations for the
	foreign_proc calls generated by this module. Some of these procedures
	affect memory beyond their arguments, but that memory is in tables,
	not in unlisted registers.

	Allow some of the smaller code fragments generated by this module
	to be duplicated.

compiler/inlining.m:
	Respect the may_not_duplicate foreign_proc attribute.

compiler/pragma_c_gen.m:
	Transmit any annotations about liveness from the HLDS to the LLDS,
	since without does_not_affect_liveness annotations use_local_vars.m
	cannot optimize foreign_proc_codes.

	Transmit any annotations about may_duplicate from the HLDS to the LLDS,
	since with them jumpopt can do a better job.

compiler/llds.m:
	Use the new foreign_proc attribute instead of a boolean to represent
	whether a foreign code fragment may be duplicated.

compiler/simplify.m:
	Generate an error message if a may_duplicate or may_not_duplicate
	attribute on a foreign_proc conflicts with a no_inline or inline pragma
	(respectively) on the predicate it belongs to.

compiler/hlds_pred.m:
	Fix some comment rot.

compiler/jumpopt.m:
compiler/livemap.m:
compiler/proc_gen.m:
compiler/trace_gen.m:
	Conform to the changes above.

doc/reference_manual.texi:
	Document the new foreign_proc attribute.

library/array.m:
library/builtin.m:
library/char.m:
library/dir.m:
library/float.m:
library/int.m:
library/io.m:
library/lexer.m:
library/math.m:
library/private_builtin.m:
library/string.m:
library/version_array.m:
	Add does_not_affect_liveness annotations to the C foreign_procs that
	deserve them.

configure.in:
	Require the installed compiler to support does_not_affect_liveness.

tests/invalid/test_may_duplicate.{m,err_exp}:
	Add a new test case to test the error checking code in simplify.m.

tests/invalid/Mmakefile:
	Enable the new test case.
2007-01-15 02:24:04 +00:00
Peter Ross
84ffc0924d Fix --warn-unused-imports warnings in some of the modules.
Estimated hours taken: 4
Branches: main

library/*.m:
compiler/*.m:
	Fix --warn-unused-imports warnings in some of the modules.
2006-09-27 06:17:09 +00:00
Julien Fischer
65ffce905f Rearrange the version array code in order to improve inlining
Estimated hours taken: 0.5
Branches: main

Rearrange the version array code in order to improve inlining
opportunities.

library/version_array.m:
	Shift some of the code from the foreign_code pragma into the
	foreign_procs.  The rationale for doing this is that it gives the
	compiler the option of inlining the code across module boundaries,
	something that it cannot do with code in foreign code pragma.

	Fix some formatting.

library/version_bitmap.m:
	Fix some formatting.
2006-08-25 07:02:49 +00:00
Julien Fischer
e0f5ac47db Make it easier for vi to jump past the initial comments
Estimated hours taken: 0.1
Branches: main

library/*.m:
	Make it easier for vi to jump past the initial comments
	at the head of a module.
2006-04-19 05:18:00 +00:00
Julien Fischer
5e92224eec Improve the library reference manual by formatting the beginning of
Estimated hours taken: 0.2
Branches: main, release

library/*.m:
	Improve the library reference manual by formatting the beginning of
	library modules consistently.

library/integer.m:
	Fix some bad indentation.
2006-04-13 06:08:05 +00:00
Julien Fischer
7a8681f774 Annotate foreign_procs with trail usage information throughout most of
Estimated hours taken: 0.5
Branches: main

library/*.m:
	Annotate foreign_procs with trail usage information throughout most of
	the standard library.

	Fix an out of date comment in string.m.

	Fix some minor formatting problems.
2005-12-14 10:33:56 +00:00
Zoltan Somogyi
74e60c1c8c Clean up the format of the foreign code used in this module.
Estimated hours taken: 0.5
Branches: main

library/version_array.m:
	Clean up the format of the foreign code used in this module.
	Convert it to four-space indentation to reduce the number of
	bad line breaks.
2005-05-24 05:51:34 +00:00
Julien Fischer
1de1dbb394 Fix more typos in library documentation.
Estimated hours taken: 0.5
Branches: main

Fix more typos in library documentation.

library/builtin.m:
	s/wheiter/whether.

library/char.m:
	s/consise/concise/

library/getopt.m:
library/getopt_io.m:
	s/keept/keep/

library/int.m:
	s/expontiation/exponentiation/

library/ops.m:
	s/precendence/precedence/

library/robdd.m:
	s/efficent/efficient/

library/set_bbbtree.m:
	s/noticable/noticeable/

library/term_to_xml.m:
	s/funtor/functor/
	s/attrinutes/attributes/
	s/fuctor/functor/

library/version_array.m:
	s/incurr/incur/
2005-01-27 03:59:27 +00:00
Julien Fischer
3e19c2fad6 Improve the termination analyser's handling of user-defined
Estimated hours taken: 20
Branches: main

Improve the termination analyser's handling of user-defined
special predicates.

Currently termination analysis assumes that all calls
to special predicates terminate.  For those that are
user-defined this is not necessarily true.

This diff adds a new pass to the compiler that is run after
the main termination analysis pass. It checks any user-defined
special predicates and emits a warning if their termination
can not be proved.

Add a new option, `--no-warn-non-term-special-preds' that
disables this warning.  The warning is only emitted when
termination analysis is enabled.  The new option has
no effect if termination analysis is not enabled.

compiler/post_term_analysis.m:
	New file.  Add an additional pass that runs after the main
	termination analysis and makes use of the information obtained
	then to perform further semantic checks and optimizations.

compiler/termination.m:
	Run the new pass after the main analysis.

	Update the comment about the termination analyser doing the
	wrong thing for user-defined special predicates.

compiler/options.m:
	Parse the new option.

	Update the special handler for the inhibit_warning
	option so that it handles `--warn-table-with-inline'
	and the new option correctly.

	Fix some typos.

compiler/transform_hlds.m:
	Include the new module.

compiler/notes/compiler_design.html:
	Mention the new module.

doc/user_guide.texi:
	Document the new option.

	Fix some typos: s/occured/occurred/,
	s/interative/interactive/, s/exlained/explained/
	and /currect/current/

library/array.m:
library/version_array.m:
	Add pragma terminates declarations to the user-defined
	equality and comparison predicates for the array/1
	and version_array/1 types.  The termination analyser
	cannot (yet) prove termination in these cases because
	it cannot reason about iteration over arrays.

tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
tests/warnings/warn_non_term_user_special.m:
tests/warnings/warn_non_term_user_special.exp:
	Test the new option.
2005-01-22 06:10:55 +00:00
Ralph Becket
f9a533fb2c Added a test case for version_array.m and fixed a few bugs.
Estimated hours taken: 2
Branches: main

Added a test case for version_array.m and fixed a few bugs.

library/version_array.m:
	Bug in version_array.rewind fixed.

tests/hard_coded/Mmakefile:
tests/hard_coded/version_array_test.m:
tests/hard_coded/version_array_test.exp:
	Test case added.
2004-10-08 07:01:29 +00:00
Julien Fischer
27692d766b Prefix things with `ML_' so that this module
Estimated hours taken: 0.5
Branches: main

library/version_array.m:
	Prefix things with `ML_' so that this module
	passes mmake check_namespace.
2004-09-27 16:31:20 +00:00
Julien Fischer
06fe5e6d99 Some minor fixes for the version types that Ralph
Estimated hours taken: 0.5
Branches: main

Some minor fixes for the version types that Ralph
has added to the standard library.

compiler/modules.m:
	Add the version type modules to the list of standard
	library modules.

library/version_array.m:
	Provided a Mercury definition of the type version_array(T)
	so that this module (and the library) compile in the java
	and il grades.  (XXX I haven't checked the latter).
2004-09-27 06:44:00 +00:00
Ralph Becket
95e97c7fc4 Add version types to the standard library.
Estimated hours taken: 60
Branches: main

Add version types to the standard library.

NEWS:
	Report the new additions.

library/library.m:
	Include the new modules in the standard library.

library/version_array.m:
library/version_array2d.m:
library/version_bitmap.m:
library/version_hash_table.m:
library/version_store.m:
library/version_types.m:
	Added.
2004-09-27 00:44:49 +00:00