navid/haze / 3c6c4021d53bee44758c7a4e9618e2a5c90f03298531081eb98fcdc6f320ce0f / runtime/hazert.h

hazert.h

← runtime · 1572 bytes · raw · download

#ifndef HAZERT_H
#define HAZERT_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct HazeRootMap {
    uint32_t count;
    uint32_t frame_size;
    const uint32_t* offsets;
} HazeRootMap;

typedef struct HazeRootFrame {
    struct HazeRootFrame* previous;
    const HazeRootMap* descriptor;
    void** slots;
} HazeRootFrame;

/* Collector entry points.  All of these use the C ABI. */
void haze_runtime_init(void);
void* haze_alloc_slow(uint32_t payload_size, uint32_t type_id);
void* haze_alloc_large(uint32_t payload_size, uint32_t type_id);
uint32_t haze_type_for_size(uint32_t total_size);
uint32_t haze_register_type(uint32_t total_size, uint32_t pointer_count,
                           const uint32_t* pointer_offsets);

void haze_gc_poll(void);
void haze_gc_request(void);
void haze_gc_collect(void);
void haze_gc_verify(void);
int haze_gc_object_alive(void* object);

void haze_thread_attach(void);
void haze_thread_detach(void);

void haze_root_enter(HazeRootFrame* frame);
void haze_root_leave(HazeRootFrame* frame);
void haze_root_add(void** slot);
void haze_root_remove(void** slot);

void haze_native_enter(void);
void haze_native_exit(void);
void haze_pin(void* object);
void haze_unpin(void* object);
void haze_wb(void* object, void** slot, void* value);

/* Small runtime used by generated programs. */
void haze_print_i32(int32_t value);
void haze_print_i64(int64_t value);
void haze_print_bool(int32_t value);
void haze_print_str(const char* value);
void haze_panic(const char* message);

#ifdef __cplusplus
}
#endif

#endif