hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
memory.h File Reference
#include <cstdint>
#include <cstdlib>
#include <runtime/build_config.h>
#include <runtime/rtti/rtti.h>
Include dependency graph for memory.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  YoiObject
 
struct  YoiObjectArray
 
struct  YoiIntegerObject
 
struct  YoiUnsignedObject
 
struct  YoiStringObject
 
struct  YoiBooleanObject
 
struct  YoiDecimalObject
 
struct  YoiCharObject
 
struct  YoiShortObject
 
struct  AllocatedMemoryList
 

Macros

#define GC_WRAPPER_IMPL(X, U)
 
#define GC_WRAPPER_INLINE(X, U)
 

Functions

void * runtime_object_alloc_report (size_t size, void *object)
 
void runtime_finalize_object_report (YoiObject *object)
 
void runtime_finalize_object (YoiObject *object)
 
void * runtime_object_alloc (unsigned long size)
 
YoiIntegerObjectruntime_get_string_array_data_pointer (YoiObjectArray *array)
 
void * runtime_exec_permit_alloc (unsigned long size)
 
void runtime_exec_permit_free (void *ptr)
 
 GC_WRAPPER_INLINE (int, YoiIntegerObject)
 
 GC_WRAPPER_INLINE (decimal, YoiDecimalObject)
 
 GC_WRAPPER_INLINE (bool, YoiBooleanObject)
 
 GC_WRAPPER_INLINE (char, YoiCharObject)
 
 GC_WRAPPER_INLINE (string, YoiStringObject)
 
 GC_WRAPPER_INLINE (unsigned, YoiUnsignedObject)
 
 GC_WRAPPER_INLINE (short, YoiShortObject)
 

Macro Definition Documentation

◆ GC_WRAPPER_IMPL

#define GC_WRAPPER_IMPL (   X,
 
)
Value:
extern "C" void basic_##X##_gc_refcount_increase(U* obj) { \
obj->gc_refcount++; \
} \
\
extern "C" void basic_##X##_gc_refcount_decrease(U* obj) { \
obj->gc_refcount--; \
if (obj->gc_refcount <= 0) { \
runtime_finalize_object((YoiObject*)obj); \
} \
}

Definition at line 104 of file memory.h.

◆ GC_WRAPPER_INLINE

#define GC_WRAPPER_INLINE (   X,
 
)
Value:
static inline void basic_##X##_gc_refcount_increase(U* obj) { \
if (!obj) return; \
obj->gc_refcount++; \
} \
\
static inline void basic_##X##_gc_refcount_decrease(U* obj) { \
if (!obj) return; \
obj->gc_refcount--; \
if (obj->gc_refcount <= 0) { \
runtime_finalize_object((YoiObject*)obj); \
} \
}

Definition at line 116 of file memory.h.

Function Documentation

◆ GC_WRAPPER_INLINE() [1/7]

GC_WRAPPER_INLINE ( bool  ,
YoiBooleanObject   
)

◆ GC_WRAPPER_INLINE() [2/7]

GC_WRAPPER_INLINE ( char  ,
YoiCharObject   
)

◆ GC_WRAPPER_INLINE() [3/7]

GC_WRAPPER_INLINE ( decimal  ,
YoiDecimalObject   
)

◆ GC_WRAPPER_INLINE() [4/7]

GC_WRAPPER_INLINE ( int  ,
YoiIntegerObject   
)

◆ GC_WRAPPER_INLINE() [5/7]

GC_WRAPPER_INLINE ( short  ,
YoiShortObject   
)

◆ GC_WRAPPER_INLINE() [6/7]

GC_WRAPPER_INLINE ( string  ,
YoiStringObject   
)

◆ GC_WRAPPER_INLINE() [7/7]

GC_WRAPPER_INLINE ( unsigned  ,
YoiUnsignedObject   
)

◆ runtime_exec_permit_alloc()

void * runtime_exec_permit_alloc ( unsigned long  size)

Definition at line 123 of file memory.cpp.

◆ runtime_exec_permit_free()

void runtime_exec_permit_free ( void *  ptr)

Definition at line 154 of file memory.cpp.

◆ runtime_finalize_object()

◆ runtime_finalize_object_report()

void runtime_finalize_object_report ( YoiObject object)

Definition at line 65 of file memory.cpp.

References hperf_report_mem_free(), AllocatedMemoryList::next, AllocatedMemoryList::prev, rtti_table, YoiObject::type_id, and YoiTypeInfo::type_name.

Referenced by runtime_finalize_object().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runtime_get_string_array_data_pointer()

YoiIntegerObject * runtime_get_string_array_data_pointer ( YoiObjectArray array)

Definition at line 102 of file memory.cpp.

References YoiObjectArray::data, YoiObjectArray::gc_refcount, YoiIntegerObject::gc_refcount, runtime_finalize_object(), and runtime_object_alloc().

Here is the call graph for this function:

◆ runtime_object_alloc()

◆ runtime_object_alloc_report()

void * runtime_object_alloc_report ( size_t  size,
void *  object 
)

Definition at line 37 of file memory.cpp.

References hperf_report_mem_alloc(), AllocatedMemoryList::memory, AllocatedMemoryList::next, AllocatedMemoryList::prev, and AllocatedMemoryList::size.

Referenced by runtime_object_alloc().

Here is the call graph for this function:
Here is the caller graph for this function: