これについて,中田さんと協議したんですが,そもそも allocator function はメソッド呼び出し(rb_funcall)で呼ばないでもいいんでないか,という結論を得ました.具体的には,rb_classext_t に allocator function を登録するようにして,それを呼び出す,ということになります.
あり得る問題点としては,allocator function から super が出来ない,という話がありました.ただし,そんなことやる奴はいないだろう,ということで allocator function の制限とするのがいいのではないか,という議論になりました.
副次的な効果として,allocator function のためにメソッドフレームを積む必要がなくなり,ユーザ定義クラスの生成が若干速くなる,ということがあります.
なお,もう一方の選択肢としては,allocator function を backtrace や set_trace_func などで特別扱いしない,というものがありましたが,今まで見えなかったものが見えると互換性的にまずいかもしれない,という話がありました.
This issue was solved with changeset r36925.
Koichi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
internal.h: allocator function in rb_classext_t
internal.h (struct rb_classext_struct): move allocator function into
rb_classext_t from ordinary method table. [ruby-dev:46121]
[Feature #6993]
object.c (rb_obj_alloc): call allocator function directly.
vm_method.c (rb_define_alloc_func, rb_undef_alloc_func)
(rb_get_alloc_func): use allocator function in rb_classext_t.
$ gem install ruby-prof
Building native extensions. This could take a while...
ERROR: Error installing ruby-prof:
ERROR: Failed to build gem native extension.
/Users/agrimm/.rvm/rubies/ruby-head/bin/ruby extconf.rb
checking for sys/times.h... yes
checking for rb_os_allocated_objects()... no
checking for rb_gc_allocated_size()... no
checking for rb_gc_collections()... no
checking for rb_gc_time()... no
checking for rb_class_superclass()... yes
checking for rb_heap_total_mem()... no
checking for rb_gc_heap_info()... no
creating Makefile
make
compiling rp_call_info.c
compiling rp_measure.c
compiling rp_measure_allocations.c
compiling rp_measure_cpu_time.c
compiling rp_measure_gc_runs.c
compiling rp_measure_gc_time.c
compiling rp_measure_memory.c
compiling rp_measure_process_time.c
compiling rp_measure_wall_time.c
compiling rp_method.c
rp_method.c: In function ‘method_name’:
rp_method.c:101: error: ‘ID_ALLOCATOR’ undeclared (first use in this function)
rp_method.c:101: error: (Each undeclared identifier is reported only once
rp_method.c:101: error: for each function it appears in.)
make: *** [rp_method.o] Error 1
Gem files will remain installed in /Users/agrimm/.rvm/gems/ruby-head/gems/ruby-prof-0.11.2 for inspection.
Results logged to /Users/agrimm/.rvm/gems/ruby-head/gems/ruby-prof-0.11.2/ext/ruby_prof/gem_make.out
$ ruby --version
ruby 2.0.0dev (2012-12-12) [x86_64-darwin10.8.0]
Mame-san, were you saying "if it doesn't work on preview2, please re-open the issue"? Apologies for re-opening if I misunderstood you.
My understanding is that this issue will be fixed in the ruby-prof side.
So, currently, we plan to include this incompatibility "as is" in Ruby 2.0.0.
But, if the impact is bigger than we expect (i.e., if this affects other existing code except ruby-prof), we may revert this.
Note that we can NOT fix this incompatibility just by restoring the ID_ALLOCATOR macro definition.
As far as I know, this is a side effect of the improvement of class allocation.
But sorry, I don't understand the improvement itself in depth.