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

* compile.c (make_masgn_lhs, iseq_compile_each): fixed indent.

* compile.c (iseq_translate_threaded_code),
  vm_evalbody.ci (get_insns_address_table),
  template/vmtc.inc.tmpl (insns_address_table): constified.

* vm_evalbody.ci (vm_eval),
  template/insns_info.inc.tmpl (insn_stack_increase, insn_ret_num):
  suppress warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-08-23 06:48:28 +00:00
parent fcab7ebb71
commit aa071a3b26
5 changed files with 73 additions and 54 deletions

View file

@ -1,3 +1,15 @@
Thu Aug 23 15:48:26 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* compile.c (make_masgn_lhs, iseq_compile_each): fixed indent.
* compile.c (iseq_translate_threaded_code),
vm_evalbody.ci (get_insns_address_table),
template/vmtc.inc.tmpl (insns_address_table): constified.
* vm_evalbody.ci (vm_eval),
template/insns_info.inc.tmpl (insn_stack_increase, insn_ret_num):
suppress warnings.
Thu Aug 23 13:19:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> Thu Aug 23 13:19:43 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (f_norm_arg): check also nested arguments. [ruby-dev:31502] * parse.y (f_norm_arg): check also nested arguments. [ruby-dev:31502]

101
compile.c
View file

