mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
eb9aaa4c4f
commit
6a69ad4df1
6 changed files with 70 additions and 59 deletions
|
@ -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.
|
||||
|
|
27
compile.c
27
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;
|
||||
}
|
||||
|
||||
|
|
10
iseq.c
10
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;
|
||||
|
|
4
proc.c
4
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),
|
||||
|
|
6
vm.c
6
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;
|
||||
|
|
75
yarvcore.h
75
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;
|
||||
/***************/
|
||||
/* static data */
|
||||
/***************/
|
||||
|
||||
VALUE self;
|
||||
VALUE name; /* String: iseq name */
|
||||
VALUE *iseq; /* iseq */
|
||||
VALUE *iseq_encoded;
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue