From ec475ab32d7ba876c1ce96f9ce6704d85be6a3ac Mon Sep 17 00:00:00 2001 From: normal Date: Fri, 12 Sep 2014 20:57:45 +0000 Subject: proc.c (rb_proc_alloc): inline and move to vm.c * proc.c (rb_proc_alloc): inline and move to vm.c (rb_proc_wrap): new wrapper function used by rb_proc_alloc (proc_dup): simplify alloc + copy + wrap operation [ruby-core:64994] * vm.c (rb_proc_alloc): new inline function (rb_vm_make_proc): call rb_proc_alloc * vm_core.h: remove rb_proc_alloc, add rb_proc_wrap * benchmark/bm_vm2_newlambda.rb: short test to show difference First we allocate and populate an rb_proc_t struct inline to avoid unnecessary zeroing of the large struct. Inlining speeds up callers as this takes many parameters to ensure correctness. We then call the new rb_proc_wrap function to create the object. rb_proc_wrap - wraps a rb_proc_t pointer as a Ruby object, but we only use it inside rb_proc_alloc. We must call this before the compiler may clobber VALUE parameters passed to rb_proc_alloc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- benchmark/bm_vm2_newlambda.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 benchmark/bm_vm2_newlambda.rb (limited to 'benchmark/bm_vm2_newlambda.rb') diff --git a/benchmark/bm_vm2_newlambda.rb b/benchmark/bm_vm2_newlambda.rb new file mode 100644 index 0000000000..6422c9b0d0 --- /dev/null +++ b/benchmark/bm_vm2_newlambda.rb @@ -0,0 +1,5 @@ +i = 0 +while i<6_000_000 # benchmark loop 2 + i += 1 + lambda {} +end -- cgit v1.2.3