@ -13,6 +13,7 @@
#include "ruby/ruby.h" #include "ruby/ruby.h"
#include "ruby/node.h" #include "ruby/node.h"
#define USE_INSN_STACK_INCREASE 1
#include "vm_core.h" #include "vm_core.h"
#include "compile.h" #include "compile.h"
#include "insns.inc" #include "insns.inc"
@ -226,10 +227,10 @@ iseq_translate_threaded_code(rb_iseq_t *iseq)
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE #if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
#if OPT_DIRECT_THREADED_CODE #if OPT_DIRECT_THREADED_CODE
void **table = (void **)vm_eval(0); const void *const *table = (const void **)vm_eval(0);
#else #else
extern void **get_insns_address_table(); extern const void *const *get_insns_address_table();
void **table = get_insns_address_table(); const void *const *table = get_insns_address_table();
#endif #endif
int i; int i;
@ -1949,36 +1950,36 @@ make_masgn_lhs(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *node)
{ {
switch (nd_type(node)) { switch (nd_type(node)) {
case NODE_ATTRASGN: { case NODE_ATTRASGN: {
INSN *iobj; INSN *iobj;
VALUE dupidx; VALUE dupidx;
COMPILE_POPED(ret, "masgn lhs (NODE_ATTRASGN)", node); COMPILE_POPED(ret, "masgn lhs (NODE_ATTRASGN)", node);
POP_ELEMENT(ret); /* pop pop insn */ POP_ELEMENT(ret); /* pop pop insn */
iobj = (INSN *)POP_ELEMENT(ret); /* pop send insn */ iobj = (INSN *)POP_ELEMENT(ret); /* pop send insn */
dupidx = iobj->operands[1]; dupidx = iobj->operands[1];
dupidx = INT2FIX(FIX2INT(dupidx) + 1); dupidx = INT2FIX(FIX2INT(dupidx) + 1);
iobj->operands[1] = dupidx; iobj->operands[1] = dupidx;
ADD_INSN1(ret, nd_line(node), topn, dupidx); ADD_INSN1(ret, nd_line(node), topn, dupidx);
ADD_ELEM(ret, (LINK_ELEMENT *)iobj); ADD_ELEM(ret, (LINK_ELEMENT *)iobj);
ADD_INSN(ret, nd_line(node), pop); /* result */ ADD_INSN(ret, nd_line(node), pop); /* result */
ADD_INSN(ret, nd_line(node), pop); /* rhs */ ADD_INSN(ret, nd_line(node), pop); /* rhs */
break; break;
} }
case NODE_MASGN: { case NODE_MASGN: {
COMPILE_POPED(ret, "nest masgn lhs", node); COMPILE_POPED(ret, "nest masgn lhs", node);
break; break;
} }
default: { default: {
DECL_ANCHOR(anchor); DECL_ANCHOR(anchor);
INIT_ANCHOR(anchor); INIT_ANCHOR(anchor);
COMPILE_POPED(anchor, "masgn lhs", node); COMPILE_POPED(anchor, "masgn lhs", node);
/* dump_disasm_list(FIRST_ELEMENT(anchor)); */ /* dump_disasm_list(FIRST_ELEMENT(anchor)); */
REMOVE_ELEM(FIRST_ELEMENT(anchor)); REMOVE_ELEM(FIRST_ELEMENT(anchor));
/* dump_disasm_list(FIRST_ELEMENT(anchor)); */ /* dump_disasm_list(FIRST_ELEMENT(anchor)); */
ADD_SEQ(ret, anchor); ADD_SEQ(ret, anchor);
/* ADD_ELEM(ret, LAST_ELEMENT(anchor)); */ /* ADD_ELEM(ret, LAST_ELEMENT(anchor)); */
} }
} }
@ -2855,41 +2856,41 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
} }
case NODE_ITER: case NODE_ITER:
case NODE_FOR:{ case NODE_FOR:{
VALUE prevblock = iseq->compile_data->current_block; VALUE prevblock = iseq->compile_data->current_block;
LABEL *retry_label = NEW_LABEL(nd_line(node)); LABEL *retry_label = NEW_LABEL(nd_line(node));
LABEL *retry_end_l = NEW_LABEL(nd_line(node)); LABEL *retry_end_l = NEW_LABEL(nd_line(node));
ID mid = 0; ID mid = 0;
ADD_LABEL(ret, retry_label); ADD_LABEL(ret, retry_label);
if (nd_type(node) == NODE_FOR) { if (nd_type(node) == NODE_FOR) {
COMPILE(ret, "iter caller (for)", node->nd_iter); COMPILE(ret, "iter caller (for)", node->nd_iter);
iseq->compile_data->current_block = iseq->compile_data->current_block =
NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq),
ISEQ_TYPE_BLOCK); ISEQ_TYPE_BLOCK);
mid = idEach; mid = idEach;
ADD_SEND_R(ret, nd_line(node), ID2SYM(idEach), INT2FIX(0), ADD_SEND_R(ret, nd_line(node), ID2SYM(idEach), INT2FIX(0),
iseq->compile_data->current_block, INT2FIX(0)); iseq->compile_data->current_block, INT2FIX(0));
} }
else { else {
iseq->compile_data->current_block = iseq->compile_data->current_block =
NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq),
ISEQ_TYPE_BLOCK); ISEQ_TYPE_BLOCK);
COMPILE(ret, "iter caller", node->nd_iter); COMPILE(ret, "iter caller", node->nd_iter);
} }
ADD_LABEL(ret, retry_end_l); ADD_LABEL(ret, retry_end_l);
if (poped) { if (poped) {
ADD_INSN(ret, nd_line(node), pop); ADD_INSN(ret, nd_line(node), pop);
} }
iseq->compile_data->current_block = prevblock; iseq->compile_data->current_block = prevblock;
ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, retry_label, retry_end_l, 0, retry_label); ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, retry_label, retry_end_l, 0, retry_label);
ADD_CATCH_ENTRY(CATCH_TYPE_BREAK, retry_label, retry_end_l, 0, retry_end_l); ADD_CATCH_ENTRY(CATCH_TYPE_BREAK, retry_label, retry_end_l, 0, retry_end_l);
break; break;
} }
case NODE_BREAK:{ case NODE_BREAK:{
unsigned long level = 0; unsigned long level = 0;

View file

@ -23,10 +23,13 @@ static int insn_len_info[] = {
<%= operands_num_info %> <%= operands_num_info %>
}; };
#ifdef USE_INSN_RET_NUM
static int insn_stack_push_num_info[] = { static int insn_stack_push_num_info[] = {
<%= stack_num_info %> <%= stack_num_info %>
}; };
#endif
#ifdef USE_INSN_STACK_INCREASE
static int static int
insn_stack_increase(int depth, int insn, VALUE *opes) insn_stack_increase(int depth, int insn, VALUE *opes)
{ {
@ -37,6 +40,7 @@ insn_stack_increase(int depth, int insn, VALUE *opes)
} }
return 0; return 0;
} }
#endif
/* some utilities */ /* some utilities */
@ -70,8 +74,10 @@ insn_op_type(int insn, int pos)
} }
} }
#ifdef USE_INSN_RET_NUM
static int static int
insn_ret_num(int insn) insn_ret_num(int insn)
{ {
return insn_stack_push_num_info[insn]; return insn_stack_push_num_info[insn];
} }
#endif

View file

@ -12,7 +12,7 @@
or insns2vm.rb or insns2vm.rb
*/ */
static const void *insns_address_table[] = { static const void *const insns_address_table[] = {
<%= insns_table %> <%= insns_table %>
}; };

View file

@ -102,7 +102,7 @@ vm_eval(rb_thread_t *th, VALUE initial)
/* unreachable */ /* unreachable */
rb_bug("vm_eval: unreachable"); rb_bug("vm_eval: unreachable");
return Qundef; goto first;
} }
#else #else
@ -110,10 +110,10 @@ vm_eval(rb_thread_t *th, VALUE initial)
#include "vm.inc" #include "vm.inc"
#include "vmtc.inc" #include "vmtc.inc"
void ** const void *const *
get_insns_address_table() get_insns_address_table()
{ {
return (void **)insns_address_table; return insns_address_table;
} }
VALUE VALUE