| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
This file shouldn't be in the repository any more (there's a
PrelGHC.hi-boot.pp).
Why is it only me that notices these phantom leftovers? Why don't they cause
problems for other people?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
NB: This commit renames some files. In each of your build directories,
you will need to:
rm -f ghc/compiler/prelude/primops.txt
rm -f ghc/compiler/prelude/primops.i
rm -f ghc/lib/std/PrelGHC.hi-boot
lndir ../fptools # or wherever your CVS working directory is
The change:
Run PrelGHC.hi-boot through the preprocesor, as we already do primops.txt.
This commit introduces a new prefix, ".pp", which means "run through
preprocesor". In a previous commit, I changed ghc/compiler/Makefile
to preprocess primops.txt into primops.i. That is gone now. We now
preprocess primops.txt.pp (a file in the CVS repository) into primops.txt
(a platform-dependent file, created at build time). We also preprocess
PrelGHC.hi-boot.pp (a file in the CVS repository) into PrelGHC.hi-boot
(a platform-dependent file, created at build time).
The reason for using the preprocessor is because fewer primops are defined
if SUPPORT_LONG_LONGS is undefined. SUPPORT_LONG_LONGS is undefined on
64-bit architectures such as the Alpha.
|
|
|
|
| |
Make eqForeignObj a primop; N.B. Not implemented for the NCG
|
|
|
|
| |
PrelGHC is package 'std'
|
|
|
|
| |
remove 4 old primops
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
| |
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 BCOzh
|
|
|
|
| |
nuke getBCOPtrszh
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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
|
|
|
|
|
| |
merge before-ghci -> before-ghci-branch-merged into the ghc
(non-compiler) parts of the tree.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Many fixes to DLLisation. These were previously covered up because code was
leaking into the import libraries for DLLs, so the fact that some symbols
were thought of as local rather than in another DLL wasn't a problem.
The main problems addressed by this commit are:
1. Fixes RTS symbols working properly when DLLised. They didn't before.
2. Uses NULL instead of stg_error_entry, because DLL entry points can't be
used as static initialisers.
3. PrelGHC.hi-boot changed to be in package RTS, and export of PrelNum and
PrelErr moved to PrelBase, so that references to primops & the like
are cross-DLL as they should be.
4. Pass imports around as Modules rather than ModuleNames, so that
ModuleInitLabels can be checked to see if they're in a DLL or not.
|
|
|
|
|
| |
This file had version 407 burned into it; the convention is that zero
means "don't check the version".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
~~~~~~~~~~~~
Apr/May 2000
~~~~~~~~~~~~
This is a pretty big commit! It adds stuff I've been working on
over the last month or so. DO NOT MERGE IT WITH 4.07!
Interface file formats have changed a little; you'll need
to make clean before remaking.
Simon PJ
Recompilation checking
~~~~~~~~~~~~~~~~~~~~~~
Substantial improvement in recompilation checking. The version management
is now entirely internal to GHC. ghc-iface.lprl is dead!
The trick is to generate the new interface file in two steps:
- first convert Types etc to HsTypes etc, and thereby
build a new ParsedIface
- then compare against the parsed (but not renamed) version of the old
interface file
Doing this meant adding code to convert *to* HsSyn things, and to
compare HsSyn things for equality. That is the main tedious bit.
Another improvement is that we now track version info for
fixities and rules, which was missing before.
Interface file reading
~~~~~~~~~~~~~~~~~~~~~~
Make interface files reading more robust.
* If the old interface file is unreadable, don't fail. [bug fix]
* If the old interface file mentions interfaces
that are unreadable, don't fail. [bug fix]
* When we can't find the interface file,
print the directories we are looking in. [feature]
Type signatures
~~~~~~~~~~~~~~~
* New flag -ddump-types to print type signatures
Type pruning
~~~~~~~~~~~~
When importing
data T = T1 A | T2 B | T3 C
it seems excessive to import the types A, B, C as well, unless
the constructors T1, T2 etc are used. A,B,C might be more types,
and importing them may mean reading more interfaces, and so on.
So the idea is that the renamer will just import the decl
data T
unless one of the constructors is used. This turns out to be quite
easy to implement. The downside is that we must make sure the
constructors are always available if they are really needed, so
I regard this as an experimental feature.
Elimininate ThinAir names
~~~~~~~~~~~~~~~~~~~~~~~~~
Eliminate ThinAir.lhs and all its works. It was always a hack, and now
the desugarer carries around an environment I think we can nuke ThinAir
altogether.
As part of this, I had to move all the Prelude RdrName defns from PrelInfo
to PrelMods --- so I renamed PrelMods as PrelNames.
I also had to move the builtinRules so that they are injected by the renamer
(rather than appearing out of the blue in SimplCore). This is if anything simpler.
Miscellaneous
~~~~~~~~~~~~~
* Tidy up the data types involved in Rules
* Eliminate RnEnv.better_provenance; use Name.hasBetterProv instead
* Add Unique.hasKey :: Uniquable a => a -> Unique -> Bool
It's useful in a lot of places
* Fix a bug in interface file parsing for __U[!]
|
|
|
|
| |
rename takeMaybeMVar to tryTakeMVar
|
|
|
|
| |
Removed the useless (and hard to implement) readForeignObjOffAddr#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add support for 'packages'.
* A package is a group of modules.
* A package has a name (e.g. std)
* A package is built into a single library (Unix; e.g. libHSstd.a)
or a single DLL (Windows; e.g. HSstd.dll)
* The '-package-name foo' flag tells GHC that the module being compiled
is destined for package foo.
* The '-package foo' flag tells GHC to make available modules
from package 'foo'. It replaces '-syslib foo' which is now deprecated.
* Cross-package references cost an extra indirection in Windows,
but not Unix
* GHC does not maintain detailed cross-package dependency information.
It does remember which modules in other packages the current module
depends on, but not which things within those imported things.
All of this tidies up the Prelude enormously. The Prelude and
Standard Libraries are built into a singl package called 'std'. (This
is a change; the library is now called libHSstd.a instead of libHS.a)
|
|
|
|
|
| |
Add takeMaybeMVarzh (I'm doing this commit in bits, since my working
sources are so full of changes I can't easily unpick them...)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Cleaning up the foreign object naming mess:
* Renamed the primop from makeForeignObj# to mkForeignObj#, this
is more consistent with the old Foreign.mkForeignObj.
* PrelForeign now exports makeForeignObj with the new signature.
* freeFile.c now uses StgAddr instead of StgForeignObj, this
removes the need for some fixIOs.
* Lots of import tweaking to prepare The Big Foreign Renamer,
which will move most of Foreign to ForeignObj, and FFI to Foreign.
Note: I've tried to track the changes in the interpreter sources, but
didn't test them.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This utterly gigantic commit is what I've been up to in background
mode in the last couple of months. Originally the main goal
was to get rid of Con (staturated constant applications)
in the CoreExpr type, but one thing led to another, and I kept
postponing actually committing. Sorry.
Simon, 23 March 2000
I've tested it pretty thoroughly, but doubtless things will break.
Here are the highlights
* Con is gone; the CoreExpr type is simpler
* NoRepLits have gone
* Better usage info in interface files => less recompilation
* Result type signatures work
* CCall primop is tidied up
* Constant folding now done by Rules
* Lots of hackery in the simplifier
* Improvements in CPR and strictness analysis
Many bug fixes including
* Sergey's DoCon compiles OK; no loop in the strictness analyser
* Volker Wysk's programs don't crash the CPR analyser
I have not done much on measuring compilation times and binary sizes;
they could have got worse. I think performance has got significantly
better, though, in most cases.
Removing the Con form of Core expressions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The big thing is that
For every constructor C there are now *two* Ids:
C is the constructor's *wrapper*. It evaluates and unboxes arguments
before calling $wC. It has a perfectly ordinary top-level defn
in the module defining the data type.
$wC is the constructor's *worker*. It is like a primop that simply
allocates and builds the constructor value. Its arguments are the
actual representation arguments of the constructor.
Its type may be different to C, because:
- useless dict args are dropped
- strict args may be flattened
For every primop P there is *one* Id, its (curried) Id
Neither contructor worker Id nor the primop Id have a defminition anywhere.
Instead they are saturated during the core-to-STG pass, and the code generator
generates code for them directly. The STG language still has saturated
primops and constructor applications.
* The Const type disappears, along with Const.lhs. The literal part
of Const.lhs reappears as Literal.lhs. Much tidying up in here,
to bring all the range checking into this one module.
* I got rid of NoRep literals entirely. They just seem to be too much trouble.
* Because Con's don't exist any more, the funny C { args } syntax
disappears from inteface files.
Parsing
~~~~~~~
* Result type signatures now work
f :: Int -> Int = \x -> x
-- The Int->Int is the type of f
g x y :: Int = x+y
-- The Int is the type of the result of (g x y)
Recompilation checking and make
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* The .hi file for a modules is not touched if it doesn't change. (It used to
be touched regardless, forcing a chain of recompilations.) The penalty for this
is that we record exported things just as if they were mentioned in the body of
the module. And the penalty for that is that we may recompile a module when
the only things that have changed are the things it is passing on without using.
But it seems like a good trade.
* -recomp is on by default
Foreign declarations
~~~~~~~~~~~~~~~~~~~~
* If you say
foreign export zoo :: Int -> IO Int
then you get a C produre called 'zoo', not 'zzoo' as before.
I've also added a check that complains if you export (or import) a C
procedure whose name isn't legal C.
Code generation and labels
~~~~~~~~~~~~~~~~~~~~~~~~~~
* Now that constructor workers and wrappers have distinct names, there's
no need to have a Foo_static_closure and a Foo_closure for constructor Foo.
I nuked the entire StaticClosure story. This has effects in some of
the RTS headers (i.e. s/static_closure/closure/g)
Rules, constant folding
~~~~~~~~~~~~~~~~~~~~~~~
* Constant folding becomes just another rewrite rule, attached to the Id for the
PrimOp. To achieve this, there's a new form of Rule, a BuiltinRule (see CoreSyn.lhs).
The prelude rules are in prelude/PrelRules.lhs, while simplCore/ConFold.lhs has gone.
* Appending of constant strings now works, using fold/build fusion, plus
the rewrite rule
unpack "foo" c (unpack "baz" c n) = unpack "foobaz" c n
Implemented in PrelRules.lhs
* The CCall primop is tidied up quite a bit. There is now a data type CCall,
defined in PrimOp, that packages up the info needed for a particular CCall.
There is a new Id for each new ccall, with an big "occurrence name"
{__ccall "foo" gc Int# -> Int#}
In interface files, this is parsed as a single Id, which is what it is, really.
Miscellaneous
~~~~~~~~~~~~~
* There were numerous places where the host compiler's
minInt/maxInt was being used as the target machine's minInt/maxInt.
I nuked all of these; everything is localised to inIntRange and inWordRange,
in Literal.lhs
* Desugaring record updates was broken: it didn't generate correct matches when
used withe records with fancy unboxing etc. It now uses matchWrapper.
* Significant tidying up in codeGen/SMRep.lhs
* Add __word, __word64, __int64 terminals to signal the obvious types
in interface files. Add the ability to print word values in hex into
C code.
* PrimOp.lhs is no longer part of a loop. Remove PrimOp.hi-boot*
Types
~~~~~
* isProductTyCon no longer returns False for recursive products, nor
for unboxed products; you have to test for these separately.
There's no reason not to do CPR for recursive product types, for example.
Ditto splitProductType_maybe.
Simplification
~~~~~~~~~~~~~~~
* New -fno-case-of-case flag for the simplifier. We use this in the first run
of the simplifier, where it helps to stop messing up expressions that
the (subsequent) full laziness pass would otherwise find float out.
It's much more effective than previous half-baked hacks in inlining.
Actually, it turned out that there were three places in Simplify.lhs that
needed to know use this flag.
* Make the float-in pass push duplicatable bindings into the branches of
a case expression, in the hope that we never have to allocate them.
(see FloatIn.sepBindsByDropPoint)
* Arrange that top-level bottoming Ids get a NOINLINE pragma
This reduced gratuitous inlining of error messages.
But arrange that such things still get w/w'd.
* Arrange that a strict argument position is regarded as an 'interesting'
context, so that if we see
foldr k z (g x)
then we'll be inclined to inline g; this can expose a build.
* There was a missing case in CoreUtils.exprEtaExpandArity that meant
we were missing some obvious cases for eta expansion
Also improve the code when handling applications.
* Make record selectors (identifiable by their IdFlavour) into "cheap" operations.
[The change is a 2-liner in CoreUtils.exprIsCheap]
This means that record selection may be inlined into function bodies, which
greatly improves the arities of overloaded functions.
* Make a cleaner job of inlining "lone variables". There was some distributed
cunning, but I've centralised it all now in SimplUtils.analyseCont, which
analyses the context of a call to decide whether it is "interesting".
* Don't specialise very small functions in Specialise.specDefn
It's better to inline it. Rather like the worker/wrapper case.
* Be just a little more aggressive when floating out of let rhss.
See comments with Simplify.wantToExpose
A small change with an occasional big effect.
* Make the inline-size computation think that
case x of I# x -> ...
is *free*.
CPR analysis
~~~~~~~~~~~~
* Fix what was essentially a bug in CPR analysis. Consider
letrec f x = let g y = let ... in f e1
in
if ... then (a,b) else g x
g has the CPR property if f does; so when generating the final annotated
RHS for f, we must use an envt in which f is bound to its final abstract
value. This wasn't happening. Instead, f was given the CPR tag but g
wasn't; but of course the w/w pass gives rotten results in that case!!
(Because f's CPR-ness relied on g's.)
On they way I tidied up the code in CprAnalyse. It's quite a bit shorter.
The fact that some data constructors return a constructed product shows
up in their CPR info (MkId.mkDataConId) not in CprAnalyse.lhs
Strictness analysis and worker/wrapper
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* BIG THING: pass in the demand to StrictAnal.saExpr. This affects situations
like
f (let x = e1 in (x,x))
where f turns out to have strictness u(SS), say. In this case we can
mark x as demanded, and use a case expression for it.
The situation before is that we didn't "know" that there is the u(SS)
demand on the argument, so we simply computed that the body of the let
expression is lazy in x, and marked x as lazily-demanded. Then even after
f was w/w'd we got
let x = e1 in case (x,x) of (a,b) -> $wf a b
and hence
let x = e1 in $wf a b
I found a much more complicated situation in spectral/sphere/Main.shade,
which improved quite a bit with this change.
* Moved the StrictnessInfo type from IdInfo to Demand. It's the logical
place for it, and helps avoid module loops
* Do worker/wrapper for coerces even if the arity is zero. Thus:
stdout = coerce Handle (..blurg..)
==>
wibble = (...blurg...)
stdout = coerce Handle wibble
This is good because I found places where we were saying
case coerce t stdout of { MVar a ->
...
case coerce t stdout of { MVar b ->
...
and the redundant case wasn't getting eliminated because of the coerce.
|
|
|
|
|
|
|
|
|
| |
Add the readBlahOffAddr suite of primitives. The previous method of
using indexStuffOffAddr didn't enforce proper ordering in the I/O
monad.
The indexBlahOffAddr primops may go away in the future if/when we
figure out how to make unsafePerformIO into a no-op at the back end.
|
|
|
|
|
| |
Remove unsafeThawByteArray# primop (which was a no-op), and use
unsafeCoerce# instead.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit implements a substantial re-organisation of the Prelude
It also fixes a couple of small renamer bugs that were reported recently
(notably, Sven pointed out that we weren't reporting
unused imports properly)
My original goal was to get rid of all "orphan" modules (i.e. ones
with instance decls that don't belong either to a tycon or a class
defined in the same module). This should reduce the number of
interface files that have to be read when compiling small Haskell
modules.
But like most expeditions into the Prelude Swamp, it spiraled out
of control. The result is quite satisfactory, though.
GONE AWAY: PrelCCall, PrelNumExtra
NEW: PrelReal, PrelFloat, PrelByteArr, PrelNum.hi-boot
(The extra PrelNum.hi-boot is because of a tiresome thin-air Id, addr2Integer,
which used to be in PrelBase.)
Quite a lot of types have moved from one module to another,
which entails some changes to part of the compiler (PrelInfo, PrelMods) etc,
and there are a few places in the RTS includes and even in the driver
that know about these home modules (alas).
So the rough structure is as follows, in (linearised) dependency order
[this list now appears in PrelBase.lhs]
PrelGHC Has no implementation. It defines built-in things, and
by importing it you bring them into scope.
The source file is PrelGHC.hi-boot, which is just
copied to make PrelGHC.hi
Classes: CCallable, CReturnable
PrelBase Classes: Eq, Ord, Functor, Monad
Types: list, (), Int, Bool, Ordering, Char, String
PrelTup Types: tuples, plus instances for PrelBase classes
PrelShow Class: Show, plus instances for PrelBase/PrelTup types
PrelEnum Class: Enum, plus instances for PrelBase/PrelTup types
PrelMaybe Type: Maybe, plus instances for PrelBase classes
PrelNum Class: Num, plus instances for Int
Type: Integer, plus instances for all classes so far (Eq, Ord, Num, Show)
Integer is needed here because it is mentioned in the signature
of 'fromInteger' in class Num
PrelReal Classes: Real, Integral, Fractional, RealFrac
plus instances for Int, Integer
Types: Ratio, Rational
plus intances for classes so far
Rational is needed here because it is mentioned in the signature
of 'toRational' in class Real
Ix Classes: Ix, plus instances for Int, Bool, Char, Integer, Ordering, tuples
PrelArr Types: Array, MutableArray, MutableVar
Does *not* contain any ByteArray stuff (see PrelByteArr)
Arrays are used by a function in PrelFloat
PrelFloat Classes: Floating, RealFloat
Types: Float, Double, plus instances of all classes so far
This module contains everything to do with floating point.
It is a big module (900 lines)
With a bit of luck, many modules can be compiled without ever reading PrelFloat.hi
PrelByteArr Types: ByteArray, MutableByteArray
We want this one to be after PrelFloat, because it defines arrays
of unboxed floats.
Other Prelude modules are much easier with fewer complex dependencies.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add Marc Van Dongen's Integer improvements. Specifically:
- new primops: gcdInt#, gcdIntegerInt#, divExact#,
quotInteger#, remInteger#.
- new definitions of quot and rem for Integer in
PrelNum (using the new quotInteger# and remInteger#
primops instead of quotRemInteger#). Should be
slightly faster than before. div & mod aren't
likewise optimised (yet).
- specialisations of gcd for Int and Integer, and
lcm for Integer in PrelNum.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Support for blocking & unblocking asynchronous exceptions.
- new primops:
blockAsyncExceptions#, unblockAsyncExceptions# :: IO a -> IO a
- raiseInThread will block if the target thread is currently
blocking async exceptions.
- async exceptions are currently implicitly blocked inside
an exception handler. This decision might be reversed when
we have more experience with this stuff.
- Move exception-related stuff in the RTS into its own file,
Exception.{h,hc}.
|
|
|
|
| |
failure to commit important files is a jumping-out-of-the-window offence
|
|
|
|
|
| |
Integer divMod now uses the native GMP method. The PrimOp was already
there, it just wasn't being used.
|
|
|
|
| |
add gcdIntegerzh.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(this is number 9 of 9 commits to be applied together)
Usage verification changes / ticky-ticky changes:
We want to verify that SingleEntry thunks are indeed entered at most
once. In order to do this, -ticky / -DTICKY_TICKY turns on eager
blackholing. We blackhole with new blackholes: SE_BLACKHOLE and
SE_CAF_BLACKHOLE. We will enter one of these if we attempt to enter
a SingleEntry thunk twice. Note that CAFs are dealt with in by
codeGen, and ordinary thunks by the RTS.
We also want to see how many times we enter each Updatable thunk.
To this end, we have modified -ticky. When -ticky is on, we update
with a permanent indirection, and arrange that when we enter a
permanent indirection we count the entry and then convert the
indirection to a normal indirection. This gives us a means of
counting the number of thunks entered again after the first entry.
Obviously this screws up profiling, and so you can't build a ticky
and profiling compiler any more.
Also a few other changes that didn't make it into the previous 8
commits, but form a part of this set.
|
|
|
|
| |
add getTag#
|
|
|
|
| |
oops, forgot to add dataToTag#.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Improvements to the threading model.
- asynchronous exceptions supported.
- killThread# can now raise an exception in the specified
thread. It's new type is
killThread# :: ThreadId# -> Exception -> IO ()
High-level versions:
killThread :: ThreadId -> IO ()
raiseInThread :: ThreadId -> Exception -> IO ()
(killThread raises a 'ThreadKilled' exception in the
specified thread).
If the thread has no exception handler, it is killed
as before. Otherwise, the exception is passed to
the innermost CATCH_FRAME and the thread is woken up
if it was blocked. The current computation is
suspended, instead of being replaced by the exception
(as is the case with throw).
Sending an exception to the current thread works too.
- new primitive: myThreadId# :: IO ThreadId# and corresponding
high-level version myThreadId :: IO ThreadId.
- new primitive: yield# :: IO (), and yield :: IO ().
- the TSO now contains a pointer to the resource currently blocked
on (MVAR or BLACKHOLE_BQ).
- Add a giant comment to TSO.h about what the various link fields
are supposed to do, and invariants etc.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Support for unsafely thawing your (Byte)Arrays, i.e., added the
following ops:
MutableArray.unsafeThawArray :: Ix ix => Array ix elt -> ST s (MutableArray s ix elt)
MutableArray.unsafeThawByteArray :: Ix ix => ByteArray ix -> ST s (MutableByteArray s ix)
MutableArray.thawByteArray :: Ix ix => ByteArray ix -> ST s (MutableByteArray s ix)
ST.unsafeThawSTArray :: Ix ix => Array ix elt -> ST s (STArray s ix elt)
LazyST.unsafeThawSTArray :: Ix ix => Array ix elt -> ST s (STArray s ix elt)
IOExts.unsafeFreezeIOArray :: Ix ix => IOArray ix elt -> IO (Array ix elt)
IOExts.unsafeThawIOArray :: Ix ix => Array ix elt -> IO (IOArray ix elt)
+ removed the re-exportation of Monad that ST and LazyST did.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add two new operations to StgPrimFloat.c:
__int_encodeFloat
__int_encodeDouble
for encoding floats/doubles from small integers. This avoids having
to convert small integers to large ones before an encodeFloat
operation, and fixes the two cases of slowdown in nofib after the
small integer changes.
Also:
- remove encodeFloat and decodeFloat as primops
- use foreign import for encode{Float,Double} and
the various isNaN etc. ccalls in PrelNumExtra.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fast Integers. The rep. of Integers is now
data Integer = S# Int#
| J# Int# ByteArray#
- several new primops added for overflow-detecting arithmetic
- negateInteger# removed; it can be done directly
- integer_0, integer_1 etc. removed.
- the compiler now uses S# where it previously used int2Integer.
- the compiler generates small integers for -2^32 .. 2^32-1, instead
of -2^29 .. -2^29-1.
- PrelST.State datatype moved to LazyST (its only use).
- some library code (in Time.lhs) still needs cleaning up, it depends
on the Integer rep.
|
|
|
|
| |
More finalise/finalize updates.
|
|
|
|
| |
More weak pointer changes.
|
|
|
|
|
|
| |
- Add finalise#
- Add mkWeakNoFinaliser
- Move deRefWeak# from an out-of-line primop to an inline one.
|
|
|
|
| |
Changes to PrelGHC.hi-boot for new z-encoding
|
|
|
|
| |
More stable name additions/changes.
|
|
|
|
|
|
|
| |
Changes to make the Prelude comply with Haskell 98.
I claim that this completes GHC's implementation of Haskell 98 (at
least feature-wise, but there's bound to be some bugs lurking..)
|
|
|
|
| |
Forgot to commit PrelGHC.hi-boot; changes to syntax of open kind in CCallable
|