Commit Graph

96 Commits

Author SHA1 Message Date
Fergus Henderson
0b45949b04 Fix a bug in the definition of float_const for the
Estimated hours taken: 0.25

runtime/imp.h:
	Fix a bug in the definition of float_const for the
	USE_SINGLE_PREC_FLOAT case.
1996-04-06 22:05:21 +00:00
Fergus Henderson
e343cf50f0 Suppress a warning about no previous declaration for
Estimated hours taken: 0.1

runtime/imp.h:
	Suppress a warning about no previous declaration for
	hash_string() in aux.c.
1996-04-06 21:06:30 +00:00
Fergus Henderson
62d6d7ca50 Fix a problem with the definition of float_to_word and word_to_float
Estimated hours taken: 0.1

runtime/imp.h:
	Fix a problem with the definition of float_to_word and word_to_float
	for the case of USE_SINGLE_PREC_FLOAT; gcc didn't like the cast
	from Integer to union FloatWord - it wanted a cast from Integer
	to Word first.
1996-04-06 17:31:52 +00:00
Fergus Henderson
913cda0f4a Add inline assembler hacks for restoring the $gp register on the alpha,
Estimated hours taken: 24

Add inline assembler hacks for restoring the $gp register on the alpha,
to make the `asm_fast.gc' grade work on the alpha.

runtime/goto.h:
	For the alpha, change the GOTO macro so that it sets up
	register $27 (the "procedure value" register) to contain the
	address to which you are going to jump, and change the
	Define_{entry,local,static} macros so that they have a `ldgp'
	instruction after the label which restores the gp register from
	$27.

runtime/call.mod:
	For the alpha, change the call macro so that it uses a `ldgp'
	instruction to restore the gp register on return from a call.
	Add new call_localret macro, for the case when the continuation
	label is a local label (this is like the inverse of the localcall
	macro), because a call_localret is two instructions cheaper
	than the equivalent call would be.

runtime/engine.mod:
	In call_engine(), we need to use `Define_label(engine_done)'
	rather than just `engine_done:', so that it works on the alpha.

These changes improve the speed of the compiler by about 21%,
and cut executable size by about 24%.

There's still a fair bit of room for improving efficiency by
avoiding moves to $27 and `ldgp' instructions in situations
where they aren't needed.
1996-04-01 19:03:47 +00:00
Fergus Henderson
06d359d2d2 Fix a problem noticed by Andreas Kuehlmann.
Estimated hours taken: 0.25

Fix a problem noticed by Andreas Kuehlmann.

runtime/{imp.h,aux.c}:
	Define hash_string() as a function in aux.c unconditionally,
	even if we're not using gcc.  This avoids trouble when linking
	programs compiled with cc with a runtime library that was
	compiled with gcc.
1996-04-01 18:46:53 +00:00
Fergus Henderson
ac8c719bbe Fix a missing cast warning for the non-gcc version of hash_string().
Estimated hours taken: 0.25

runtime/{imp.h,aux.c}:
	Fix a missing cast warning for the non-gcc version of hash_string().
1996-03-30 09:30:18 +00:00
David Jeffery
4b58650200 Mercurial Constraints II (the plot thickens)
Estimated hours taken: 1 summer studentship

This is the implementation of the constraint solver interface runtime stuff.
We maintain a stack of tickets, accessible via mercury_solver_sp.

runtime/aux.[ch]
	Introduce a new memory allocation function, checked_malloc(). This is
	similar to newmem(), except that it always uses malloc(), not
	GC_malloc(), regardless of the grade. This is useful when allocating
	memory for the ticket stack as the garbage collector needn't know
	about the ticket stack - it never contains pointers into gc'ed memory.
runtime/imp.h
	Include mercury_solver_backtrack.h if we are in an appropriate grade.
runtime/wrapper.mod
	Initialise the ticket stack, call the solver initialisation macro.
runtime/mercury_solver_backtrack.h
	Implement the ticket macros, and the solver initialisation macro. This
	file is currently specific to the CLP(R) solver; to interface to a
	different solver, only the macros etc. in this file need be altered.
