2 * Copyright (C) 2013-2019 Free Software Foundation, Inc.
4 * This file is part of GNU lightning.
6 * GNU lightning is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 3, or (at your option)
11 * GNU lightning is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 * License for more details.
17 * Paulo Cesar Pereira de Andrade
20 #include <lightning.h>
21 #include <lightning/jit_private.h>
29 static jit_int16_t _szs[jit_code_last_code] = {
31 # define JIT_INSTR_MAX 256
33 # if defined(__i386__) || defined(__x86_64__)
34 # include "jit_x86-sz.c"
35 # elif defined(__mips__)
36 # include "jit_mips-sz.c"
37 # elif defined(__arm__)
38 # include "jit_arm-sz.c"
39 # elif defined(__powerpc__)
40 # include "jit_ppc-sz.c"
41 # elif defined(__sparc__)
42 # include "jit_sparc-sz.c"
43 # elif defined(__ia64__)
44 # include "jit_ia64-sz.c"
45 # elif defined(__hppa__)
46 # include "jit_hppa-sz.c"
47 # elif defined(__aarch64__)
48 # include "jit_aarch64-sz.c"
49 # elif defined(__s390__) || defined(__s390x__)
50 # include "jit_s390-sz.c"
51 # elif defined(__alpha__)
52 # include "jit_alpha-sz.c"
53 # elif defined(__riscv)
54 # include "jit_riscv-sz.c"
69 for (offset = 0; offset < jit_size(_szs); offset++)
70 if (_szs[offset] != 0)
72 /* Ensure data was collected */
80 _jit_size_prepare(jit_state_t *_jit)
82 _jitc->cptr = _jit->code.ptr;
83 _jitc->size = _jit->pc.w;
87 _jit_size_collect(jit_state_t *_jit, jit_node_t *node)
91 if (_jitc->cptr == _jit->code.ptr) {
92 length = _jit->pc.w - _jitc->size;
93 if (_szs[node->code] < length)
94 _szs[node->code] = length;
100 _jit_get_size(jit_state_t *_jit)
105 for (size = JIT_INSTR_MAX, node = _jitc->head; node; node = node->next)
106 size += _szs[node->code];
108 return ((size + 4095) & -4096);
113 jit_get_max_instr(void)
115 return (JIT_INSTR_MAX >= 144 ? JIT_INSTR_MAX : 144);
119 jit_finish_size(void)
125 /* Define a single path */
126 fp = fopen(JIT_SIZE_PATH, "a");
128 for (offset = 0; offset < jit_size(_szs); offset++)
129 fprintf(fp, "%d %d\n", offset, _szs[offset]);