/*
- * Copyright (C) 2013-2019 Free Software Foundation, Inc.
+ * Copyright (C) 2013-2022 Free Software Foundation, Inc.
*
* This file is part of GNU lightning.
*
*/
static jit_int16_t _szs[jit_code_last_code] = {
#if GET_JIT_SIZE
-# define JIT_INSTR_MAX 256
+# define JIT_INSTR_MAX 512
#else
# if defined(__i386__) || defined(__x86_64__)
# include "jit_x86-sz.c"
# include "jit_alpha-sz.c"
# elif defined(__riscv)
# include "jit_riscv-sz.c"
+# elif defined(__loongarch__)
+# include "jit_loongarch-sz.c"
# endif
#endif
};
{
jit_word_t size;
jit_node_t *node;
+# if __riscv && __WORDSIZE == 64
+ jit_word_t extra = 0;
+# endif
- for (size = JIT_INSTR_MAX, node = _jitc->head; node; node = node->next)
+ for (size = JIT_INSTR_MAX, node = _jitc->head; node; node = node->next) {
+# if __riscv && __WORDSIZE == 64
+ /* Get estimative of extra memory for constants at end of code. */
+ switch (node->code) {
+ case jit_code_movi:
+ case jit_code_movi_f:
+ case jit_code_movi_d:
+ case jit_code_jmpi:
+ case jit_code_calli:
+ extra += sizeof(jit_word_t);
+ default:
+ break;
+ }
+# endif
size += _szs[node->code];
+ }
+# if __riscv && __WORDSIZE == 64
+ /* Heuristically only 20% of constants are unique. */
+ size += extra / 5;
+# endif
- return ((size + 4095) & -4096);
+ return size;
}
#endif