diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-10 06:14:07 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-10 06:14:07 +0000 |
commit | ea4c97904e37df0937af1742b41f3bb999b785b8 (patch) | |
tree | c2e9a9e62f287300406293effd8d28d43ba6fbf8 /vm_core.h | |
parent | fd31eb3f5c2047415ae741ef7cdd7a5f985ebc7a (diff) |
compile: translate iseq in-place
running "ruby -rpp -e 'pp GC.stat'", a reduction in
malloc usage is shown:
before:
:malloc_increase=>118784,
:oldmalloc_increase=>1178736,
after:
:malloc_increase=>99832,
:oldmalloc_increase=>1031976,
For "ruby -e exit", valgrind reports over 300K reduction in
overall allocations (and unnecessary memory copies).
before:
total heap usage: 49,622 allocs, 20,492 frees, 8,697,493 bytes allocated
after:
total heap usage: 48,935 allocs, 19,805 frees, 8,373,773 bytes allocated
(numbers from x86-64)
v2 changes based on ko1 recommendations [ruby-core:64883]:
- squashed in-place direct thread translation to avoid alloc+copy
- renamed rb_iseq_untranslate_threaded_code to rb_iseq_original_iseq,
cache new iseq->iseq_original field.
* compile.c (rb_iseq_translate_threaded_code): modify in-place w/o copy
(rb_vm_addr2insn): new function for debug
(rb_iseq_original_iseq): ditto
(iseq_set_sequence): assign iseq_encoded directly
[Feature #10185]
* vm_core (rb_iseq_t): move original ->iseq to bottom
* iseq.c (iseq_free, iseq_free): adjust for new layout
(rb_iseq_disasm): use original iseq for dump
(iseq_data_to_ary): ditto
(rb_iseq_line_trace_each): ditto
(rb_iseq_build_for_ruby2cext): use iseq_encoded directly
* vm_dump.c (rb_vmdebug_debug_print_pre): use original iseq
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_core.h')
-rw-r--r-- | vm_core.h | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -212,8 +212,7 @@ struct rb_iseq_struct { rb_iseq_location_t location; - VALUE *iseq; /* iseq (insn number and operands) */ - VALUE *iseq_encoded; /* encoded iseq */ + VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */ unsigned int iseq_size; unsigned int line_info_size; @@ -309,6 +308,10 @@ struct rb_iseq_struct { /* used at compile time */ struct iseq_compile_data *compile_data; + + /* original iseq, before encoding + * used for debug/dump (TODO: union with compile_data) */ + VALUE *iseq; }; enum ruby_special_exceptions { |