summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-24 06:31:15 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-24 06:31:15 +0000
commit7049d9c80d1ba859beb5d68c7a9de37d5c11b8e8 (patch)
treee64aa3d7290f296d3685aa27a3e0997fac84a76d /vm.c
parent4f03f0cb67b0bf6497ffd4051e872905e3b49ead (diff)
* iseq.h, iseq.c, compile.c: Change the line number data structure
to solve an issue reported at [ruby-dev:44413] [Ruby 1.9 - Bug #5217]. Before this fix, each instruction has an information including line number (iseq::iseq_insn_info_table). Instead of this data structure, recording only line number changing places (iseq::iseq_line_info_table). The order of entries in iseq_line_info_table is ascending order of iseq_line_info_table_entry::position. You can get a line number by an iseq and a program counter with this data structure. This fix reduces memory consumption of iseq (bytecode). On my measurement, a rails application consumes 21.8MB for iseq with this fix on the 32bit CPU. Without this fix, it consumes 24.7MB for iseq [ruby-dev:44415]. * proc.c: ditto. * vm_insnhelper.c: ditto. * vm_method.c: ditto. * vm.c (rb_vm_get_sourceline): change to use rb_iseq_line_no(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/vm.c b/vm.c
index 16d04db312..bacb5ed7d3 100644
--- a/vm.c
+++ b/vm.c
@@ -716,20 +716,10 @@ rb_vm_get_sourceline(const rb_control_frame_t *cfp)
int line_no = 0;
const rb_iseq_t *iseq = cfp->iseq;
- if (RUBY_VM_NORMAL_ISEQ_P(iseq) && iseq->insn_info_size > 0) {
- rb_num_t i;
+ if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
size_t pos = cfp->pc - cfp->iseq->iseq_encoded;
-
- if (iseq->insn_info_table[0].position == pos) goto found;
- for (i = 1; i < iseq->insn_info_size; i++) {
- if (iseq->insn_info_table[i].position == pos) {
- line_no = iseq->insn_info_table[i - 1].line_no;
- goto found;
+ line_no = rb_iseq_line_no(iseq, pos);
}
- }
- line_no = iseq->insn_info_table[i - 1].line_no;
- }
- found:
return line_no;
}