Граф коммитов

490 Коммитов

Автор SHA1 Сообщение Дата
stomar 81395f22f3 proc.c: further improve docs for {Method,Proc}#arity
* 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-02 20:21:15 +00:00
stomar ab149d1689 proc.c: improve docs for {Method,Proc}#arity
* 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-11-02 20:20:11 +00:00
ko1 ed21061f21 `th` -> `ec` for rb_vm_call()
* 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 11:52:56 +00:00
ko1 42d137ff19 * proc.c (rb_block_arity): use `ec` directly.
* 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 11:46:32 +00:00
ko1 7df94b0f3d * proc.c (proc_new): use `ec` directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28 11:43:17 +00:00
ko1 4cd402ae1f `th` -> `ec` for rb_vm_make_binding().
* 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-28 11:15:56 +00:00
ko1 f8a9d044f4 move fields from `th` to `ec`.
* 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-28 10:01:54 +00:00
ko1 88910e94a8 `th` -> `ec` for block related functions.
* 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-27 06:06:31 +00:00
ko1 a399badeeb move decl.
* 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-27 00:31:59 +00:00
mame fab73ba556 Restore the prototype declaration of rb_vm_bh_to_procval
Fixes r60460

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 00:25:57 +00:00
ko1 a8868b3fe5 rb_vm_bh_to_procval() accepts `ec` instead of `th`.
* 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-26 23:33:59 +00:00
ko1 4552f74715 introduce EC_*_TAG() instead of TH_*_TAG()
* 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-26 11:02:13 +00:00
ko1 e95de48f1d some functions accept `ec` instead of `th`.
* 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-26 08:41:34 +00:00
ko1 837fd5e494 Use rb_execution_context_t instead of rb_thread_t
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-26 08:32:49 +00:00
svn f18caee991 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 11:13:50 +00:00
ko1 5ee9513a71 Lazy Proc allocation for block parameters
[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-24 11:13:49 +00:00
nobu a15028bc38 proc.c: super_method of included method
* 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-06 05:55:11 +00:00
nobu 581c023127 proc.c: prefer name method result to inspect
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-06 05:55:10 +00:00
rhe 1e9fad234a proc.c: [DOC] fixup r59720
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-02 06:17:52 +00:00
nobu caf92db486 Add Method#original_name code example [ci skip]
* 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-09-02 01:41:14 +00:00
ko1 480c84e1af fix error message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-29 07:01:27 +00:00
ko1 43384ae978 Fiber#to_s (#inspect) return richer information.
* 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-08-10 02:58:36 +00:00
nobu 1f67a3900f vm_eval.c: rb_lambda_call
* 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-18 08:31:02 +00:00
nobu 8ffb23c2e1 proc.c: rb_block_min_max_arity
* 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-07-18 07:48:37 +00:00
ko1 2108e55c0b use "enum ruby_tag_type" and TAG_NONE.
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-23 07:25:52 +00:00
nobu bacadbe9bf proc.c: infect inspect result
* 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-14 14:02:33 +00:00
nobu dbf67bf02d proc.c: skip prepended modules
* 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-14 06:03:55 +00:00
ko1 fccbc2d278 * proc.c (get_local_variable_ptr): return found env ptr. Returned env
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-12 02:20:09 +00:00
ko1 9301ef5d0e make Binding object WB protected.
* 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-01 15:12:14 +00:00
ko1 478003f6df rename absolute_path to realpath internally and introduce pathobj.
* 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-06-01 00:05:33 +00:00
normal 9d09240d9e rb_execution_context_t: move stack, stack_size and cfp from rb_thread_t
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-05-09 05:06:41 +00:00
nobu 8a7419814c proc.c: recursion loop
* 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-04-29 10:27:46 +00:00
normal cad4591086 remove branches in dmark and dfree GC callbacks
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-17 19:59:56 +00:00
nobu 4e61f6d31d proc.c: preserve class name encoding in Proc#to_s
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-08 07:34:13 +00:00
stomar bf5b0c4956 proc.c: documentation for Proc#{call,yield,[]}
* 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-03-03 08:45:04 +00:00
ko1 a17384301b use rb_iseq_check() for USE_LAZY_LOAD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-16 08:24:37 +00:00
normal 103a6a4cbd doc: improve documentation for Binding [ci skip]
* 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
2017-01-16 21:08:12 +00:00
rhe c54ede0560 proc.c: assume rb_iseq_location_t::first_lineno is always a Fixnum
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-12-20 05:26:07 +00:00
nobu 2a546caae6 proc.c: enable Proc#to_s rdoc
* 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-20 10:52:28 +00:00
nobu 3a996e8a83 proc.c: suppress warning
* 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-20 10:41:09 +00:00
a_matsuda a01c388465 Fix typo in code doc of proc.c
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-08 19:37:59 +00:00
ktsj 8004ad33bc * eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
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-11-05 13:15:26 +00:00
nobu 4e44f6ef86 [DOC] replace Fixnum with Integer [ci skip]
* 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-26 06:11:23 +00:00
nobu d977cd4e0a proc.c: follow the original class
* 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-25 03:54:09 +00:00
usa c2dd2d268e * internal.h (ST2FIX): new macro to convert st_index_t to Fixnum.
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-10-04 16:25:01 +00:00
nobu 598fd0cd94 proc.c: trivial optimization
* 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-25 13:33:08 +00:00
akr 577de1e93d replace fixnum by integer in documents.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08 04:57:49 +00:00
sho-h ba32b53e48 * proc.c: [DOC] fix Object#define_singleton_method and
main.define_method return value. [ci skip]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-03 15:21:43 +00:00
yui-knk c4d4abf241 * proc.c (mnew_missing): Remove an unused argument.
After r51126 rid is not used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-18 15:59:12 +00:00
ko1 03cad83593 * vm_core.h: introduce VM_FRAME_RUBYFRAME_P()
and VM_FRAME_CFRAME_P().
  Most of case, RUBY_VM_NORMAL_ISEQ_P() is no
  longer needed.

* vm_core.h: introduce rb_obj_is_iseq().

* cont.c, vm.c: VM_FRAME_MAGIC_DUMMY with
  VM_FRAME_FLAG_CFRAME.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-03 01:50:50 +00:00
ko1 e3120e1a99 * vm_core.h: introduce VM_FRAME_FLAG_CFRAME to represent cfp->iseq
type.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-03 00:16:34 +00:00
ko1 26de0b131e * proc.c (env_write): remove unused function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29 01:52:17 +00:00
ko1 e06698d257 * vm.c, internal.h: remove RubyVM::Env class and all of env objects
are imemo objects (imemo_env).

* NEWS: describe this change. I believe nobody touch these objects
  because there are no method defined.

* vm_core.h: remove the following definitions.
  * rb_cEnv decl.
  * GetEnvPtr() because Env is no longer T_DATA object.

* vm_core.h (rb_env_t): fix layout for imemo values.

* vm_core.h (vm_assert_env): added.

* vm_core.h (vm_env_new): added.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-28 19:13:26 +00:00
ko1 9f60791a04 * vm_core.h: revisit the structure of frame, block and env.
[Bug #12628]

  This patch introduce many changes.

  * Introduce concept of "Block Handler (BH)" to represent
    passed blocks.

  * move rb_control_frame_t::flag to ep[0] (as a special local
    variable). This flags represents not only frame type, but also
    env flags such as escaped.

  * rename `rb_block_t` to `struct rb_block`.

  * Make Proc, Binding and RubyVM::Env objects wb-protected.

  Check [Bug #12628] for more details.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-28 11:02:30 +00:00
nobu 86a756ae15 Passed block symbol to proc
* proc.c (passed_block): convert passed block symbol to proc.
  based on the patch by Daisuke Sato in [ruby-dev:49695].
  [Bug #12531]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-28 23:45:55 +00:00
normal 3044a0bcd9 proc.c: fix RDoc of Proc#===/call/yield/[]
[Bug #12332]

Since r52050 ("proc.c: enable optimization of Proc#call")
for [Feature #11569], we need to maintain this documentation
in a way RDoc comprehends.  This is probably not worth fixing
in RDoc itself since this uses a non-standard internal C API
which is subject to change without notice.

ref:
http://mid.gmane.org/20160429212836.GA16605@dcvr.yhbt.net
http://mid.gmane.org/1461959651.806728.670.51764@mail.rambler.ru
http://blade.nagaokaut.ac.jp/ruby/ruby-talk/435458

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-15 21:11:33 +00:00
nobu 6112b29003 proc.c: no temporary args array
* proc.c (bmcall): method proc is always lambda, args is the array
  which is made from argc and argv.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-05 07:27:10 +00:00
nobu cfc29cf289 proc.c: no unnecessary temporary array
* proc.c (bmcall): get rid of making temporary single element
  array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-05 07:18:14 +00:00
nobu 5c19519e8c proc.c: suppress a warning
* proc.c (call_method_data_safe): suppress clobbered warning by
  old gcc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-05 07:11:34 +00:00
nobu 84f94652b0 use TH_JUMP_TAG
* vm_eval.c (rb_eval_cmd, rb_catch_obj): use TH_JUMP_TAG with the
  same rb_thread_t used for TH_PUSH_TAG, instead of JUMP_TAG with
  the current thread global variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-05 03:22:20 +00:00
nobu 09550d14b6 proc.c: separate rb_method_call_with_block
* proc.c (rb_method_call_with_block): separate the cases with and
  without tag for optimization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-04 10:10:07 +00:00
nobu 759773bf0e proc.c: passed_block
* proc.c (passed_block): extract conversion from passed proc value
  to rb_block_t pointer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-04 10:10:06 +00:00
nobu c8932036d2 proc.c: constify
* proc.c (method_callable_method_entry): constify data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-04 10:10:05 +00:00
nobu 6c7fd3b5cf proc.c: fail symbol proc binding
* proc.c (proc_binding): proc from symbol can not make a binding.
  [ruby-core:74100] [Bug #12137]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-16 11:03:38 +00:00
naruse 794eb48e00 Add example for Method#parameters from [ruby-core:19759]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-09 18:43:45 +00:00
yui-knk 5cf9b65aa3 Use `rb_method_visibility_t` instead of `int` in `rb_print_undef`
* eval_error.c (rb_print_undef): Use `rb_method_visibility_t`
  instead of `int`.
* eval_intern.h (rb_print_undef): ditto
* proc.c (mnew_internal): ditto
* vm_method.c (rb_export_method): ditto
  [Misc #11649] [ruby-core:71311] [fix GH-1078]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-03 04:59:54 +00:00
ko1 a8b0c25293 * proc.c (rb_mod_define_method): should check Symbol or not.
[Bug #11850]

* test/ruby/test_method.rb: add a test.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-20 02:14:57 +00:00
ko1 3b8730058e * proc.c (rb_mod_define_method): fix notation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-20 02:02:55 +00:00
ko1 c46ff1bb27 * proc.c (proc_new): fix notation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-20 01:54:59 +00:00
nobu 2d97cee4d5 proc.c: fix infinite loop
* proc.c (rb_proc_get_iseq): proc made from symbol does not have
  iseq.  fix infinite loop.  [ruby-core:72381] [Bug #11845]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-19 15:29:01 +00:00
nobu ea46a6408c fix commit miss
* proc.c: fix expanded name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-19 15:14:50 +00:00
nobu 8879071030 proc.c: remove old macro
* proc.c (proc_get_iseq): remove and expand old name macro.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-19 15:12:45 +00:00
shugo 94b3c4121b * proc.c (rb_block_arity): should not call GetProcPtr() for symbols.
[ruby-core:72205] [Bug #11830]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-17 07:16:14 +00:00
normal 06d1660e69 proc.c: remove bm_free, use default
bm_free no longer has special handling of unlinked method
entries since r50728 when method entries were made VALUEs
for GC safety.

* proc.c (bm_free): remove, use default free
  (method_data_type): use RUBY_TYPED_DEFAULT_FREE

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09 19:58:48 +00:00
ko1 2f5b8f0529 * *.c (*_memsize): do not check ptr.
NULL checking is finished Before call of memsize functions.
  See r52979.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09 00:38:32 +00:00
ko1 3dbb390180 * introduce new ISeq binary format serializer/de-serializer
and a pre-compilation/runtime loader sample.
  [Feature #11788]

* iseq.c: add new methods:
  * RubyVM::InstructionSequence#to_binary_format(extra_data = nil)
  * RubyVM::InstructionSequence.from_binary_format(binary)
  * RubyVM::InstructionSequence.from_binary_format_extra_data(binary)

* compile.c: implement body of this new feature.

* load.c (rb_load_internal0), iseq.c (rb_iseq_load_iseq):
  call RubyVM::InstructionSequence.load_iseq(fname) with
  loading script name if this method is defined.

  We can return any ISeq object as a result value.
  Otherwise loading will be continue as usual.

  This interface is not matured and is not extensible.
  So that we don't guarantee the future compatibility of this method.
  Basically, you should'nt use this method.

* iseq.h: move ISEQ_MAJOR/MINOR_VERSION (and some definitions)
  from iseq.c.

* encoding.c (rb_data_is_encoding), internal.h: added.

* vm_core.h: add several supports for lazy load.
  * add USE_LAZY_LOAD macro to specify enable or disable of
    this feature.
  * add several fields to rb_iseq_t.
  * introduce new macro rb_iseq_check().

* insns.def: some check for lazy loading feature.

* vm_insnhelper.c: ditto.

* proc.c: ditto.

* vm.c: ditto.

* test/lib/iseq_loader_checker.rb: enabled iff suitable
  environment variables are provided.

* test/runner.rb: enable lib/iseq_loader_checker.rb.

* sample/iseq_loader.rb: add sample compiler and loader.

    $ ruby sample/iseq_loader.rb [dir]

  will compile all ruby scripts in [dir].
  With default setting, this compile creates *.rb.yarb files
  in same directory of target .rb scripts.

    $ ruby -r sample/iseq_loader.rb [app]

  will run with enable to load compiled binary data.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 13:58:50 +00:00
hsbt f6ea3cc675 * proc.c: Add call-seq of `Method#super_method`
[ci skip][fix GH-1094]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-16 07:00:56 +00:00
nobu bda0e2fd84 proc.c: cfunc_proc_t
* proc.c (cfunc_proc_t): add room for me.
* proc.c (cfunc_proc_new): generalise for cfunc proc without env.
* proc.c (rb_func_proc_new, rb_func_lambda_new): new functions to
  make proc/lambda without env from cfunc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10 09:24:41 +00:00
nobu 72ff61f4a8 NameError#receiver of uninitialized constant
* error.c (name_err_mesg_to_str): quote the name if unprintable.
* object.c (check_setter_id): use rb_check_id to convert names.
* variable.c (uninitialized_constant): use NameError::message to
  keep the receiver of uninitialized constant.  [Feature #10881]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-28 06:24:12 +00:00
nobu ec4ba1b728 proc.c: remove rb_block_clear_env_self
* proc.c (rb_block_clear_env_self): removed as deprecated at
  r52129.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-27 03:49:18 +00:00
nobu 94bdb010f6 update document [ci skip]
* error.c (ArgumentError): [DOC] update document following
  [Feature #9025]

* proc.c (proc_call, proc_curry): [DOC] ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-25 00:39:29 +00:00
nobu 6291c6ad77 vm_args.c: symbol proc
* vm_args.c (vm_caller_setup_arg_block): store symbols instead of
  ifuncs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-16 03:21:10 +00:00
nobu 2fda4a5568 proc.c: merge blocks
* proc.c (proc_binding): merge blocks in same condition.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-15 16:06:52 +00:00
nobu beeaef3d32 proc.c: refine ifunc checks
* proc.c (IS_METHOD_PROC_IFUNC): separate from IS_METHOD_PROC_ISEQ
  for vm_ifunc.

* proc.c (rb_proc_get_iseq): use RUBY_VM_IFUNC_P to see if iseq is
  an ifunc.

* proc.c (rb_proc_get_iseq, proc_binding): reduce redundant checsk
  by IS_METHOD_PROC_IFUNC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-15 15:54:48 +00:00
nobu 14b8530454 proc.c: void env
* proc.c (rb_sym_to_proc): make void env.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-15 14:56:05 +00:00
nobu 1bcc7ebda2 proc.c: iseq conditions
* proc.c (rb_block_min_max_arity, rb_mod_define_method): use
  RUBY_VM_NORMAL_ISEQ_P() to check if iseq.

* proc.c (make_curry_proc): IS_METHOD_PROC_ISEQ() includes
  RUBY_VM_IFUNC_P().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-15 06:34:31 +00:00
nobu c2e8fb0f34 proc.c: proc without env
* proc.c (rb_sym_to_proc): move from string.c and create a Proc
  with no environments.  [ruby-core:71088] [Bug #11594]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-15 04:37:26 +00:00
ko1 daa13ad2af * proc.c (rb_method_entry_min_max_arity): should support
OPTIMIZED_METHOD_TYPE_CALL.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-06 14:44:06 +00:00
ko1 7432df370d * proc.c (Init_Proc): Proc#call and others should be public.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-06 10:24:34 +00:00
ko1 0018a71184 * proc.c: enable optimization of Proc#call.
[Feature #11569]
* NEWS: write about this optimization and incompatibilities.
* test/ruby/test_backtrace.rb: catch up this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 21:34:24 +00:00
nobu 2475db5764 proc.c: set ep properly
* proc.c (proc_new): link ep to calling block.
  [ruby-core:70980] [Bug #11566]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 06:34:58 +00:00
nobu 63c7d9111c proc.c: fix symbol proc mark
* proc.c (proc_mark): block.ep of Proc from Symbol is now NULL.
  [ruby-core:70961] [Bug #11560]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-01 15:18:42 +00:00
nobu c90550c251 vm_args.c: fix marking symbol ifunc
* vm_args.c (vm_caller_setup_arg_block): store new ifunc for
  symbol in control frame proc to be marked.

* proc.c (proc_new), vm_insnhelper.c (vm_yield_with_cfunc):
  block->proc may be an ifunc now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-01 10:52:52 +00:00
nobu 66296d3774 proc.c: include symbol name
* proc.c (proc_to_s): include the original symbol name in string
  form.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-30 06:36:11 +00:00
nobu 866952300d proc.c: fix GC guard location
* proc.c (proc_call): fix GC guard location after the use of its
  content.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-28 17:30:09 +00:00
nobu 24da2db3e1 vm_method.c: reuse method entry
* vm_method.c (rb_obj_respond_to): reuse found method entry
  instead of searching same entry repeatedly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-19 23:53:12 +00:00
nobu 6b7c4dfa67 proc.c: fix for uncallable method
* proc.c (method_super_method): uncallable method entry does not
  have the defined class, use the owner instead.
  [ruby-core:70254] [Bug #11419]
* test/ruby/test_method.rb (test_super_method_unbound): add test
  by Akira Matsuda.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-07 08:07:58 +00:00
ko1 033e093363 * proc.c (rb_block_clear_env_self): clear by Qfalse intead of Qnil.
[Bug #11409]
* test/ruby/test_eval.rb: add tests for this issue,
  written by @0x0dea.
  https://github.com/ruby/ruby/pull/988



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-04 06:35:31 +00:00
hsbt d91e11b59d * proc.c: Removing duplicate doc [fix GH-987][ci skip]
Patch by @ronakjangir47

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-04 00:35:26 +00:00
ko1 22be6d06ab * vm_core.h: size should be unsigned.
* rb_call_info_t::index
  * rb_iseq_constant_body::stack_max
  * rb_iseq_constant_body::local_size
  * rb_iseq_constant_body::param::size
  * rb_iseq_constant_body::local_table_size
  * rb_iseq_constant_body::is_size
  * rb_iseq_constant_body::callinfo_size
* iseq.h: same for iseq_catch_table::size.
* compile.c: catch up these fix.
* iseq.c: ditto.
* proc.c: ditto.
* vm.c: ditto.
* vm_args.c: ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24 21:44:14 +00:00