Flipper Developer Docs
Loading...
Searching...
No Matches
mjs_gc.h
1
/*
2
* Copyright (c) 2014 Cesanta Software Limited
3
* All rights reserved
4
*/
5
6
#ifndef MJS_GC_H_
7
#define MJS_GC_H_
8
9
#include "mjs_core.h"
10
#include "mjs_mm.h"
11
#include "mjs_internal.h"
12
#include "mjs_gc_public.h"
13
14
#if defined(__cplusplus)
15
extern
"C"
{
16
#endif
/* __cplusplus */
17
18
/*
19
* performs arithmetics on gc_cell pointers as if they were arena->cell_size
20
* bytes wide
21
*/
22
#define GC_CELL_OP(arena, cell, op, arg) \
23
((struct gc_cell*)(((char*)(cell))op((arg) * (arena)->cell_size)))
24
25
struct
gc_cell
{
26
union
{
27
struct
gc_cell
* link;
28
uintptr_t word;
29
} head;
30
};
31
32
MJS_PRIVATE
int
gc_strings_is_gc_needed(
struct
mjs
*
mjs
);
33
34
/* perform gc if not inhibited */
35
MJS_PRIVATE
int
maybe_gc(
struct
mjs
*
mjs
);
36
37
MJS_PRIVATE
struct
mjs_object
* new_object(
struct
mjs
*);
38
MJS_PRIVATE
struct
mjs_property
* new_property(
struct
mjs
*);
39
MJS_PRIVATE
struct
mjs_ffi_sig
* new_ffi_sig(
struct
mjs
*
mjs
);
40
41
MJS_PRIVATE
void
gc_mark(
struct
mjs
*
mjs
, mjs_val_t* val);
42
43
MJS_PRIVATE
void
gc_arena_init(
struct
gc_arena
*,
size_t
,
size_t
,
size_t
);
44
MJS_PRIVATE
void
gc_arena_destroy(
struct
mjs
*,
struct
gc_arena
* a);
45
MJS_PRIVATE
void
gc_sweep(
struct
mjs
*,
struct
gc_arena
*,
size_t
);
46
MJS_PRIVATE
void
* gc_alloc_cell(
struct
mjs
*,
struct
gc_arena
*);
47
48
MJS_PRIVATE uint64_t gc_string_mjs_val_to_offset(mjs_val_t v);
49
50
/* return 0 if v is an object/function with a bad pointer */
51
MJS_PRIVATE
int
gc_check_val(
struct
mjs
*
mjs
, mjs_val_t v);
52
53
/* checks whether a pointer is within the ranges of an arena */
54
MJS_PRIVATE
int
gc_check_ptr(
const
struct
gc_arena
* a,
const
void
* p);
55
56
#if defined(__cplusplus)
57
}
58
#endif
/* __cplusplus */
59
60
#endif
/* MJS_GC_H_ */
gc_arena
Definition
mjs_mm.h:25
gc_cell
Definition
mjs_gc.h:25
mjs_ffi_sig
Definition
mjs_ffi.h:30
mjs_object
Definition
mjs_object.h:24
mjs_property
Definition
mjs_object.h:18
mjs
Definition
mjs_core.h:63
lib
mjs
mjs_gc.h
Generated by
1.12.0