summaryrefslogtreecommitdiff
path: root/proc.c
AgeCommit message (Collapse)Author
2014-09-12proc/env DATA_PTR is never NULLnormal
* proc.c (proc_free): remove, use RUBY_TYPED_DEFAULT_FREE (proc_mark, proc_memsize): remove needless branching * vm.c (env_free): remove, use RUBY_TYPED_DEFAULT_FREE (env_mark, env_memsize): remove needless branching This shows a tiny ~0.5% improvement in benchmark/bm_vm2_newlambda.rb but also removes a lot of code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-12proc.c (rb_proc_alloc): inline and move to vm.cnormal
* 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
2014-09-11* vm.c (rb_vm_register_special_exception): make new function toko1
make and register special exceptions. * vm.c (rb_vm_mark): do not need to mark special exceptions because they are registerd by rb_gc_register_mark_object(). * eval.c (Init_eval): use rb_vm_register_special_exception(). * gc.c (Init_GC): ditto. * proc.c (Init_Proc): ditto. * thread.c (Init_Thread): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-08vm_core.h (rb_env_t): use flexible arraynormal
* vm_core.h (rb_env_t): use flexible array This reduces allocations and speeds up the lambda calculus fizzbuzz (bm_app_lc_fizzbuzz.rb) benchmark [ruby-core:64858] * proc.c (get_local_variable_ptr): deconst to adjust for flex array * vm.c (env_mark, env_free, env_memsize): remove check for env->env * vm.c (env_alloc): single allocation for flex array * vm.c (vm_make_env_each): adjust env_alloc call git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-26* proc.c (method_super_method): [DOC] Method#super_methodzzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-26proc.c: method_super_methodnobu
* proc.c (method_super_method): new method Method#super_method, which returns a method object of the method to be called by `super` in the receiver method object. [ruby-core:62202] [Feature #9781] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-26eval_error.c: rb_print_inaccessiblenobu
* eval_error.c (rb_print_inaccessible): exract from mnew_from_me() in proc.c git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-01vm.c: rb_vm_env_local_variablesnobu
* vm.c (rb_vm_env_local_variables): returns array of local variable name symbols in the environment by envval. * proc.c (bind_local_variables): use rb_vm_env_local_variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-01proc.c: Binding#receivernobu
* proc.c (bind_receiver): new method to return the bound receiver of the binding object. [ruby-dev:47613] [Feature #8779] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-01proc.c: fix infinite loopnobu
* proc.c (bind_local_variables): update env from envval for each iterations. [ruby-dev:48351] [Bug #10001] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23Backtrace for SystemStackErrornobu
* eval.c (setup_exception): set backtrace in system stack error other than the pre-allocated sysstack_error. [Feature #6216] * proc.c (Init_Proc): freeze the pre-allocated sysstack_error. * vm_insnhelper.c (vm_stackoverflow): raise new instance for each times without calling any methods to keep the backtrace with no further stack overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-19proc.c: Implement Method#currynobu
* proc.c (rb_method_curry): Implement Method#curry, which delegates to to_proc.curry. [ruby-core:62212] [Feature #9783] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18constify parametersnobu
* include/ruby/intern.h: constify `argv` parameters. * include/ruby/ruby.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-14proc.c: use already included ancestor iclassnobu
* proc.c (umethod_bind): use the ancestor iclass instead of new iclass to get rid of infinite recursion, if the defined module is already included. [ruby-core:62014] [Bug #9721] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-12string.c: clear env self in symbol procnobu
* string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear caller's self which is useless, so that it can get collected. [Fixes GH-592] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-11proc.c: fix super in bound UnboundMethodnobu
* proc.c (rb_method_call_with_block, umethod_bind): call with IClass including the module for a module instance method. [ruby-core:61936] [Bug #9721] * vm_insnhelper.c (vm_search_super_method): allow bound UnboundMethod case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-04eval_intern.h: VAR_INITIALIZEDnobu
* eval_intern.h (VAR_INITIALIZED): macro to suppress maybe-uninitialized warnings by gcc 4.7 and 4.8. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-14[DOC] add links to `Object#hash`nobu
add links to `Object#hash` to each #`hash` methods rdocs. [Fixes GH-567] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02* proc.c: Complete rdoc of Proc#arity regarding keyword arguments.marcandre
See #8072 and #9299. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02* proc.c: Modify rdoc of Proc#arity to fit with current behavior.marcandre
See #5694 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02* proc.c: Tweak rdoc for consistent whitespacemarcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-19* gc.c: fix typo by @windwiny [fix GH-506]hsbt
* proc.c: ditto * variable.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-29proc.c: fix inherited method ownernobu
* proc.c (mnew_from_me): keep iclass as-is, to make inheritance chain consistent. [ruby-core:59358] [Bug #9315] * proc.c (method_owner): return the original defined_class from prepended iclass, instead. * vm_insnhelper.c (vm_search_super_method): revert r44455, no longer defined_class becomes a module. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25* proc.c: Having any mandatory keyword argument increases min arity [#9299]marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25* proc.c: Having optional keyword arguments makes maximum arity +1, not ↵marcandre
unlimited [#8072] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25proc.c: fix arity of rest keywords argumentnobu
* proc.c (rb_iseq_min_max_arity): maximum argument is unlimited if having rest keywords argument. [ruby-core:53298] [Bug #8072] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-24proc.c: Binding#local_variablesnobu
* proc.c (bind_local_variables): allowing binding to list its local variables. patch by Jack Danger Canty <jackdanger AT squareup.com> at [ruby-core:56543]. [Feature #8773] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-24vm.c: check cbasenobu
* vm.c (rb_vm_cref_in_context): check also cbase, not only self. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-24proc.c: make method by define_method publicnobu
* proc.c (rb_mod_define_method): consider visibility only if self in the caller is same as the receiver, otherwise make public as well as old behavior. [ruby-core:57747] [Bug #9005] [ruby-core:58497] [Bug #9141] * vm.c (rb_vm_cref_in_context): return ruby level cref if self is same. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN intoko1
RB_OBJ_WRITE and RB_OBJ_WRITTEN. * array.c, class.c, compile.c, hash.c, internal.h, iseq.c, proc.c, process.c, re.c, string.c, variable.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-14proc.c: method by respond_to_missing?nobu
* proc.c (mnew_from_me): method by respond_to_missing? should be owned by the original class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13proc.c: fix inherited ownernobu
* proc.c (mnew_from_me): achieve the original defined_class from prepended iclass, to fix inherited owner. * proc.c (method_owner): return the defined class, but not the class which the method object is created from. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13proc.c, vm_method.c: fix super and aliasnobu
* proc.c (method_owner): return the class where alias is defined, not the class original method is defined. * vm_method.c (rb_method_entry_make, rb_alias): store the originally defined class in me. [Bug #7993] [Bug #7842] [Bug #9236] * vm_method.c (rb_method_entry_get_without_cache): cache included module but not iclass. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13proc.c: local variablenobu
* proc.c (method_inspect): use a local variable instead of repeating dereferences. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29* add RUBY_TYPED_FREE_IMMEDIATELY to data types which only useko1
safe functions during garbage collection such as xfree(). On default, T_DATA objects are freed at same points as fianlizers. This approach protects issues such as reported by [ruby-dev:35578]. However, freeing T_DATA objects immediately helps heap usage. Most of T_DATA (in other words, most of dfree functions) are safe. However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default for safety. * cont.c: ditto. * dir.c: ditto. * encoding.c: ditto. * enumerator.c: ditto. * error.c: ditto. * file.c: ditto. * gc.c: ditto. * io.c: ditto. * iseq.c: ditto. * marshal.c: ditto. * parse.y: ditto. * proc.c: ditto. * process.c: ditto. * random.c: ditto. * thread.c: ditto. * time.c: ditto. * transcode.c: ditto. * variable.c: ditto. * vm.c: ditto. * vm_backtrace.c: ditto. * vm_trace.c: ditto. * ext/bigdecimal/bigdecimal.c: ditto. * ext/objspace/objspace.c: ditto. * ext/stringio/stringio.c: ditto. * ext/strscan/strscan.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-07* proc.c: catch up last commit.ko1
Type of return value of rb_iseq_first_lineno() is now VALUE. * vm_insnhelper.c (argument_error): ditto. * vm_method.c (rb_method_entry_make): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-07* iseq.c, internal.h: change to public (but internal) functionsko1
* VALUE rb_iseq_path(VALUE iseqval); * VALUE rb_iseq_absolute_path(VALUE iseqval); * VALUE rb_iseq_label(VALUE iseqval); * VALUE rb_iseq_base_label(VALUE iseqval); * VALUE rb_iseq_first_lineno(VALUE iseqval); And new (temporary) function: * VALUE rb_iseq_klass(VALUE iseqval); * iseq.c. vm_core.h (int rb_iseq_first_lineno): remove function `int rb_iseq_first_lineno(const rb_iseq_t *iseq)'. Use `VALUE rb_iseq_first_lineno(VALUE iseqval)' instead. * proc.c. vm_insnhelper.c, vm_method.c: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25* include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().ko1
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and usecase of this macro is not acquire raw pointer, but acquire read-only pointer. So we rename to better name. RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR() (I expect that nobody use it). * array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c, string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-18proc.c: allocate wrapper object firstnobu
* proc.c (mnew_from_me): allocate structs after allocated wrapper object successfully, to get rid of potential memory leak. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-31proc.c: preserve encodingsnobu
* proc.c (mnew_from_me, rb_mod_define_method, umethod_bind), (method_inspect): preserve class name encodings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-31proc.c: local variablenobu
* proc.c (umethod_bind): extract a local variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-14* proc.c (rb_mod_define_method): now they return the symbols of theusa
defined methods, not the methods/procs themselves. [ruby-dev:42151] [Feature #3753] * NEWS: documents about above change and def-expr (see r42337). * test/ruby/test_module.rb: tests about above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-10* proc.c: [DOC] rdoc code formattingzzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-09proc.c: tabifynobu
* proc.c (check_local_id): tabify. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-09* proc.c: add Binding#local_variable_get/set/defined?ko1
to access local variables which a binding contains. Most part of implementation by nobu. * test/ruby/test_proc.rb: add a tests for above. * vm.c, vm_core.h (rb_binding_add_dynavars): add a new function to add a new environment to create space for new local variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-08proc.c: constifiynobu
* proc.c (rb_proc_call_with_block): constifiy argv. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-07* cont.c (rb_fiber_start): use RARRAY_RAWPTR() instead ofko1
RARRAY_PTR() because there is no new reference. * proc.c (curry): ditto. * proc.c (rb_proc_call): remove line break. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22vm_eval.c: Check_TypedStructnobu
* vm_eval.c (eval_string_with_cref): check by Check_TypedStruct instead of rb_obj_is_kind_of. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-20* proc.c (proc_to_s): use PRIsVALUE to preserve the result encoding.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16* proc.c (rb_block_arity): raise ArgumentError if no block given.glass
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e