mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-25 14:22:27 +03:00
0154018363
* FBT: cdefines to env, libs order * API: strtod, modf, itoa, calloc * Apps: elk js * Apps: mjs * JS: scripts as assets * mjs: composite resolver * mjs: stack trace * ELK JS example removed * MJS thread, MJS lib modified to support script interruption * JS console UI * Module system, BadUSB bindings rework * JS notifications, simple dialog, BadUSB demo * Custom dialogs, dialog demo * MJS as system library, some dirty hacks to make it compile * Plugin-based js modules * js_uart(BadUART) module * js_uart: support for byte array arguments * Script icon and various fixes * File browser: multiple extensions filter, running js scripts from app loader * Running js scripts from archive browser * JS Runner as system app * Example scripts moved to /ext/apps/Scripts * JS bytecode listing generation * MJS builtin printf cleanup * JS examples cleanup * mbedtls version fix * Unused lib cleanup * Making PVS happy & TODOs cleanup * TODOs cleanup #2 * MJS: initial typed arrays support * JS: fix mem leak in uart destructor Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
61 lines
1.6 KiB
C
61 lines
1.6 KiB
C
/*
|
|
* Copyright (c) 2014 Cesanta Software Limited
|
|
* All rights reserved
|
|
*/
|
|
|
|
#ifndef MJS_GC_H_
|
|
#define MJS_GC_H_
|
|
|
|
#include "mjs_core.h"
|
|
#include "mjs_mm.h"
|
|
#include "mjs_internal.h"
|
|
#include "mjs_gc_public.h"
|
|
|
|
#if defined(__cplusplus)
|
|
extern "C" {
|
|
#endif /* __cplusplus */
|
|
|
|
/*
|
|
* performs arithmetics on gc_cell pointers as if they were arena->cell_size
|
|
* bytes wide
|
|
*/
|
|
#define GC_CELL_OP(arena, cell, op, arg) \
|
|
((struct gc_cell*)(((char*)(cell))op((arg) * (arena)->cell_size)))
|
|
|
|
struct gc_cell {
|
|
union {
|
|
struct gc_cell* link;
|
|
uintptr_t word;
|
|
} head;
|
|
};
|
|
|
|
MJS_PRIVATE int gc_strings_is_gc_needed(struct mjs* mjs);
|
|
|
|
/* perform gc if not inhibited */
|
|
MJS_PRIVATE int maybe_gc(struct mjs* mjs);
|
|
|
|
MJS_PRIVATE struct mjs_object* new_object(struct mjs*);
|
|
MJS_PRIVATE struct mjs_property* new_property(struct mjs*);
|
|
MJS_PRIVATE struct mjs_ffi_sig* new_ffi_sig(struct mjs* mjs);
|
|
|
|
MJS_PRIVATE void gc_mark(struct mjs* mjs, mjs_val_t* val);
|
|
|
|
MJS_PRIVATE void gc_arena_init(struct gc_arena*, size_t, size_t, size_t);
|
|
MJS_PRIVATE void gc_arena_destroy(struct mjs*, struct gc_arena* a);
|
|
MJS_PRIVATE void gc_sweep(struct mjs*, struct gc_arena*, size_t);
|
|
MJS_PRIVATE void* gc_alloc_cell(struct mjs*, struct gc_arena*);
|
|
|
|
MJS_PRIVATE uint64_t gc_string_mjs_val_to_offset(mjs_val_t v);
|
|
|
|
/* return 0 if v is an object/function with a bad pointer */
|
|
MJS_PRIVATE int gc_check_val(struct mjs* mjs, mjs_val_t v);
|
|
|
|
/* checks whether a pointer is within the ranges of an arena */
|
|
MJS_PRIVATE int gc_check_ptr(const struct gc_arena* a, const void* p);
|
|
|
|
#if defined(__cplusplus)
|
|
}
|
|
#endif /* __cplusplus */
|
|
|
|
#endif /* MJS_GC_H_ */
|