[MLton] More on Parallel Runtime
Daniel Spoonhower
spoons+ at cs.cmu.edu
Wed Oct 31 04:14:03 PST 2007
I think I've done something pretty similar, though there are some differences
since I am using a shared heap (e.g. heaps, statistics- and marking-related
fields). Here are two other issues that I've solved by adding fields to the
shared state.
1. raise operands - The value carried by an exception is stored in one of the
globalObjptrNonRoot entries. This seems to be the only time these particular
"globals" are used, so I've moved them into the per-pthread state. Can anyone
else comment on this? Are there other uses of this array that really are
global (and should be shared across processors)?
2. FFI operation and operands - the implementation of _export temporarily
stores the identifier for the exported function as well as its arguments in a
set of global variables (MLton_FFI_*). These globals are then read by the
stub ML code generated by the compiler.
--djs
schatzp at purdue.edu wrote:
> Below are my GC_state (which is per-pthread) and GC_sharedState (which
> is a global var) structs. To note, I added nextFunc and returnToC into
> GC_state.
>
> struct GC_state {
> /* These fields are at the front because they are the most commonly
> * referenced, and having them at smaller offsets may decrease code
> * size and improve cache performance.
> */
> pointer frontier; /* heap.start <= frontier < limit */
> pointer limit; /* limit = heap.start + heap.size */
> pointer stackTop; /* Top of stack in current thread. */
> pointer stackLimit; /* stackBottom + stackSize - maxFrameSize */
> size_t exnStack;
> uintptr_t nextFunc; //Now per-pthread.
> // Also, include/c-common.h needs to find nextFunc by offset
> int returnToC; //Now per-pthread
>
> /* Alphabetized fields follow. */
> uint32_t atomicState;
> objptr callFromCHandlerThread; /* Handler for exported C calls (in
> heap). */
> struct GC_callStackState callStackState;
> bool canMinor; /* TRUE iff there is space for a minor gc. */
> objptr currentThread; /* Currently executing thread (in heap). */
> struct GC_generationalMaps generationalMaps;
> bool hashConsDuringGC;
> struct GC_heap heap;
> struct GC_lastMajorStatistics lastMajorStatistics;
> pointer limitPlusSlop; /* limit + GC_HEAP_LIMIT_SLOP */
> GC_objectHashTable objectHashTable;
> objptr savedThread; /* Result of GC_copyCurrentThread.
> * Thread interrupted by arrival of signal.
> */
> struct GC_heap secondaryHeap; /* Used for major copying collection. */
> objptr signalHandlerThread; /* Handler for signals (in heap). */
> struct GC_signalsInfo signalsInfo;
> pointer stackBottom; /* Bottom of stack in current thread. */
> GC_weak weaks; /* Linked list of (live) weak pointers */
> };
>
> struct GC_sharedState {
> /* Global info shared by all GC_state's.
> */
> bool amInGC;
> bool amOriginal;
> char **atMLtons; /* Initial @MLton args, processed before command
> line. */
> uint32_t atMLtonsLength;
> size_t alignment; /* */
> struct GC_controls controls;
> struct GC_cumulativeStatistics cumulativeStatistics;
> struct GC_forwardState forwardState;
> GC_frameLayout frameLayouts; /* Array of frame layouts. */
> uint32_t frameLayoutsLength; /* Cardinality of frameLayouts array. */
> objptr *globals;
> uint32_t globalsLength;
> struct GC_intInfInit *intInfInits;
> uint32_t intInfInitsLength;
> int (*loadGlobals)(FILE *f); /* loads the globals from the file. */
> uint32_t magic; /* The magic number for this executable. */
> uint32_t maxFrameSize;
> bool mutatorMarksCards;
> GC_objectType objectTypes; /* Array of object types. */
> uint32_t objectTypesLength; /* Cardinality of objectTypes array. */
> struct GC_profiling profiling;
> GC_frameIndex (*returnAddressToFrameIndex) (GC_returnAddress ra);
> int (*saveGlobals)(FILE *f); /* saves the globals to the file. */
> bool saveWorldStatus; /* */
> struct GC_sourceMaps sourceMaps;
> uintmax_t startTime; /* The time when GC_init or GC_loadWorld was
> called. */
> struct GC_sysvals sysvals;
> struct GC_translateState translateState;
> struct GC_vectorInit *vectorInits;
> uint32_t vectorInitsLength;
> };
>
>
More information about the MLton
mailing list