Skip to content

Commit

Permalink
rename internal memory functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Dec 26, 2020
1 parent 7807aea commit 7bfc7f1
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 75 deletions.
8 changes: 4 additions & 4 deletions include/lightning/jit_private.h
Expand Up @@ -739,11 +739,11 @@ extern void _jit_annotate(jit_state_t*);
#define jit_print_node(u) _jit_print_node(_jit,u)
extern void _jit_print_node(jit_state_t*,jit_node_t*);

extern jit_pointer_t jit_memcpy(jit_pointer_t,const void*,jit_word_t);
extern jit_pointer_t jit_memmove(jit_pointer_t,const void*,jit_word_t);
extern jit_pointer_t jit_lightning_memcpy(jit_pointer_t,const void*,jit_word_t);
extern jit_pointer_t jit_lightning_memmove(jit_pointer_t,const void*,jit_word_t);
extern void jit_alloc(jit_pointer_t*, jit_word_t);
extern void jit_realloc(jit_pointer_t*, jit_word_t, jit_word_t);
void jit_free(jit_pointer_t*);
extern void jit_lightning_realloc(jit_pointer_t*, jit_word_t, jit_word_t);
void jit_lightning_free(jit_pointer_t*);

extern void jit_init_size(void);
extern void jit_finish_size(void);
Expand Down
4 changes: 2 additions & 2 deletions lib/jit_aarch64.c
Expand Up @@ -163,7 +163,7 @@ _jit_prolog(jit_state_t *_jit)
jit_regset_set_ui(&_jitc->regsav, 0);
offset = _jitc->functions.offset;
if (offset >= _jitc->functions.length) {
jit_realloc((jit_pointer_t *)&_jitc->functions.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->functions.ptr,
_jitc->functions.length * sizeof(jit_function_t),
(_jitc->functions.length + 16) * sizeof(jit_function_t));
_jitc->functions.length += 16;
Expand Down Expand Up @@ -1571,7 +1571,7 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
flag = node->u.n->flag;
assert(!(flag & jit_flag_patch));
if (_jitc->patches.offset >= _jitc->patches.length) {
jit_realloc((jit_pointer_t *)&_jitc->patches.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->patches.ptr,
_jitc->patches.length * sizeof(jit_patch_t),
(_jitc->patches.length + 1024) * sizeof(jit_patch_t));
_jitc->patches.length += 1024;
Expand Down
4 changes: 2 additions & 2 deletions lib/jit_alpha.c
Expand Up @@ -163,7 +163,7 @@ _jit_prolog(jit_state_t *_jit)
jit_regset_set_ui(&_jitc->regsav, 0);
offset = _jitc->functions.offset;
if (offset >= _jitc->functions.length) {
jit_realloc((jit_pointer_t *)&_jitc->functions.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->functions.ptr,
_jitc->functions.length * sizeof(jit_function_t),
(_jitc->functions.length + 16) * sizeof(jit_function_t));
_jitc->functions.length += 16;
Expand Down Expand Up @@ -1541,7 +1541,7 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
flag = node->u.n->flag;
assert(!(flag & jit_flag_patch));
if (_jitc->patches.offset >= _jitc->patches.length) {
jit_realloc((jit_pointer_t *)&_jitc->patches.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->patches.ptr,
_jitc->patches.length * sizeof(jit_patch_t),
(_jitc->patches.length + 1024) * sizeof(jit_patch_t));
_jitc->patches.length += 1024;
Expand Down
8 changes: 4 additions & 4 deletions lib/jit_arm.c
Expand Up @@ -237,7 +237,7 @@ _jit_prolog(jit_state_t *_jit)
jit_regset_set_ui(&_jitc->regsav, 0);
offset = _jitc->functions.offset;
if (offset >= _jitc->functions.length) {
jit_realloc((jit_pointer_t *)&_jitc->functions.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->functions.ptr,
_jitc->functions.length * sizeof(jit_function_t),
(_jitc->functions.length + 16) * sizeof(jit_function_t));
_jitc->functions.length += 16;
Expand Down Expand Up @@ -2207,13 +2207,13 @@ _flush_consts(jit_state_t *_jit)
_jitc->consts.size = _jitc->consts.length << 2;
/* FIXME check will not overrun, otherwise, need to reallocate
* code buffer and start over */
jit_memcpy(_jitc->consts.data, _jitc->consts.values, _jitc->consts.size);
jit_lightning_memcpy(_jitc->consts.data, _jitc->consts.values, _jitc->consts.size);
_jit->pc.w += _jitc->consts.size;

#if DISASSEMBLER
if (_jitc->data_info.ptr) {
if (_jitc->data_info.offset >= _jitc->data_info.length) {
jit_realloc((jit_pointer_t *)&_jitc->data_info.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->data_info.ptr,
_jitc->data_info.length * sizeof(jit_data_info_t),
(_jitc->data_info.length + 1024) *
sizeof(jit_data_info_t));
Expand Down Expand Up @@ -2262,7 +2262,7 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
assert(!(flag & jit_flag_patch));
kind |= arm_patch_node;
if (_jitc->patches.offset >= _jitc->patches.length) {
jit_realloc((jit_pointer_t *)&_jitc->patches.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->patches.ptr,
_jitc->patches.length * sizeof(jit_patch_t),
(_jitc->patches.length + 1024) * sizeof(jit_patch_t));
_jitc->patches.length += 1024;
Expand Down
6 changes: 3 additions & 3 deletions lib/jit_disasm.c
Expand Up @@ -189,7 +189,7 @@ jit_init_debug(const char *progname)
sym_count,
&disasm_synthetic);
if (disasm_num_synthetic > 0) {
jit_realloc((jit_pointer_t *)&disasm_symbols,
jit_lightning_realloc((jit_pointer_t *)&disasm_symbols,
(sym_storage + dyn_storage) * sizeof(asymbol *),
(sym_storage + dyn_storage + disasm_num_synthetic) *
sizeof(asymbol *));
Expand Down Expand Up @@ -222,9 +222,9 @@ jit_finish_debug(void)
{
#if DISASSEMBLER
if (disasm_synthetic)
jit_free((jit_pointer_t *)&disasm_synthetic);
jit_lightning_free((jit_pointer_t *)&disasm_synthetic);
if (disasm_symbols)
jit_free((jit_pointer_t *)&disasm_symbols);
jit_lightning_free((jit_pointer_t *)&disasm_symbols);
if (disasm_bfd)
bfd_close (disasm_bfd);
#endif
Expand Down
4 changes: 2 additions & 2 deletions lib/jit_hppa.c
Expand Up @@ -149,7 +149,7 @@ _jit_prolog(jit_state_t *_jit)
jit_regset_set_ui(&_jitc->regsav, 0);
offset = _jitc->functions.offset;
if (offset >= _jitc->functions.length) {
jit_realloc((jit_pointer_t *)&_jitc->functions.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->functions.ptr,
_jitc->functions.length * sizeof(jit_function_t),
(_jitc->functions.length + 16) * sizeof(jit_function_t));
_jitc->functions.length += 16;
Expand Down Expand Up @@ -1574,7 +1574,7 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
flag = node->u.n->flag;
assert(!(flag & jit_flag_patch));
if (_jitc->patches.offset >= _jitc->patches.length) {
jit_realloc((jit_pointer_t *)&_jitc->patches.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->patches.ptr,
_jitc->patches.length * sizeof(jit_patch_t),
(_jitc->patches.length + 1024) * sizeof(jit_patch_t));
_jitc->patches.length += 1024;
Expand Down
6 changes: 3 additions & 3 deletions lib/jit_ia64.c
Expand Up @@ -259,7 +259,7 @@ _jit_prolog(jit_state_t *_jit)
jit_regset_set_ui(&_jitc->regsav, 0);
offset = _jitc->functions.offset;
if (offset >= _jitc->functions.length) {
jit_realloc((jit_pointer_t *)&_jitc->functions.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->functions.ptr,
_jitc->functions.length * sizeof(jit_function_t),
(_jitc->functions.length + 16) * sizeof(jit_function_t));
_jitc->functions.length += 16;
Expand Down Expand Up @@ -1531,7 +1531,7 @@ _emit_code(jit_state_t *_jit)
* a common practice as first jit instruction */
if (_jitc->prolog.offset >= _jitc->prolog.length) {
_jitc->prolog.length += 16;
jit_realloc((jit_pointer_t *)&_jitc->prolog.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->prolog.ptr,
(_jitc->prolog.length - 16) *
sizeof(jit_word_t),
_jitc->prolog.length * sizeof(jit_word_t));
Expand Down Expand Up @@ -1758,7 +1758,7 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
flag = node->u.n->flag;
assert(!(flag & jit_flag_patch));
if (_jitc->patches.offset >= _jitc->patches.length) {
jit_realloc((jit_pointer_t *)&_jitc->patches.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->patches.ptr,
_jitc->patches.length * sizeof(jit_patch_t),
(_jitc->patches.length + 1024) * sizeof(jit_patch_t));
_jitc->patches.length += 1024;
Expand Down
8 changes: 4 additions & 4 deletions lib/jit_memory.c
Expand Up @@ -39,15 +39,15 @@ static jit_free_func_ptr jit_free_ptr = jit_default_free_func;
* Implementation
*/
jit_pointer_t
jit_memcpy(jit_pointer_t dst, const void * src, jit_word_t size)
jit_lightning_memcpy(jit_pointer_t dst, const void * src, jit_word_t size)
{
if (size)
return (memcpy(dst, src, size));
return (dst);
}

jit_pointer_t
jit_memmove(jit_pointer_t dst, const void *src , jit_word_t size)
jit_lightning_memmove(jit_pointer_t dst, const void *src , jit_word_t size)
{
if (size)
return (memmove(dst, src, size));
Expand Down Expand Up @@ -88,15 +88,15 @@ jit_alloc(jit_pointer_t *ptr, jit_word_t size)
}

void
jit_realloc(jit_pointer_t *ptr, jit_word_t old_size, jit_word_t new_size)
jit_lightning_realloc(jit_pointer_t *ptr, jit_word_t old_size, jit_word_t new_size)
{
*ptr = (*jit_realloc_ptr)(*ptr, new_size);
if (old_size < new_size)
memset((jit_int8_t*)*ptr + old_size, 0, new_size - old_size);
}

void
jit_free(jit_pointer_t *ptr)
jit_lightning_free(jit_pointer_t *ptr)
{
if (*ptr) {
(*jit_free_ptr)(*ptr);
Expand Down
4 changes: 2 additions & 2 deletions lib/jit_mips.c
Expand Up @@ -177,7 +177,7 @@ _jit_prolog(jit_state_t *_jit)
jit_regset_set_ui(&_jitc->regsav, 0);
offset = _jitc->functions.offset;
if (offset >= _jitc->functions.length) {
jit_realloc((jit_pointer_t *)&_jitc->functions.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->functions.ptr,
_jitc->functions.length * sizeof(jit_function_t),
(_jitc->functions.length + 16) * sizeof(jit_function_t));
_jitc->functions.length += 16;
Expand Down Expand Up @@ -1919,7 +1919,7 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
flag = node->u.n->flag;
assert(!(flag & jit_flag_patch));
if (_jitc->patches.offset >= _jitc->patches.length) {
jit_realloc((jit_pointer_t *)&_jitc->patches.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->patches.ptr,
_jitc->patches.length * sizeof(jit_patch_t),
(_jitc->patches.length + 1024) * sizeof(jit_patch_t));
_jitc->patches.length += 1024;
Expand Down
24 changes: 12 additions & 12 deletions lib/jit_note.c
Expand Up @@ -136,8 +136,8 @@ _jit_annotate(jit_state_t *_jit)
if ((length = sizeof(jit_line_t) * note->length) == 0)
continue;
assert(_jitc->note.base + length < _jit->data.ptr + _jit->data.length);
jit_memcpy(_jitc->note.base, note->lines, length);
jit_free((jit_pointer_t *)&note->lines);
jit_lightning_memcpy(_jitc->note.base, note->lines, length);
jit_lightning_free((jit_pointer_t *)&note->lines);
note->lines = (jit_line_t *)_jitc->note.base;
_jitc->note.base += length;
}
Expand All @@ -150,14 +150,14 @@ _jit_annotate(jit_state_t *_jit)
length = sizeof(jit_int32_t) * line->length;
assert(_jitc->note.base + length <
_jit->data.ptr + _jit->data.length);
jit_memcpy(_jitc->note.base, line->linenos, length);
jit_free((jit_pointer_t *)&line->linenos);
jit_lightning_memcpy(_jitc->note.base, line->linenos, length);
jit_lightning_free((jit_pointer_t *)&line->linenos);
line->linenos = (jit_int32_t *)_jitc->note.base;
_jitc->note.base += length;
assert(_jitc->note.base + length <
_jit->data.ptr + _jit->data.length);
jit_memcpy(_jitc->note.base, line->offsets, length);
jit_free((jit_pointer_t *)&line->offsets);
jit_lightning_memcpy(_jitc->note.base, line->offsets, length);
jit_lightning_free((jit_pointer_t *)&line->offsets);
line->offsets = (jit_int32_t *)_jitc->note.base;
_jitc->note.base += length;
}
Expand Down Expand Up @@ -193,17 +193,17 @@ _jit_set_note(jit_state_t *_jit, jit_note_t *note,
else {
/* line or offset changed */
if ((line->length & 15) == 0) {
jit_realloc((jit_pointer_t *)&line->linenos,
jit_lightning_realloc((jit_pointer_t *)&line->linenos,
line->length * sizeof(jit_int32_t),
(line->length + 17) * sizeof(jit_int32_t));
jit_realloc((jit_pointer_t *)&line->offsets,
jit_lightning_realloc((jit_pointer_t *)&line->offsets,
line->length * sizeof(jit_int32_t),
(line->length + 17) * sizeof(jit_int32_t));
}
if (index < note->length) {
jit_memmove(line->linenos + index + 1, line->linenos + index,
jit_lightning_memmove(line->linenos + index + 1, line->linenos + index,
sizeof(jit_int32_t) * (line->length - index));
jit_memmove(line->offsets + index + 1, line->offsets + index,
jit_lightning_memmove(line->offsets + index + 1, line->offsets + index,
sizeof(jit_int32_t) * (line->length - index));
}
line->linenos[index] = lineno;
Expand Down Expand Up @@ -276,12 +276,12 @@ new_line(jit_int32_t index, jit_note_t *note,
if (note->lines == NULL)
jit_alloc((jit_pointer_t *)&note->lines, 16 * sizeof(jit_line_t));
else if ((note->length & 15) == 15)
jit_realloc((jit_pointer_t *)&note->lines,
jit_lightning_realloc((jit_pointer_t *)&note->lines,
note->length * sizeof(jit_line_t),
(note->length + 17) * sizeof(jit_line_t));

if (index < note->length)
jit_memmove(note->lines + index + 1, note->lines + index,
jit_lightning_memmove(note->lines + index + 1, note->lines + index,
sizeof(jit_line_t) * (note->length - index));
line = note->lines + index;
++note->length;
Expand Down
6 changes: 3 additions & 3 deletions lib/jit_ppc.c
Expand Up @@ -203,7 +203,7 @@ _jit_prolog(jit_state_t *_jit)
jit_regset_set_ui(&_jitc->regsav, 0);
offset = _jitc->functions.offset;
if (offset >= _jitc->functions.length) {
jit_realloc((jit_pointer_t *)&_jitc->functions.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->functions.ptr,
_jitc->functions.length * sizeof(jit_function_t),
(_jitc->functions.length + 16) * sizeof(jit_function_t));
_jitc->functions.length += 16;
Expand Down Expand Up @@ -1725,7 +1725,7 @@ _emit_code(jit_state_t *_jit)
* a common practice as first jit instruction */
if (_jitc->prolog.offset >= _jitc->prolog.length) {
_jitc->prolog.length += 16;
jit_realloc((jit_pointer_t *)&_jitc->prolog.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->prolog.ptr,
(_jitc->prolog.length - 16) *
sizeof(jit_word_t),
_jitc->prolog.length * sizeof(jit_word_t));
Expand Down Expand Up @@ -1901,7 +1901,7 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
flag = node->u.n->flag;
assert(!(flag & jit_flag_patch));
if (_jitc->patches.offset >= _jitc->patches.length) {
jit_realloc((jit_pointer_t *)&_jitc->patches.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->patches.ptr,
_jitc->patches.length * sizeof(jit_patch_t),
(_jitc->patches.length + 1024) * sizeof(jit_patch_t));
_jitc->patches.length += 1024;
Expand Down
4 changes: 2 additions & 2 deletions lib/jit_riscv.c
Expand Up @@ -136,7 +136,7 @@ _jit_prolog(jit_state_t *_jit)
jit_regset_set_ui(&_jitc->regsav, 0);
offset = _jitc->functions.offset;
if (offset >= _jitc->functions.length) {
jit_realloc((jit_pointer_t *)&_jitc->functions.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->functions.ptr,
_jitc->functions.length * sizeof(jit_function_t),
(_jitc->functions.length + 16) * sizeof(jit_function_t));
_jitc->functions.length += 16;
Expand Down Expand Up @@ -1604,7 +1604,7 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
flag = node->u.n->flag;
assert(!(flag & jit_flag_patch));
if (_jitc->patches.offset >= _jitc->patches.length) {
jit_realloc((jit_pointer_t *)&_jitc->patches.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->patches.ptr,
_jitc->patches.length * sizeof(jit_patch_t),
(_jitc->patches.length + 1024) * sizeof(jit_patch_t));
_jitc->patches.length += 1024;
Expand Down
4 changes: 2 additions & 2 deletions lib/jit_s390.c
Expand Up @@ -155,7 +155,7 @@ _jit_prolog(jit_state_t *_jit)
jit_regset_set_ui(&_jitc->regsav, 0);
offset = _jitc->functions.offset;
if (offset >= _jitc->functions.length) {
jit_realloc((jit_pointer_t *)&_jitc->functions.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->functions.ptr,
_jitc->functions.length * sizeof(jit_function_t),
(_jitc->functions.length + 16) * sizeof(jit_function_t));
_jitc->functions.length += 16;
Expand Down Expand Up @@ -1679,7 +1679,7 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
flag = node->u.n->flag;
assert(!(flag & jit_flag_patch));
if (_jitc->patches.offset >= _jitc->patches.length) {
jit_realloc((jit_pointer_t *)&_jitc->patches.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->patches.ptr,
_jitc->patches.length * sizeof(jit_patch_t),
(_jitc->patches.length + 1024) * sizeof(jit_patch_t));
_jitc->patches.length += 1024;
Expand Down
4 changes: 2 additions & 2 deletions lib/jit_sparc.c
Expand Up @@ -176,7 +176,7 @@ _jit_prolog(jit_state_t *_jit)
jit_regset_set_ui(&_jitc->regsav, 0);
offset = _jitc->functions.offset;
if (offset >= _jitc->functions.length) {
jit_realloc((jit_pointer_t *)&_jitc->functions.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->functions.ptr,
_jitc->functions.length * sizeof(jit_function_t),
(_jitc->functions.length + 16) * sizeof(jit_function_t));
_jitc->functions.length += 16;
Expand Down Expand Up @@ -1911,7 +1911,7 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
flag = node->u.n->flag;
assert(!(flag & jit_flag_patch));
if (_jitc->patches.offset >= _jitc->patches.length) {
jit_realloc((jit_pointer_t *)&_jitc->patches.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->patches.ptr,
_jitc->patches.length * sizeof(jit_patch_t),
(_jitc->patches.length + 1024) * sizeof(jit_patch_t));
memset(_jitc->patches.ptr + _jitc->patches.length, 0,
Expand Down
4 changes: 2 additions & 2 deletions lib/jit_x86.c
Expand Up @@ -408,7 +408,7 @@ _jit_prolog(jit_state_t *_jit)
jit_regset_set_ui(&_jitc->regsav, 0);
offset = _jitc->functions.offset;
if (offset >= _jitc->functions.length) {
jit_realloc((jit_pointer_t *)&_jitc->functions.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->functions.ptr,
_jitc->functions.length * sizeof(jit_function_t),
(_jitc->functions.length + 16) * sizeof(jit_function_t));
_jitc->functions.length += 16;
Expand Down Expand Up @@ -2228,7 +2228,7 @@ _patch(jit_state_t *_jit, jit_word_t instr, jit_node_t *node)
flag = node->u.n->flag;
assert(!(flag & jit_flag_patch));
if (_jitc->patches.offset >= _jitc->patches.length) {
jit_realloc((jit_pointer_t *)&_jitc->patches.ptr,
jit_lightning_realloc((jit_pointer_t *)&_jitc->patches.ptr,
_jitc->patches.length * sizeof(jit_patch_t),
(_jitc->patches.length + 1024) * sizeof(jit_patch_t));
_jitc->patches.length += 1024;
Expand Down

0 comments on commit 7bfc7f1

Please sign in to comment.