summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-30 18:04:35 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-30 18:04:35 +0000
commit6a69ad4df1719516a2da8b95872d3a44deae026c (patch)
tree805550c7516a6296d4d0a660c4e374b045e9c54b
parenteb9aaa4c4fdaee9225e1843a71b5cdefaf179db6 (diff)
* yarvcore.h: some refactoring on rb_iseq_t.
rename some variable names, add comments, etc. * compile.c, iseq.c, proc.c, vm.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--compile.c27
-rw-r--r--iseq.c10
-rw-r--r--proc.c4
-rw-r--r--vm.c6
-rw-r--r--yarvcore.h77
6 files changed, 71 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index 921b2055c93..8a562fa79b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sun Jul 1 03:02:29 2007 Koichi Sasada <ko1@atdot.net>
+
+ * yarvcore.h: some refactoring on rb_iseq_t.
+ rename some variable names, add comments, etc.
+
+ * compile.c, iseq.c, proc.c, vm.c: ditto.
+
Sun Jul 1 02:57:57 2007 Koichi Sasada <ko1@atdot.net>
* vm.h: rename insn_func_type to rb_insn_func_type.
diff --git a/compile.c b/compile.c
index 72323e0c1f1..8c77572751e 100644
--- a/compile.c
+++ b/compile.c
@@ -227,10 +227,10 @@ iseq_translate_direct_threaded_code(rb_iseq_t *iseq)
#endif
int i;
- iseq->iseq_encoded = ALLOC_N(VALUE, iseq->size);
- MEMCPY(iseq->iseq_encoded, iseq->iseq, VALUE, iseq->size);
+ iseq->iseq_encoded = ALLOC_N(VALUE, iseq->iseq_size);
+ MEMCPY(iseq->iseq_encoded, iseq->iseq, VALUE, iseq->iseq_size);
- for (i = 0; i < iseq->size; /* */ ) {
+ for (i = 0; i < iseq->iseq_size; /* */ ) {
int insn = iseq->iseq_encoded[i];
int len = insn_len(insn);
iseq->iseq_encoded[i] = (VALUE)table[insn];
@@ -950,7 +950,7 @@ set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
{
LABEL *lobj;
INSN *iobj;
- struct insn_info_struct *insn_info_tbl;
+ struct insn_info_struct *insn_info_table;
LINK_ELEMENT *list;
VALUE *generated_iseq;
@@ -992,7 +992,7 @@ set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
/* make instruction sequence */
generated_iseq = ALLOC_N(VALUE, pos);
- insn_info_tbl = ALLOC_N(struct insn_info_struct, k);
+ insn_info_table = ALLOC_N(struct insn_info_struct, k);
list = FIRST_ELEMENT(anchor);
k = pos = sp = 0;
@@ -1122,8 +1122,8 @@ set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
return 0;
}
}
- insn_info_tbl[k].line_no = iobj->line_no;
- insn_info_tbl[k].position = pos;
+ insn_info_table[k].line_no = iobj->line_no;
+ insn_info_table[k].position = pos;
pos += len;
k++;
break;
@@ -1146,13 +1146,12 @@ set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
list = list->next;
}
- {
- iseq->iseq = (void *)generated_iseq;
- iseq->size = pos;
- iseq->insn_info_tbl = insn_info_tbl;
- iseq->insn_info_size = k;
- iseq->stack_max = stack_max;
- }
+ iseq->iseq = (void *)generated_iseq;
+ iseq->iseq_size = pos;
+ iseq->insn_info_table = insn_info_table;
+ iseq->insn_info_size = k;
+ iseq->stack_max = stack_max;
+
return COMPILE_OK;
}
diff --git a/iseq.c b/iseq.c
index adcb0e2ec61..36aa7eef67b 100644
--- a/iseq.c
+++ b/iseq.c
@@ -54,7 +54,7 @@ iseq_free(void *ptr)
}
RUBY_FREE_UNLESS_NULL(iseq->iseq);
- RUBY_FREE_UNLESS_NULL(iseq->insn_info_tbl);
+ RUBY_FREE_UNLESS_NULL(iseq->insn_info_table);
RUBY_FREE_UNLESS_NULL(iseq->local_table);
RUBY_FREE_UNLESS_NULL(iseq->catch_table);
RUBY_FREE_UNLESS_NULL(iseq->arg_opt_tbl);
@@ -499,7 +499,7 @@ static unsigned short
find_line_no(rb_iseq_t *iseqdat, unsigned long pos)
{
unsigned long i, size = iseqdat->insn_info_size;
- struct insn_info_struct *iiary = iseqdat->insn_info_tbl;
+ struct insn_info_struct *iiary = iseqdat->insn_info_table;
for (i = 0; i < size; i++) {
if (iiary[i].position == pos) {
@@ -514,7 +514,7 @@ static unsigned short
find_prev_line_no(rb_iseq_t *iseqdat, unsigned long pos)
{
unsigned long i, size = iseqdat->insn_info_size;
- struct insn_info_struct *iiary = iseqdat->insn_info_tbl;
+ struct insn_info_struct *iiary = iseqdat->insn_info_table;
for (i = 0; i < size; i++) {
if (iiary[i].position == pos) {
@@ -723,7 +723,7 @@ ruby_iseq_disasm(VALUE self)
char buff[0x200];
iseq = iseqdat->iseq;
- size = iseqdat->size;
+ size = iseqdat->iseq_size;
rb_str_cat2(str, "== disasm: ");
@@ -1201,7 +1201,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
}
/* body */
- for (seq = iseq->iseq; seq < iseq->iseq + iseq->size; ) {
+ for (seq = iseq->iseq; seq < iseq->iseq + iseq->iseq_size; ) {
VALUE insn = *seq++;
int j, len = insn_len(insn);
VALUE *nseq = seq + len - 1;
diff --git a/proc.c b/proc.c
index abf26a68bb5..1628f68275a 100644
--- a/proc.c
+++ b/proc.c
@@ -548,8 +548,8 @@ proc_to_s(VALUE self)
if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
int line_no = 0;
- if (iseq->insn_info_tbl) {
- line_no = iseq->insn_info_tbl[0].line_no;
+ if (iseq->insn_info_table) {
+ line_no = iseq->insn_info_table[0].line_no;
}
str = rb_sprintf("#<%s:%p@%s:%d%s>", cname, (void *)self,
RSTRING_PTR(iseq->filename),
diff --git a/vm.c b/vm.c
index 27d6d42de97..aeab116c3ed 100644
--- a/vm.c
+++ b/vm.c
@@ -699,12 +699,12 @@ vm_get_sourceline(rb_control_frame_t *cfp)
int pos = cfp->pc - cfp->iseq->iseq_encoded;
for (i = 0; i < iseq->insn_info_size; i++) {
- if (iseq->insn_info_tbl[i].position == pos) {
- line_no = iseq->insn_info_tbl[i - 1].line_no;
+ if (iseq->insn_info_table[i].position == pos) {
+ line_no = iseq->insn_info_table[i - 1].line_no;
goto found;
}
}
- line_no = iseq->insn_info_tbl[i - 1].line_no;
+ line_no = iseq->insn_info_table[i - 1].line_no;
}
found:
return line_no;
diff --git a/yarvcore.h b/yarvcore.h
index 85842a00a4e..9bd74624456 100644
--- a/yarvcore.h
+++ b/yarvcore.h
@@ -234,50 +234,50 @@ typedef struct rb_iseq_profile_struct {
struct rb_iseq_struct;
struct rb_iseq_struct {
- /* instruction sequence type */
- VALUE type;
-
- VALUE self;
- VALUE name; /* String: iseq name */
- VALUE *iseq; /* iseq */
- VALUE *iseq_encoded;
+ /***************/
+ /* static data */
+ /***************/
+
+ VALUE type; /* instruction sequence type */
+ VALUE name; /* String: iseq name */
+ VALUE filename; /* file information where this sequence from */
+ VALUE *iseq; /* iseq (insn number and openrads) */
+ VALUE *iseq_encoded; /* encoded iseq */
+ unsigned long iseq_size;
VALUE iseq_mark_ary; /* Array: includes operands which should be GC marked */
- /* sequence size */
- unsigned long size;
/* insn info, must be freed */
- struct insn_info_struct *insn_info_tbl;
-
- /* insn info size, this value shows also instruction count */
- unsigned int insn_info_size;
-
- /* file information where this sequence from */
- VALUE filename;
+ struct insn_info_struct *insn_info_table;
+ unsigned long insn_info_size;
ID *local_table; /* must free */
int local_table_size;
/* method, class frame: sizeof(vars) + 1, block frame: sizeof(vars) */
- int local_size;
-
- /* jit compiled or not */
- void *jit_compiled;
- void *iseq_orig;
+ int local_size;
/**
* argument information
*
- * def m(a1, a2, ..., aM, b1=(...), b2=(...), ..., bN=(...), *c, &d)
+ * def m(a1, a2, ..., aM, # mandatory
+ * b1=(...), b2=(...), ..., bN=(...), # optinal
+ * *c, # rest
+ * d1, d2, ..., dO, # post
+ * &e) # block
* =>
*
- * argc = M
- * arg_rest = M+N + 1 // if no rest arguments, rest is 0
- * arg_opts = N
- * arg_opts_tbl = [ (N entries) ]
- * arg_block = M+N + 1 (rest) + 1 (block)
- * check:
- * M <= num
+ * argc = M
+ * arg_rest = M+N+1 // or -1 if no rest arg
+ * arg_opts = N
+ * arg_opts_tbl = [ (N entries) ]
+ * arg_post_len = O // 0 if no post arguments
+ * arg_post_start = M+N+2
+ * arg_block = M+N + 1 + O + 1 // -1 if no block arg
+ * arg_simple = 0 if not simple arguments.
+ * = 1 if no opt, rest, post, block.
+ * = 2 if ambiguos block parameter ({|a|}).
+ * arg_size = argument size.
*/
int argc;
@@ -288,15 +288,9 @@ struct rb_iseq_struct {
int arg_post_len;
int arg_post_start;
int arg_size;
-
VALUE *arg_opt_tbl;
- /* for stack overflow check */
- int stack_max;
-
- /* klass/module nest information stack (cref) */
- NODE *cref_stack;
- VALUE klass;
+ int stack_max; /* for stack overflow check */
/* catch table */
struct catch_table_entry *catch_table;
@@ -306,16 +300,27 @@ struct rb_iseq_struct {
struct rb_iseq_struct *parent_iseq;
struct rb_iseq_struct *local_iseq;
+ /****************/
+ /* dynamic data */
+ /****************/
+
+ VALUE self;
+
/* block inlining */
NODE *node;
void *special_block_builder;
void *cached_special_block_builder;
VALUE cached_special_block;
+ /* klass/module nest information stack (cref) */
+ NODE *cref_stack;
+ VALUE klass;
+
/* misc */
ID defined_method_id; /* for define_method */
rb_iseq_profile_t profile;
+ /* used at compile time */
struct iseq_compile_data *compile_data;
};