1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* compile.c (iseq_set_sequence): rename variable names

to make it readable.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2015-08-27 06:25:53 +00:00
parent 5ac1f6546c
commit d995d98a08
2 changed files with 45 additions and 40 deletions

View file

@ -1,3 +1,8 @@
Thu Aug 27 15:24:57 2015 Koichi Sasada <ko1@atdot.net>
* compile.c (iseq_set_sequence): rename variable names
to make it readable.
Thu Aug 27 07:45:34 2015 Koichi Sasada <ko1@atdot.net> Thu Aug 27 07:45:34 2015 Koichi Sasada <ko1@atdot.net>
* thread_tools.c: add Queue#close(exception=false) and * thread_tools.c: add Queue#close(exception=false) and

View file

@ -1445,25 +1445,25 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
LINK_ELEMENT *list; LINK_ELEMENT *list;
VALUE *generated_iseq; VALUE *generated_iseq;
int k, pos, sp, stack_max = 0, line = 0; int insn_num, code_index, line_info_index, sp, stack_max = 0, line = 0;
/* set label position */ /* fix label position */
list = FIRST_ELEMENT(anchor); list = FIRST_ELEMENT(anchor);
k = pos = 0; insn_num = code_index = 0;
while (list) { while (list) {
switch (list->type) { switch (list->type) {
case ISEQ_ELEMENT_INSN: case ISEQ_ELEMENT_INSN:
{ {
iobj = (INSN *)list; iobj = (INSN *)list;
line = iobj->line_no; line = iobj->line_no;
pos += insn_data_length(iobj); code_index += insn_data_length(iobj);
k++; insn_num++;
break; break;
} }
case ISEQ_ELEMENT_LABEL: case ISEQ_ELEMENT_LABEL:
{ {
lobj = (LABEL *)list; lobj = (LABEL *)list;
lobj->position = pos; lobj->position = code_index;
lobj->set = TRUE; lobj->set = TRUE;
break; break;
} }
@ -1476,8 +1476,8 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
{ {
ADJUST *adjust = (ADJUST *)list; ADJUST *adjust = (ADJUST *)list;
if (adjust->line_no != -1) { if (adjust->line_no != -1) {
pos += 2 /* insn + 1 operand */; code_index += 2 /* insn + 1 operand */;
k++; insn_num++;
} }
break; break;
} }
@ -1492,14 +1492,14 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
} }
/* make instruction sequence */ /* make instruction sequence */
generated_iseq = ALLOC_N(VALUE, pos); generated_iseq = ALLOC_N(VALUE, code_index);
line_info_table = ALLOC_N(struct iseq_line_info_entry, k); line_info_table = ALLOC_N(struct iseq_line_info_entry, insn_num);
iseq->body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, iseq->body->is_size); iseq->body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, iseq->body->is_size);
iseq->body->callinfo_entries = ALLOC_N(rb_call_info_t, iseq->body->callinfo_size); iseq->body->callinfo_entries = ALLOC_N(rb_call_info_t, iseq->body->callinfo_size);
/* MEMZERO(iseq->body->callinfo_entries, rb_call_info_t, iseq->body->callinfo_size); */ /* MEMZERO(iseq->body->callinfo_entries, rb_call_info_t, iseq->body->callinfo_size); */
list = FIRST_ELEMENT(anchor); list = FIRST_ELEMENT(anchor);
k = pos = sp = 0; line_info_index = code_index = sp = 0;
while (list) { while (list) {
switch (list->type) { switch (list->type) {
@ -1520,7 +1520,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
/* fprintf(stderr, "insn: %-16s, sp: %d\n", insn_name(iobj->insn_id), sp); */ /* fprintf(stderr, "insn: %-16s, sp: %d\n", insn_name(iobj->insn_id), sp); */
operands = iobj->operands; operands = iobj->operands;
insn = iobj->insn_id; insn = iobj->insn_id;
generated_iseq[pos] = insn; generated_iseq[code_index] = insn;
types = insn_op_types(insn); types = insn_op_types(insn);
len = insn_len(insn); len = insn_len(insn);
@ -1551,7 +1551,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
if (lobj->sp == -1) { if (lobj->sp == -1) {
lobj->sp = sp; lobj->sp = sp;
} }
generated_iseq[pos + 1 + j] = lobj->position - (pos + len); generated_iseq[code_index + 1 + j] = lobj->position - (code_index + len);
break; break;
} }
case TS_CDHASH: case TS_CDHASH:
@ -1559,28 +1559,28 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
VALUE map = operands[j]; VALUE map = operands[j];
struct cdhash_set_label_struct data; struct cdhash_set_label_struct data;
data.hash = map; data.hash = map;
data.pos = pos; data.pos = code_index;
data.len = len; data.len = len;
rb_hash_foreach(map, cdhash_set_label_i, (VALUE)&data); rb_hash_foreach(map, cdhash_set_label_i, (VALUE)&data);
freeze_hide_obj(map); freeze_hide_obj(map);
generated_iseq[pos + 1 + j] = map; generated_iseq[code_index + 1 + j] = map;
break; break;
} }
case TS_LINDEX: case TS_LINDEX:
case TS_NUM: /* ulong */ case TS_NUM: /* ulong */
generated_iseq[pos + 1 + j] = FIX2INT(operands[j]); generated_iseq[code_index + 1 + j] = FIX2INT(operands[j]);
break; break;
case TS_ISEQ: /* iseq */ case TS_ISEQ: /* iseq */
{ {
VALUE v = operands[j]; VALUE v = operands[j];
generated_iseq[pos + 1 + j] = v; generated_iseq[code_index + 1 + j] = v;
break; break;
} }
case TS_VALUE: /* VALUE */ case TS_VALUE: /* VALUE */
{ {
VALUE v = operands[j]; VALUE v = operands[j];
generated_iseq[pos + 1 + j] = v; generated_iseq[code_index + 1 + j] = v;
/* to mark ruby object */ /* to mark ruby object */
iseq_add_mark_object(iseq, v); iseq_add_mark_object(iseq, v);
break; break;
@ -1592,7 +1592,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
if (UNLIKELY(ic_index >= iseq->body->is_size)) { if (UNLIKELY(ic_index >= iseq->body->is_size)) {
rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", ic_index, iseq->body->is_size); rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", ic_index, iseq->body->is_size);
} }
generated_iseq[pos + 1 + j] = (VALUE)ic; generated_iseq[code_index + 1 + j] = (VALUE)ic;
break; break;
} }
case TS_CALLINFO: /* call info */ case TS_CALLINFO: /* call info */
@ -1604,21 +1604,21 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
if (UNLIKELY(base_ci->aux.index >= iseq->body->callinfo_size)) { if (UNLIKELY(base_ci->aux.index >= iseq->body->callinfo_size)) {
rb_bug("iseq_set_sequence: ci_index overflow: index: %d, size: %d", base_ci->argc, iseq->body->callinfo_size); rb_bug("iseq_set_sequence: ci_index overflow: index: %d, size: %d", base_ci->argc, iseq->body->callinfo_size);
} }
generated_iseq[pos + 1 + j] = (VALUE)ci; generated_iseq[code_index + 1 + j] = (VALUE)ci;
break; break;
} }
case TS_ID: /* ID */ case TS_ID: /* ID */
generated_iseq[pos + 1 + j] = SYM2ID(operands[j]); generated_iseq[code_index + 1 + j] = SYM2ID(operands[j]);
break; break;
case TS_GENTRY: case TS_GENTRY:
{ {
struct rb_global_entry *entry = struct rb_global_entry *entry =
(struct rb_global_entry *)(operands[j] & (~1)); (struct rb_global_entry *)(operands[j] & (~1));
generated_iseq[pos + 1 + j] = (VALUE)entry; generated_iseq[code_index + 1 + j] = (VALUE)entry;
} }
break; break;
case TS_FUNCPTR: case TS_FUNCPTR:
generated_iseq[pos + 1 + j] = operands[j]; generated_iseq[code_index + 1 + j] = operands[j];
break; break;
default: default:
rb_compile_error(RSTRING_PTR(iseq->body->location.path), iobj->line_no, rb_compile_error(RSTRING_PTR(iseq->body->location.path), iobj->line_no,
@ -1629,11 +1629,11 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
} }
} }
if (last_line != iobj->line_no) { if (last_line != iobj->line_no) {
line_info_table[k].line_no = last_line = iobj->line_no; line_info_table[line_info_index].line_no = last_line = iobj->line_no;
line_info_table[k].position = pos; line_info_table[line_info_index].position = code_index;
k++; line_info_index++;
} }
pos += len; code_index += len;
break; break;
} }
case ISEQ_ELEMENT_LABEL: case ISEQ_ELEMENT_LABEL:
@ -1662,22 +1662,22 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
if (adjust->line_no != -1) { if (adjust->line_no != -1) {
if (orig_sp - sp > 0) { if (orig_sp - sp > 0) {
if (last_line != (unsigned int)adjust->line_no) { if (last_line != (unsigned int)adjust->line_no) {
line_info_table[k].line_no = last_line = adjust->line_no; line_info_table[line_info_index].line_no = last_line = adjust->line_no;
line_info_table[k].position = pos; line_info_table[line_info_index].position = code_index;
k++; line_info_index++;
} }
generated_iseq[pos++] = BIN(adjuststack); generated_iseq[code_index++] = BIN(adjuststack);
generated_iseq[pos++] = orig_sp - sp; generated_iseq[code_index++] = orig_sp - sp;
} }
else if (orig_sp - sp == 0) { else if (orig_sp - sp == 0) {
/* jump to next insn */ /* jump to next insn */
if (last_line != (unsigned int)adjust->line_no) { if (last_line != (unsigned int)adjust->line_no) {
line_info_table[k].line_no = last_line = adjust->line_no; line_info_table[line_info_index].line_no = last_line = adjust->line_no;
line_info_table[k].position = pos; line_info_table[line_info_index].position = code_index;
k++; line_info_index++;
} }
generated_iseq[pos++] = BIN(nop); generated_iseq[code_index++] = BIN(nop);
generated_iseq[pos++] = BIN(nop); generated_iseq[code_index++] = BIN(nop);
} }
else { else {
rb_bug("iseq_set_sequence: adjust bug"); rb_bug("iseq_set_sequence: adjust bug");
@ -1693,12 +1693,12 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
} }
iseq->body->iseq_encoded = (void *)generated_iseq; iseq->body->iseq_encoded = (void *)generated_iseq;
iseq->body->iseq_size = pos; iseq->body->iseq_size = code_index;
iseq->body->stack_max = stack_max; iseq->body->stack_max = stack_max;
REALLOC_N(line_info_table, struct iseq_line_info_entry, k); REALLOC_N(line_info_table, struct iseq_line_info_entry, line_info_index);
iseq->body->line_info_table = line_info_table; iseq->body->line_info_table = line_info_table;
iseq->body->line_info_size = k; iseq->body->line_info_size = line_info_index;
return COMPILE_OK; return COMPILE_OK;
} }