1996-03-26 16:54:51 +00:00
Zoltan Somogyi
fe2eb0323a Fix the byzantine inclusion relationship between prof.h and imp.h.
Estimated hours taken: 1

imp.h, prof.h:
	Fix the byzantine inclusion relationship between prof.h and imp.h.

prof.c:
	Fix the hashing function for code addresses so that it doesn't waste
	three quarters of the hash table.

	In each hash slot, use a binary search tree instead of an unordered
	list of entries. This can be expected to handle high loads better,
	which is necessary because the hash table size is not adaptive.
	(Making it adaptive would be a better fix.)

	Instead of turning signals off and on in the handler of profiling
	signals, simply set a volatile variable to detect cases when two
	profiling signals arrive too closely.
1996-03-24 06:40:57 +00:00
Peter Ross
acb95582e5 Moved the profiling initialisation code so that it sits around
Estimated hours taken: 1


library/io.m:
	Moved the profiling initialisation code so that it sits around
	the call to main/2(0).  Thus the profiler will now begin all it's
	profiles from main not from call_engine.

profiler/read.m:
	The profiler now expects that it's address are written out in decimal.
	read.m now assumes that an address is a decimal, but if it can't parse
	it, it will then read it in as a hexadecimal.  Thus the profiler will
	still be able to read it's old files.
	NB. A possible bug with this is that two numbers will get converted to
	the same number if one is treated as hex and the other decimal.

profiler/.cvsignore:
	Some more files to ignore.

runtime/{engine, wrapper}.mod:
	Remove the profiling initialisation code.

runtime/imp.h:
	Add a new call macro noprof_call() which doesn't record an arc
	in the call graph for profiling ever.  This is used to ignore some
	of the initial system set-up calls.

runtime/prof.c:
	Output integers instead of hexs for the addresses.
1996-03-21 12:00:10 +00:00
Fergus Henderson
300df90c9a Fix a bug in the code for float_to_word() in non-gc grades:
Estimated hours taken: 0.75

runtime/imp.h:
	Fix a bug in the code for float_to_word() in non-gc grades:
	the part which was supposed to ensure correct alignment
	of floats allocated on the heap was not working correctly.
1996-03-19 09:14:24 +00:00
Fergus Henderson
505c3504f1 Move the C implementation of various builtins from the `runtime' directory
to inside pragma(c_code) declarations in the `library' directory sources.

runtime/{Mmake,{math,io}_rt.mod}:
	Remove math_rt.mod and io_rt.mod, since the code has been moved
	into `.m' files in the library directory.

runtime/main.mod:
	Remove this file, since it wasn't used.

runtime/imp.h:
	Add SUCCESS_INDICATOR as a macro for r1, for use by
	pragma_c_code.

Also a few minor unrelated changes:

runtime/imp.h:
	Avoid code duplication in hash_string macros.

runtime/tags.h:
	Use sizeof(Word) rather than WORD_SIZE (in this old code, the
	extra level of indirection only obfuscated things).

runtime/{aux.c,aux.h,prof.c}:
	Add some more #ifdefs to avoid including debugging/profiling
	code in the non-debugging/non-profiling version of the library.
1996-02-28 15:46:04 +00:00
Fergus Henderson
89d22843e4 Add type Char', to hold a Mercury char'.
Estimated hours taken: 0.25

runtime/imp.h:
	Add type `Char', to hold a Mercury `char'.
1996-02-03 14:18:02 +00:00
Fergus Henderson
d82309baad Add typedef of continuation function `Cont' for use with the
Estimated hours taken: 0.1

runtime/imp.h:
	Add typedef of continuation function `Cont' for use with the
	`--high-level-C' option.
1996-01-15 00:26:53 +00:00
Fergus Henderson
6e2801a6fe Fix problem on Linux where global register declarations occur after
Estimated hours taken: 0.5

Fix problem on Linux where global register declarations occur after
inline function definitions in system header files.

runtime/imp.h:
	Make sure that "reg.h" is the first header file included.
1995-12-28 03:57:36 +00:00
Fergus Henderson
e4e25c2cdf Suppress a spurious warning about `cast from pointer to integer
Estimated hours taken: 0.25

runtime/imp.h:
	Suppress a spurious warning about `cast from pointer to integer
	of different size' when compiling in a non-gc grade on the alpha.
1995-11-24 16:48:07 +00:00
Fergus Henderson
fe81c61efe Add `typedef char *String' which is now used by the C interface.
Estimated hours taken: 0.25

runtime/imp.h:
	Add `typedef char *String' which is now used by the C interface.
1995-11-24 01:21:33 +00:00
Fergus Henderson
a624d928c0 Add a couple of comments.
imp.h:
	Add a couple of comments.
1995-10-07 09:07:37 +00:00
Fergus Henderson
fd9798eb03 Oops, fix missing \ line continuations in macro.
imp.h:
	Oops, fix missing \ line continuations in macro.
	(This only showed up when compiling in a non-gc grade.)
1995-10-04 01:10:41 +00:00
Fergus Henderson
627831b89b When not using conservative GC, ensure appropriate alignment of
runtime/imp.h:
	When not using conservative GC, ensure appropriate alignment of
	floating point constants.  Also fix a couple of missing
	parentheses in the float_to_word macro.
1995-10-03 16:13:07 +00:00
Fergus Henderson
bf3df78c41 Add #include of <string.h> for strcmp().
runtime/imp.h:
	Add #include of <string.h> for strcmp().
	(This missing #include was not previously noted because gcc has
	a builtin-declaration for strcmp() - it only caused a warning
	when compiled with `-fno-builtin'.)
1995-09-09 01:58:07 +00:00
Fergus Henderson
fce9c95a8c A bunch of changes resulting from work during the BSD/386 port.
imp.h, engine.mod, io_rt.mod:
	Reorder #include lines so that "regs.h" gets included
	before any of the system header files (other than <stddef.h>).
	This is necessary because on some systems, the system header files
	contain inline functions, and the global register variable
	declarations must precede these.

regs.h:
	Add case for i386, since global register variables now work
	on the 386 (the problem was just that we needed -fno-builtin).

