| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Merge backend-hacking-branch onto HEAD. Yay!
|
|
|
|
|
|
|
|
|
|
|
|
| |
Tidy up a couple of unportable coding issues:
- conditionally use empty structs.
- use GNU attributes only if supported.
- 'long long' usage
- use of 'inline' in declarations and definitions.
Upshot of these changes is that MSVC is now capable of compiling
the non-.hc portions of the RTS.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
New implementation & changed type signature of forkProcess
forkProcess now has the following type:
forkProcess :: IO () -> IO ProcessID
forkProcessAll has been removed as it is unimplementable in the threaded RTS.
forkProcess using the old type (IO (Maybe ProcessID)) was impossible to
implement correctly in the non-threaded RTS and very hard to implement
in the threaded RTS.
The new type signature allows a clean and simple implementation.
|
|
|
|
|
|
|
|
| |
Move forkOS_createThread into the RTS so its implementation can be
dependent on RTS_SUPPORTS_THREADS, which means we can provide a stub
implementation in the !RTS_SUPPORTS_THREADS case, and hence not depend
on pthread_create, which requires -lpthread. The upshot is that GHCi
now works again when !RTS_SUPPORTS_THREADS.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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)
|
|
|
|
|
|
|
|
|
|
|
| |
New primop (mingw only),
asyncDoProc# :: Addr# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
which lets a Haskell thread hand off a pointer to external code (1st arg) for
asynchronous execution by the RTS worker thread pool. Second arg is data passed
in to the asynchronous routine. The routine is _not_ permitted to re-enter
the RTS as part of its execution.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add raiseIO# primop.
This is part of ensuring that exceptions are *precise* in the IO monad
(as opposed to imprecise exceptions in the pure world). If we allow
the strictness analyser to see the definition of throwIO:
throwIO e = IO $ \s -> throw e
then it might re-order evaluation in the IO monad, with the result
that we get _|_ instead of an exception, or one kind of exception when
we were expecting another. We therefore must prevent the strictness
analyser from doing these reorderings in the IO monad. Hiding the
definition of throwIO by making it a primop solves part of the problem
(there's more to come).
See SourceForge bug #752149.
|
|
|
|
| |
Change argument of stg_exit to int in line with definition.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Asynchronous / non-blocking I/O for Win32 platforms.
This commit introduces a Concurrent Haskell friendly view of I/O on
Win32 platforms. Through the use of a pool of worker Win32 threads, CH
threads may issue asynchronous I/O requests without blocking the
progress of other CH threads. The issuing CH thread is blocked until
the request has been serviced though.
GHC.Conc exports the primops that take care of issuing the
asynchronous I/O requests, which the IO implementation now takes
advantage of. By default, all Handles are non-blocking/asynchronous,
but should performance become an issue, having a per-Handle flag for
turning off non-blocking could easily be imagined&introduced.
[Incidentally, this thread pool-based implementation could easily be
extended to also allow Haskell code to delegate the execution of
arbitrary pieces of (potentially blocking) external code to another OS
thread. Given how relatively gnarly the locking story has turned out
to be with the 'threaded' RTS, that may not be such a bad idea.]
|
|
|
|
|
|
|
|
|
|
| |
change the types of cmp_thread, rts_getThreadId, and labelThread to
take StgPtr rather than StgTSO *, since the compiler now has no
distinction between these two types in the back end.
I also noticed that labelThread need not be a primitive: it could just
as well be a normal C function called by the FFI, but I haven't made
that change.
|
|
|
|
| |
Add atomicModifyIORef, as discussed on the FFI list.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Partial rewrite of the POSIX library.
The main purpose of this sweep is to remove the last dependencies of
the compiler on hslibs. When I've committed the associated compiler
changes, only the 'base' package will be required to bootstrap the
compiler. Additionally to build GHCi, the 'readline' and 'unix'
packages will be required.
The new POSIX library lives mostly in libraries/unix, with a few bits
required for compiler bootstrapping in libraries/base. The 'base'
package is mostly free of hsc2hs code to make bootstrapping from HC
files easier, but the 'unix' package will use hsc2hs liberally.
The old POSIX library continues to provide more-or-less the same
interface as before, although some of the types are more correct now
(previously lots of POSIX types were just mapped to Int). The new
interface is largely the same as the old, except that some new
functionality from the latest POSIX spec has been added (eg. symbolic
links).
So far, the new POSIX library has signal support, directory/file
operations and lots of stuff from unistd.h. The module names are:
System.Posix
The main dude, exports everything
System.Posix.Types
All the POSIX types, using the same naming scheme as
Foreign.C.Types, Eg. CUid, COff, etc. Many of these types
were previously exported by GHC.Posix.
Additionally exports the "nicer" names used by the old POSIX
library for compatibility (eg. ProcessID == CPid, FileMode ==
CMode, etc.)
All reasonable instances are derived for these types.
System.Posix.Signals
Signal support, contains most of which was in PosixProcPrim before.
The RTS interface to the signal handling support has been
rationalised slightly.
System.Posix.Directory
Directory support, most were in PosixFiles before.
System.Posix.Files
File operations, most were in PosixFiles before.
System.Posix.Unistd
(for want of a better name) Miscellaneous bits that mostly come
from the unistd.h header file. PosixProcEnv before.
The rest of the library should pan out like so:
System.Posix.IO
System.Posix.Error (maybe)
System.Posix.Process
System.Posix.Terminal
(I've no doubt broken Win32 support, but I'm checking the build at the moment).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Remove most #includes of system headers from Stg.h, and instead
#include any required headers directly in each RTS source file.
The idea is to (a) reduce namespace pollution from system headers that
we don't need, (c) be clearer about dependencies on system things in
the RTS, and (c) improve via-C compilation times (maybe).
In practice though, HsBase.h #includes everything anyway, so the
difference from the point of view of .hc source is minimal. However,
this makes it easier to move to zero-includes if we wanted to (see
discussion on the FFI list; I'm still not sure that's possible but
at least this is a step in the right direction).
|
|
|
|
|
|
|
| |
Given how CPP works, the prev. commit does not cut the mustard.
Reduce the risk of name clashes by giving the #defines some more
obscure names instead.
|
|
|
|
|
| |
#undef C & R after using them, we don't want to pollute C's namespace
with one-character #defines...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Two new scheduler-API primops:
1) GHC.Conc.forkProcess/forkProcess# :: IO Int
This is a low-level call to fork() to replace Posix.forkProcess().
In a Concurrent Haskell setting, only the thread invoking forkProcess()
is alive in the child process. Other threads will be GC'ed!
This brings the RTS closer to pthreads, where a call to fork()
doesn't clone any pthreads, either.
The result is 0 for the child and the child's pid for the parent.
The primop will barf() when used on mingw32, sorry.
2) GHC.Conc.labelThread/forkProcess# :: String -> IO ()
Useful for scheduler debugging: If the RTS is compiled with DEBUGging
support, this primitive assigns a name to the current thread which
will be used in debugging output (+RTS -D1). For larger applications,
simply numbering threads is not sufficient.
Notice: The Haskell side of this call is always available, but if
you are not compiling with debugging support, the actual primop will
turn into a no-op.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix 64-bit shift operations.
- Move the declarations of the 64-bit "primops" from PrimOps.h to
HsBase.h where they more properly belong.
- change the names of the 64-bit shift ops to include the "unchecked"
prefix
- add checked versions of these primops to GHC.Int and GHC.Word, and
use them.
- update the FFI declarations in GHC.Int and GHC.Word while I'm there.
|
|
|
|
| |
re-introduce dataToTagzh macro (unreg builds only)
|
|
|
|
| |
Fix various bugs in the implementation of subIntC and mulMayOflo.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Get rid of multiple-result MachOps (MO_NatS_AddC, MO_NatS_SubC,
MO_NatS_MulC) which implement {add,sub,mul}IntC#. Supporting gunk
in the NCG disappears as a result.
Instead:
* {add,sub}IntC# are translated out during abstract C simplification,
turning into the xor-xor-invert-and-shift sequence previously defined
in PrimOps.h.
* mulIntC# is more difficult to get rid of portably. Instead we have
a new single-result PrimOp, mulIntMayOflo, with corresponding MachOp
MO_NatS_MulMayOflo. This tells you whether a W x W -> W signed
multiply might overflow, where W is the word size. When W=32, is
implemented by computing a 2W-long result. When W=64, we use the
previous approximation.
PrelNum.lhs' implementation of timesInteger changes slightly, to use
the new PrimOp.
|
|
|
|
| |
restore ForeignObj_CLOSURE_DATA - still used by PprAbsC.ppr_casm_arg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change the story on shifting primops: SllOp, SrlOp, ISllOp, ISraOp, ISrlOp.
In the old primop story, these were implemented by C macros which
checked that the shift amount did not exceed the word size, and if so
returns a suitable value (0 or -1). This gives consistent, defined
behaviour for any shift amount. However, these checks were not
implemented on the NCG route, an inconsistency.
New story: these primops do NOT check their args; they just do the shift.
Shift values >= word size give undefined results. To reflect this, their
Haskell names have been prefixed with 'unchecked'.
The checks are now done on the Bits instances in the Prelude. This means
all code generation routes are consistently checked, and hopefully the
simplifier will remove the checks for literal shift amounts.
I have tried to fix up the implementation for 64-bit platforms too, but
not having one to hand, I don't know if it will work as-is.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
--------------------------------------------
Translate out PrimOps at the AbstractC level
--------------------------------------------
This is the first in what might be a series of changes intended
to make GHC less dependent on its C back end. The main change is
to translate PrimOps into vanilla abstract C inside the compiler,
rather than having to duplicate that work in each code generation
route. The main changes are:
* A new type, MachOp, in compiler/absCSyn/MachOp.hs. A MachOp
is a primitive operation which we can reasonably expect the
native code generators to implement. The set is quite small
and unlikely to change much, if at all.
* Translations from PrimOps to MachOps, at the end of
absCSyn/AbsCUtils. This should perhaps be moved to a different
module, but it is hard to see how to do this without creating
a circular dep between it and AbsCUtils.
* The x86 insn selector has been updated to track these changes. The
sparc insn selector remains to be done.
As a result of this, it is possible to compile much more code via the
NCG than before. Almost all the Prelude can be compiled with it.
Currently it does not know how to do 64-bit code generation. Once
this is fixed, the entire Prelude should be compilable that way.
I also took the opportunity to clean up the NCG infrastructure.
The old Stix data type has been split into StixStmt (statements)
and StixExpr (now denoting values only). This removes a class
of impossible constructions and clarifies the NCG.
Still to do, in no particular order:
* String and literal lifting, currently done in the NCG at the top
of nativeGen/MachCode, should be done in the AbstractC flattener,
for the benefit of all targets.
* Further cleaning up of Stix assignments.
* Remove word-size dependency from Abstract C. (should be easy).
* Translate out MagicIds in the AbsC -> Stix translation, not
in the Stix constant folder. (!)
Testsuite failures caused by this:
* memo001 - fails (segfaults) for some unknown reason now.
* arith003 - wrong answer in gcdInt boundary cases.
* arith011 - wrong answer for shifts >= word size.
* cg044 - wrong answer for some FP boundary cases.
These should be fixed, but I don't think they are mission-critical for
anyone.
|
|
|
|
| |
StablePtr indexes/counts are no longer weighted (i.e., sync wrt Stable.{c,h} changes)
|
|
|
|
|
| |
Added Show instance for Concurrent.ThreadId; useful when
debugging/diagnosing.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix a bug with arithmetic primops on platforms where StgInt is not int,
such as the 64-bit Alpha. The bug is that, for example,
1# `iShiftL#` 32#
returns zero rather than 2^32. The reason is that we should cast the
macro arguments to I_ in the definition of iShiftL#, but did not.
MERGE TO STABLE
|
|
|
|
| |
Use char * instead of void * for pointer arithmetic.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
How I spent my summer vacation.
Primops
-------
The format of the primops.txt.pp file has been enhanced to allow
(latex-style) primop descriptions to be included. There is a new flag
to genprimopcode that generates documentation including these
descriptions. A first cut at descriptions of the more interesting
primops has been made, and the file has been reordered a bit.
31-bit words
------------
The front end now can cope with the possibility of 31-bit (or even 30-bit)
Int# and Word# types. The only current use of this is to generate
external .core files that can be translated into OCAML source files
(OCAML uses a one-bit tag to distinguish integers from pointers).
The only way to get this right now is by hand-defining the preprocessor
symbol WORD_SIZE_IN_BITS, which is normally set automatically from
the familiar WORD_SIZE_IN_BYTES.
Just in case 31-bit words are used, we now have Int32# and Word32# primitive types
and an associated family of operators, paralleling the existing 64-bit
stuff. Of course, none of the operators actually need to be implemented
in the absence of a 31-bit backend.
There has also been some minor re-jigging of the 32 vs. 64 bit stuff.
See the description at the top of primops.txt.pp file for more details.
Note that, for the first time, the *type* of a primop can now depend
on the target word size.
Also, the family of primops intToInt8#, intToInt16#, etc.
have been renamed narrow8Int#, narrow16Int#, etc., to emphasize
that they work on Int#'s and don't actually convert between types.
Addresses
---------
As another part of coping with the possibility of 31-bit ints,
the addr2Int# and int2Addr# primops are now thoroughly deprecated
(and not even defined in the 31-bit case) and all uses
of them have been removed except from the (deprecated) module
hslibs/lang/Addr
Addr# should now be treated as a proper abstract type, and has these suitable operators:
nullAddr# : Int# -> Addr# (ignores its argument; nullary primops cause problems at various places)
plusAddr# : Addr# -> Int# -> Addr#
minusAddr : Addr# -> Addr# -> Int#
remAddr# : Addr# -> Int# -> Int#
Obviously, these don't allow completely arbitrary offsets if 31-bit ints are
in use, but they should do for all practical purposes.
It is also still possible to generate an address constant, and there is a built-in rule
that makes use of this to remove the nullAddr# calls.
Misc
----
There is a new compile flag -fno-code that causes GHC to quit after generating .hi files
and .core files (if requested) but before generating STG.
Z-encoded names for tuples have been rationalized; e.g.,
Z3H now means an unboxed 3-tuple, rather than an unboxed
tuple with 3 commas (i.e., a 4-tuple)!
Removed misc. litlits in hslibs/lang
Misc. small changes to external core format. The external core description
has also been substantially updated, and incorporates the automatically-generated
primop documentation; its in the repository at /papers/ext-core/core.tex.
A little make-system addition to allow passing CPP options to compiler and
library builds.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Had a brainwave on the way to work this morning, and realised that the
garbage collector can handle "pinned objects" as long as they don't
contain any pointers.
This is absolutely ideal for doing temporary allocation in the FFI,
because what we really want to do is allocate a pinned ByteArray and
let the GC clean it up later. So this set of changes adds the
required framework.
There are two new primops:
newPinnedByteArray# :: Int# -> State# s -> (# State# s, MutByteArr# s #)
byteArrayContents# :: ByteArr# -> Addr#
obviously byteArrayContents# is highly unsafe.
Allocating a pinned ByteArr# isn't the default, because a pinned
ByteArr# will hold an entire block (currently 4k) live until it is
garbage collected (that doesn't mean each pinned ByteArr# requires
4k of storage, just that if a block contains a single live pinned
ByteArray, the whole block must be retained).
|
|
|
|
| |
Innocent changes to resurrect/add 64-bit support.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Heal HEID
- eqForeignObjZh in include/PrimOps.h didn't have quite the right
shape (the result is a macro arg). hslibs/lang/ForeignObj
wasn't up on the change to eqForeignObj now being a primop.
- recent ghc/compiler/deSugar/ changes broke the handling of
CCall & FFI decls quite a bit. Backed out most the rewrites
of Type.splitFoo to TcType.tcSplitFoo (i.e., now back to using
TcType.tcSplitFoo).
The backed-out newtype-related changes were by no means accidental.
But, I don't profess to understand their intention to make the
proper fix, so my change is just a stop-gap measure to get HEAD
back to the land of the living.
- recent changes to the behaviour of 'hiding' & qualified names
broke hslibs/lang/CString hslibs/data/edison/Seq/ListSeq,
hslibs/data/edison/Coll/TestOrdBag, hslibs/data/edison/Coll/UnbalancedSet,
hslibs/data/edison/Coll/TestOrdSet, hslibs/data/edison/Seq/TestSeq
- rename 64-bit 'primop' funs that now live in lib/std/cbits/longlong.c
back to what they used to be called (i.e., prefixed with "stg_").
Why?
- less likely they'll clash with other (user supplied) entry points
at link-time.
- matches protos in ghc/includes/PrimOp.h
|
|
|
|
| |
Make eqForeignObj a primop; N.B. Not implemented for the NCG
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
-*- 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add {intToInt,wordToWord}{8,16,32}# primops. WARNING: Not implemented
in ncg for Alpha and Sparc. But -O -fasm is not going to go far anyway
because of other omissions.
* Have full repertoire of 8,16,32-bit signed and unsigned MachMisc.Size
values. Again only x86 is fully supported. They are used for
{index,read,write}{Int,Word}{8,16,32}{OffAddr,Array}# and
{intToInt,wordToWord}{8,16,32}# primops.
* Have full repertoire of
{index,read,write}\
{Char,WideChar,Int,Word,Addr,Float,Double,StablePtr,\
{Int,Word}{8,16,32,64}}\
{OffAddr,Array} primops and appropriate instances.
There were various omissions in various places.
* Add {plus,minus,times}Word# primops to avoid so many Word# <-> Int#
coercions.
* Rewrite modules PrelWord and PrelInt almost from scratch.
* Simplify fromInteger and realToFrac rules. For each of
{Int,Word}{8,16,32} there is just a pair of fromInteger rules
replacing the source or target type with Int or Word. For
{Int,Word,Int64,Word64} there are rules from any to any.
Don't include rules which are derivable from inlining anyway,
e.g. those mentioning Integer. Old explicit coercions are simply
defined as appropriately typed fromInteger.
* Various old coercion functions marked as deprecated.
* Add instance Bits Int, and
instance {Show,Num,Real,Enum,Integral,Bounded,Ix,Read,Bits} Word.
* Coercions to sized integer types consistently behave as cutting the
right amount of bits from the infinite two-complement representation.
For example (fromIntegral (-1 :: Int8) :: Word64) == maxBound.
* ghc/tests/numeric/should_run/arith011 tests {Int,Word}64 and instance
Bits Int, and does not try to use overflowing toEnum. arith011.stdout
is not updated yet because of a problem I will tell about soon.
* Move fromInteger and realToFrac from Prelude to PrelReal.
Move fromInt from PrelNum to PrelReal and define as fromInteger.
Define toInt as fromInteger. fromInteger is the place to write
integer conversion rules for.
* Remove ArrayBase.newInitialisedArray, use default definition of
newArray instead.
* Bugs fixed:
- {quot,rem}Word# primop attributes.
- integerToInt64# for small negative values.
- {min,max}Bound::Int on 64-bit platforms.
- iShiftRL64#.
- Various Bits instances.
* Polishing:
- Use 'ppr' instead of 'pprPrimOp' and 'text . showPrimRep'.
- PrimRep.{primRepString,showPrimRepToUser} removed.
- MachMisc.sizeOf returns Int instead of Integer.
- Some eta reduction, parens, spacing, and reordering cleanups -
sorry, couldn't resist.
* Questions:
- Should iShiftRL and iShiftRL64 be removed? IMHO they should,
s/iShiftRA/iShiftR/, s/shiftRL/shiftR/. The behaviour on shifting
is a property of the signedness of the type, not the operation!
I haven't done this change.
|
|
|
|
|
|
|
| |
- make putMVar block rather than raise an exception when it encounters a
full MVar (to match the semantics in our recent paper on async excpetions).
- add tryPutMVar, a non-blocking version of putMVar.
|
|
|
|
| |
rename sig_install to stg_sig_install
|
|
|
|
|
| |
Add mkApUpd0# primop, used to make sure bytecode-compiled top-level things
are updateable.
|
|
|
|
|
| |
Start getting the bytecode interpreter to work. A matching commit to
compiler/ghci/ByteCodeGen.lhs follows ...
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Add primops for {read,write,index}{Int,Word}{8,16,32,64}OffAddr.
This enables us to remove all the _casm_s from Int/Word.
- Replace new{Char,Int,etc.}Array# with newByteArray# (save a few primops,
at the cost of having to know the size of these types in PrelArr).
- Implement MArray/IArray support for sized types. finally.
- Move the guts of the sized types into ghc/lib/std, we'll need
them for doing more FFIish things in the Prelude.
|
|
|
|
| |
New BCO primops.
|
|
|
|
| |
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.
|
|
|
|
|
| |
Wave goodbye to FLOATS_AS_DOUBLES, it was a somewhat misconceived idea
which will cause trouble with the FFI on 64-bit machines.
|
|
|
|
|
| |
merge before-ghci -> before-ghci-branch-merged into the ghc
(non-compiler) parts of the tree.
|
|
|
|
| |
remove superfluous defns of index{Word,Ptr}OffClosure
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Remove all traces of addr2Integer. Big integer literals are now
done by multiplying up small integers.
* As a result, we can remove PrelNum.hi-boot altogether.
* Correct the default method for (==) in PrelBase. (It simply
returned True, which seems bogus to me!)
* Add a type signature for PrelBase.mapFB
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Initial primop support for the metacircular interpreter (GHCI).
Only appears if you compile with -DGHCI; if not, the world is
unchanged.
new primops:
indexPtrOffClosure#
indexWordOffClosure#
modified:
dataToTag# -- now dereferences indirections before extracting tag
new entry code
mci_constr_entry and
mci_constr[1..8]entry
being the direct and vectored return code fragments for interpreter
created constructors. Support for static constructors is not yet
done.
New handwritten .hc functions:
mci_make_constr*
being code to create various flavours of constructors from args
on the stack. An interface file to describe these will follow in
a later commit.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- add touch# and foreignObjToAddr# primops.
- add these functions to ForeignObj:
withForeignObj :: ForeignObj -> (Addr -> IO a) -> IO a
touchForeignObj :: ForeignObj -> IO ()
- foreignObjToAddr, which was previously implemented using a _casm_, now
uses the foreignObjToAddr# primop.
- replace implementations of readXXXOffForeignObj and writeXXXOffForeignObj
using the withForeignObj and the Addr operations. ForeignObj.lhs now has
no _casms_ in it! (it still can't be compiled with the NCG though, because
it has a f.i.d.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Changed ERTSF_ to EXTFUN_RTS.
|