diff --git a/ChangeLog b/ChangeLog index f66e2639b6..afd3d56373 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Jul 26 16:55:18 2014 Eric Wong + + * iseq.h (struct iseq_compile_data_storage): reduce overhead + to 16 bytes (from 32) on 64-bit + Sat Jul 26 16:28:06 2014 Eric Wong * vm_core.h (struct rb_iseq_struct): reduce to 280 bytes diff --git a/compile.c b/compile.c index 7dfaa81f47..f9bd9a531e 100644 --- a/compile.c +++ b/compile.c @@ -604,13 +604,11 @@ compile_data_alloc(rb_iseq_t *iseq, size_t size) goto retry; } storage->next = (void *)ALLOC_N(char, alloc_size + - sizeof(struct - iseq_compile_data_storage)); + SIZEOF_ISEQ_COMPILE_DATA_STORAGE); storage = iseq->compile_data->storage_current = storage->next; storage->next = 0; storage->pos = 0; storage->size = alloc_size; - storage->buff = (char *)(&storage->buff + 1); } ptr = (void *)&storage->buff[storage->pos]; diff --git a/iseq.c b/iseq.c index aadb28b8ee..834f3bbb17 100644 --- a/iseq.c +++ b/iseq.c @@ -153,7 +153,7 @@ iseq_memsize(const void *ptr) cur = iseq->compile_data->storage_head; while (cur) { - size += cur->size + sizeof(struct iseq_compile_data_storage); + size += cur->size + SIZEOF_ISEQ_COMPILE_DATA_STORAGE; cur = cur->next; } size += sizeof(struct iseq_compile_data); @@ -293,15 +293,13 @@ prepare_iseq_build(rb_iseq_t *iseq, iseq->compile_data->storage_head = iseq->compile_data->storage_current = (struct iseq_compile_data_storage *) ALLOC_N(char, INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE + - sizeof(struct iseq_compile_data_storage)); + SIZEOF_ISEQ_COMPILE_DATA_STORAGE); RB_OBJ_WRITE(iseq->self, &iseq->compile_data->catch_table_ary, rb_ary_new()); iseq->compile_data->storage_head->pos = 0; iseq->compile_data->storage_head->next = 0; iseq->compile_data->storage_head->size = INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE; - iseq->compile_data->storage_head->buff = - (char *)(&iseq->compile_data->storage_head->buff + 1); iseq->compile_data->option = option; iseq->compile_data->last_coverable_line = -1; diff --git a/iseq.h b/iseq.h index 9a225180df..da2b678c1b 100644 --- a/iseq.h +++ b/iseq.h @@ -88,11 +88,15 @@ iseq_catch_table_bytes(int n) struct iseq_compile_data_storage { struct iseq_compile_data_storage *next; - unsigned long pos; - unsigned long size; - char *buff; + unsigned int pos; + unsigned int size; + char buff[1]; /* flexible array */ }; +/* account for flexible array */ +#define SIZEOF_ISEQ_COMPILE_DATA_STORAGE \ + (sizeof(struct iseq_compile_data_storage) - 1) + struct iseq_compile_data { /* GC is needed */ const VALUE err_info;