| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Most of the other users of the fptools build system have migrated to
Cabal, and with the move to darcs we can now flatten the source tree
without losing history, so here goes.
The main change is that the ghc/ subdir is gone, and most of what it
contained is now at the top level. The build system now makes no
pretense at being multi-project, it is just the GHC build system.
No doubt this will break many things, and there will be a period of
instability while we fix the dependencies. A straightforward build
should work, but I haven't yet fixed binary/source distributions.
Changes to the Building Guide will follow, too.
|
|
|
|
| |
Modify some assertions that were occasionally incorrect
|
|
|
|
|
|
| |
Package up the various properties of Capabilities/Tasks that we were
asserting all over the place, and put them in a single macro
ASSERT_CAPABILITY_INVARIANTS().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Big re-hash of the threaded/SMP runtime
This is a significant reworking of the threaded and SMP parts of
the runtime. There are two overall goals here:
- To push down the scheduler lock, reducing contention and allowing
more parts of the system to run without locks. In particular,
the scheduler does not require a lock any more in the common case.
- To improve affinity, so that running Haskell threads stick to the
same OS threads as much as possible.
At this point we have the basic structure working, but there are some
pieces missing. I believe it's reasonably stable - the important
parts of the testsuite pass in all the (normal,threaded,SMP) ways.
In more detail:
- Each capability now has a run queue, instead of one global run
queue. The Capability and Task APIs have been completely
rewritten; see Capability.h and Task.h for the details.
- Each capability has its own pool of worker Tasks. Hence, Haskell
threads on a Capability's run queue will run on the same worker
Task(s). As long as the OS is doing something reasonable, this
should mean they usually stick to the same CPU. Another way to
look at this is that we're assuming each Capability is associated
with a fixed CPU.
- What used to be StgMainThread is now part of the Task structure.
Every OS thread in the runtime has an associated Task, and it
can ask for its current Task at any time with myTask().
- removed RTS_SUPPORTS_THREADS symbol, use THREADED_RTS instead
(it is now defined for SMP too).
- The RtsAPI has had to change; we must explicitly pass a Capability
around now. The previous interface assumed some global state.
SchedAPI has also changed a lot.
- The OSThreads API now supports thread-local storage, used to
implement myTask(), although it could be done more efficiently
using gcc's __thread extension when available.
- I've moved some POSIX-specific stuff into the posix subdirectory,
moving in the direction of separating out platform-specific
implementations.
- lots of lock-debugging and assertions in the runtime. In particular,
when DEBUG is on, we catch multiple ACQUIRE_LOCK()s, and there is
also an ASSERT_LOCK_HELD() call.
What's missing so far:
- I have almost certainly broken the Win32 build, will fix soon.
- any kind of thread migration or load balancing. This is high up
the agenda, though.
- various performance tweaks to do
- throwTo and forkProcess still do not work in SMP mode
|
|
|
|
| |
Yet another StgClosure that should be StgThunk
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some multi-processor hackery, including
- Don't hang blocked threads off BLACKHOLEs any more, instead keep
them all on a separate queue which is checked periodically for
threads to wake up.
This is good because (a) we don't have to worry about locking the
closure in SMP mode when we want to block on it, and (b) it means
the standard update code doesn't need to wake up any threads or
check for a BLACKHOLE_BQ, simplifying the update code.
The downside is that if there are lots of threads blocked on
BLACKHOLEs, we might have to do a lot of repeated list traversal.
We don't expect this to be common, though. conc023 goes slower
with this change, but we expect most programs to benefit from the
shorter update code.
- Fixing up the Capability code to handle multiple capabilities (SMP
mode), and related changes to get the SMP mode at least building.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
rts_evalStableIO: set rtsApiCapability to NULL *before* calling
scheduleWaitThread, matching the way the other eval_* functions do
this.
The previous way lead to a suble race condition:
- thread A calls rts_evalIO, enters scheduleWaitThread()
(rtsApiCapability == NULL).
- thread B calls rts_evalStableIO, creates a main thread and enters
scheduleWaitThread() (rtsApiCapability == &MainCapability)
- thread A exits scheduleWaitThread, sees that rtsApiCapability is
non-NULL, and calls releaseCapability() on it. This is bogus,
because thread A doesn't actually hold the capability, and we've
done a double-release.
This scenario leads to assertion failures in a debug threaded RTS, and
probably crashes in a non-debug threaded RTS.
MERGE TO STABLE
|
|
|
|
|
| |
Removed the annoying "Id" CVS keywords, they're a real PITA when it
comes to merging...
|
|
|
|
|
|
|
|
|
|
|
|
| |
Cleanup: all (well, most) messages from the RTS now go through the
functions in RtsUtils: barf(), debugBelch() and errorBelch(). The
latter two were previously called belch() and prog_belch()
respectively. See the comments for the right usage of these message
functions.
One reason for doing this is so that we can avoid spurious uses of
stdout/stderr by Haskell apps on platforms where we shouldn't be using
them (eg. non-console apps on Windows).
|
|
|
|
|
| |
Fix up following changes to the Capability API. (strange, I'm *sure*
I tested this stuff...)
|
|
|
|
|
|
| |
Tweaks to have RTS (C) sources compile with MSVC. Apart from wibbles
related to the handling of 'inline', changed Schedule.h:POP_RUN_QUEUE()
not to use expression-level statement blocks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Threaded RTS:
Don't start new worker threads earlier than necessary.
After this commit, a Haskell program that uses neither forkOS nor forkIO is
really single-threaded (rather than using two OS threads internally).
Some details:
Worker threads are now only created when a capability is released, and
only when
(there are no worker threads)
&& (there are runnable Haskell threads ||
there are Haskell threads blocked on IO or threadDelay)
awaitEvent can now be called from bound thread scheduling loops
(so that we don't have to create a worker thread just to run awaitEvent)
|
|
|
|
|
|
|
| |
Make sure that the sequence
rts_lock();
rts_unlock(); /* (with nothing in between) */
doesn't crash the threaded RTS.
|
|
|
|
|
|
|
|
|
| |
rts_getBool: we should check the constructor tag instead of comparing
directly against False_closure and True_closure, since we might be
using the dynamically-linked versions of these.
This may or may not be the cause of bug [ 792761 ] rts_getBool: not a
Bool.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Bound Threads
=============
Introduce a way to use foreign libraries that rely on thread local state
from multiple threads (mainly affects the threaded RTS).
See the file threads.tex in CVS at haskell-report/ffi/threads.tex
(not entirely finished yet) for a definition of this extension. A less formal
description is also found in the documentation of Control.Concurrent.
The changes mostly affect the THREADED_RTS (./configure --enable-threaded-rts),
except for saving & restoring errno on a per-TSO basis, which is also necessary
for the non-threaded RTS (a bugfix).
Detailed list of changes
------------------------
- errno is saved in the TSO object and restored when necessary:
ghc/includes/TSO.h, ghc/rts/Interpreter.c, ghc/rts/Schedule.c
- rts_mainLazyIO is no longer needed, main is no special case anymore
ghc/includes/RtsAPI.h, ghc/rts/RtsAPI.c, ghc/rts/Main.c, ghc/rts/Weak.c
- passCapability: a new function that releases the capability and "passes"
it to a specific OS thread:
ghc/rts/Capability.h ghc/rts/Capability.c
- waitThread(), scheduleWaitThread() and schedule() get an optional
Capability *initialCapability passed as an argument:
ghc/includes/SchedAPI.h, ghc/rts/Schedule.c, ghc/rts/RtsAPI.c
- Bound Thread scheduling (that's what this is all about):
ghc/rts/Schedule.h, ghc/rts/Schedule.c
- new Primop isCurrentThreadBound#:
ghc/compiler/prelude/primops.txt.pp, ghc/includes/PrimOps.h, ghc/rts/PrimOps.hc,
ghc/rts/Schedule.h, ghc/rts/Schedule.c
- a simple function, rtsSupportsBoundThreads, that returns true if THREADED_RTS
is defined:
ghc/rts/Schedule.h, ghc/rts/Schedule.c
- a new implementation of forkProcess (the old implementation stays in place
for the non-threaded case). Partially broken; works for the standard
fork-and-exec case, but not for much else. A proper forkProcess is
really next to impossible to implement:
ghc/rts/Schedule.c
- Library support for bound threads:
Control.Concurrent.
rtsSupportsBoundThreads, isCurrentThreadBound, forkOS,
runInBoundThread, runInUnboundThread
libraries/base/Control/Concurrent.hs, libraries/base/Makefile,
libraries/base/include/HsBase.h, libraries/base/cbits/forkOS.c (new file)
|
|
|
|
| |
Warning police: fix a few 64-bit warnings
|
|
|
|
| |
Remove ancient vestiges of StgHugs: the COMPILER #define.
|
|
|
|
|
|
|
|
|
|
|
| |
This should have been committed along with rev. 1.36 of Main.c (and
others) yesterday, but for some reason it got left out.
Change the way Main.main is run, so it now doesn't force the return
value. Now 'main = return undefined' will run and exit successfully.
The change affects finalizers too - but since they have type IO (), it
won't do any harm not to evaluate the ().
|
|
|
|
| |
Oops, Add rts_getFunPtr too.
|
|
|
|
|
|
|
| |
rts_mkFunPtr and rts_getFunPtr were missing. Thanks to Daan Leijen
for spotting and reporting the bug.
MERGE TO STABLE
|
|
|
|
|
| |
Un-break the non-threaded RTS
Sorry :-/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit fixes many bugs and limitations in the threaded RTS.
There are still some issues remaining, though.
The following bugs should have been fixed:
- [+] "safe" calls could cause crashes
- [+] yieldToReturningWorker/grabReturnCapability
- It used to deadlock.
- [+] couldn't wake blocked workers
- Calls into the RTS could go unanswered for a long time, and
that includes ordinary callbacks in some circumstances.
- [+] couldn't block on an MVar and expect to be woken up by a signal
handler
- Depending on the exact situation, the RTS shut down or
blocked forever and ignored the signal.
- [+] The locking scheme in RtsAPI.c didn't work
- [+] run_thread label in wrong place (schedule())
- [+] Deadlock in GHC.Handle
- if a signal arrived at the wrong time, an mvar was never
filled again
- [+] Signals delivered to the "wrong" thread were ignored or handled
too late.
Issues:
*) If GC can move TSO objects (I don't know - can it?), then ghci
will occasionally crash when calling foreign functions, because the
parameters are stored on the TSO stack.
*) There is still a race condition lurking in the code
(both threaded and non-threaded RTS are affected):
If a signal arrives after the check for pending signals in
schedule(), but before the call to select() in awaitEvent(),
select() will be called anyway. The signal handler will be
executed much later than expected.
*) For Win32, GHC doesn't yet support non-blocking IO, so while a
thread is waiting for IO, no call-ins can happen. If the RTS is
blocked in awaitEvent, it uses a polling loop on Win32, so call-ins
should work (although the polling loop looks ugly).
*) Deadlock detection is disabled for the threaded rts, because I
don't know how to do it properly in the presence of foreign call-ins
from foreign threads.
This causes the tests conc031, conc033 and conc034 to fail.
*) "safe" is currently treated as "threadsafe". Implementing "safe" in
a way that blocks other Haskell threads is more difficult than was
thought at first. I think it could be done with a few additional lines
of code, but personally, I'm strongly in favour of abolishing the
distinction.
*) Running finalizers at program termination is inefficient - there
are two OS threads passing messages back and forth for every finalizer
that is run. Also (just as in the non-threaded case) the finalizers
are run in parallel to any remaining haskell threads and to any
foreign call-ins that might still happen.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Merge the eval-apply-branch on to the HEAD
------------------------------------------
This is a change to GHC's evaluation model in order to ultimately make
GHC more portable and to reduce complexity in some areas.
At some point we'll update the commentary to describe the new state of
the RTS. Pending that, the highlights of this change are:
- No more Su. The Su register is gone, update frames are one
word smaller.
- Slow-entry points and arg checks are gone. Unknown function calls
are handled by automatically-generated RTS entry points (AutoApply.hc,
generated by the program in utils/genapply).
- The stack layout is stricter: there are no "pending arguments" on
the stack any more, the stack is always strictly a sequence of
stack frames.
This means that there's no need for LOOKS_LIKE_GHC_INFO() or
LOOKS_LIKE_STATIC_CLOSURE() any more, and GHC doesn't need to know
how to find the boundary between the text and data segments (BIG WIN!).
- A couple of nasty hacks in the mangler caused by the neet to
identify closure ptrs vs. info tables have gone away.
- Info tables are a bit more complicated. See InfoTables.h for the
details.
- As a side effect, GHCi can now deal with polymorphic seq. Some bugs
in GHCi which affected primitives and unboxed tuples are now
fixed.
- Binary sizes are reduced by about 7% on x86. Performance is roughly
similar, some programs get faster while some get slower. I've seen
GHCi perform worse on some examples, but haven't investigated
further yet (GHCi performance *should* be about the same or better
in theory).
- Internally the code generator is rather better organised. I've moved
info-table generation from the NCG into the main codeGen where it is
shared with the C back-end; info tables are now emitted as arrays
of words in both back-ends. The NCG is one step closer to being able
to support profiling.
This has all been fairly thoroughly tested, but no doubt I've messed
up the commit in some way.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix a bug and clean up some cruft in here:
- In each function in the rts_getXXXX() family, there was a test that
the object is actually of the desired type by examining its info
table. Some of these tests were disabled, but there was no comment
explaining why. I've just (re-)discovered the reason: the
info table might be dynamically-loaded in the GHCi case.
Not all the tests were disabled, which lead to bugs using the FFI
in GHCi (in particular with functions that return Float or Double).
- I've added consistent, but commented out, assertions to each of
the rts_getXXXX() functions, and left a comment explaining why
these reasonable-looking assertions are disabled.
MERGE TO STABLE
|
|
|
|
|
| |
Use an stg_ap_2 thunk rather than an AP_UPD in rts_apply(). Saves one
word per rts_apply(), and a little time too.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When handling external call-ins (via the RTS API) in
the multi-threaded case, add the StgMainThread that
the external thread is going to block waiting on
to the main_threads list prior to scheduling the new
worker thread.
Do this by having the scheduler provide a new entry
point, scheduleWaitThread().
Fixes a bug/race condition spotted by Wolfgang Thaller
(see scheduleWaitThread() comment) + enables a little
tidier interface between RtsAPI and Schedule.
|
|
|
|
| |
entry points that scheduled/created an external thread weren't correctly blocking on the TSO condition variable; now fixed.
|
|
|
|
| |
Use scheduleExtThread() (see 20020214 commit msg for SchedAPI.h for details)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Revised implementation of multi-threaded callouts (and callins):
- unified synchronisation story for threaded and SMP builds,
following up on SimonM's suggestion. The following synchro
variables are now used inside the Scheduler:
+ thread_ready_cond - condition variable that is signalled
when a H. thread has become runnable (via the THREAD_RUNNABLE()
macro) and there are available capabilities. Waited on:
+ upon schedule() entry (iff no caps. available).
+ when a thread inside of the Scheduler spots that there
are no runnable threads to service, but one or more
external call is in progress.
+ in resumeThread(), waiting for a capability to become
available.
Prior to waiting on thread_ready_cond, a counter rts_n_waiting_tasks
is incremented, so that we can keep track of the number of
readily available worker threads (need this in order to make
an informed decision on whether or not to create a new thread
when an external call is made).
+ returning_worker_cond - condition variable that is waited
on by an OS thread that has finished executing and external
call & now want to feed its result back to the H thread
that made the call. Before doing so, the counter
rts_n_returning_workers is incremented.
Upon entry to the Scheduler, this counter is checked for &
if it is non-zero, the thread gives up its capability and
signals returning_worker_cond before trying to re-grab a
capability. (releaseCapability() takes care of this).
+ sched_mutex - protect Scheduler data structures.
+ gc_pending_cond - SMP-only condition variable for signalling
completion of GCs.
- initial implementation of call-ins, i.e., multiple OS threads
may concurrently call into the RTS without interfering with
each other. Implementation uses cheesy locking protocol to
ensure that only one OS thread at a time can construct a
function application -- stop-gap measure until the RtsAPI
is revised (as discussed last month) *and* a designated
block is used for allocating these applications.
- In the implementation of call-ins, the OS thread blocks
waiting for an RTS worker thread to complete the evaluation
of the function application. Since main() also uses the
RtsAPI, provide a separate entry point for it (rts_mainEvalIO()),
which avoids creating a separate thread to evaluate Main.main,
that can be done by the thread exec'ing main() directly.
[Maybe there's a tidier way of doing this, a bit ugly the
way it is now..]
There are a couple of dark corners that needs to be looked at,
such as conditions for shutting down (and how) + consider what
ought to happen when async I/O is thrown into the mix (I know
what will happen, but that's maybe not what we want).
Other than that, things are in a generally happy state & I hope
to declare myself done before the week is up.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Deadlock is now an exception instead of a return status from
rts_evalIO().
The current behaviour is as follows, and can be changed if necessary:
in the event of a deadlock, the top main thread is taken from the main
thread queue, and if it is blocked on an MVar or an Exception (for
throwTo), then it receives a Deadlock exception. If it is blocked on
a BLACKHOLE, we instead send it the NonTermination exception. Note
that only the main thread gets the exception: it is the responsibility
of the main thread to unblock other threads if necessary.
There's a slight difference in the SMP build: *all* the main threads
get an exception, because clearly none of them may make progress
(compared to the non-SMP situation, where all but the top main thread
are usually blocked).
|
|
|
|
|
|
|
|
|
| |
Add new function:
rts_evalStableIO (HsStablePtr s, /*out*/HsStablePtr *ret)
which is a version of rts_evalStrictIO() that can be invoked from
Haskell.
|
|
|
|
|
|
|
|
| |
- use SET_HDR rather than initialising header.info directly (fixes
potential bugs with profiling).
- add some masking to the Int32/Word32 cases to match the Int8-16 and
Word8-16 cases (potential 64-bit bugs).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change the story about POSIX headers in C compilation.
Until now, all C code in the RTS and library cbits has by default been
compiled with settings for POSIXness enabled, that is:
#define _POSIX_SOURCE 1
#define _POSIX_C_SOURCE 199309L
#define _ISOC9X_SOURCE
If you wanted to negate this, you'd have to define NON_POSIX_SOURCE
before including headers.
This scheme has some bad effects:
* It means that ccall-unfoldings exported via interfaces from a
module compiled with -DNON_POSIX_SOURCE may not compile when
imported into a module which does not -DNON_POSIX_SOURCE.
* It overlaps with the feature tests we do with autoconf.
* It seems to have caused borkage in the Solaris builds for some
considerable period of time.
The New Way is:
* The default changes to not-being-in-Posix mode.
* If you want to force a C file into Posix mode, #include as
the **first** include the new file ghc/includes/PosixSource.h.
Most of the RTS C sources have this include now.
* NON_POSIX_SOURCE is almost totally expunged. Unfortunately
we have to retain some vestiges of it in ghc/compiler so that
modules compiled via C on Solaris using older compilers don't
break.
|
|
|
|
| |
Full complement of sized Int/Word getter routines
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
-*- outline -*-
Time-stamp: <Thu Mar 22 2001 03:50:16 Stardate: [-30]6365.79 hwloidl>
This commit covers changes in GHC to get GUM (way=mp) and GUM/GdH (way=md)
working. It is a merge of my working version of GUM, based on GHC 4.06,
with GHC 4.11. Almost all changes are in the RTS (see below).
GUM is reasonably stable, we used the 4.06 version in large-ish programs for
recent papers. Couple of things I want to change, but nothing urgent.
GUM/GdH has just been merged and needs more testing. Hope to do that in the
next weeks. It works in our working build but needs tweaking to run.
GranSim doesn't work yet (*sigh*). Most of the code should be in, but needs
more debugging.
ToDo: I still want to make the following minor modifications before the release
- Better wrapper skript for parallel execution [ghc/compiler/main]
- Update parallel docu: started on it but it's minimal [ghc/docs/users_guide]
- Clean up [nofib/parallel]: it's a real mess right now (*sigh*)
- Update visualisation tools (minor things only IIRC) [ghc/utils/parallel]
- Add a Klingon-English glossary
* RTS:
Almost all changes are restricted to ghc/rts/parallel and should not
interfere with the rest. I only comment on changes outside the parallel
dir:
- Several changes in Schedule.c (scheduling loop; createThreads etc);
should only affect parallel code
- Added ghc/rts/hooks/ShutdownEachPEHook.c
- ghc/rts/Linker.[ch]: GUM doesn't know about Stable Names (ifdefs)!!
- StgMiscClosures.h: END_TSO_QUEUE etc now defined here (from StgMiscClosures.hc)
END_ECAF_LIST was missing a leading stg_
- SchedAPI.h: taskStart now defined in here; it's only a wrapper around
scheduleThread now, but might use some init, shutdown later
- RtsAPI.h: I have nuked the def of rts_evalNothing
* Compiler:
- ghc/compiler/main/DriverState.hs
added PVM-ish flags to the parallel way
added new ways for parallel ticky profiling and distributed exec
- ghc/compiler/main/DriverPipeline.hs
added a fct run_phase_MoveBinary which is called with way=mp after linking;
it moves the bin file into a PVM dir and produces a wrapper script for
parallel execution
maybe cleaner to add a MoveBinary phase in DriverPhases.hs but this way
it's less intrusive and MoveBinary makes probably only sense for mp anyway
* Nofib:
- nofib/spectral/Makefile, nofib/real/Makefile, ghc/tests/programs/Makefile:
modified to skip some tests if HWL_NOFIB_HACK is set; only tmp to record
which test prgs cause problems in my working build right now
|
|
|
|
| |
Fix bitrot in SMP code.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Re-organisation of ghc/lib/std and hslibs/lang
----------------------------------------------
In brief: move deprecated features out of ghc/lib/std and into
hslibs/lang, move new FFI libraries into ghc/lib/std and start
using them.
- foreign import may now return an unboxed type (this was
advertised to work before, but in fact didn't). Subsequent
cleanups in PrelInt/PrelWord.
- Ptr is now defined in ghc/lib/std/PrelPtr.lhs. Ptr is no
longer a newtype of Addr, it is defined directly in terms of
Addr#.
- PrelAddr has disappeared from ghc/lib/std, all uses of Addr in
ghc/lib/std have been replaced with Ptr. The definitions of
Addr has been moved to hslibs/lang/Addr.lhs, as has
lots of other Addr-related stuff.
- ForeignObj has been removed from ghc/lib/std, and replaced with
ForeignPtr. The definition of ForeignObj has been moved to
hslibs/lang/ForeignObj.lhs.
- Most of the new FFI has been moved into ghc/lib/std in the form
of modules PrelMarshalAlloc, PrelCString, PrelCError,
PrelMarshalError, PrelMarshalArray, PrelMarshalUtils,
PrelCTypes, PrelCTypesISO, and PrelStorable. The corresponding
modules in hslibs/lang simply re-export the contents of these
modules.
- PrelPosixTypes defines a few POSIX types (CMode == mode_t,
etc.)
- PrelCError changed to access errno using foreign label and peek
(the POSIX book I have says that errno is guaranteed to be an
extern int, so this should be OK until I get around to making
errno thread-safe).
- Hacked the macros that generate the code for CTypes and
CTypesISO to generate much less code
(ghc/lib/std/cbits/CTypes.h).
- RtsAPI is now a bit more honest when it comes to building heap
objects (it uses the correct constructors).
- the Bits class and related stuff has been moved to ghc/lib/std
(it was simpler this way).
- Directory and System have been converted to use the new FFI.
|
|
|
|
| |
merge recent changes from before-ghci-branch onto the HEAD
|
|
|
|
|
|
| |
Change the names of several RTS symbols so they don't potentially
clash with user code. All the symbols that may clash now have an
"stg_" prefix.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Clean ups:
- reduce the namespace pollution of StgTypes.h, it doesn't define
the shorthand versions any more (W_, I_ etc.). These are moved into
Stg.h. StgTypes.h also defines StgClosure as an "opaque" struct.
- RtsAPI.h is now standalone, and includes HsFFI.h and thereby
config.h & StgTypes.h. Now we don't need to #include "Stg.h" in
*_stub.c.
- all the rts_mkXXXX and rts_getXXXX functions are defined in terms
of the HsXXXX types rather than random C types (this fixes some
potential bugs in our foreign export support).
- added HsWord type, to match StgWord. The Haskell version of this
type isn't "documented", but perhaps it should be.
|
|
|
|
|
|
| |
Don't use a typedef called int64 in RtsAPI.
It conflicts with e.g. OCaml's headers.
It should be cleaned better...
|
|
|
|
|
| |
Minor cleanups to a few closure types: we don't use StgPtr in
Closures.h anymore.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now Char, Char#, StgChar have 31 bits (physically 32).
"foo"# is still an array of bytes.
CharRep represents 32 bits (on a 64-bit arch too). There is also
Int8Rep, used in those places where bytes were originally meant.
readCharArray, indexCharOffAddr etc. still use bytes. Storable and
{I,M}Array use wide Chars.
In future perhaps all sized integers should be primitive types. Then
some usages of indexing primops scattered through the code could
be changed to then-available Int8 ones, and then Char variants of
primops could be made wide (other usages that handle text should use
conversion that will be provided later).
I/O and _ccall_ arguments assume ISO-8859-1. UTF-8 is internally used
for string literals (only).
Z-encoding is ready for Unicode identifiers.
Ranges of intlike and charlike closures are more easily configurable.
I've probably broken nativeGen/MachCode.lhs:chrCode for Alpha but I
don't know the Alpha assembler to fix it (what is zapnot?). Generally
I'm not sure if I've done the NCG changes right.
This commit breaks the binary compatibility (of course).
TODO:
* is* and to{Lower,Upper} in Char (in progress).
* Libraries for text conversion (in design / experiments),
to be plugged to I/O and a higher level foreign library.
* PackedString.
* StringBuffer and accepting source in encodings other than ISO-8859-1.
|
|
|
|
| |
Give a more informative error message in rts_checkSchedStatus().
|
|
|
|
|
|
| |
Fix bug in rts_apply when profiling.
This fixes Sven's foreign export dynamic/profiling bug.
|
|
|
|
| |
Removed comments about HsFalse/HsTrue, we guarantee 0/1.
|
|
|
|
| |
Enable Bool in foreign import/export
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Numerous changes in the RTS to get GUM-4.06 working (currently works with
parfib-ish programs). Most changes are isolated in the rts/parallel dir.
rts/parallel/:
The most important changes are a rewrite of the (un-)packing code (Pack.c)
and changes in LAGA, GALA table operations (Global.c) expecially in
rebuilding the tables during GC.
rts/:
Minor changes in Schedule.c, GC.c (interface to par specific root marking
and evacuation), and lots of additions to Sanity.c (surprise ;-)
Main.c change for startup: I use a new function rts_evalNothing to
start non-main-PEs in a PAR || SMP setup (RtsAPI.c)
includes/:
Updated GranSim macros in PrimOps.h.
lib/std:
Few changes in PrelHandle.c etc replacing ForeignObj by Addr in a PAR
setup (we still don't support ForeignObjs or WeakPtrs in GUM).
Typically use
#define FILE_OBJECT Addr
when dealing with files.
hslibs/lang/:
Same as above (in Foreign(Obj).lhs, Weak.lhs, IOExts.lhs etc).
-- HWL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Handle references from the RTS to the Prelude in a more consistent
way.
- For statically-linked binaries, nothing has changed.
- For the interpreter, refs from the RTS to the Prelude
are now indirected. The indirections need to be
filled in at some point during startup by calling
fixupPreludeRefs (in Prelude.c).
- The CHARLIKE and INTLIKE tables are now handled in
the same way for both Hugs and DLLs.
Hugs will be broken for a short while until Julian sorts out the Hugs
parts of this change.
|
|
|
|
|
|
|
|
| |
Move Prelude.h from ghc/includes into ghc/rts. It's essentially a
list of the things from the Prelude that the RTS depends on, and isn't
relevant to STG code. Furthermore, this helps to clarify which parts
of the RTS depend on things from the Prelude (by an explicity
#include).
|