summaryrefslogtreecommitdiff
path: root/proc.c
AgeCommit message (Collapse)Author
2017-11-16provide rb_vm_make_proc/lambda().ko1
* vm.c (rb_vm_make_proc): removed. * vm_core.h: provide utility inline functions * rb_vm_make_proc() * rb_vm_make_lambda() to call rb_vm_make_proc_lambda(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-02proc.c: fix rdoc for Method class documentationstomar
* proc.c: [DOC] fix rdoc syntax for the class documentation of the Method class so that it is displayed in the rendered docs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-02proc.c: further improve docs for {Method,Proc}#aritystomar
* proc.c: [DOC] fix grammar in docs for {Method,Proc}#arity; for Method#arity, move special case of methods written in C to the end of the description, fix a typo in a method name, and add an example for required arguments with an optional keyword argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-02proc.c: improve docs for {Method,Proc}#aritystomar
* proc.c: [DOC] improve Method#arity documentation to match with Proc#arity, mentioning keyword arguments; also make Proc#arity examples more consistent in the naming of keyword arguments. Patch by Nikita Misharin (TheSmartnik). [Fix GH-1735] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for rb_vm_call()ko1
* vm_eval.c (rb_vm_call): accepts `ec` instead of `th`. * proc.c: catch up this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28* proc.c (rb_block_arity): use `ec` directly.ko1
* proc.c (rb_mod_define_method): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28* proc.c (proc_new): use `ec` directly.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28`th` -> `ec` for rb_vm_make_binding().ko1
* vm.c (rb_vm_make_binding): accepts (const) `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28move fields from `th` to `ec`.ko1
* vm_core.h: move rb_thread_t::passed_block_handler to rb_execution_context_t::passed_block_handler. Also move rb_thread_t::passed_bmethod_me to rb_execution_context_t::passed_bmethod_me. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27`th` -> `ec` for block related functions.ko1
* vm.c: the following functions accept `ec` instead of `th`. * invoke_block * invoke_bmethod * invoke_iseq_block_from_c * invoke_block_from_c_bh * check_block_handler * vm_yield_with_cref * vm_yield * vm_yield_with_block * vm_yield_force_blockarg * invoke_block_from_c_proc * vm_invoke_proc * vm_invoke_bmethod * rb_vm_invoke_proc * vm_insnhelper.c: ditto. * vm_yield_with_cfunc * vm_yield_with_symbol * vm_callee_setup_block_arg * vm_yield_setup_args * vm_invoke_iseq_block * vm_invoke_symbol_block * vm_invoke_ifunc_block * vm_invoke_block git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27move decl.ko1
* proc.c: move declaration of rb_vm_bh_to_procval() to vm_core.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Restore the prototype declaration of rb_vm_bh_to_procvalmame
Fixes r60460 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26rb_vm_bh_to_procval() accepts `ec` instead of `th`.ko1
* vm_insnhelper.c (rb_vm_bh_to_procval): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26introduce EC_*_TAG() instead of TH_*_TAG()ko1
* eval_intern.h: introduce EC_*_TAG() macros instead of TH_*_TAG() macros. * TH_PUSH_TAG() -> EC_PUSH_TAG() * TH_POP_TAG() -> EC_POP_TAG() * TH_TMPPOP_TAG() -> EC_TMPPOP_TAG() * TH_REPUSH_TAG() -> EC_REPUSH_TAG() * TH_EXEC_TAG() -> EC_EXEC_TAG() * TH_JUMP_TAG() -> EC_JUMP_TAG() rb_threadptr_tag_state() , rb_ec_tag_jump() also accept `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26some functions accept `ec` instead of `th`.ko1
* vm.c (vm_make_env_object): accepts `ec`. * vm.c (rb_vm_get_ruby_level_next_cfp): ditto. * vm.c (rb_vm_make_proc): ditto. * vm.c (rb_vm_make_proc_lambda): ditto. * vm_core.h: some macros accept ec instead of th (and make them inline functions): * RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW * RUBY_VM_END_CONTROL_FRAME * RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P * eval.c (frame_func_id): constify for the first parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26Use rb_execution_context_t instead of rb_thread_tko1
to represent execution context [Feature #14038] * vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer. There are many code using `th` to represent execution context (such as cfp, VM stack and so on). To access `ec`, they need to use `th->ec->...` (adding one indirection) so that we need to replace them by passing `ec` instead of `th`. * vm_core.h (GET_EC()): introduced to access current ec. Also remove `ruby_current_thread` global variable. * cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of rb_context_t::thread_value. * cont.c (ec_set_vm_stack): added to update vm_stack explicitly. * cont.c (ec_switch): added to switch ec explicitly. * cont.c (rb_fiber_close): added to terminate fibers explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24Lazy Proc allocation for block parametersko1
[Feature #14045] * insns.def (getblockparam, setblockparam): add special access instructions for block parameters. getblockparam checks VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM and if it is not set this instruction creates a Proc object from a given blcok and set VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM. setblockparam is similar to setlocal, but set VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM. * compile.c: use get/setblockparm instead get/setlocal instructions. Note that they are used for method local block parameters (def m(&b)), not for block local method parameters (iter{|&b|). * proc.c (get_local_variable_ptr): creates Proc object for Binding#local_variable_get/set. * safe.c (safe_setter): we need to create Proc objects for postponed block parameters when $SAFE is changed. * vm_args.c (args_setup_block_parameter): used only for block local blcok parameters. * vm_args.c (vm_caller_setup_arg_block): if called with VM_CALL_ARGS_BLOCKARG_BLOCKPARAM flag then passed block values should be a block handler. * test/ruby/test_optimization.rb: add tests. * benchmark/bm_vm1_blockparam*: added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-06proc.c: super_method of included methodnobu
* proc.c (method_super_method): search the next super method along the included ancestor chain. [ruby-core:83114] [Bug #13973] * vm_method.c (rb_callable_method_entry_without_refinements): return the defined class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-06proc.c: prefer name method result to inspectnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-02proc.c: [DOC] fixup r59720rhe
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-02Add Method#original_name code example [ci skip]nobu
* proc.c (method_original_name): [DOC] add code example. [Fix GH-1693] Author: Seiei Miyagi <hanachin@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-29fix error message.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-10Fiber#to_s (#inspect) return richer information.ko1
* cont.c (fiber_to_s): return with block and status information. * proc.c (proc_to_s_): removed and introduce rb_block_to_s() function to return block information string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-18vm_eval.c: rb_lambda_callnobu
* enum.c (enum_collect): make the block arity same as the given block. [Bug #13391] * internal.h (vm_ifunc): store arity instead of unused id. * proc.c (rb_vm_block_min_max_arity): return ifunc arity. * vm_eval.c (rb_lambda_call): call method with lambda block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-18proc.c: rb_block_min_max_aritynobu
* proc.c (rb_block_min_max_arity): new function to get arity range from the current block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23use "enum ruby_tag_type" and TAG_NONE.ko1
Return value of EXEC_TAG() is saved by "int state". Instead of "int", use "enum ruby_tag_type". First EXEC_TAG() value should be 0, so that define TAG_NONE (= 0) and use it. Some code used "status" instead of "state". To make them clear, rename them to state. We can change variable name from "state" to "tag_state", but this ticket doesn't contain it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-14proc.c: infect inspect resultnobu
* proc.c (method_inspect): the result should be infected by the object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-14proc.c: skip prepended modulesnobu
* proc.c (method_super_method): skip prepended modules and continue from the super class of the original class. [ruby-core:81666] [Bug #13656] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-12* proc.c (get_local_variable_ptr): return found env ptr. Returned envko1
will be used by write barrier at `bind_local_variable_set()'. [Bug #13605] * test/ruby/test_proc.rb: add a test for this issue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-01make Binding object WB protected.ko1
* proc.c (ruby_binding_data_type): set RUBY_TYPED_WB_PROTECTED. Insert write barriers (WBs) to all of writes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-01rename absolute_path to realpath internally and introduce pathobj.ko1
* vm_core.h: rename absolute_path to realpath because it is expected name. external APIs (#absolute_path methods) are remained. * vm_core.h: remove rb_iseq_location_struct::path and rb_iseq_location_struct::absolute_path and introduce pathobj. if given path equals to given absolute_path (and most of case it is true), pathobj is simply given path String. If it is not same, pathobj is Array and pathobj[0] is path and pathobj[1] is realpath. This size optimization reduce 8 bytes and sizeof(struct rb_iseq_constant_body) is 200 bytes -> 192 bytes on 64bit CPU. To support this change, the following functions are introduced: * pathobj_path() (defined in vm_core.h) * pathobj_realpath() (ditto) * rb_iseq_path() (decl. in vm_core.h) * rb_iseq_realpath() (ditto) * rb_iseq_pathobj_new() (ditto) * rb_iseq_pathobj_set() (ditto) * vm_core.h (rb_binding_t): use pathobj instead of path. If binding is given at eval methods, realpath (absolute_path) was caller's realpath. However, they should use binding's realpath. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09rb_execution_context_t: move stack, stack_size and cfp from rb_thread_tnormal
The goal is to reduce rb_context_t and rb_fiber_t size by removing the need to store the entire rb_thread_t in there. [ruby-core:81045] Work-in-progress: soon, we will move more fields here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-29proc.c: recursion loopnobu
* proc.c (rb_block_min_max_arity, rb_method_entry_min_max_arity): turn loop by recursion into goto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-17remove branches in dmark and dfree GC callbacksnormal
dmark and dfree callbacks are never called in gc.c for NULL DATA_PTR values, not even for zombie objects. * compile.c (ibf_loader_mark): remove branch for pointer validity * compile.c (ibf_loader_free): ditto * cont.c (cont_free): ditto * cont.c (fiber_free): ditto * dir.c (dir_free): ditto * ext/stringio/stringio.c (strio_mark): ditto * proc.c (binding_free): ditto * thread_sync.c (mutex_free): ditto * vm.c (thread_free): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-08proc.c: preserve class name encoding in Proc#to_snobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-03proc.c: documentation for Proc#{call,yield,[]}stomar
* proc.c: [DOC] fix and improve docs for Proc#{call,yield,[]}: * change order of Document-method directives as workaround for an RDoc rendering problem where the documentation for Proc#call displays a "Document-method: []" code block. [ruby-core:79887] [Bug #13273] * add missing call-seq and example for Proc#yield * remove pointless cross reference to Proc#yield * update description for handling of extra or missing arguments, improve examples and add cross reference to #lambda? git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-16use rb_iseq_check() for USE_LAZY_LOAD.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-16doc: improve documentation for Binding [ci skip]normal
* remove explicit return from code examples * grammar fixes * other small fixes Patch by: Marcus Stollsteimer <sto.mar@web.de> [ruby-core:79082] [Bug #13132] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-20proc.c: assume rb_iseq_location_t::first_lineno is always a Fixnumrhe
Do not check for the value of rb_iseq_constant_body::line_info_table as it is no longer related. The checks seem to be the remains from the day before the dedicated 'first_lineno' field was introduced. Remove them. Note, rb_iseq_constant_body::line_info_table can be NULL only when the iseq does not contain any instructions that originate from Ruby code, for example, an iseq created with 'proc {}' under a non-default compile options where trace instructions are disabled. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-20proc.c: enable Proc#to_s rdocnobu
* proc.c (proc_to_s): move just after the rdoc comment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-20proc.c: suppress warningnobu
* proc.c (NO_CLOBBERED): suppress clobbered warning which appears only on mingw. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-08Fix typo in code doc of proc.ca_matsuda
Insure has a different meaning than ensure and we mean the latter in this case. *Ensure* is to do or have what is necessary for success. Example: These blankets ensure that you’ll be warm enough. *Insure* is to cover with an insurance policy. Example: I will insure my home with additional fire and flood policies. Patch by: Dimitris Zorbas <zorbash@skroutz.gr> (@Zorbash) Signed-off-by: Akira Matsuda <ronnie@dio.jp> closes #1352 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05* eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:ktsj
TracePoint#method_id should return method_id, not callee_id. [ruby-core:77241] [Feature #12747] * test/ruby/test_settracefunc.rb: change accordingly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26[DOC] replace Fixnum with Integer [ci skip]nobu
* numeric.c: [DOC] update document for Integer class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-25proc.c: follow the original classnobu
* proc.c (mnew_internal): follow the original class, not to loop the prepended module. [ruby-core:77591] [Bug #12832] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-04* internal.h (ST2FIX): new macro to convert st_index_t to Fixnum.usa
a hash value of Object might be Bignum, but it causes many troubles expecially the Object is used as a key of a hash. so I've gave up to do so. * array.c (rb_ary_hash): use above macro. * bignum.c (rb_big_hash): ditto. * hash.c (rb_obj_hash, rb_hash_hash): ditto. * numeric.c (rb_dbl_hash): ditto. * proc.c (proc_hash): ditto. * re.c (rb_reg_hash, match_hash): ditto. * string.c (rb_str_hash_m): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-25proc.c: trivial optimizationnobu
* proc.c (rb_proc_arity): reduce repeated GetProcPtr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08replace fixnum by integer in documents.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-03* proc.c: [DOC] fix Object#define_singleton_method andsho-h
main.define_method return value. [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e