/**************************************************************************/
/*                                                                        */
/*                                 OCaml                                  */
/*                                                                        */
/*      KC Sivaramakrishnan, Indian Institute of Technology, Madras       */
/*                   Stephen Dolan, University of Cambridge               */
/*                                                                        */
/*   Copyright 2019 Indian Institute of Technology, Madras                */
/*   Copyright 2019 University of Cambridge                               */
/*                                                                        */
/*   All rights reserved.  This file is distributed under the terms of    */
/*   the GNU Lesser General Public License version 2.1, with the          */
/*   special exception on linking described in the file LICENSE.          */
/*                                                                        */
/**************************************************************************/

DOMAIN_STATE(atomic_uintnat, young_limit)

/* Minor heap limit. Typically [young_start] <= [young_limit] <=
 * [young_end], but this field can be set atomically to UINTNAT_MAX by
 * another thread (typically from another domain), or by the memory
 * profiler, in order to interrupt this domain (by causing an
 * allocation failure). Setting [young_limit] to UINTNAT_MAX can be
 * done safely at any time whatsoever by any thread. To avoid races,
 * setting [young_limit] to anything else than UINTNAT_MAX should only
 * be done via [caml_reset_young_limit] by the domain itself. */

DOMAIN_STATE(value*, young_ptr)
/* Minor heap pointer */

DOMAIN_STATE(value*, young_start)
/* Start of the minor heap */

DOMAIN_STATE(value*, young_end)
/* End of the minor heap. always(young_start <= young_ptr <= young_end) */

DOMAIN_STATE(value*, young_trigger)
/* Input for setting the young_limit */

DOMAIN_STATE(struct stack_info*, current_stack)
/* Current stack */

DOMAIN_STATE(void*, exn_handler)
/* Pointer into the current stack */

DOMAIN_STATE(intnat, action_pending)
/* Whether we are due to start the processing of delayable pending
   actions. See runtime/signal.c. Valid values: 0,1. */

DOMAIN_STATE(struct c_stack_link*, c_stack)
/* The C stack associated with this domain.
 * Used by this domain to perform external calls. */

DOMAIN_STATE(struct stack_info**, stack_cache)
/* This is a list of freelist buckets of stacks */

DOMAIN_STATE(value*, gc_regs_buckets)
/* Cache of free gc_regs buckets.
   Documented in fiber.h. */

DOMAIN_STATE(value*, gc_regs)
/* Pointer to currently-used register bucket, or NULL.
   Documented in fiber.h. */

DOMAIN_STATE(struct caml_minor_tables*, minor_tables)

DOMAIN_STATE(struct mark_stack*, mark_stack)
/* Mark stack */

DOMAIN_STATE(uintnat, marking_done)
/* Is marking done for the current major cycle. */

DOMAIN_STATE(uintnat, sweeping_done)
/* Is sweeping done for the current major cycle. */

DOMAIN_STATE(uintnat, allocated_words)

DOMAIN_STATE(uintnat, swept_words)

DOMAIN_STATE(uintnat, major_slice_epoch)

DOMAIN_STATE(struct caml__roots_block*, local_roots)

DOMAIN_STATE(struct caml_ephe_info*, ephe_info)

DOMAIN_STATE(struct caml_final_info*, final_info)

DOMAIN_STATE(intnat, backtrace_pos)

DOMAIN_STATE(intnat, backtrace_active)

DOMAIN_STATE(backtrace_slot*, backtrace_buffer)

DOMAIN_STATE(value, backtrace_last_exn)

DOMAIN_STATE(intnat, compare_unordered)

DOMAIN_STATE(uintnat, oo_next_id_local)

DOMAIN_STATE(uintnat, requested_major_slice)
DOMAIN_STATE(uintnat, requested_global_major_slice)

DOMAIN_STATE(uintnat, requested_minor_gc)

DOMAIN_STATE(atomic_uintnat, requested_external_interrupt)

DOMAIN_STATE(int, parser_trace)
/* See parsing.c */

DOMAIN_STATE(asize_t, minor_heap_wsz)

DOMAIN_STATE(struct caml_heap_state*, shared_heap)

DOMAIN_STATE(int, id)

DOMAIN_STATE(int, unique_id)

DOMAIN_STATE(value, dls_root)
/* Domain-local state */

DOMAIN_STATE(double, extra_heap_resources)
DOMAIN_STATE(double, extra_heap_resources_minor)

DOMAIN_STATE(uintnat, dependent_size)
DOMAIN_STATE(uintnat, dependent_allocated)

/* How much work needs to be done (by all domains) before we stop this slice. */
DOMAIN_STATE(intnat, slice_target)

/* Minimum amount of work to do in this slice by this domain. */
DOMAIN_STATE(intnat, slice_budget)

/* Accounting for sweeping work done while allocating. */
DOMAIN_STATE(intnat, major_work_done_between_slices)

DOMAIN_STATE(struct caml_extern_state*, extern_state)
DOMAIN_STATE(struct caml_intern_state*, intern_state)

/*****************************************************************************/
/* GC stats (see gc_ctrl.c and the Gc module). */
/* These stats represent only the current domain's respective values. */
/* Use the Gc module to get aggregated total program stats. */
/*****************************************************************************/
DOMAIN_STATE(uintnat, stat_minor_words)
DOMAIN_STATE(uintnat, stat_promoted_words)
DOMAIN_STATE(uintnat, stat_major_words)
DOMAIN_STATE(intnat, stat_forced_major_collections)
DOMAIN_STATE(uintnat, stat_blocks_marked)

DOMAIN_STATE(int, inside_stw_handler)
/* whether or not a domain is inside of a stop-the-world handler
   this is used for several debug assertions inside of methods
   that can only be called from either in or outside this state. */

DOMAIN_STATE(intnat, trap_sp_off)
DOMAIN_STATE(intnat, trap_barrier_off)
DOMAIN_STATE(int64_t, trap_barrier_block)
DOMAIN_STATE(struct caml_exception_context*, external_raise)
/* Bytecode TLS vars, not used for native code */

DOMAIN_STATE(struct memprof_domain_s *, memprof)
DOMAIN_STATE(value *, memprof_young_trigger)

DOMAIN_STATE(extra_params_area, extra_params)
/* This member must occur last, because it is an array, not a scalar */
