- 13 Oct, 2008 3 commits
-
-
dias@eecs.harvard.edu authored
-
dias@eecs.harvard.edu authored
-
dias@eecs.harvard.edu authored
o Fixed bug that emitted the copy-in code for closure entry in the wrong place -- at the initialization of the closure. o Refactored some of the closure entry code. o Added code to check that no LocalRegs are live-in to a procedure -- trip up some buggy programs earlier o Fixed environment bindings for thunks -- we weren't (re)binding the free variables in a thunk o Fixed a bug in proc-point splitting that dropped some updates to the entry block in a procedure. o Fixed improper calls to code that generates CmmLit's for strings o New invariant on cg_loc in CgIdInfo: the expression is always tagged o Code to load free vars on entry to a thunk was (wrongly) placed before the heap check. o Some of the StgCmm code was redundantly passing around Id's along with CgIdInfo's; no more. o Initialize the LocalReg's that point to a closure before allocating and initializing the closure itself -- otherwise, we have problems with recursive closure bindings o BlockEnv and BlockSet types are now abstract. o Update frames: - push arguments in Old call area - keep track of the return sp in the FCode monad - keep the return sp in every call, tail call, and return (because it might be different at different call sites, e.g. tail calls to the gc after a heap check are performed before pushing the update frame) - set the sp appropriately on returns and tail calls o Reduce call, tail call, and return to a single LastCall node o Added slow entry code, using different calling conventions on entry and tail call o More fixes to the calling convention code. The tricky stuff is all about the closure environment: it must be passed in R1, but in non-closures, there is no such argument, so we can't treat all arguments the same way: the closure environment is special. Maybe the right step forward would be to define a different calling convention for closure arguments. o Let-no-escapes need to be emitted out-of-line -- otherwise, we drop code. o Respect RTS requirement of word alignment for pointers My stack allocation can pack sub-word values into a single word on the stack, but it wasn't requiring word-alignment for pointers. It does now, by word-aligning both pointer registers and call areas. o CmmLint was over-aggresively ruling out non-word-aligned memory references, which may be kosher now that we can spill small values into a single word. o Wrong label order on a conditional branch when compiling switches. o void args weren't dropped in many cases. To help prevent this kind of mistake, I defined a NonVoid wrapper, which I'm applying only to Id's for now, although there are probably other good candidates. o A little code refactoring: separate modules for procpoint analysis splitting, stack layout, and building infotables. o Stack limit check: insert along with the heap limit check, using a symbolic constant (a special CmmLit), then replace it when the stack layout is known. o Removed last node: MidAddToContext o Adding block id as a literal: means that the lowering of the calling conventions no longer has to produce labels early, which was inhibiting common-block elimination. Will also make it easier for the non-procpoint-splitting path. o Info tables: don't try to describe the update frame! o Over aggressive use of NonVoid!!!! Don't drop the non-void args before setting the type of the closure!!! o Sanity checking: Added a pass to stub dead dead slots on the stack (only ~10 lines with the dataflow framework) o More sanity checking: Check that incoming pointer arguments are non-stubbed. Note: these checks are still subject to dead-code removal, but they should still be quite helpful. o Better sanity checking: why stop at function arguments? Instead, in mkAssign, check that _any_ assignment to a pointer type is non-null -- the sooner the crash, the easier it is to debug. Still need to add the debugging flag to turn these checks on explicitly. o Fixed yet another calling convention bug. This time, the calls to the GC were wrong. I've added a new convention for GC calls and invoked it where appropriate. We should really straighten out the calling convention stuff: some of the code (and documentation) is spread across the compiler, and there's some magical use of the node register that should really be handled (not avoided) by calling conventions. o Switch bug: the arms in mkCmmLitSwitch weren't returning to a single join point. o Environment shadowing problem in Stg->Cmm: When a closure f is bound at the top-level, we should not bind f to the node register on entry to the closure. Why? Because if the body of f contains a let-bound closure g that refers to f, we want to make sure that it refers to the static closure for f. Normally, this would all be fine, because when we compile a closure, we rebind free variables in the environment. But f doesn't look like a free variable because it's a static value. So, the binding for f remains in the environment when we compile g, inconveniently referring to the wrong thing. Now, I bind the variable in the local environment only if the closure is not bound at the top level. It's still okay to make assumptions about the node holding the closure environment; we just won't find the binding in the environment, so code that names the closure will now directly get the label of the static closure, not the node register holding a pointer to the static closure. o Don't generate bogus Cmm code containing SRTs during the STG -> Cmm pass! The tables made reference to some labels that don't exist when we compute and generate the tables in the back end. o Safe foreign calls need some special treatment (at least until we have the integrated codegen). In particular: o they need info tables o they are not procpoints -- the successor had better be in the same procedure o we cannot (yet) implement the calling conventions early, which means we have to carry the calling-conv info all the way to the end o We weren't following the old convention when registering a module. Now, we use update frames to push any new modules that have to be registered and enter the youngest one on the stack. We also use the update frame machinery to specify that the return should pop the return address off the stack. o At each safe foreign call, an infotable must be at the bottom of the stack, and the TSO->sp must point to it. o More problems with void args in a direct call to a function: We were checking the args (minus voids) to check whether the call was saturated, which caused problems when the function really wasn't saturated because it took an extra void argument. o Forgot to distinguish integer != from floating != during Stg->Cmm o Updating slotEnv and areaMap to include safe foreign calls The dataflow analyses that produce the slotEnv and areaMap give results for each basic block, but we also need the results for a safe foreign call, which is a middle node. After running the dataflow analysis, we have another pass that updates the results to includ any safe foreign calls. o Added a static flag for the debugging technique that inserts instructions to stub dead slots on the stack and crashes when a stubbed value is loaded into a pointer-typed LocalReg. o C back end expects to see return continuations before their call sites. Sorted the flowgraphs appropriately after splitting. o PrimOp calling conventions are special -- unlimited registers, no stack Yet another calling convention... o More void value problems: if the RHS of a case arm is a void-typed variable, don't try to return it. o When calling some primOp, they may allocate memory; if so, we need to do a heap check when we return from the call.
-
- 14 Aug, 2008 1 commit
-
-
dias@eecs.harvard.edu authored
This merge does not turn on the new codegen (which only compiles a select few programs at this point), but it does introduce some changes to the old code generator. The high bits: 1. The Rep Swamp patch is finally here. The highlight is that the representation of types at the machine level has changed. Consequently, this patch contains updates across several back ends. 2. The new Stg -> Cmm path is here, although it appears to have a fair number of bugs lurking. 3. Many improvements along the CmmCPSZ path, including: o stack layout o some code for infotables, half of which is right and half wrong o proc-point splitting
-
- 25 Nov, 2008 3 commits
-
-
Thomas Schilling authored
This patch entails a major restructuring of HscMain and a small bugfix to MkIface (which required the restructuring in HscMain). In MkIface: - mkIface* no longer outputs orphan warnings directly and also no longer quits GHC when -Werror is set. Instead, errors are reported using the common IO (Messages, Maybe result) scheme. In HscMain: - Get rid of the 'Comp' monad. This monad was mostly GhcMonad + two reader arguments, a ModSummary for the currently compiled module and a possible old interface. The latter actually lead to a small space-leak since only its hash was needed (to check whether the newly-generated interface file was the same as the original one). Functions originally of type 'Comp' now only take the arguments that they actually need. This leads to slighly longer argument lists in some places, however, it is now much easier to see what is actually going on. - Get rid of 'myParseModule'. Rename 'parseFile' to 'hscParse'. - Join 'deSugarModule' and 'hscDesugar' (keeping the latter). - Rename 'typecheck{Rename}Module{'}' to 'hscTypecheck{Rename}'. One variant keeps the renamed syntax, the other doesn't. - Parameterise 'HscStatus', so that 'InteractiveStatus' is just a different parameterisation of 'HscStatus'. - 'hscCompile{OneShot,Batch,Nothing,Interactive}' are now implemented using a (local) typeclass called 'HsCompiler'. The idea is to make the common structure more obvious. Using this typeclass we now have two functions 'genericHscCompile' (original 'hscCompiler') and 'genericHscRecompile' (original 'genComp') describing the default pipeline. The methods of the typeclass describe a sort of "hook" interface (in OO-terms this would be called the "template method" pattern). One problem with this approach is that we parameterise over the /result/ type which, in fact, is not actually different for "nothing" and "batch" mode. To avoid functional dependencies or associated types, we use type tags to make them artificially different and parameterise the type class over the result type. A perhaps better approach might be to use records instead. - Drop some redundant 'HscEnv' arguments. These were likely different from what 'getSession' would return because during compilation we temporarily set the module's DynFlags as well as a few other fields. We now use the 'withTempSession' combinator to temporarily change the 'HscEnv' and automatically restore the original session after the enclosed action has returned (even in case of exceptions). - Rename 'hscCompile' to 'hscGenHardCode' (since that is what it does). Calls in 'GHC' and 'DriverPipeline' accordingly needed small adaptions.
-
simonpj@microsoft.com authored
A missing case (for equality predicates) in isOverloadedTy make bindInstsOfLocalFuns/Pats do the wrong thing. Core Lint nailed it. Merge to 6.10 branch.
-
Simon Marlow authored
Particularly boolean expresions: the conditional of an 'if', and guards, were missing their free variables.
-
- 21 Nov, 2008 1 commit
-
-
Thorkil Naur authored
-
- 23 Nov, 2008 1 commit
-
-
Ian Lynagh authored
Currently it only affects the -t flag output
-
- 22 Nov, 2008 4 commits
-
-
Thomas Schilling authored
-
Thomas Schilling authored
-
Thomas Schilling authored
-
Thomas Schilling authored
It now uses the standard warning log and error reporting mechanism.
-
- 21 Nov, 2008 6 commits
-
-
Thomas Schilling authored
-
Thomas Schilling authored
-
Simon Marlow authored
Previously, the GC had its own pool of threads to use as workers when doing parallel GC. There was a "leader", which was the mutator thread that initiated the GC, and the other threads were taken from the pool. This was simple and worked fine for sequential programs, where we did most of the benchmarking for the parallel GC, but falls down for parallel programs. When we have N mutator threads and N cores, at GC time we would have to stop N-1 mutator threads and start up N-1 GC threads, and hope that the OS schedules them all onto separate cores. It practice it doesn't, as you might expect. Now we use the mutator threads to do GC. This works quite nicely, particularly for parallel programs, where each mutator thread scans its own spark pool, which is probably in its cache anyway. There are some flag changes: -g<n> is removed (-g1 is still accepted for backwards compat). There's no way to have a different number of GC threads than mutator threads now. -q1 Use one OS thread for GC (turns off parallel GC) -qg<n> Use parallel GC for generations >= <n> (default: 1) Using parallel GC only for generations >=1 works well for sequential programs. Compiling an ordinary sequential program with -threaded and running it with -N2 or more should help if you do a lot of GC. I've found that adding -qg0 (do parallel GC for generation 0 too) speeds up some parallel programs, but slows down some sequential programs. Being conservative, I left the threshold at 1. ToDo: document the new options.
-
Simon Marlow authored
-
Thomas Schilling authored
Parse errors during dependency analysis or options parsing really shouldn't kill GHC; this is particularly annoying for GHC API clients.
-
Simon Marlow authored
-
- 20 Nov, 2008 4 commits
-
-
Simon Marlow authored
-
Simon Marlow authored
After a deadlock it was possible for the timer signal to remain off, which meant that the next deadlock would not be detected, and the system would hang. Spotted by conc047(threaded2).
-
Simon Marlow authored
-
simonpj@microsoft.com authored
-
- 19 Nov, 2008 5 commits
-
-
Simon Marlow authored
Also avoid padding if possible using __attribute__((packed)) Fixes the Windows build
-
Simon Marlow authored
-
Simon Marlow authored
I discovered a new invariant while experimenting (blackholing is not optional when using parallel GC), so documented it.
-
Simon Marlow authored
Fixes crashes when using reclaimSpark() (not used currently, but may be in the future).
-
Simon Marlow authored
-
- 14 Nov, 2008 1 commit
-
-
Simon Marlow authored
-
- 19 Nov, 2008 2 commits
-
-
Simon Marlow authored
If we're using the system's installed GMP, we don't want to be picking up the local gmp.h header file. Fixes 2469(ghci) for me, because it turns out the system's GMP is more up-to-date than GHC's version and has a fix for more recent versions of gcc. We also need to pull in a more recent GMP, but that's a separte issue.
-
Simon Marlow authored
There were races between workerTaskStop() and freeTaskManager(): we need to be sure that all Tasks have exited properly before we start tearing things down. This isn't completely straighforward, see comments for details.
-
- 14 Nov, 2008 1 commit
-
-
judah authored
-
- 18 Nov, 2008 1 commit
-
-
Simon Marlow authored
Eager blackholing can improve parallel performance by reducing the chances that two threads perform the same computation. However, it has a cost: one extra memory write per thunk entry. To get the best results, any code which may be executed in parallel should be compiled with eager blackholing turned on. But since there's a cost for sequential code, we make it optional and turn it on for the parallel package only. It might be a good idea to compile applications (or modules) with parallel code in with -feager-blackholing. ToDo: document -feager-blackholing.
-
- 17 Nov, 2008 5 commits
-
-
Simon Marlow authored
At some point we regressed on detecting simple black-hole loops. This happened due to the introduction of duplicate-work detection for parallelism: a black-hole loop looks very much like duplicate work, except it's duplicate work being performed by the very same thread. So we have to detect and handle this case.
-
Simon Marlow authored
-
Simon Marlow authored
-
Simon Marlow authored
On x86_64, the RTS needs to allocate memory in the low 2Gb of the address space. On Linux we can do this with MAP_32BIT, but sometimes this doesn't work (#2512) and other OSs don't support it at all (#2063). So to work around this: - Try MAP_32BIT first, if available. - Otherwise, try allocating memory from a fixed address (by default 1Gb) - We now provide an option to configure the address to allocate from. This allows a workaround on machines where the default breaks, and also provides a way for people to test workarounds that we can incorporate in future releases.
-
Simon Marlow authored
If we encounter a runnable thread during shutdown, just kill it. All the threads are supposed to be dead at this stage, but this catches threads that might have just returned from a foreign call, or were finalizers created by the GC. Fixes memo002(threaded1)
-
- 16 Nov, 2008 2 commits
-
-
Ian Lynagh authored
-
Ian Lynagh authored
Based on a patch from juhpetersen.
-