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

* compile.c (iseq_compile_each): add pop after throw as return.

* bootstraptest/test_knownbug.rb, test_syntax.rb: move resolved test.
* vm_core.h, iseq.c, compile.h: add debug output code.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-12-19 21:39:08 +00:00
parent 10b933295a
commit 5485df3e10
6 changed files with 43 additions and 19 deletions

View file

@ -1,3 +1,11 @@
Thu Dec 20 06:34:27 2007 Koichi Sasada <ko1@atdot.net>
* compile.c (iseq_compile_each): add pop after throw as return.
* bootstraptest/test_knownbug.rb, test_syntax.rb: move resolved test.
* vm_core.h, iseq.c, compile.h: add debug output code.
Thu Dec 20 04:57:18 2007 Koichi Sasada <ko1@atdot.net>
* compile.c (iseq_compile_each): remove unused retry entry.

View file

@ -31,10 +31,6 @@ assert_equal 'ok', %q{
end
}
assert_normal_exit %q{
eval "while true; return; end rescue p $!"
}, '[ruby-dev:31663]'
assert_equal 'ok', %q{
1.times{
eval("break")

View file

@ -641,5 +641,8 @@ assert_equal 'true', %q{
class C; def !@; true; end; end
!C.new
}
assert_normal_exit %q{
eval "while true; return; end rescue p $!"
}, '[ruby-dev:31663]'

View file

@ -1127,6 +1127,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
}
insn_info_table[k].line_no = iobj->line_no;
insn_info_table[k].position = pos;
insn_info_table[k].sp = sp;
pos += len;
k++;
break;
@ -3802,8 +3803,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
ADD_INSN(ret, nd_line(node), leave);
}
else {
ADD_INSN1(ret, nd_line(node), throw,
INT2FIX(0x01) /* TAG_RETURN */ );
ADD_INSN1(ret, nd_line(node), throw, INT2FIX(0x01) /* TAG_RETURN */ );
ADD_INSN(ret, nd_line(node), pop);
}
break;
}

41
iseq.c
View file

@ -534,24 +534,33 @@ iseq_to_a(VALUE self)
return iseq_data_to_ary(iseq);
}
/*
now, search algorithm is brute force. but this should be binary search.
*/
static unsigned short
find_line_no(rb_iseq_t *iseqdat, unsigned long pos)
/* TODO: search algorithm is brute force.
this should be binary search or so. */
static struct iseq_insn_info_entry *
get_insn_info(const rb_iseq_t *iseq, const unsigned long pos)
{
unsigned long i, size = iseqdat->insn_info_size;
struct iseq_insn_info_entry *iiary = iseqdat->insn_info_table;
unsigned long i, size = iseq->insn_info_size;
struct iseq_insn_info_entry *table = iseq->insn_info_table;
for (i = 0; i < size; i++) {
if (iiary[i].position == pos) {
return iiary[i].line_no;
if (table[i].position == pos) {
return &table[i];
}
}
/* rb_bug("find_line_no: can't find %lu", pos); */
return 0;
}
static unsigned short
find_line_no(rb_iseq_t *iseq, unsigned long pos)
{
struct iseq_insn_info_entry *entry = get_insn_info(iseq, pos);
if (entry) {
return entry->line_no;
}
}
static unsigned short
find_prev_line_no(rb_iseq_t *iseqdat, unsigned long pos)
{
@ -569,8 +578,6 @@ find_prev_line_no(rb_iseq_t *iseqdat, unsigned long pos)
}
}
/* rb_bug("find_prev_line_no: can't find - %lu", pos); */
return 0;
}
@ -717,7 +724,7 @@ ruby_iseq_disasm_insn(VALUE ret, VALUE *iseq, int pos,
}
}
{
if (1) {
int line_no = find_line_no(iseqdat, pos);
int prev = find_prev_line_no(iseqdat, pos);
if (line_no && line_no != prev) {
@ -726,6 +733,14 @@ ruby_iseq_disasm_insn(VALUE ret, VALUE *iseq, int pos,
str = rb_str_new2(buff);
}
}
else {
/* for debug */
struct iseq_insn_info_entry *entry = get_insn_info(iseqdat, pos);
snprintf(buff, sizeof(buff), "%-60s(line: %d, sp: %d)",
RSTRING_PTR(str), entry->line_no, entry->sp);
str = rb_str_new2(buff);
}
if (ret) {
rb_str_cat2(str, "\n");
rb_str_concat(ret, str);

View file

@ -108,6 +108,7 @@
struct iseq_insn_info_entry {
unsigned short position;
unsigned short line_no;
unsigned short sp;
};
struct iseq_catch_table_entry {