Skip to content

Commit 62ef5db

Browse files
committed
irep.h: rename mrb_pool_value to mrb_irep_pool
mrb_pool_value is a structure that represents a value in the irep literal pool and is unrelated to mrb_pool, which performs region-based memory management. It has been renamed mrb_irep_pool to avoid confusion.
1 parent 2436b32 commit 62ef5db

File tree

5 files changed

+51
-51
lines changed

5 files changed

+51
-51
lines changed

include/mruby/irep.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ enum irep_pool_type {
2727
#define IREP_TT_NFLAG 1 /* number (non string) flag */
2828
#define IREP_TT_SFLAG 2 /* static string flag */
2929

30-
typedef struct mrb_pool_value {
30+
typedef struct mrb_irep_pool {
3131
uint32_t tt; /* packed type and length (for string) */
3232
union {
3333
const char *str;
@@ -37,7 +37,7 @@ typedef struct mrb_pool_value {
3737
mrb_float f;
3838
#endif
3939
} u;
40-
} mrb_pool_value;
40+
} mrb_irep_pool;
4141

4242
enum mrb_catch_type {
4343
MRB_CATCH_RESCUE = 0,
@@ -65,7 +65,7 @@ struct mrb_irep {
6565
* structure from bloating. The catch handler table can be obtained with
6666
* `mrb_irep_catch_handler_table(irep)`.
6767
*/
68-
const mrb_pool_value *pool;
68+
const mrb_irep_pool *pool;
6969
const mrb_sym *syms;
7070
const struct mrb_irep *const *reps;
7171

mrbgems/mruby-compiler/core/codegen.c

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ typedef struct scope {
7070
uint32_t icapa;
7171

7272
mrb_irep *irep;
73-
mrb_pool_value *pool;
73+
mrb_irep_pool *pool;
7474
mrb_sym *syms;
7575
mrb_irep **reps;
7676
struct mrb_irep_catch_handler *catch_table;
@@ -126,9 +126,9 @@ codegen_error(codegen_scope *s, const char *message)
126126
if (s->irep) {
127127
mrb_free(s->mrb, s->iseq);
128128
for (int i=0; i<s->irep->plen; i++) {
129-
mrb_pool_value *pv = &s->pool[i];
130-
if ((pv->tt & 0x3) == IREP_TT_STR || pv->tt == IREP_TT_BIGINT) {
131-
mrb_free(s->mrb, (void*)pv->u.str);
129+
mrb_irep_pool *p = &s->pool[i];
130+
if ((p->tt & 0x3) == IREP_TT_STR || p->tt == IREP_TT_BIGINT) {
131+
mrb_free(s->mrb, (void*)p->u.str);
132132
}
133133
}
134134
mrb_free(s->mrb, s->pool);
@@ -776,14 +776,14 @@ get_int_operand(codegen_scope *s, struct mrb_insn_data *data, mrb_int *n)
776776

777777
case OP_LOADL:
778778
{
779-
mrb_pool_value *pv = &s->pool[data->b];
779+
mrb_irep_pool *p = &s->pool[data->b];
780780

781-
if (pv->tt == IREP_TT_INT32) {
782-
*n = (mrb_int)pv->u.i32;
781+
if (p->tt == IREP_TT_INT32) {
782+
*n = (mrb_int)p->u.i32;
783783
}
784784
#ifdef MRB_INT64
785-
else if (pv->tt == IREP_TT_INT64) {
786-
*n = (mrb_int)pv->u.i64;
785+
else if (p->tt == IREP_TT_INT64) {
786+
*n = (mrb_int)p->u.i64;
787787
}
788788
#endif
789789
else {
@@ -989,12 +989,12 @@ pop_n_(codegen_scope *s, int n)
989989
#define pop_n(n) pop_n_(s,n)
990990
#define cursp() (s->sp)
991991

992-
static mrb_pool_value*
992+
static mrb_irep_pool*
993993
lit_pool_extend(codegen_scope *s)
994994
{
995995
if (s->irep->plen == s->pcapa) {
996996
s->pcapa *= 2;
997-
s->pool = (mrb_pool_value*)codegen_realloc(s, s->pool, sizeof(mrb_pool_value)*s->pcapa);
997+
s->pool = (mrb_irep_pool*)codegen_realloc(s, s->pool, sizeof(mrb_irep_pool)*s->pcapa);
998998
}
999999

10001000
return &s->pool[s->irep->plen++];
@@ -1005,7 +1005,7 @@ new_litbint(codegen_scope *s, const char *p, int base, mrb_bool neg)
10051005
{
10061006
int i;
10071007
size_t plen;
1008-
mrb_pool_value *pv;
1008+
mrb_irep_pool *pv;
10091009

10101010
plen = strlen(p);
10111011
if (plen > 255) {
@@ -1039,30 +1039,30 @@ static int
10391039
new_lit_str(codegen_scope *s, const char *str, mrb_int len)
10401040
{
10411041
int i;
1042-
mrb_pool_value *pv;
1042+
mrb_irep_pool *pool;
10431043

10441044
for (i=0; i<s->irep->plen; i++) {
1045-
pv = &s->pool[i];
1046-
if (pv->tt & IREP_TT_NFLAG) continue;
1047-
mrb_int plen = pv->tt>>2;
1045+
pool = &s->pool[i];
1046+
if (pool->tt & IREP_TT_NFLAG) continue;
1047+
mrb_int plen = pool->tt>>2;
10481048
if (len != plen) continue;
1049-
if (memcmp(pv->u.str, str, plen) == 0)
1049+
if (memcmp(pool->u.str, str, plen) == 0)
10501050
return i;
10511051
}
10521052

1053-
pv = lit_pool_extend(s);
1053+
pool = lit_pool_extend(s);
10541054

10551055
if (mrb_ro_data_p(str)) {
1056-
pv->tt = (uint32_t)(len<<2) | IREP_TT_SSTR;
1057-
pv->u.str = str;
1056+
pool->tt = (uint32_t)(len<<2) | IREP_TT_SSTR;
1057+
pool->u.str = str;
10581058
}
10591059
else {
10601060
char *p;
1061-
pv->tt = (uint32_t)(len<<2) | IREP_TT_STR;
1061+
pool->tt = (uint32_t)(len<<2) | IREP_TT_STR;
10621062
p = (char*)codegen_realloc(s, NULL, len+1);
10631063
memcpy(p, str, len);
10641064
p[len] = '\0';
1065-
pv->u.str = p;
1065+
pool->u.str = p;
10661066
}
10671067

10681068
return i;
@@ -1078,29 +1078,29 @@ static int
10781078
new_lit_int(codegen_scope *s, mrb_int num)
10791079
{
10801080
int i;
1081-
mrb_pool_value *pv;
1081+
mrb_irep_pool *pool;
10821082

10831083
for (i=0; i<s->irep->plen; i++) {
1084-
pv = &s->pool[i];
1085-
if (pv->tt == IREP_TT_INT32) {
1086-
if (num == pv->u.i32) return i;
1084+
pool = &s->pool[i];
1085+
if (pool->tt == IREP_TT_INT32) {
1086+
if (num == pool->u.i32) return i;
10871087
}
10881088
#ifdef MRB_64BIT
1089-
else if (pv->tt == IREP_TT_INT64) {
1090-
if (num == pv->u.i64) return i;
1089+
else if (pool->tt == IREP_TT_INT64) {
1090+
if (num == pool->u.i64) return i;
10911091
}
10921092
continue;
10931093
#endif
10941094
}
10951095

1096-
pv = lit_pool_extend(s);
1096+
pool = lit_pool_extend(s);
10971097

10981098
#ifdef MRB_INT64
1099-
pv->tt = IREP_TT_INT64;
1100-
pv->u.i64 = num;
1099+
pool->tt = IREP_TT_INT64;
1100+
pool->u.i64 = num;
11011101
#else
1102-
pv->tt = IREP_TT_INT32;
1103-
pv->u.i32 = num;
1102+
pool->tt = IREP_TT_INT32;
1103+
pool->u.i32 = num;
11041104
#endif
11051105

11061106
return i;
@@ -1111,20 +1111,20 @@ static int
11111111
new_lit_float(codegen_scope *s, mrb_float num)
11121112
{
11131113
int i;
1114-
mrb_pool_value *pv;
1114+
mrb_irep_pool *pool;
11151115

11161116
for (i=0; i<s->irep->plen; i++) {
11171117
mrb_float f;
1118-
pv = &s->pool[i];
1119-
if (pv->tt != IREP_TT_FLOAT) continue;
1120-
f = pv->u.f;
1118+
pool = &s->pool[i];
1119+
if (pool->tt != IREP_TT_FLOAT) continue;
1120+
f = pool->u.f;
11211121
if (f == num && !signbit(f) == !signbit(num)) return i;
11221122
}
11231123

1124-
pv = lit_pool_extend(s);
1124+
pool = lit_pool_extend(s);
11251125

1126-
pv->tt = IREP_TT_FLOAT;
1127-
pv->u.f = num;
1126+
pool->tt = IREP_TT_FLOAT;
1127+
pool->u.f = num;
11281128

11291129
return i;
11301130
}
@@ -3862,7 +3862,7 @@ scope_new(mrb_state *mrb, codegen_scope *prev, node *nlv)
38623862
s->iseq = (mrb_code*)mrb_malloc(mrb, sizeof(mrb_code)*s->icapa);
38633863

38643864
s->pcapa = 32;
3865-
s->pool = (mrb_pool_value*)mrb_malloc(mrb, sizeof(mrb_pool_value)*s->pcapa);
3865+
s->pool = (mrb_irep_pool*)mrb_malloc(mrb, sizeof(mrb_irep_pool)*s->pcapa);
38663866

38673867
s->scapa = 256;
38683868
s->syms = (mrb_sym*)mrb_malloc(mrb, sizeof(mrb_sym)*s->scapa);
@@ -3928,7 +3928,7 @@ scope_finish(codegen_scope *s)
39283928
}
39293929
mrb_free(s->mrb, s->catch_table);
39303930
s->catch_table = NULL;
3931-
irep->pool = (const mrb_pool_value*)codegen_realloc(s, s->pool, sizeof(mrb_pool_value)*irep->plen);
3931+
irep->pool = (const mrb_irep_pool*)codegen_realloc(s, s->pool, sizeof(mrb_irep_pool)*irep->plen);
39323932
irep->syms = (const mrb_sym*)codegen_realloc(s, s->syms, sizeof(mrb_sym)*irep->slen);
39333933
irep->reps = (const mrb_irep**)codegen_realloc(s, s->reps, sizeof(mrb_irep*)*irep->rlen);
39343934
if (s->filename_sym) {

mrbgems/mruby-os-memsize/src/memsize.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ static size_t
1717
os_memsize_of_irep(mrb_state* state, const struct mrb_irep *irep)
1818
{
1919
size_t size = (irep->slen * sizeof(mrb_sym)) +
20-
(irep->plen * sizeof(mrb_pool_value)) +
20+
(irep->plen * sizeof(mrb_irep_pool)) +
2121
(irep->ilen * sizeof(mrb_code)) +
2222
(irep->rlen * sizeof(struct mrb_irep*));
2323

2424
for (int i = 0; i < irep->plen; i++) {
25-
const mrb_pool_value *p = &irep->pool[i];
25+
const mrb_irep_pool *p = &irep->pool[i];
2626
if ((p->tt & IREP_TT_NFLAG) == 0) { /* string pool value */
2727
size += (p->tt>>2);
2828
}

src/cdump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#endif
2222

2323
static int
24-
cdump_pool(mrb_state *mrb, const mrb_pool_value *p, FILE *fp)
24+
cdump_pool(mrb_state *mrb, const mrb_irep_pool *p, FILE *fp)
2525
{
2626
if (p->tt & IREP_TT_NFLAG) { /* number */
2727
switch (p->tt) {
@@ -352,7 +352,7 @@ cdump_irep_struct(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp,
352352
/* dump pool */
353353
if (irep->pool) {
354354
len=irep->plen;
355-
fprintf(fp, "static const mrb_pool_value %s_pool_%d[%d] = {\n", name, n, len);
355+
fprintf(fp, "static const mrb_irep_pool %s_pool_%d[%d] = {\n", name, n, len);
356356
for (i=0; i<len; i++) {
357357
if (cdump_pool(mrb, &irep->pool[i], fp) != MRB_DUMP_OK)
358358
return MRB_DUMP_INVALID_ARGUMENT;

src/load.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, const uint8_t *end, size_
6767
ptrdiff_t diff;
6868
uint16_t tt, pool_data_len, snl;
6969
int plen;
70-
mrb_pool_value *pool;
70+
mrb_irep_pool *pool;
7171
mrb_sym *syms;
7272
int ai = mrb_gc_arena_save(mrb);
7373
mrb_irep *irep = mrb_add_irep(mrb);
@@ -124,7 +124,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, const uint8_t *end, size_
124124
if (SIZE_ERROR_MUL(plen, sizeof(mrb_value))) {
125125
return FALSE;
126126
}
127-
irep->pool = pool = (mrb_pool_value*)mrb_calloc(mrb, sizeof(mrb_pool_value), plen);
127+
irep->pool = pool = (mrb_irep_pool*)mrb_calloc(mrb, sizeof(mrb_irep_pool), plen);
128128

129129
for (i = 0; i < plen; i++) {
130130
mrb_bool st = (flags & FLAG_SRC_MALLOC)==0;

0 commit comments

Comments
 (0)