From 9fadf16fdb1489c9337c10a8cb9d7f6895ccf6ff Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sat, 18 Jan 2014 22:54:28 +0900 Subject: [PATCH] make iseq length configurable --- include/config.h | 1 + src/codegen.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/config.h b/include/config.h index 29be46d0..d89ccc82 100644 --- a/include/config.h +++ b/include/config.h @@ -27,6 +27,7 @@ #define PIC_MACROS_SIZE 1024 #define PIC_SYM_POOL_SIZE 128 #define PIC_POOL_SIZE 1024 +#define PIC_ISEQ_SIZE 1024 /* enable all debug flags */ /* #define DEBUG 1 */ diff --git a/src/codegen.c b/src/codegen.c index 091593c0..266798fd 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -74,9 +74,9 @@ new_global_scope(pic_state *pic) scope->localc = -1; scope->dirty_flags = NULL; scope->varg = false; - scope->code = (struct pic_code *)pic_alloc(pic, sizeof(struct pic_code) * 1024); + scope->code = (struct pic_code *)pic_calloc(pic, PIC_ISEQ_SIZE, sizeof(struct pic_code)); scope->clen = 0; - scope->ccapa = 1024; + scope->ccapa = PIC_ISEQ_SIZE; scope->irep = (struct pic_irep **)pic_calloc(pic, PIC_IREP_SIZE, sizeof(struct pic_irep *)); scope->ilen = 0; scope->icapa = PIC_IREP_SIZE; @@ -121,9 +121,9 @@ new_local_scope(pic_state *pic, pic_value args, codegen_scope *scope) new_scope->localc = l; new_scope->dirty_flags = (int *)pic_calloc(pic, i + l, sizeof(int)); - new_scope->code = (struct pic_code *)pic_alloc(pic, sizeof(struct pic_code) * 1024); + new_scope->code = (struct pic_code *)pic_calloc(pic, PIC_ISEQ_SIZE, sizeof(struct pic_code)); new_scope->clen = 0; - new_scope->ccapa = 1024; + new_scope->ccapa = PIC_ISEQ_SIZE; new_scope->irep = (struct pic_irep **)pic_calloc(pic, PIC_IREP_SIZE, sizeof(struct pic_irep *)); new_scope->ilen = 0;