#include <stddef.h>
#include <stdint.h>
#include "serene/rt/impl/hashmap.h"
#include "serene/utils.h"
Go to the source code of this file.
|
| struct | srn_engine_t |
| | Engine is a structure to own the long living and main pieces of the compiler. More...
|
| |
◆ ENGINE_FIRST_OBJECT_ID
| #define ENGINE_FIRST_OBJECT_ID 100 |
Start allocating IDs from 100, earlier IDs are reserved.
Definition at line 42 of file engine.h.
◆ SRN_HASH_TYPE
| #define SRN_HASH_TYPE uint32_t |
◆ SRN_SEED_TYPE
| #define SRN_SEED_TYPE uint32_t |
◆ hmap_t
| typedef struct hmap_t hmap_t |
◆ srn_engine_t
| typedef struct srn_engine_t srn_engine_t |
Engine is a structure to own the long living and main pieces of the compiler.
There will be only oe instance of the engine at anytime.
◆ srn_object_id_t
◆ srn_scheduler_t
| typedef struct srn_scheduler_t srn_scheduler_t |
◆ srn_allocate_object_id()
Definition at line 137 of file engine.c.
137 {
139 return atomic_fetch_add_explicit(&engine->
object_id_counter, 1, memory_order_relaxed);
140}
_Atomic srn_object_id_t object_id_counter
An unsigned counter to allocate object ids atomically.
#define PANIC_IF_NULL(ptr)
◆ srn_engine_make()
Definition at line 92 of file engine.c.
92 {
95
96 if (engine == nullptr) {
97 return nullptr;
98 }
99
101
103
104#ifdef SRN_WITH_SERENE
106#endif
108
109#ifdef SRN_WITH_SERENE
110
111
112
113 engine->namespaces = (
hmap_t){.len = 0, .root =
nullptr};
115 engine->keywords = (
hmap_t){.len = 0, .root =
nullptr};
117#endif
119
120 return engine;
121}
static srn_seed_t srn_generate_seed()
#define ENGINE_FIRST_OBJECT_ID
Start allocating IDs from 100, earlier IDs are reserved.
#define srn_mm_immortal_allocate(mm, T)
srn_jit_t * srn_jit_make(srn_mm_t *mm)
srn_scheduler_t * srn_sched_init(srn_engine_t *engine)
Engine is a structure to own the long living and main pieces of the compiler.
srn_scheduler_t * scheduler
The fiber scheduler, set by srn_sched_init.
srn_seed_t seed
We use the seed for hashing and the value will be generated at random for each new context.
srn_mm_t * mm
Memory manager.
static void srn_spinlock_init(srn_spinlock_t *lock)
◆ srn_engine_shutdown()
Definition at line 123 of file engine.c.
123 {
126#ifdef SRN_WITH_SERENE
128#endif
129}
int srn_jit_shutdown(srn_jit_t *jit)
void srn_sched_shutdown(srn_scheduler_t *sched)
The one stop tear down of the fiber subsystem, should be called once srn_sched_run has returned.
◆ srn_hash()
Definition at line 131 of file engine.c.
131 {
132
133 size_t length = (data == nullptr) ? 0 : len;
134 return XXH32(data, length, engine->
seed);
135}