1 /* Copyright (C) 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.
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
10 void displayThread (GC_state s
,
14 "\t\texnStack = %"PRIuMAX
"\n"
15 "\t\tbytesNeeded = %"PRIuMAX
"\n"
16 "\t\tstack = "FMTOBJPTR
"\n",
17 (uintmax_t)thread
->exnStack
,
18 (uintmax_t)thread
->bytesNeeded
,
20 displayStack (s
, (GC_stack
)(objptrToPointer (thread
->stack
, s
->heap
.start
)),
24 size_t sizeofThread (GC_state s
) {
27 res
= GC_NORMAL_METADATA_SIZE
+ sizeof (struct GC_thread
);
28 res
= align (res
, s
->alignment
);
31 uint16_t bytesNonObjptrs
, numObjptrs
;
33 splitHeader (s
, GC_THREAD_HEADER
, NULL
, NULL
, &bytesNonObjptrs
, &numObjptrs
);
34 check
= GC_NORMAL_METADATA_SIZE
+ (bytesNonObjptrs
+ (numObjptrs
* OBJPTR_SIZE
));
37 "sizeofThread: res = %"PRIuMAX
" check = %"PRIuMAX
"\n",
38 (uintmax_t)res
, (uintmax_t)check
);
39 assert (check
== res
);
41 assert (isAligned (res
, s
->alignment
));
45 size_t offsetofThread (GC_state s
) {
46 return (sizeofThread (s
)) - (GC_NORMAL_METADATA_SIZE
+ sizeof (struct GC_thread
));