Reduct  v4.0.5-1-g4851deb
A functional and immutable language.
Loading...
Searching...
No Matches
Item

Detailed Description

An item is a generic container for all data types and heap allocated structures within Reduct.

To optimize memory cacheing and reduce fragmentation, all items are 64 bytes and aligned to cache lines.

Data Structures

struct  reduct_item_t
 Item structure. More...
 
struct  reduct_item_block_t
 Item block structure. More...
 
struct  reduct_item_global_t
 Global item-related state structure. More...
 
struct  reduct_item_local_t
 Per-thread item-related state structure. More...
 

Macros

#define REDUCT_ITEM_TYPE_NONE   0
 No type.
 
#define REDUCT_ITEM_TYPE_ATOM   1
 An atom.
 
#define REDUCT_ITEM_TYPE_ARENA   2
 An arena.
 
#define REDUCT_ITEM_TYPE_LIST   3
 A list.
 
#define REDUCT_ITEM_TYPE_FUNCTION   4
 A function.
 
#define REDUCT_ITEM_TYPE_CLOSURE   5
 A closure.
 
#define REDUCT_ITEM_TYPE_RVSDG_NODE   6
 An IR node.
 
#define REDUCT_ITEM_TYPE_RVSDG_EDGE   7
 An IR edge.
 
#define REDUCT_ITEM_TYPE_RVSDG_REGION   8
 An IR region.
 
#define REDUCT_ITEM_TYPE_RVSDG_USER   9
 An IR user (input/result).
 
#define REDUCT_ITEM_TYPE_RVSDG_ORIGIN   10
 An IR origin (output/argument).
 
#define REDUCT_ITEM_TYPE_FUTURE   11
 A future.
 
#define REDUCT_ITEM_FLAG_NONE   0
 No flags.
 
#define REDUCT_ITEM_FLAG_MARKED   (1 << 0)
 Item is marked by the GC.
 
#define REDUCT_ITEM_FLAG_RETAINED   (1 << 1)
 Item is retained and should be considered a root by the GC.
 
#define REDUCT_ITEM_PAYLOAD_MAX   56
 The maximum size of the item payload.
 
#define REDUCT_ITEM_BLOCK_MAX   127
 The maximum number of items in a block.
 

Typedefs

typedef uint8_t reduct_item_type_t
 Item type enumeration.
 
typedef uint8_t reduct_item_flags_t
 Item flags enumeration.
 

Functions

REDUCT_API void reduct_item_global_init (reduct_item_global_t *global)
 Initialize a global item state.
 
REDUCT_API void reduct_item_global_deinit (struct reduct *reduct, reduct_item_global_t *global)
 Deinitialize a global item state.
 
REDUCT_API void reduct_item_local_init (reduct_item_local_t *local)
 Initialize a local item state.
 
REDUCT_API void reduct_item_local_deinit (reduct_item_local_t *local)
 Deinitialize a local item state.
 
REDUCT_API reduct_item_treduct_item_new (struct reduct *reduct)
 Allocate a new item.
 
REDUCT_API void reduct_item_deinit (struct reduct *reduct, reduct_item_t *item)
 Deinitialize a item without adding it to the freelist.
 
REDUCT_API void reduct_item_free (struct reduct *reduct, reduct_item_t *item)
 Free an item.
 
REDUCT_API const char * reduct_item_type_str (reduct_item_t *item)
 Get the string representation of the type of an item.
 
REDUCT_API void reduct_item_mark (reduct_item_t *item)
 Mark an item as reachable.
 
static REDUCT_ALWAYS_INLINE void reduct_item_retain (struct reduct_item *item)
 Retain an item, preventing it from being collected by the garbage collector.
 
static REDUCT_ALWAYS_INLINE void reduct_item_release (struct reduct_item *item)
 Release an item, potentially allowing the garbage collector to collect it.
 

Macro Definition Documentation

◆ REDUCT_ITEM_TYPE_NONE

#define REDUCT_ITEM_TYPE_NONE   0

No type.

Definition at line 30 of file item.h.

◆ REDUCT_ITEM_TYPE_ATOM

#define REDUCT_ITEM_TYPE_ATOM   1

An atom.

Definition at line 31 of file item.h.

◆ REDUCT_ITEM_TYPE_ARENA

#define REDUCT_ITEM_TYPE_ARENA   2

An arena.

Definition at line 32 of file item.h.

◆ REDUCT_ITEM_TYPE_LIST

#define REDUCT_ITEM_TYPE_LIST   3

A list.

Definition at line 33 of file item.h.

◆ REDUCT_ITEM_TYPE_FUNCTION

#define REDUCT_ITEM_TYPE_FUNCTION   4

A function.

Definition at line 34 of file item.h.

◆ REDUCT_ITEM_TYPE_CLOSURE

#define REDUCT_ITEM_TYPE_CLOSURE   5

A closure.

Definition at line 35 of file item.h.

◆ REDUCT_ITEM_TYPE_RVSDG_NODE

#define REDUCT_ITEM_TYPE_RVSDG_NODE   6

An IR node.