label.c, wrapper.mod:
	Add #include of <string.h> for strcmp().
	(These missing #include were not previously noted because gcc has
	a builtin-declaration for strcmp() - it only caused a warning
	when I compiled with `-fno-builtin'.)

regorder.h:
	Change the register allocation order so that `sp' gets
	allocated first, since for the compiler, 36% of all Mercury
	register references are to `sp'.

memory.c:
	With `-dm', if we're using CONSERVATIVE_GC, don't output the
	size etc. for the heap, since they will all be zero - the
	heap gets allocated by the Boehm collector.
1995-09-03 15:22:49 +00:00
Fergus Henderson
3174b8faf7 Make oldmem() call GC_FREE() if CONSERVATIVE_GC is defined.
runtime/aux.c:
	Make oldmem() call GC_FREE() if CONSERVATIVE_GC is defined.
	Improve the error messages from fatal_error().

runtime/{imp.h,label.c}
	Use `Unsigned' rather than `Uinteger'.

runtime/dlist.c:
	Fix incorrect comment.

runtime/memory.c:
	Various portability fixes for the Alpha, mostly to do with
	mixing integers and pointers of different sizes.
	Also make sure we only use PC_INDEX if it is defined.

runtime/prof.c:
	Another portability fix for the Alpha: use `sysconf(_SC_CLK_TCK)'
	if `HZ' is not available.
	Also a major clean-up:
	Tidy up the code.  Avoid memory leaks.  Remember to close files.
	Tidy up the error messages for when fopen() fails.
	Check the return values from fclose().
	(XXX still need to check return values of signal() and setitimer().)

runtime/regs.h:
	Add alpha_regs.h.
1995-07-28 13:55:04 +00:00
Zoltan Somogyi
ab52fbdeb0 Changed format fields to use %ld in most cases of printing integers.
aux.c, label.c:
	Changed format fields to use %ld in most cases of printing integers.

imp.h:
	Added a new type Uinteger.

list.c:
	This has been renamed dlist.c a long time ago.
1995-07-21 09:43:37 +00:00
Zoltan Somogyi
332db2aa35 Set up the type of Word at configuration time.
conf.h.in:
	Set up the type of Word at configuration time.

imp.h:
	Changed definition of Word. Also gathered two of the three
	definitions of hash_string into one place, defining a macro
	for use by aux.c.

aux.c:
	Use the macro in imp.h for the body of hash_string.

engine.mod:
	Minor formatting change.
1995-07-12 15:16:43 +00:00
Zoltan Somogyi
19bcfcbab4 Now memory diagnostics are printed on stderr.
memory.c:
	Now memory diagnostics are printed on stderr.

wrapper.mod, memory.c:
	Convert whens to cases and ors to else ifs.

other files:
	copyright notices.
1995-05-29 02:04:10 +00:00
Zoltan Somogyi
0f46c5d4e7 Merged in changes from the pass_str_branch. 1995-05-06 07:29:58 +00:00
Fergus Henderson
deec160d03 Implement solutions/2. (We still haven't implemented mode/determinism
checking for higher-order preds, though, so the compiler doesn't
diagnose errors correctly - if you use the wrong mode you will probably
just get a core dump.)
1995-04-18 03:57:05 +00:00
Fergus Henderson
6e8294eee2 Add incr_hp_atomic macro, which for USE_CONSERVATIVE_GC
imp.h:
	Add incr_hp_atomic macro, which for USE_CONSERVATIVE_GC
	invokes GC_MALLOC_ATOMIC() rather than GC_MALLOC().

io.mod:
	Use the new incr_hp_atomic() macro for allocating strings.
	Add implementations of string__index/2, string__length/2,
	and string__append/3.

Note - these changes sped up the compiler by nearly 40%!
1995-04-15 06:09:39 +00:00
Fergus Henderson
3fc5389b53 Add copyright notices.
runtime/*:
	Add copyright notices.
1995-03-30 21:57:11 +00:00
Fergus Henderson
84437da656 Fix bug in floating point handling.
imp.h:
	Fix bug in floating point handling.
1995-03-15 14:13:20 +00:00
Fergus Henderson
8bdae2366b Add macros for floating point.
imp.h:
	Add macros for floating point.
1995-03-14 16:27:24 +00:00
Peter Ross
b0edde4d3d Added an option to turn time and call profiling on seperately.
CFLAGSFILE:
	Added an option to turn time and call profiling on seperately.

imp.h:
	Added macro 'update_prof_current_proc'.  Also removed stack
	implementation of time profiling.

engine.mod:
	Added all the init and finish code for time profiling.

label.*:
	Changed option from USE_PROFILING to PROFILE_CALLS

prof.*:
	Added all the neccesary code to do time profiling.
1995-03-13 17:14:51 +00:00
Fergus Henderson
9548e252a6 Fix problems with -s fast that I introduced when I added -s asm_fast.
imp.h:
	Fix problems with -s fast that I introduced when I added -s asm_fast.
1995-03-02 01:36:38 +00:00
Fergus Henderson
73eae4222d Fix succeed_discard().
imp.h:
	Fix succeed_discard().
	Remove extraneous semicolons in Declare_xxx macros.
1995-03-01 09:15:16 +00:00
Fergus Henderson
0b6351d090 Add some changes for profiling (untested).
imp.h:
	Add some changes for profiling (untested).
1995-03-01 08:00:52 +00:00
Peter Ross
c94a851582 Redefined the tailcall macro's to include the Caller address for
imp.h:
	Redefined the tailcall macro's to include the Caller address for
	profiling, and to call the profile function.

*.mod:
	Changed all the handwritten tailcall's to conform to the new tailcall.
	Need to add makelocalentry macro so that I can save all the handwritten
	label names and they can be looked up by mprof.

prof.*:
	Added some more comment's.
1995-02-28 04:32:32 +00:00
Fergus Henderson
5835cddc6a Cakefile dummy.c dummy.h engine.h engine.mod imp.h io.mod label.h wrapper.mod:
Make various changes required for using assembler labels.
1995-02-26 13:52:58 +00:00
Fergus Henderson
4f29dffb2f A few more fixes to get conservative garbage collection
aux.c, imp.h, memory.c:
	A few more fixes to get conservative garbage collection
	to actually work.
1995-02-22 04:23:39 +00:00
Fergus Henderson
f175dd9930 Don't source .gdbinit.arch, since it seems to have suffered
.gdbinit:
	Don't source .gdbinit.arch, since it seems to have suffered
	software rot.

aux.c, std.h, imp.h, access.c, iface.mod, prof.c:
	Make sure that all memory allocation goes through
	newmem(), resizemem() and oldmem().
	Fix those functions so that they work with conservative
	garbage collection.
1995-02-21 19:27:26 +00:00
Fergus Henderson
c2b848e6b6 D'oh! Change the call to GC_MALLOC() so that it allocates
imp.h:
	D'oh!  Change the call to GC_MALLOC() so that it allocates
	`count * sizeof(Word)' bytes rather than just `count' bytes.
	(How could I make such a beginner's mistake?
	I hate manual memory management.)
1995-02-16 03:21:54 +00:00
Fergus Henderson
9841169e9a Make things work with conservative garbage collection.
imp.h:
	Make things work with conservative garbage collection.

tags.h, io.mod:
	Make things work with --tags none.
1995-02-15 03:58:01 +00:00
Thomas Conway
90ce96d31f add a new debugging option: -dr which writes the values of
various:
	add a new debugging option: -dr which writes the values of
	the first 8 registers immediately after each goto.
1995-02-12 10:40:27 +00:00
Fergus Henderson
d45f5c6aec Add a new compilation flag -DDEBUG_GOTOS for use in combination
engine.mod label.h imp.h:
	Add a new compilation flag -DDEBUG_GOTOS for use in combination
	with -DSPEED for minimal debugging.
1995-02-08 06:30:52 +00:00
Peter Ross
a05ed0ae3f Included prof.c and prof.h in the compile
Cakefile :
	Included prof.c and prof.h in the compile

CFLAGSFILE:
	Added the USE_PROFILING flag.

engine.mod:
	Added calls so that all the profiling info is dumped to a file

prof.*:
	Added some comments.

imp.h:
	Modified the call and localcall macros so that they save the
	callee-caller address pair if USE_PROFILING defined.

*.mod:
	Added the extra argument to all calls and local calls for the
	handwritten mod files.
1995-02-08 05:19:19 +00:00
Fergus Henderson
aeec8f6113 Fix succcont vs succont bugs by replacing them all with succ_cont.
imp.h:
	Fix succcont vs succont bugs by replacing them all with succ_cont.
1995-02-02 05:35:37 +00:00
Thomas Conway
f25ceb6faf Make the virtual machine registers map to an array of Words rather
*.h. memory.c:
	Make the virtual machine registers map to an array of Words rather
	than to descrete variables.

misc:
	Related changes.
1995-01-30 06:32:49 +00:00
Fergus Henderson
e8d1bb3002 Change the semidet call_closure macro so that it only uses 32 regs, not 33. 1995-01-20 02:37:17 +00:00
Zoltan Somogyi
313131240b Added a new macro, tag_incr_hp/3, to tag the new lval in the same
imp.h:
	Added a new macro, tag_incr_hp/3, to tag the new lval in the same
	statement as its copy from hp.
1995-01-19 08:47:38 +00:00
Fergus Henderson
91cb5bca0b Add mark_hp and restore_hp macros.
imp.h:
	Add mark_hp and restore_hp macros.
1995-01-17 22:17:35 +00:00
Fergus Henderson
f3b01045f0 Define Integer' to be a signed type the same size as Word'.
imp.h:
	Define `Integer' to be a signed type the same size as `Word'.

imp.h, io.mod:
	Replace incr_hp/1 macro with incr_hp/2.

list.c, std.h:
	Various minor cleanups.

tags.h:
	Replace all the casts to `unsigned' and `uint' with cases
	to `Word'.
1995-01-14 16:28:53 +00:00