summaryrefslogtreecommitdiff
path: root/ghc/rts/Evaluator.c
Commit message (Collapse)AuthorAgeFilesLines
* [project @ 2000-12-11 12:55:43 by sewardj]sewardj2000-12-111-4105/+0
| | | | Remove the old bytecode interpreter and add the new one.
* [project @ 2000-11-20 11:15:41 by simonmar]simonmar2000-11-201-4/+2
| | | | remove #warn
* [project @ 2000-11-07 13:30:40 by simonmar]simonmar2000-11-071-9/+3
| | | | | Wave goodbye to FLOATS_AS_DOUBLES, it was a somewhat misconceived idea which will cause trouble with the FFI on 64-bit machines.
* [project @ 2000-10-09 11:18:46 by daan]daan2000-10-091-156/+629
| | | | | | | | | | Lots of changes for Xmlambda. all changes are between #ifdef XMLAMBDA blocks. - new bytecodes for Inj constructors and witnesses - new primops for rows - code for calling foreign functions. This only works with 'dynamic.c' but that is not checked in yet.
* [project @ 2000-10-09 10:28:33 by daan]daan2000-10-091-7/+6
| | | | removed references to 'splim' in code for the INTERPRETER.
* [project @ 2000-06-23 12:09:00 by sewardj]sewardj2000-06-231-2/+16
| | | | Minor mods to make fully-optimised builds of Hugs work again.
* [project @ 2000-06-15 13:23:51 by daan]daan2000-06-151-2/+267
| | | | | | | | | | | | Added new primitives and bytecodes that support code generation for XMLambda. All additions are surrounded by #ifdef XMLAMBDA. Most important additions: - Rows (n-tuples) which are implemented on top of Frozen Mutarrays - Inj (variant sums), which is implemented using a new constructor called Inj which contains both the value and an unboxed int which represents the index.
* [project @ 2000-05-26 10:14:33 by sewardj]sewardj2000-05-261-10/+15
| | | | | | | | | Changes to allow Hugs to be built with mingw32, not cygwin. Also, updates so that DietHEP works properly for mingw32. Most changes are trivial (assert --> ASSERT), etc. For hugs, have deleted queries about the width of a terminal window, and so the printing of dots as progress indicators is gone too. No great loss. Zapped various other out-of-date platform-specific junk in machdep.c.
* [project @ 2000-05-18 09:54:47 by simonmar]simonmar2000-05-181-3/+3
| | | | Upd_frame ==> upd_frame
* [project @ 2000-05-10 09:00:20 by sewardj]sewardj2000-05-101-175/+2
| | | | | Zap CRUDE_PROFILING. It was there mainly to test assess the effect of the simplifier; is redundant.
* [project @ 2000-05-09 10:00:35 by sewardj]sewardj2000-05-091-8/+9
| | | | Fix various compile-time warnings in the assembler and evaluator.
* [project @ 2000-04-27 16:35:29 by sewardj]sewardj2000-04-271-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A total rewrite of the BCO assembler/linker, and rationalisation of the code management and code generation phases of Hugs. Problems with the old linker: * Didn't have a clean way to insert a pointer to GHC code into a BCO. This meant CAF GC didn't work properly in combined mode. * Leaked memory. Each BCO, caf and constructor generated by Hugs had a corresponding malloc'd record used in its construction. These records existed forever. Pointers from the Hugs symbol tables into the runtime heap always went via these intermediates, for no apparent reason. * A global variable holding a list of top-level stg trees was used during code generation. It was hard to associate trees in this list with entries in the name/tycon tables. Just too many mechanisms. The New World Order is as follows: * The global code list (stgGlobals) is gone. * Each name in the name table has a .closure field. This points to the top-level code for that name. Before bytecode generation this points to a STG tree. During bytecode generation but before bytecode linking it is a MPtr pointing to a malloc'd intermediate structure (an AsmObject). After linking, it is a real live pointer into the execution heap (CPtr) which is treated as a root during GC. Because tuples do not have name table entries, tycons which are tuples also have a .closure field, which is treated identically to those of name table entries. * Each module has a code list -- a list of names and tuples. If you are a name or tuple and you have something (code, CAF or Con) which needs to wind up in the execution heap, you MUST be on your module's code list. Otherwise you won't get code generated. * Lambda lifting generates new name table entries, which of course also wind up on the code list. * The initial phase of code generation for a module m traverses m's code list. The stg trees referenced in the .closure fields are code generated, creating AsmObject (AsmBCO, AsmCAF, AsmCon) in mallocville. The .closure fields then point to these AsmObjects. Since AsmObjects can be mutually recursive, they can contain references to: * Other AsmObjects Asm_RefObject * Existing closures Asm_RefNoOp * name/tycon table entries Asm_RefHugs AsmObjects can also contain BCO insns and non-ptr words. * A second copy-and-link phase copies the AsmObjects into the execution heap, resolves the Asm_Ref* items, and frees up the malloc'd entities. * Minor cleanups in compile-time storage. There are now 3 kinds of address-y things available: CPtr/mkCPtr/cptrOf -- ptrs to Closures, probably in exec heap ie anything which the exec GC knows about MPtr/mkMPtr/mptrOf -- ptrs to mallocville, which the exec GC knows nothing about Addr/mkAddr/addrOf -- literal addresses (like literal ints) * Many hacky cases removed from codegen.c. Referencing code or data during code generation is a lot simpler, since an entity is either: a CPtr, in which case use it as is a MPtr -- stuff it into the AsmObject and the linker will fix it a name or tycon -- ditto * I've checked, using Purify that, at least in standalone mode, no longer leaks mallocd memory. Prior to this it would leak at the rate of about 300k per Prelude. * Added this comment to the top of codegen.c. Still to do: * Reinstate peephole optimisation for BCOs. * Nuke magic number headers in AsmObjects, used for debugging. * Profile and accelerate. Code generation is slower because linking is slower. Evaluation GC is slower because markHugsObjects has slowed down. * Make setCurrentModule ignore name table entries created by the lambda-lifter. * Zap various #if 0's in codegen.c/Assembler.c. * Zap CRUDE_PROFILING.
* [project @ 2000-04-25 17:47:42 by andy]andy2000-04-251-3/+4
| | | | Adding trivial entry counter.
* [project @ 2000-04-14 15:18:05 by sewardj]sewardj2000-04-141-10/+7
| | | | | | Clean up the runtime heap before deleting modules (and, currently, after every evaluation) so that the combined system can safely throw away modules and info tables without creating dangling refs from the heap.
* [project @ 2000-04-11 20:44:17 by panne]panne2000-04-111-3/+3
| | | | | | | | | | | | | | | | | | 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.
* [project @ 2000-04-03 15:24:21 by rrt]rrt2000-04-031-3/+3
| | | | | | | Stopped getourtimeofday() being called under mingwin. MBlock.c: changed one instance of 128 * 1024 * 1024 into SIZE_RESERVED_POOL and added a TODO comment (bug in is_heap_alloced(), which won't work if more than one megablock is ever allocated).
* [project @ 2000-03-20 15:49:56 by panne]panne2000-03-201-3/+3
| | | | | ITimer.h is really called Itimer.h. Hmmm, let's guess on what brilliant OS this part of the RTS was developed... :-))
* [project @ 2000-03-20 09:42:49 by andy]andy2000-03-201-2/+8
| | | | | | | | | | | | Adding an alternative to the "delay" system used for threads that are waiting for time to pass. This works on a target time basis, eliminating the need to use the ticky style counter. It is only enabled under: #if defined(INTERPRETER) && !defined(HAVE_SETITIMER)
* [project @ 2000-03-20 04:26:23 by andy]andy2000-03-201-30/+115
| | | | | | | Second attack at supporting threads inside STG Hugs. We now support most of the concurrency primitives. Also a wibble in Evaluator.c, letting Hugs compile.
* [project @ 2000-03-17 14:37:21 by simonmar]simonmar2000-03-171-6/+7
| | | | More random cleanups.
* [project @ 2000-03-17 13:30:23 by simonmar]simonmar2000-03-171-5/+5
| | | | | Random cleanup: rename the TSO->whatNext field to what_next, to be a bit more consistent.
* [project @ 2000-03-14 14:34:47 by sewardj]sewardj2000-03-141-9/+9
| | | | | | Update Hugs so as to work with the new way of referencing Prelude symbols from the RTS. The main action is in fixupRTStoPreludeRefs() in rts/Prelude.c.
* [project @ 2000-03-13 13:00:00 by sewardj]sewardj2000-03-131-2/+3
| | | | Track recent re-homing of Prelude.h for INTERPRETER.
* [project @ 2000-03-13 10:39:11 by sewardj]sewardj2000-03-131-7/+7
| | | | Clean up a couple of compilation warnings.
* [project @ 2000-03-13 10:30:25 by sewardj]sewardj2000-03-131-44/+16
| | | | Remove #ifdef STANDALONE_INTEGER.
* [project @ 2000-02-29 12:54:51 by sewardj]sewardj2000-02-291-4/+10
| | | | | | | | Make foreign import work in combined mode: -- Allow interpreter to do ccall primops even in combined mode -- Implement hugsprimMkIO in combined mode, so as to wrap up a an IO value created by Hugs in a form compatible with GHC's IO representation.
* [project @ 2000-02-24 17:26:12 by sewardj]sewardj2000-02-241-3/+3
| | | | primUnpackString --> hugsprimUnpackString
* [project @ 2000-02-15 15:14:09 by sewardj]sewardj2000-02-151-4/+14
| | | | Implement CONST_INT_big and CONST_ADDR_big.
* [project @ 2000-02-15 13:16:19 by sewardj]sewardj2000-02-151-4/+6
| | | | | | | | | Backend interop fixes: -- Make Hugs use the same constructor tag numbering as GHC, viz, starting at zero. -- Evaluator.c: when unwinding the stack on entering a constructor, return to the scheduler if a RET_{VEC_}{SMALL|BIG} is found on the stack.
* [project @ 2000-02-14 11:04:58 by sewardj]sewardj2000-02-141-3/+9
| | | | | Paranoia: barf if enterBCO_primop1 or enterBCO_primop2 are called in combined mode (since GHC should handle all primops in that case).
* [project @ 1999-12-07 11:49:09 by sewardj]sewardj1999-12-071-2/+12
| | | | | | Add i_ALLOC_CONSTR_big (== i_ALLOC_CONSTR with a 16-bit field denoting offset of into table). The large constant tables in nofib/spectral/hartel/nucleic2 need this.
* [project @ 1999-11-29 18:59:23 by sewardj]sewardj1999-11-291-5/+8
| | | | | | | | | | | | | | | | Make StgHugs use the same naming scheme as GHC does for class + instance machinery. Add machinery to do Z-encoding/decoding of names extracted from interface files. Make the ELF object loader work again. It seemed to have suffered slight bitrot over the past couple of months. Fix various minor bugs. Track a small change in interface file syntax. Make Printer.c print tagged-unboxed stack sections in a decent way now that Alastair-style stack tags have been abandoned.
* [project @ 1999-11-18 16:02:17 by sewardj]sewardj1999-11-181-10/+6
| | | | | | | | | Minor bugfixes for concurrency support in Hugs. Evaluator.c: correctly handle case of entering a black hole. Prelude.hs: better exception catching in forkIO and primRunIO GC.c: (revert_dead_CAFs): don't ASSERT(0) on a dead CAF (I don't know why this assert was there)
* [project @ 1999-11-18 12:10:17 by sewardj]sewardj1999-11-181-40/+52
| | | | | | In hugs, implement ThreadId(..), instance Eq/Ord ThreadId, and forkIO. Add deleteAllThreads() to scheduler so Hugs can clean up after evaluation.
* [project @ 1999-11-16 17:38:54 by sewardj]sewardj1999-11-161-104/+86
| | | | | Added basic support for MVars: data MVar, and newMVar, putMVar and getMVar.
* [project @ 1999-11-12 17:50:01 by sewardj]sewardj1999-11-121-2/+3
| | | | | Wibbles to make get a fully-optimised build to work. (We've been building debug versions for a v. long time now).
* [project @ 1999-11-08 15:30:32 by sewardj]sewardj1999-11-081-168/+170
| | | | | Make Hugs evaluator work with new register table arrangements arising from Simon's SMP work.
* [project @ 1999-11-01 18:19:39 by sewardj]sewardj1999-11-011-2/+11
| | | | | Computation of max-stack-use during BCO generation was completely bogus. Fix it. Also, add a i_STK_CHECK_big insn with 16-bit opcode.
* [project @ 1999-10-29 13:41:23 by sewardj]sewardj1999-10-291-2/+16
| | | | Make foreign import and thus the Prelude work on cygwin.
* [project @ 1999-10-26 17:27:25 by sewardj]sewardj1999-10-261-6/+12
| | | | | | | | | | | | Add foreign import/export implementations for x86 stdcall convention. Make parser notice calling conventions on f-i and f-x declarations, check they are supported on the platform Hugs is compiled on. Pass them all the way through the code generator to the interpreter. Allow f-i/f-x decls to omit the calling convention, in which case ccall is used. Remove calling convention from all such decls in the Prelude so it will work on any platform.
* [project @ 1999-10-22 15:58:21 by sewardj]sewardj1999-10-221-165/+6
| | | | | | | | | | | | | | * Completion of foreign import and foreign export for x86 ccall convention. f-i's and f-x's can pass and return Char Int Word Addr StablePtr Float and Double. * Significant cleanups and infrastructure improvements. Characterise functions by (instruction set, calling convention) pair where necessary, since that's what counts. Moved foreign export code into rts/ForeignCall.c. Should now be in a good position to implement x86 stdcall convention.
* [project @ 1999-10-22 09:59:28 by sewardj]sewardj1999-10-221-6/+6
| | | | | Cleanup of the foreign import code. Also allow StablePtrs to be passed back and forth.
* [project @ 1999-10-19 11:01:24 by sewardj]sewardj1999-10-191-7/+14
| | | | | | | | | | | | | | | | Reimplement back-end for foreign import (calling out). Return to a cleaned-up version of Alastair's callfun.S, wherein an architecture and calling-convention specific piece of assembly code is used to construct arguments and then call the specified function, under the direction of a type descriptor string. Defined an interface to this function (universal_call_c) which I hope will work regardless of 32-or-64 bitness, endianness and calling convention. Current implementation is for x86-linux only.
* [project @ 1999-10-15 11:02:06 by sewardj]sewardj1999-10-151-132/+311
| | | | | | | | | | | | | | | | | | | | | Added basic support for foreign export dynamic. Many aspects of it are still broken: * Only supports x86-linux. * The range of allowable types is small: Char Int Float Double Addr and Word. * Adjustor thunks are never freed. * Returning Doubles or Floats doesn't work at all. I expect to fix some of these shortly. foreign import also needs redoing, so it can accept any number of arguments of any type. Also: * Fixed setRtsFlags in Evaluator.c to make it endian-independent. * Fixed raisePrim in Evaluator.c so things like division by zero, array index errors, etc, throw an exception instead of terminating StgHugs. raisePrim is renamed makeErrorCall.
* [project @ 1999-07-06 16:40:22 by sewardj]sewardj1999-07-061-13/+23
| | | | | | | Assembler/Disassembler: handle and print calls to compiled code Evaluator: return to scheduler when entering unknown closure StgCRun: debugging trace in miniinterpreter (temporary) Updates: fix normal and vectored returns to Hugs
* [project @ 1999-05-11 16:47:39 by keithw]keithw1999-05-111-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | (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.
* [project @ 1999-04-28 12:59:51 by sewardj]sewardj1999-04-281-8/+8
| | | | Nano-fixes to make it work on sparc-solaris.
* [project @ 1999-04-27 14:07:53 by sewardj]sewardj1999-04-271-3/+2
| | | | Further fixes to make -DDEBUG work right from mk/build.mk.
* [project @ 1999-04-27 12:27:49 by sewardj]sewardj1999-04-271-9/+10
| | | | Correctify usage of -DDEBUG and -DDEBUG_EXTRA.
* [project @ 1999-04-27 10:06:47 by sewardj]sewardj1999-04-271-2121/+2492
| | | | | | | | | Changes to improve runtime performance of STG Hugs. -- Reorganisation of the evaluator (Evaluator.c). -- Changes to code emission (Assembler.c) to support peephole opts -- An experimental simplifier (optimise.c). -- Many supporting bug fixes and minor changes. -- Experimental implementation of integer for standalone hugs (sainteger.c).