Definition at line 36 of file item.h.

◆ REDUCT_ITEM_TYPE_RVSDG_EDGE

#define REDUCT_ITEM_TYPE_RVSDG_EDGE   7

An IR edge.

Definition at line 37 of file item.h.

◆ REDUCT_ITEM_TYPE_RVSDG_REGION

#define REDUCT_ITEM_TYPE_RVSDG_REGION   8

An IR region.

Definition at line 38 of file item.h.

◆ REDUCT_ITEM_TYPE_RVSDG_USER

#define REDUCT_ITEM_TYPE_RVSDG_USER   9

An IR user (input/result).

Definition at line 39 of file item.h.

◆ REDUCT_ITEM_TYPE_RVSDG_ORIGIN

#define REDUCT_ITEM_TYPE_RVSDG_ORIGIN   10

An IR origin (output/argument).

Definition at line 40 of file item.h.

◆ REDUCT_ITEM_TYPE_FUTURE

#define REDUCT_ITEM_TYPE_FUTURE   11

A future.

Definition at line 41 of file item.h.

◆ REDUCT_ITEM_FLAG_NONE

#define REDUCT_ITEM_FLAG_NONE   0

No flags.

Definition at line 44 of file item.h.

◆ REDUCT_ITEM_FLAG_MARKED

#define REDUCT_ITEM_FLAG_MARKED   (1 << 0)

Item is marked by the GC.

Definition at line 45 of file item.h.

◆ REDUCT_ITEM_FLAG_RETAINED

#define REDUCT_ITEM_FLAG_RETAINED   (1 << 1)

Item is retained and should be considered a root by the GC.

Definition at line 46 of file item.h.

◆ REDUCT_ITEM_PAYLOAD_MAX

#define REDUCT_ITEM_PAYLOAD_MAX   56

The maximum size of the item payload.

Definition at line 48 of file item.h.

◆ REDUCT_ITEM_BLOCK_MAX

#define REDUCT_ITEM_BLOCK_MAX   127

The maximum number of items in a block.

Definition at line 86 of file item.h.

Typedef Documentation

◆ reduct_item_type_t

typedef uint8_t reduct_item_type_t

Item type enumeration.

Definition at line 29 of file item.h.

◆ reduct_item_flags_t

typedef uint8_t reduct_item_flags_t

Item flags enumeration.

Definition at line 43 of file item.h.

Function Documentation

◆ reduct_item_global_init()

REDUCT_API void reduct_item_global_init ( reduct_item_global_t global)

Initialize a global item state.

Parameters
globalPointer to the global item state to initialize.

◆ reduct_item_global_deinit()

REDUCT_API void reduct_item_global_deinit ( struct reduct *  reduct,
reduct_item_global_t global 
)

Deinitialize a global item state.

Parameters
reductPointer to the Reduct structure.
globalPointer to the global item state to deinitialize.

◆ reduct_item_local_init()

REDUCT_API void reduct_item_local_init ( reduct_item_local_t local)

Initialize a local item state.

Parameters
localPointer to the local item state to initialize.

◆ reduct_item_local_deinit()

REDUCT_API void reduct_item_local_deinit ( reduct_item_local_t local)

Deinitialize a local item state.

Parameters
localPointer to the local item state to deinitialize.

◆ reduct_item_new()

REDUCT_API reduct_item_t * reduct_item_new ( struct reduct *  reduct)

Allocate a new item.

Parameters
reductPointer to the Reduct structure.
Returns
A pointer to the newly created item.

◆ reduct_item_deinit()

REDUCT_API void reduct_item_deinit ( struct reduct *  reduct,
reduct_item_t item 
)

Deinitialize a item without adding it to the freelist.

Parameters
reductPointer to the Reduct structure.
itemPointer to the item to deinitialize.

◆ reduct_item_free()

REDUCT_API void reduct_item_free ( struct reduct *  reduct,
reduct_item_t item 
)

Free an item.

Intended to be used by the GC or when it is known that an item has no more users and was allocated by the current thread.

Parameters
reductPointer to the Reduct structure.
itemPointer to the item to free.

◆ reduct_item_type_str()

REDUCT_API const char * reduct_item_type_str ( reduct_item_t item)

Get the string representation of the type of an item.

Parameters
itemPointer to the item.
Returns
The string representation of the item type.

◆ reduct_item_mark()

REDUCT_API void reduct_item_mark ( reduct_item_t item)

Mark an item as reachable.

Used by the garbage collector.

Parameters
itemPointer to the item to mark.

◆ reduct_item_retain()

static REDUCT_ALWAYS_INLINE void reduct_item_retain ( struct reduct_item *  item)
inlinestatic

Retain an item, preventing it from being collected by the garbage collector.

Parameters
itemPointer to the item to retain.

Definition at line 209 of file item.h.

◆ reduct_item_release()

static REDUCT_ALWAYS_INLINE void reduct_item_release ( struct reduct_item *  item)
inlinestatic

Release an item, potentially allowing the garbage collector to collect it.

Parameters
itemPointer to the item to release.

Definition at line 220 of file item.h.