Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | /* Copyright (C) 2012,2016 Matthew Fluet. |
2 | * Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh | |
3 | * Jagannathan, and Stephen Weeks. | |
4 | * Copyright (C) 1997-2000 NEC Research Institute. | |
5 | * | |
6 | * MLton is released under a BSD-style license. | |
7 | * See the file MLton-LICENSE for details. | |
8 | */ | |
9 | ||
10 | #if (defined (MLTON_GC_INTERNAL_TYPES)) | |
11 | ||
12 | /* | |
13 | * Array objects have the following layout: | |
14 | * | |
15 | * counter :: | |
16 | * length :: | |
17 | * header :: | |
18 | * ( (non heap-pointers)* :: (heap pointers)* )* | |
19 | * | |
20 | * The counter word is used by mark compact GC. The length word is | |
21 | * the number of elements in the array. Array elements have the same | |
22 | * individual layout as normal objects, omitting the header word. | |
23 | */ | |
24 | ||
25 | #define GC_ARRLEN_TYPE__(z) uint ## z ## _t | |
26 | #define GC_ARRLEN_TYPE_(z) GC_ARRLEN_TYPE__(z) | |
27 | #define GC_ARRLEN_TYPE GC_ARRLEN_TYPE_(GC_MODEL_ARRLEN_SIZE) | |
28 | typedef GC_ARRLEN_TYPE GC_arrayLength; | |
29 | #define GC_ARRAY_LENGTH_SIZE sizeof(GC_arrayLength) | |
30 | #define PRIxARRLEN__(z) PRIx ## z | |
31 | #define PRIxARRLEN_(z) PRIxARRLEN__(z) | |
32 | #define PRIxARRLEN PRIxARRLEN_(GC_MODEL_ARRLEN_SIZE) | |
33 | #define FMTARRLEN "%"PRIxARRLEN | |
34 | typedef GC_arrayLength GC_arrayCounter; | |
35 | #define GC_ARRAY_COUNTER_SIZE sizeof(GC_arrayCounter) | |
36 | #define PRIxARRCTR PRIxARRLEN | |
37 | #define FMTARRCTR "%"PRIxARRCTR | |
38 | #define GC_ARRAY_METADATA_SIZE (GC_ARRAY_COUNTER_SIZE + GC_ARRAY_LENGTH_SIZE + GC_HEADER_SIZE) | |
39 | ||
40 | COMPILE_TIME_ASSERT(sizeof_header__le__sizeof_arrlen, | |
41 | sizeof(GC_header) <= sizeof(GC_arrayLength)); | |
42 | COMPILE_TIME_ASSERT(sizeof_arrlen__eq__sizeof_arrctr, | |
43 | sizeof(GC_arrayLength) == sizeof(GC_arrayCounter)); | |
44 | ||
45 | ||
46 | #endif /* (defined (MLTON_GC_INTERNAL_TYPES)) */ | |
47 | ||
48 | #if (defined (MLTON_GC_INTERNAL_FUNCS)) | |
49 | ||
50 | static inline GC_arrayLength* getArrayLengthp (pointer a); | |
51 | static inline GC_arrayLength getArrayLength (pointer a); | |
52 | static inline GC_arrayCounter* getArrayCounterp (pointer a); | |
53 | static inline GC_arrayCounter getArrayCounter (pointer a); | |
54 | ||
55 | #if ASSERT | |
56 | static inline pointer indexArrayAtObjptrIndex (GC_state s, pointer a, | |
57 | GC_arrayCounter arrayIndex, | |
58 | uint32_t objptrIndex); | |
59 | #endif | |
60 | ||
61 | #endif /* (defined (MLTON_GC_INTERNAL_FUNCS)) */ | |
62 | ||
63 | PRIVATE uintmax_t GC_getArrayLength (pointer a); | |
64 | PRIVATE void GC_arrayCopy (GC_state s, pointer ad, size_t ds, pointer as, size_t ss, size_t l); |