root/includes/rts/storage/ClosureTypes.h

Revision f30d527344db528618f64a25250a3be557d9f287, 2.3 KB (checked in by Simon Marlow <marlowsd@…>, 18 months ago)

Implement stack chunks and separate TSO/STACK objects

This patch makes two changes to the way stacks are managed:

1. The stack is now stored in a separate object from the TSO.

This means that it is easier to replace the stack object for a thread
when the stack overflows or underflows; we don't have to leave behind
the old TSO as an indirection any more. Consequently, we can remove
ThreadRelocated? and deRefTSO(), which were a pain.

This is obviously the right thing, but the last time I tried to do it
it made performance worse. This time I seem to have cracked it.

2. Stacks are now represented as a chain of chunks, rather than

a single monolithic object.

The big advantage here is that individual chunks are marked clean or
dirty according to whether they contain pointers to the young
generation, and the GC can avoid traversing clean stack chunks during
a young-generation collection. This means that programs with deep
stacks will see a big saving in GC overhead when using the default GC
settings.

A secondary advantage is that there is much less copying involved as
the stack grows. Programs that quickly grow a deep stack will see big
improvements.

In some ways the implementation is simpler, as nothing special needs
to be done to reclaim stack as the stack shrinks (the GC just recovers
the dead stack chunks). On the other hand, we have to manage stack
underflow between chunks, so there's a new stack frame
(UNDERFLOW_FRAME), and we now have separate TSO and STACK objects.
The total amount of code is probably about the same as before.

There are new RTS flags:

-ki<size> Sets the initial thread stack size (default 1k) Egs: -ki4k -ki2m
-kc<size> Sets the stack chunk size (default 32k)
-kb<size> Sets the stack chunk buffer size (default 1k)

-ki was previously called just -k, and the old name is still accepted
for backwards compatibility. These new options are documented.

  • Property mode set to 100644
Line 
1/* ----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2005
4 *
5 * Closure Type Constants: out here because the native code generator
6 * needs to get at them.
7 *
8 * -------------------------------------------------------------------------- */
9
10#ifndef RTS_STORAGE_CLOSURETYPES_H
11#define RTS_STORAGE_CLOSURETYPES_H
12
13/*
14 * WARNING WARNING WARNING
15 *
16 * If you add or delete any closure types, don't forget to update
17 * the closure flags table in rts/ClosureFlags.c.
18 */
19
20/* Object tag 0 raises an internal error */
21#define INVALID_OBJECT          0
22#define CONSTR                  1
23#define CONSTR_1_0              2
24#define CONSTR_0_1              3
25#define CONSTR_2_0              4
26#define CONSTR_1_1              5
27#define CONSTR_0_2              6
28#define CONSTR_STATIC           7
29#define CONSTR_NOCAF_STATIC     8
30#define FUN                     9
31#define FUN_1_0                 10
32#define FUN_0_1                 11
33#define FUN_2_0                 12
34#define FUN_1_1                 13
35#define FUN_0_2                 14
36#define FUN_STATIC              15
37#define THUNK                   16
38#define THUNK_1_0               17
39#define THUNK_0_1               18
40#define THUNK_2_0               19
41#define THUNK_1_1               20
42#define THUNK_0_2               21
43#define THUNK_STATIC            22
44#define THUNK_SELECTOR          23
45#define BCO                     24
46#define AP                      25
47#define PAP                     26
48#define AP_STACK                27
49#define IND                     28
50#define IND_PERM                29
51#define IND_STATIC              30
52#define RET_BCO                 31
53#define RET_SMALL               32
54#define RET_BIG                 33
55#define RET_DYN                 34
56#define RET_FUN                 35
57#define UPDATE_FRAME            36
58#define CATCH_FRAME             37
59#define UNDERFLOW_FRAME         38
60#define STOP_FRAME              39
61#define BLOCKING_QUEUE          40
62#define BLACKHOLE               41
63#define MVAR_CLEAN              42
64#define MVAR_DIRTY              43
65#define ARR_WORDS               44
66#define MUT_ARR_PTRS_CLEAN      45
67#define MUT_ARR_PTRS_DIRTY      46
68#define MUT_ARR_PTRS_FROZEN0    47
69#define MUT_ARR_PTRS_FROZEN     48
70#define MUT_VAR_CLEAN           49
71#define MUT_VAR_DIRTY           50
72#define WEAK                    51
73#define PRIM                    52
74#define MUT_PRIM                53
75#define TSO                     54
76#define STACK                   55
77#define TREC_CHUNK              56
78#define ATOMICALLY_FRAME        57
79#define CATCH_RETRY_FRAME       58
80#define CATCH_STM_FRAME         59
81#define WHITEHOLE               60
82#define N_CLOSURE_TYPES         61
83
84#endif /* RTS_STORAGE_CLOSURETYPES_H */
Note: See TracBrowser for help on using the browser.