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

490 Коммитов

Автор SHA1 Сообщение Дата
ko1 e4198a73d4 * make rb_iseq_t T_IMEMO object (type is imemo_iseq).
All contents of previous rb_iseq_t is in rb_iseq_t::body.
  Remove rb_iseq_t::self because rb_iseq_t is an object.
  RubyVM::InstructionSequence is wrapper object points T_IMEMO/iseq.
  So RubyVM::ISeq.of(something) method returns different wrapper
  objects but they point the same T_IMEMO/iseq object.
  This patch is big, but most of difference is replacement of
  iseq->xxx to iseq->body->xxx.
  (previous) rb_iseq_t::compile_data is also located to
  rb_iseq_t::compile_data.
  It was moved from rb_iseq_body::compile_data.
  Now rb_iseq_t has empty two pointers.
  I will split rb_iseq_body data into static data and dynamic data.
* compile.c: rename some functions/macros.
  Now, we don't need to separate iseq and iseqval (only VALUE).
* eval.c (ruby_exec_internal): `n' is rb_iseq_t (T_IMEMO/iseq).
* ext/objspace/objspace.c (count_imemo_objects): count T_IMEMO/iseq.
* gc.c: check T_IMEMO/iseq.
* internal.h: add imemo_type::imemo_iseq.
* iseq.c: define RubyVM::InstructionSequnce as T_OBJECT.
  Methods are implemented by functions named iseqw_....
* load.c (rb_load_internal0): rb_iseq_new_top() returns
  rb_iseq_t (T_IMEMO/iesq).
* method.h (rb_add_method_iseq): accept rb_iseq_t (T_IMEMO/iseq).
* vm_core.h (GetISeqPtr): removed because it is not T_DATA now.
* vm_core.h (struct rb_iseq_body): remove padding for
  [Bug #10037][ruby-core:63721].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21 22:52:59 +00:00
ko1 c5618920ed * method.h: constify rb_method_iseq_t::iseqptr.
* proc.c (rb_method_entry_min_max_arity): catch up this fix.
* vm_insnhelper.c (def_iseq_ptr): constify.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21 21:19:02 +00:00
normal dab4d077d1 remove redundant NULL checks after RUBY_VM_IFUNC_P
* proc.c (proc_mark): remove redundant check
* vm.c (env_mark): ditto

This doesn't change object code size, but the unstripped
executable is smaller and the code less confusing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-15 09:32:08 +00:00
normal a0908cb413 remove redundant NULL check in mark functions
gc.c (gc_mark_children)only calls mark_func if the T_DATA ptr is
non-NULL, so avoid redundantly checking for that in each
mark function.

* iseq.c (iseq_mark): remove check for data pointer
* proc.c (binding_mark): ditto
* vm.c (rb_thread_mark): ditto
* vm_trace.c (tp_mark): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-15 08:29:22 +00:00
ko1 994460c4db * vm_core.h, vm.c: remove rb_proc_t::envval because we can know it via
rb_proc_t::block::ep.
  rb_vm_proc_envval(const rb_proc_t *proc) returns an Env object which
  the Proc object use.
* proc.c: catch up this fix.
* vm_dump.c (rb_vmdebug_proc_dump_raw): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-14 17:59:03 +00:00
ko1 e07dad00ee * vm_core.h, vm.c: remvoe rb_env_t::prev_envval because we can know it
via env->ep.
  rb_vm_env_prev_envval(env) returns prev_envval via env->ep.
* vm_core.h (rb_vm_env_local_variables): change parameter type
  from VALUE (T_DATA/env) to `const rb_env_t *' to make same as
  rb_vm_env_prev_envval().
* proc.c: catch up these changes.
* vm_dump.c: ditto.
* vm.c: rename macros.
  * ENV_IN_HEAP_P() to VM_EP_IN_HEAP_P() because it uses ep.
  * ENV_VAL() to VM_ENV_EP_ENVVAL() because it is too short.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-14 17:36:36 +00:00
ko1 a82ce7c556 * vm.c: refactoring Proc/Env related code.
* vm_core.h: remove blockprocval field from rb_proc_t and rb_binding_t.
  Instead of this field, mark given block in Proc at rb_env_t::env.
* vm.c (vm_make_env_each): make an Env object with this layout.
  And also simplify parameters.
* proc.c: catch up this fix.
* vm_core.h: remove rb_env_t::local_size because it is not used.
* vm_dump.c (rb_vmdebug_env_dump_raw): catch up this fix.
* vm_core.h (rb_vm_make_env_object): remove rb_vm_make_env_object()
  because it is only refered from vm.c.
* vm_eval.c (eval_string_with_cref): catch up this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-14 16:23:17 +00:00
ko1 c5dad98c41 * proc.c (rb_method_call): because data->me should be non-NULL,
do not check data->me
* proc.c (method_inspect): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07 02:52:34 +00:00
ko1 5c4d7b9a9e * vm_core.h: remove rb_iseq_t::defined_method_id because it is not
needed.
* eval.c (frame_func_id): simplify. rb_callable_method_entry_t
  has enough information.
* eval.c (frame_called_id): ditto.
* iseq.c (prepare_iseq_build): catch up this fix.
* proc.c (rb_mod_define_method): ditto.
* vm.c (vm_define_method): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06 19:08:05 +00:00
ko1 02d5868962 * vm_core.h: remove rb_iseq_t::klass to reduce dynamic data.
* internal.h, iseq.c (rb_iseq_klass): remove it because
  rb_iseq_t::klass is removed.
* vm_insnhelper.c (vm_super_outside): do not see cfp->iseq, but
  check callable method entry on a frame.
  This fix simplify the logic to search super class.
* test/ruby/test_method.rb: support super() from Proc.
  Now, [Bug #4881] and [Bug #3136] was solved.
* proc.c (rb_mod_define_method): catch up this change.
* vm.c (vm_define_method): ditto.
* vm_backtrace.c (rb_profile_frames): now, each `frame' objects
  are rb_callable_method_entry_t data or iseq VALUEs.
  This fix introduce minor compatibility issue that
  rb_profile_frame_label() always returns
  rb_profile_frame_base_label().
* test/-ext-/debug/test_profile_frames.rb: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06 18:44:54 +00:00
ko1 b07e78fa32 * method.h, proc.c (rb_method_entry_location): make it static
and remoev prefix `rb_' because it is used only in proc.c.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06 08:35:22 +00:00
ko1 5e8a147480 * method.h: introduce rb_callable_method_entry_t to remove
rb_control_frame_t::klass.
  [Bug #11278], [Bug #11279]
  rb_method_entry_t data belong to modules/classes.
  rb_method_entry_t::owner points defined module or class.
    module M
      def foo; end
    end
  In this case, owner is M.
  rb_callable_method_entry_t data belong to only classes.
  For modules, MRI creates corresponding T_ICLASS internally.
  rb_callable_method_entry_t can also belong to T_ICLASS.
  rb_callable_method_entry_t::defined_class points T_CLASS or
  T_ICLASS.
  rb_method_entry_t data for classes (not for modules) are also
  rb_callable_method_entry_t data because it is completely same data.
  In this case, rb_method_entry_t::owner == rb_method_entry_t::defined_class.
  For example, there are classes C and D, and incldues M,
    class C; include M; end
    class D; include M; end
  then, two T_ICLASS objects for C's super class and D's super class
  will be created.
  When C.new.foo is called, then M#foo is searcheed and
  rb_callable_method_t data is used by VM to invoke M#foo.
  rb_method_entry_t data is only one for M#foo.
  However, rb_callable_method_entry_t data are two (and can be more).
  It is proportional to the number of including (and prepending)
  classes (the number of T_ICLASS which point to the module).
  Now, created rb_callable_method_entry_t are collected when
  the original module M was modified. We can think it is a cache.
  We need to select what kind of method entry data is needed.
  To operate definition, then you need to use rb_method_entry_t.
  You can access them by the following functions.
  * rb_method_entry(VALUE klass, ID id);
  * rb_method_entry_with_refinements(VALUE klass, ID id);
  * rb_method_entry_without_refinements(VALUE klass, ID id);
  * rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
  To invoke methods, then you need to use rb_callable_method_entry_t
  which you can get by the following APIs corresponding to the
  above listed functions.
  * rb_callable_method_entry(VALUE klass, ID id);
  * rb_callable_method_entry_with_refinements(VALUE klass, ID id);
  * rb_callable_method_entry_without_refinements(VALUE klass, ID id);
  * rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me);
  VM pushes rb_callable_method_entry_t, so that rb_vm_frame_method_entry()
  returns rb_callable_method_entry_t.
  You can check a super class of current method by
  rb_callable_method_entry_t::defined_class.
* method.h: renamed from rb_method_entry_t::klass to
  rb_method_entry_t::owner.
* internal.h: add rb_classext_struct::callable_m_tbl to cache
  rb_callable_method_entry_t data.
  We need to consider abotu this field again because it is only
  active for T_ICLASS.
* class.c (method_entry_i): ditto.
* class.c (rb_define_attr): rb_method_entry() does not takes
  defiend_class_ptr.
* gc.c (mark_method_entry): mark RCLASS_CALLABLE_M_TBL() for T_ICLASS.
* cont.c (fiber_init): rb_control_frame_t::klass is removed.
* proc.c: fix `struct METHOD' data structure because
  rb_callable_method_t has all information.
* vm_core.h: remove several fields.
  * rb_control_frame_t::klass.
  * rb_block_t::klass.
  And catch up changes.
* eval.c: catch up changes.
* gc.c: ditto.
* insns.def: ditto.
* vm.c: ditto.
* vm_args.c: ditto.
* vm_backtrace.c: ditto.
* vm_dump.c: ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-03 11:24:50 +00:00
nobu e77f9fcb13 proc.c: ArgumentError if no block
* proc.c (rb_mod_define_method): now requires a block direct to
  this method call.  [ruby-core:69655] [Bug #11283]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-19 05:53:41 +00:00
nobu 0ba2ccc51d proc.c: inadvertent ID
* proc.c (rb_mod_define_method): get rid of inadvertent ID
  creations at error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-19 04:55:01 +00:00
nobu 88249ada75 proc.c: extract same messages
* proc.c (proc_new): extract same warning and error messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-19 04:54:23 +00:00
nobu 91af3e00d1 proc.c: reduce type checks
* proc.c (rb_mod_define_method): no needs to check same type
  twice.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-15 08:18:18 +00:00
ko1 c19d373750 * method.h: back to share rb_method_definition_t by
rb_method_entry_t.
  r50728 changed sharing `def's to isolating `def's
  on alias and so on. However, this change conflicts
  future improvement plan. So I change back to sharing approach.
* method.h: move rb_method_definition_t::flags to
  rb_method_entry_t::attr::flags.
  rb_method_entry_t::attr is union with VALUE because this field
  should have same size of VALUE. rb_method_entry_t is T_IMEMO).
  And also add the following access macros to it's fileds.
  * METHOD_ENTRY_VISI(me)
  * METHOD_ENTRY_BASIC(me)
  * METHOD_ENTRY_SAFE(me)
* vm_method.c (rb_method_definition_addref): added instead of
  rb_method_definition_clone().
  Do not create new definition, but increment alias_count.
* class.c (clone_method): catch up this fix.
* class.c (method_entry_i): ditto.
* proc.c (mnew_internal): ditto.
* proc.c (mnew_missing): ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-06 10:19:48 +00:00
ko1 c3cc282f7f * class.c (clone_method): remove redundant check for me->def != NULL.
Now, all `me` have `me->def`.
* proc.c (rb_method_entry_location): ditto.
* vm.c (rb_vm_check_redefinition_opt_method): ditto.
* vm.c (add_opt_method): ditto.
* vm_eval.c (vm_call0_body): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 11:10:16 +00:00
ko1 18bbd05709 * method.h: split rb_method_definition_t::flag to several flags.
`flag' contains several categories of attributes and it makes us
  confusion (at least, I had confused).
  * rb_method_visibility_t (flags::visi)
    * NOEX_UNDEF     -> METHOD_VISI_UNDEF     = 0
    * NOEX_PUBLIC    -> METHOD_VISI_PUBLIC    = 1
    * NOEX_PRIVATE   -> METHOD_VISI_PRIVATE   = 2
    * NOEX_PROTECTED -> METHOD_VISI_PROTECTED = 3
  * NOEX_SAFE(flag)) -> safe (flags::safe, 2 bits)
  * NOEX_BASIC       -> basic (flags::basic, 1 bit)
  * NOEX_MODFUNC     -> rb_scope_visibility_t in CREF
  * NOEX_SUPER       -> MISSING_SUPER (enum missing_reason)
  * NOEX_VCALL       -> MISSING_VCALL (enum missing_reason)
  * NOEX_RESPONDS    -> BOUND_RESPONDS (macro)
  Now, NOEX_NOREDEF is not supported (I'm not sure it is needed).
  Background:
    I did not know what "NOEX" stands for.
    I asked Matz (who made this name) and his answer was "Nothing".
    "At first, it meant NO EXport (private), but the original
    meaning was gone."
    This is why I remove the mysterious word "NOEX" from MRI.
* vm_core.h: introduce `enum missing_reason' to represent
  method_missing (NoMethodError) reason.
* eval_intern.h: introduce rb_scope_visibility_t to represent
  scope visibility.
  It has 3 method visibilities (public/private/protected)
  and `module_function`.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 01:39:16 +00:00
ko1 ac88162198 * method.h: remove rb_method_iseq_t::iseqval.
While making a r50728, iseqval is needed (to mark correctly),
  but now just iseqptr is enough.
* class.c: catch up this fix.
* gc.c: ditto.
* proc.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 14:32:33 +00:00
ko1 8ff3ab515c * proc.c (proc_curry): remove a debug line.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 12:33:07 +00:00
ko1 57b817f4c5 * method.h: make rb_method_entry_t a VALUE.
Motivation and new data structure are described in [Bug #11203].
  This patch also solve the following issues.
  * [Bug #11200] Memory leak of method entries
  * [Bug #11046] __callee__ returns incorrect method name in orphan
                 proc
* test/ruby/test_method.rb: add a test for [Bug #11046].
* vm_core.h: remvoe rb_control_frame_t::me. me is located at value
  stack.
* vm_core.h, gc.c, vm_method.c: remove unlinked_method... codes
  because method entries are simple VALUEs.
* method.h:  Now, all method entries has own independent method
  definititons. Strictly speaking, this change is not essential,
  but for future changes.
  * rb_method_entry_t::flag is move to rb_method_definition_t::flag.
  * rb_method_definition_t::alias_count is now
    rb_method_definition_t::alias_count_ptr, a pointer to the counter.
* vm_core.h, vm_insnhelper.c (rb_vm_frame_method_entry) added to
  search the current method entry from value stack.
* vm_insnhelper.c (VM_CHECK_MODE): introduced to enable/disable
  assertions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 04:20:30 +00:00
ko1 f1d4e8b3b3 * method.h: add VM_METHOD_TYPE_ALIAS rb_method_definition_t::type
to fix [Bug #11173].
  Now, inter class/method alias creates new method entry
  VM_METHOD_TYPE_ALIAS, which has an original method entry.
* vm_insnhelper.c (find_defiend_class_by_owner): added.
  Search corresponding defined_class from owner class/module.
* vm_method.c (rb_method_entry_get_without_cache): return me->klass
  directly for defined_class.
  Now, no need to check me->klass any more.
* vm_method.c (method_entry_set0): separated from method_entry_set().
* vm_method.c (rb_alias): make method entry has VM_METHOD_TYPE_ALIAS.
* vm_method.c (release_method_definition): support VM_METHOD_TYPE_ALIAS.
* vm_method.c (rb_hash_method_definition): ditto.
* vm_method.c (rb_method_definition_eq): ditto.
* vm_method.c (release_method_definition): ditto.
* vm_insnhelper.c (vm_call_method): ditto.
* vm_insnhelper.c (vm_method_cfunc_entry): ditto.
* vm_eval.c (vm_call0_body): ditto.
* gc.c (mark_method_entry): ditto.
* proc.c (method_def_iseq): ditto.
* proc.c (method_cref): ditto.
* proc.c (rb_method_entry_min_max_arity): ditto.
* test/ruby/test_alias.rb: add tests.
* test/ruby/test_module.rb: fix a test to catch up current behavior.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 18:45:28 +00:00
ko1 c722f8ad1d fix indent
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 11:52:21 +00:00
ko1 7239111ef5 * iseq.c: constify.
* iseq.h: ditto.
* method.h: ditto.
* proc.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 09:01:44 +00:00
ko1 928d89c77b * proc.c: fix issues caused by binding created from Method#to_proc.
[Bug #11163]
* vm.c (vm_cref_new_toplevel): export as rb_vm_cref_new_toplevel().
* test/ruby/test_method.rb: add some assersions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 08:45:57 +00:00
ko1 f6e9524026 * proc.c: rename functions.
* method_get_def() -> method_def()
  * method_get_iseq() -> method_def_iseq()
  * method_get_cref() -> method_cref()



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 08:03:58 +00:00
ko1 0dba10a47f * proc.c (rb_method_get_iseq): rename to rb_method_iseq.
* iseq.c: catch up this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 07:54:44 +00:00
ko1 8147bd1e49 * proc.c (method_proc): rename to method_to_proc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 02:00:31 +00:00
nobu ec0a083d93 proc.c: rb_proc_alloc
* proc.c (rb_proc_alloc, proc_dup): allocate rb_proc_t instead of
  wrapping to get rid of potential memory leak.

* vm.c (rb_proc_create): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-16 12:21:25 +00:00
nobu 3875df97f1 proc.c, vm.c: fix possible memory leak
* proc.c (proc_binding): fix possible memory leak of rb_env_t when
  TypedData_Wrap_Struct failed.

* vm.c (vm_make_env_each): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 12:34:26 +00:00
ktsj 280d4c3733 * proc.c (proc_binding): fix segmentation fault on marking phase.
envptr of newenvval should not be NULL.

  You can reproduce by
   make test-all TESTS='--gc-stress -n test_to_proc_binding ruby/test_method.rb'

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 07:29:44 +00:00
sho-h daed912954 * proc.c: [DOC] fix Binding#local_variable_set example. [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-07 13:28:03 +00:00
nobu 0899bd5227 proc.c: check iseq before replication
* proc.c (proc_binding): do not replicate when iseq not found as
  rb_method_get_iseq() can return NULL.
  [ruby-core:68673] [Bug #11012]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-29 04:49:57 +00:00
nobu 509089e9b1 proc.c: replicate method env
* proc.c (proc_binding): replicate env from method object, and
  allocate the local variable area for the iseq local table.
  [ruby-core:68673] [Bug #11012]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-29 02:51:34 +00:00
nobu c8a28a5a1b proc.c: respond_to_missing? at Method
* proc.c (respond_to_missing_p): check if the receiver responds to
  the given method by respond_to_missing?.
* proc.c (mnew_missing): create Method object for method_missing.
  [ruby-core:68564] [Bug #10985]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-20 09:41:06 +00:00
ko1 7790f37efd * node.h: remove NODE_IFUNC, NEW_IFUNC.
* internal.h: use T_IMEMO for IFUNC.
  rename `struct IFUNC' to `struct vm_ifunc' and move the definition
  from vm_insnhelper.h. Add imemo_ifunc.
* gc.c (gc_mark_children): mark imemo_ifunc type T_IMEMO object.
* compile.c: catch up these changes.
* proc.c: ditto.
* vm_core.h (RUBY_VM_IFUNC_P): ditto.
* vm_eval.c (rb_iterate): ditto.
* vm_insnhelper.c: ditto.
* ext/objspace/objspace.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11 13:31:11 +00:00
ko1 ed130faf28 * proc.c: use RUBY_VM_IFUNC_P() to recognize IFUNC or not.
* vm.c: ditto.
* vm_dump.c: ditto.
* vm_insnhelper.c: ditto.
* vm_core.h: use RB_TYPE_P() instead of BUILTIN_TYPE().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-10 18:50:15 +00:00
nobu 140d7fd95d proc.c, vm.c: fix implicit conversions
* proc.c (rb_mod_define_method): fix implicit conversion of
  visibility type. erred by -Werror=shorten-64-to-32.

* vm.c (vm_define_method): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 23:20:13 +00:00
ko1 8dced4d2c0 * internal.h: define rb_cref_t and change to use it.
rb_cref_t is data type of CREF. Now, the body is still NODE.
  It is easy to understand what is CREF and what is pure NODE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 21:22:43 +00:00
ko1 ae166317a4 * internal.h: define CREF accessor macros.
* CREF_CLASS(cref)
  * CREF_NEXT(cref)
  * CREF_VISI(cref)
  * CREF_VISI_SET(cref, v)
  * CREF_REFINEMENTS(cref)
  * CREF_PUSHED_BY_EVAL(cref)
  * CREF_PUSHED_BY_EVAL_SET(cref)
  * CREF_OMOD_SHARED(cref)
  * CREF_OMOD_SHARED_SET(cref)
  * CREF_OMOD_SHARED_UNSET(cref)
  This is process to change CREF data type from NODE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 19:50:37 +00:00
ko1 d84f9b1694 * fix namespace issue on singleton class expressions. [Bug #10943]
* vm_core.h, method.h: remove rb_iseq_t::cref_stack. CREF is stored
  to rb_method_definition_t::body.iseq_body.cref.
* vm_insnhelper.c: modify SVAR usage.
  When calling ISEQ type method, push CREF information onto method
  frame, SVAR located place. Before this fix, SVAR is simply nil.
  After this patch, CREF (or NULL == Qfalse for not iseq methods)
  is stored at the method invocation.
  When SVAR is requierd, then put NODE_IF onto SVAR location,
  and NDOE_IF::nd_reserved points CREF itself.
* vm.c (vm_cref_new, vm_cref_dump, vm_cref_new_toplevel): added.
* vm_insnhelper.c (vm_push_frame): accept CREF.
* method.h, vm_method.c (rb_add_method_iseq): added. This function
  accepts iseq and CREF.
* class.c (clone_method): use rb_add_method_iseq().
* gc.c (mark_method_entry): mark method_entry::body.iseq_body.cref.
* iseq.c: remove CREF related codes.
* insns.def (getinlinecache/setinlinecache): CREF should be cache key
  because a different CREF has a different namespace.
* node.c (rb_gc_mark_node): mark NODE_IF::nd_reserved for SVAR.
* proc.c: catch up changes.
* struct.c: ditto.
* insns.def: ditto.
* vm_args.c (raise_argument_error): ditto.
* vm_eval.c: ditto.
* test/ruby/test_class.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-06 12:24:58 +00:00
nobu 16294913f7 use rb_funcallv
* use rb_funcallv() for no arguments call instead of variadic
  rb_funcall().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-16 04:08:52 +00:00
drbrain 678ae5d17f * proc.c (proc_call): Improve Proc#call documentation. Patch by
Hsing-Hui Hsu.  [fix GH-761]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-12 01:46:33 +00:00
nobu 0fce0b7ba1 proc.c: singleton_method should not use refinements
* proc.c (rb_obj_singleton_method): Kernel#singleton_method should
  not use refinements, as well as Kernel#method.
  [ruby-core:67603] [Bug #10744]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-15 12:35:00 +00:00
nobu e580a631be use 0 for reserved
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 06:38:04 +00:00
hsbt 089429eab9 * proc.c: fix grammar by @BenMorganIO [fix GH-764][ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 02:05:53 +00:00
nobu 058044c211 proc.c: use RUBY_SAFE_LEVEL_MAX
* proc.c (rb_method_call_with_block): use RUBY_SAFE_LEVEL_MAX,
  which is declared in include/ruby/ruby.h since 2.1.  The safe
  level is now limited upto 3.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-26 08:01:56 +00:00
nobu 0884d0b944 proc.c: fix method proc binding location
* proc.c (proc_binding): use the original iseq on a binding from
  proc from method object to get the location.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-16 21:13:10 +00:00
nobu 2eefb48f6f proc.c: adjust argument type
* proc.c (proc_new): adjust `is_lambda` argument type to
  `rb_vm_make_proc_lambda` to suppress a warning by VC6.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-14 03:38:42 +00:00
nobu 2a754a7330 proc.c: make lambda directly
* vm.c (rb_vm_make_proc_lambda): similar to rb_vm_make_proc() with
  is_lambda argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13 09:10:40 +00:00
nobu 35656631d7 proc.c: remove rb_f_lambda
* proc.c (rb_f_lambda): remove deprecated function, which has been
  unavailable from extension libraries.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-05 07:55:54 +00:00
ko1 ef25be7391 * vm_core.h: change semantics of opt_num and opt_table.
`opt_num' was the number of optional parameters + 1.
  `opt_table' has "opt_num" entries.
  Change them to:
  `opt_num' is the number of optional parameters.
  `opt_talbe' has "opt_num + 1" entries.
  This change simplify parameter fitting logics.
* compile.c: catch up this change.
* iseq.c: ditto.
* proc.c: ditto.
* vm_args.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-03 04:43:07 +00:00
ko1 831e33c780 * vm_core.h: change iseq parameter data structure.
https://bugs.ruby-lang.org/issues/10440#change-49694
  * change terminology `arg' to `param'.
  * move rb_iseq_t::arg_* to rb_iseq_t::param.
  * move rb_iseq_t::arg_size to rb_iseq_t::param::size.
  * move rb_iseq_t::argc to rb_iseq_t::param::lead_num.
  * move rb_iseq_t::arg_opts to rb_iseq_t::param::opt_num.
  * move rb_iseq_t::arg_rest to rb_iseq_t::param::rest_start.
  * move rb_iseq_t::arg_post_num to rb_iseq_t::param::post_num.
  * move rb_iseq_t::arg_post_start to rb_iseq_t::param::post_start.
  * move rb_iseq_t::arg_block to rb_iseq_t::param::block_start.
  * move rb_iseq_t::arg_keyword* to rb_iseq_t::param::keyword.
    rb_iseq_t::param::keyword is allocated only when keyword
    parameters are available.
  * introduce rb_iseq_t::param::flags to represent parameter
    availability. For example, rb_iseq_t::param:🎏:has_kw
    represents that this iseq has keyword parameters and
    rb_iseq_t::param::keyword is allocated.
    We don't need to compare with -1 to check availability.
  * remove rb_iseq_t::arg_simple.
* compile.c: catch up this change.
* iseq.c: ditto.
* proc.c: ditto.
* vm.c, vm_args.c, vm_dump.c, vm_insnhelper.c: ditto.
* iseq.c (iseq_data_to_ary): support keyword argument.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 23:14:21 +00:00
ko1 fbebd502f9 * rewrite method/block parameter fitting logic to optimize
keyword arguments/parameters and a splat argument.
  [Feature #10440] (Details are described in this ticket)
  Most of complex part is moved to vm_args.c.
  Now, ISeq#to_a does not catch up new instruction format.
* vm_core.h: change iseq data structures.
  * introduce rb_call_info_kw_arg_t to represent keyword arguments.
  * add rb_call_info_t::kw_arg.
  * rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num.
  * rename rb_iseq_t::arg_keywords to arg_keyword_num.
  * rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits.
    to represent keyword bitmap parameter index.
    This bitmap parameter shows that which keyword parameters are given
    or not given (0 for given).
    It is refered by `checkkeyword' instruction described bellow.
  * rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest
    to represent keyword rest parameter index.
  * add rb_iseq_t::arg_keyword_default_values to represent default
    keyword values.
  * rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE
    to represent
      (ci->flag & (SPLAT|BLOCKARG)) &&
      ci->blockiseq == NULL &&
      ci->kw_arg == NULL.
* vm_insnhelper.c, vm_args.c: rewrite with refactoring.
  * rewrite splat argument code.
  * rewrite keyword arguments/parameters code.
  * merge method and block parameter fitting code into one code base.
* vm.c, vm_eval.c: catch up these changes.
* compile.c (new_callinfo): callinfo requires kw_arg parameter.
* compile.c (compile_array_): check the last argument Hash object or
  not. If Hash object and all keys are Symbol literals, they are
  compiled to keyword arguments.
* insns.def (checkkeyword): add new instruction.
  This instruction check the availability of corresponding keyword.
  For example, a method "def foo k1: 'v1'; end" is cimpiled to the
  following instructions.
    0000 checkkeyword     2, 0  # check k1 is given.
    0003 branchif         9     # if given, jump to address #9
    0005 putstring        "v1"
    0007 setlocal_OP__WC__0 3   # k1 = 'v1'
    0009 trace            8
    0011 putnil
    0012 trace            16
    0014 leave
* insns.def (opt_send_simple): removed and add new instruction
  "opt_send_without_block".
* parse.y (new_args_tail_gen): reorder variables.
  Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)"
  has parameter variables "k1, kr1, k2, &b, internal_id, krest",
  but this patch reorders to "kr1, k1, k2, internal_id, krest, &b".
  (locate a block variable at last)
* parse.y (vtable_pop): added.
  This function remove latest `n' variables from vtable.
* iseq.c: catch up iseq data changes.
* proc.c: ditto.
* class.c (keyword_error): export as rb_keyword_error().
* common.mk: depend vm_args.c for vm.o.
* hash.c (rb_hash_has_key): export.
* internal.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 18:02:55 +00:00
nobu e45b215fdd proc.c: fix method proc binding receiver
* proc.c (method_proc): the receiver of binding from method should
  be same as the receiver of the method.
  [ruby-core:65917] [Bug #10432]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-27 08:17:26 +00:00
nobu 9bcf16f01a proc.c: local variable
* proc.c (proc_binding): extract a local variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-27 08:12:52 +00:00
ktsj a2608f293d * vm_core.h, proc.c, vm_backtrace.c, vm_trace.c:
remove rb_binding_new_with_cfp, and use rb_vm_make_binding instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-18 11:46:41 +00:00
ktsj 231f45ad36 * vm_core.h, vm.c, proc.c: fix GC mark miss on bindings.
[ruby-dev:48616] [Bug #10368]

* test/ruby/test_eval.rb: add a test code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-18 11:46:31 +00:00
nobu e9c5e7625c proc.c: method body GC guard
* proc.c (rb_mod_define_method): guard method body to prevent its
  method entry from GC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-12 13:24:35 +00:00
normal 1972a3136c proc/env DATA_PTR is never NULL
* 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-12 21:34:12 +00:00
normal ec475ab32d 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
2014-09-12 20:57:45 +00:00
ko1 8c6c9c46d8 * vm.c (rb_vm_register_special_exception): make new function to
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-11 10:53:48 +00:00
normal 27f9e70795 vm_core.h (rb_env_t): use flexible array
* 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-09-08 19:38:22 +00:00
zzak 1788d08d25 * proc.c (method_super_method): [DOC] Method#super_method
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-26 16:47:27 +00:00
nobu b4981594dd proc.c: method_super_method
* 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-26 16:22:41 +00:00
nobu c56b3d1418 eval_error.c: rb_print_inaccessible
* 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-26 16:13:21 +00:00
nobu 1a2b90d5e6 vm.c: rb_vm_env_local_variables
* 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-01 17:57:37 +00:00
nobu 43ba2c01e7 proc.c: Binding#receiver
* 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-01 17:24:02 +00:00
nobu 02c391a1c9 proc.c: fix infinite loop
* 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-07-01 17:14:48 +00:00
nobu 053759edfc Backtrace for SystemStackError
* 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-23 02:35:18 +00:00
nobu b2066b11d8 proc.c: Implement Method#curry
* 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-19 04:42:16 +00:00
nobu e99ee55abc constify parameters
* 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-06-18 06:16:39 +00:00
nobu 160b67df68 proc.c: use already included ancestor iclass
* 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-14 08:20:10 +00:00
nobu 2f3b28c682 string.c: clear env self in symbol proc
* 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-12 13:11:11 +00:00
nobu 46f578d806 proc.c: fix super in bound UnboundMethod
* 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-11 06:05:28 +00:00
nobu e18259424e eval_intern.h: VAR_INITIALIZED
* 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-04-04 08:34:12 +00:00
nobu fc23374f06 [DOC] add links to `Object#hash`
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-14 01:27:43 +00:00
marcandre 47d6a7ee1c * proc.c: Complete rdoc of Proc#arity regarding keyword arguments.
See #8072 and #9299.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02 01:55:49 +00:00
marcandre 9b7b441687 * proc.c: Modify rdoc of Proc#arity to fit with current behavior.
See #5694

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02 01:55:33 +00:00
marcandre 04042ec6eb * proc.c: Tweak rdoc for consistent whitespace
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02 01:55:17 +00:00
hsbt 689755a1ad * gc.c: fix typo by @windwiny [fix GH-506]
*  proc.c: ditto
*  variable.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-19 05:43:28 +00:00
nobu a69f01fa52 proc.c: fix inherited method owner
* 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-29 03:11:17 +00:00
marcandre 64f0682d7d * proc.c: Having any mandatory keyword argument increases min arity [#9299]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25 21:36:19 +00:00
marcandre 43c3f447a4 * proc.c: Having optional keyword arguments makes maximum arity +1, not unlimited [#8072]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25 21:27:48 +00:00
nobu 7fd58845d9 proc.c: fix arity of rest keywords argument
* 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-25 11:28:56 +00:00
nobu a11831a9a5 proc.c: Binding#local_variables
* 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-24 16:03:12 +00:00
nobu 20c38381a8 vm.c: check cbase
* 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-24 14:04:31 +00:00
nobu 1fc3319973 proc.c: make method by define_method public
* 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-24 07:28:11 +00:00
ko1 c702005a7b * include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
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-20 08:07:47 +00:00
nobu b83d68a38f proc.c: method by respond_to_missing?
* 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-14 04:02:00 +00:00
nobu b7c2f5bc93 proc.c: fix inherited owner
* 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-13 15:18:12 +00:00
nobu b71956d12b proc.c, vm_method.c: fix super and alias
* 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-13 13:29:23 +00:00
nobu c6d03509cc proc.c: local variable
* 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-12-13 01:36:31 +00:00
ko1 c5e08b764e * add RUBY_TYPED_FREE_IMMEDIATELY to data types which only use
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-29 11:16:54 +00:00
ko1 40b1aa9adf * proc.c: catch up last commit.
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 05:31:47 +00:00
ko1 12f368d6a4 * iseq.c, internal.h: change to public (but internal) functions
* 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-10-07 05:12:08 +00:00
ko1 dc626dbab3 * include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
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-25 08:24:34 +00:00
nobu 61d79504c9 proc.c: allocate wrapper object first
* 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-09-18 07:32:17 +00:00
nobu 9eb141196b proc.c: preserve encodings
* 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-31 04:30:30 +00:00
nobu bdbda951d1 proc.c: local variable
* 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-31 04:30:28 +00:00
usa a28d1eff65 * proc.c (rb_mod_define_method): now they return the symbols of the
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-14 05:35:21 +00:00
zzak ff1abb0367 * proc.c: [DOC] rdoc code formatting
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-10 00:19:44 +00:00
nobu 90981c50ba proc.c: tabify
* 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 13:24:37 +00:00
ko1 568c5a8193 * proc.c: add Binding#local_variable_get/set/defined?
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-09 09:51:00 +00:00
nobu d1ede0c12b proc.c: constifiy
* 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-08 05:48:52 +00:00
ko1 382abb7526 * cont.c (rb_fiber_start): use RARRAY_RAWPTR() instead of
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-08-07 07:19:57 +00:00
nobu 03813f6dac vm_eval.c: Check_TypedStruct
* 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-22 07:32:52 +00:00
ktsj 92084a8b23 * proc.c (proc_to_s): use PRIsVALUE to preserve the result encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-20 23:14:48 +00:00
glass 7317bda66a * proc.c (rb_block_arity): raise ArgumentError if no block given.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 02:22:17 +00:00
glass f344841e30 * proc.c (rb_block_arity): create internal API rb_block_arity().
it return arity of given block.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 04:26:58 +00:00
ko1 4223f00713 * include/ruby/ruby.h (OBJ_WRITE): cast to (VALUE *) for second
parameter `slot'. You don't need to write a cast (VALUE *) any more.
* class.c, compile.c, hash.c, iseq.c, proc.c, re.c, variable.c,
  vm.c, vm_method.c: remove cast expressions for OBJ_WRITE().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 19:52:40 +00:00
ko1 9b47ec04a8 * include/ruby/ruby.h (struct rb_data_type_struct), gc.c: add
rb_data_type_struct::flags. Now, this flags is passed
  at T_DATA object creation. You can specify FL_WB_PROTECTED
  on this flag.
* iseq.c: making non-shady iseq objects.
* class.c, compile.c, proc.c, vm.c: add WB for iseq objects.
* vm_core.h, iseq.h: constify fields to detect WB insertion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 06:26:01 +00:00
ktsj 1720a5bac4 * include/ruby/intern.h, proc.c (rb_method_call_with_block):
new function to invoke a Method object with a block passed
  as an argument.

* proc.c (bmcall): use the above function to avoid a block sharing.
  [ruby-core:54626] [Bug #8341]

* test/ruby/test_proc.rb (TestProc#test_block_persist_between_calls):
  run related tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17 12:38:52 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
zzak acae96deb7 * object.c, proc.c: s/call_seq/call-seq in rdoc. [Fix GH-322]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-31 07:04:33 +00:00
mame 458b79e47b * proc.c (rb_method_entry_min_max_arity): fix missing break in switch.
This was introduced in r38236, which is not intentional apparently.
  This has caused no actual harm because VM_METHOD_TYPE_OPTIMIZED is
  not used except for OPTIMIZED_METHOD_TYPE_SEND, but may do in
  future.  Coverity Scan found this inadequacy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-25 09:55:17 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
nobu 0824f9f224 proc.c: Kernel#singleton_method
* proc.c (rb_obj_singleton_method): new method Kernel#singleton_method
  which returns a Method object of the singleton method.
  non-singleton method causes NameError, but not aliased or zsuper
  method, right now.
  [ruby-core:54914] [Feature #8391]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 05:52:03 +00:00
nobu 97982e823f id.def: predefined IDs
* defs/id.def: add more predefined IDs used in core.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-02 07:54:17 +00:00
nobu 9644f9b572 proc.c: use predefined IDs
* defs/id.def (predefined): add "idProc".
* proc.c (mnew, mproc, mlambda): use predefined IDs.
* vm.c (Init_VM): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-01 02:38:44 +00:00
nobu 787cdae5df proc.c: frozen core methods
* proc.c (mproc, mlambda): use frozen core methods instead of plain
  global methods, so that methods cannot be overridden.
  [ruby-core:54687] [Bug #8345]
* vm.c (Init_VM): define proc and lambda on the frozen core object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-30 03:31:43 +00:00
nobu 71a6870513 proc.c: remove unnecessary static function
* proc.c (proc_lambda): remove and use rb_block_lambda directly
  instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-30 03:30:21 +00:00
zzak 9ef4e13459 * array.c: Document synonymous methods, by windwiny [GH-277]
* bignum.c: ditto
* complex.c: ditto
* dir.c: ditto
* encoding.c: ditto
* enumerator.c: ditto
* numeric.c: ditto
* proc.c: ditto
* re.c: ditto
* string.c: ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-12 02:59:07 +00:00
nobu c68234f7d1 proc.c: consider noex in define_method
* proc.c (rb_mod_define_method): consider visibility in define_method.
  patch by mashiro <mail AT mashiro.org>.  fix GH-268.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-31 08:18:09 +00:00
nari 02ff097705 * proc.c (bm_free): need to clean up the mark flag of a free and
unlinked method entry. [Bug #8100] [ruby-core:53439]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-24 17:15:54 +00:00
zzak 1b179216a9 * proc.c: Typo in Proc.arity found by Jack Nagel [Bug #8094]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-14 19:08:57 +00:00
nobu 2ff56cc9b4 proc.c: revert r39224
* proc.c (mnew): revert r39224.  [ruby-core:53038] [Bug #7988]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05 11:29:27 +00:00
ko1 7cbeff908f * proc.c (rb_binding_new_with_cfp): create binding object even if
the frame is IFUNC. But return a ruby-level binding to keep
  compatibility.
  This patch fix degradation introduced from r39067.
  [Bug #7774] [ruby-dev:46960]
* test/ruby/test_settracefunc.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-16 06:51:17 +00:00
nobu 4b75145278 proc.c: skip prepends
* proc.c (mnew): skip prepending modules and return the method bound
  on the given class.  [ruby-core:52160] [Bug #7836]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-13 09:38:49 +00:00
nobu aae1d28b6f proc.c: original_name
* proc.c (method_original_name): new methods Method#original_name and
  UnboundMethod#original_name.  [ruby-core:52048] [Bug #7806]
  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-13 09:12:04 +00:00
nobu d40ef8a85c proc.c: show the given name
* proc.c (method_inspect): show the given name primarily, and
  original_id if aliased.  [ruby-core:52048] [Bug #7806]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-13 09:10:12 +00:00
nobu 6eb76ba664 vm_method.c: show respond_to location
* proc.c (rb_method_entry_location, rb_{mod,obj}_method_location): new
  functions to obtain source location of method definition.
* vm_method.c (rb_obj_respond_to): show the location of old style
  respond_to? method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-06 04:35:23 +00:00
ko1 88101695ab * proc.c (rb_binding_new_with_cfp): permit to create binding object
of IFUNC frame.
  When `rb_binding_new_with_cfp()' is called, VM finds out the first
  normal (has iseq) frame and create a binding object of this frame
  and create Env objects. `ep's of related frames are updated
  (`ep's point Env object managed spaces).
  However, `ep' of skipped IFUNC frame was not updated and
  old invalid `ep' was remained. It causes serious problems.
  To solve this issue, permit IFUNC to create binding.
  (Maybe there is no problem on it)
  [ruby-dev:46908] [ruby-trunk - Bug #7774]
* test/ruby/test_settracefunc.rb: add a test.
* vm.c (rb_vm_get_binding_creatable_next_cfp), vm_core.h: added.
* vm_trace.c: fix to use `rb_vm_get_binding_creatable_next_cfp()'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 06:04:59 +00:00
marcandre f810d1804a * proc.c (proc_curry): Fix arity check [Bug #5747]
* test/ruby/test_proc.rb: Test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-01 22:46:32 +00:00
marcandre 83610815d4 * proc.c: Add {*}_min_max_arity and refactor.
[Bug #7765]

* test/ruby/test_proc.rb: Fix wrong test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-01 22:46:07 +00:00
nobu b0c4ac7779 proc.c: original arity
* proc.c (rb_mod_method_arity): return original arity of the method if
  aliased because of visibility change, like as Method#arity.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-29 07:49:22 +00:00
shugo 19768b6cac * vm_method.c (Init_eval_method): main.public and main.private
should be private.

* proc.c (Init_Proc): main.define_method should be private.

* test/ruby/test_module.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-07 12:42:48 +00:00
shugo d5a39c0aa8 * proc.c (method_eq): fix the documentation to refer to owner.
[ruby-core:51105] [Bug #7613]

* test/ruby/test_method.rb (test_alias_onwer): new test to confirm
  that `a == b' returns false if owners of a and b are different.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-28 02:23:11 +00:00
nobu 6f02547d83 internal.h: quote unprintable
* internal.h (QUOTE, QUOTE_ID): quote unprintable chars in strings and
  IDs. [Bug #7574] [ruby-dev:46749]
* string.c (rb_str_quote_unprintable): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22 15:04:57 +00:00
ko1 256c5f2577 * method.h: remove `VM_METHOD_TYPE_CFUNC_FRAMELESS' method type.
This method type is for optimized CFUNC such as Fixnum#+ and so on.
  This feature is half-baked and no way to use them.
  [Background]
  Now, VM has opt_plus instructions to optimize `+' methods for
  some Classes (such as Fixnum, Float (flonum)). We call this
  type of instructions as `specialized instructions'.
  This simple technique improve simple program dramatically.
  However, we can make specialized instructions for only several
  types (classes) and selectors (method names) because a large
  instruction will be slow. In other words, this technique has no
  extensibility.
  To overcome this problem, VM_METHOD_TYPE_CFUNC_FRAMELESS was
  introduced (r37198). This type is a variant of CFUNC, but called
  their functiions directly without building a method frame.
  Any CFUNC method can be defined as frameless methods if a method
  is not needed to make method frame. Frameless methods are faster
  as specialized instructions (a bit slower, but no need to care).
  No problem described at
  http://charlie.bz/blog/why-do-singleton-methods-make-ruby-slow
  because this technique doesn't see class, but see method body
  itself. Alias is also no problem.
  [Problem]
  However, we can't set frameless method type for polymorphic methods
  such as Array#[]. Necessity for method frame depends on which
  parameter type. For example, Fixnum#+ needs method frame if
  coerce is needed. Current VM_METHOD_TYPE_CFUNC_FRAMELESS is not
  flexible and need more tuning to introduce it.
  Expected behavior of frameless method type may be:
  result = optimized_cfunc(params); /* call optimized cfunc */
  if (result == Qundef) { result = normal_cfunc(); }
  This is why I say this feature is half-baked.
  We need to learn primitive method in Smalltalk more.
  (I heard this name at RubyConf Taiwan this month. Thanks!)
  [Conclusion]
  Nobody may use this feature and there is no compatibility issue.
  This feature goes to next minor (2.1?).
* proc.c (rb_method_entry_arity): ditto.
* vm_eval.c, vm_insnhelper.c, vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-17 22:04:12 +00:00
nobu 691ee91c1a * proc.c (rb_binding_new_with_cfp): allocate the object after envirionment check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 06:10:04 +00:00
nobu 0667541894 method transplanting
* proc.c (umethod_bind): allow another form of method transplanting
  from a module via UnboundMethod.  [ruby-core:34267][Feature #4254]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13 04:06:40 +00:00
ko1 33fedef5a5 * method.h: remove "VM_METHOD_TYPE__MAX" from rb_method_type_t.
rb_method_type_t is not a number and "_MAX" causes misunderstanding.
* proc.c (rb_method_entry_arity): ditto.
* vm_eval.c (vm_call0_body): ditto.
* vm_insnhelper.c (vm_call_method): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13 02:27:58 +00:00
nobu 3c4f8ce092 method.h: NOEX_SAFE_SHIFT_OFFSET
* method.h (rb_method_flag_t): name a magic number for NOEX_SAFE and
  NOEX_WITH as NOEX_SAFE_SHIFT_OFFSET.
* method.h (rb_method_type_t, method_optimized_type): C89 forbids a
  comma after the last element in enum.
* proc.c (rb_method_entry_arity), vm_eval.c (vm_call0_body),
  vm_insnhelper.c (vm_call_method): add VM_METHOD_TYPE__MAX case.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-12 07:07:25 +00:00
nobu 9354b05e5c proc.c: move misplaced case
* proc.c (rb_method_entry_arity): move misplaced case added at r38236.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-12 07:06:14 +00:00
shugo 29756c5e94 * vm_insnhelper.c (vm_call_opt_send): Kernel#send should not use
refinements.

* proc.c (mnew): Kernel#method, Kernel#public_method,
  Module#instance_method, and Module#public_instance_method should
  not use refinements.

* vm_method.c (rb_method_boundp): Kernel#respond_to? should not use
  refinements.

* test/ruby/test_refinement.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-09 08:48:34 +00:00
shugo 60d6038dda * revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
entry with VM_METHOD_TYPE_REFINED holds only the original method
  definition, so ci->me is set to a method entry allocated in the
  stack, and it causes SEGV/ILL.  In this commit, a method entry
  with VM_METHOD_TYPE_REFINED holds the whole original method entry.
  Furthermore, rb_thread_mark() is changed to mark cfp->klass to
  avoid GC for iclasses created by copy_refinement_iclass().

* vm_method.c (rb_method_entry_make): add a method entry with
  VM_METHOD_TYPE_REFINED to the class refined by the refinement if
  the target module is a refinement.  When a method entry with
  VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
  the same name is searched in refinements.  If such a method is
  found, the method is invoked.  Otherwise, the original method in
  the refined class (rb_method_definition_t::body.orig_me) is
  invoked.  This change is made to simplify the normal method lookup
  and to improve the performance of normal method calls.

* vm_method.c (EXPR1, search_method, rb_method_entry),
  vm_eval.c (rb_call0, rb_search_method_entry): do not use
  refinements for method lookup.

* vm_insnhelper.c (vm_call_method): search methods in refinements if
  ci->me is VM_METHOD_TYPE_REFINED.  If the method is called by
  super (i.e., ci->call == vm_call_super_method), skip the same
  method entry as the current method to avoid infinite call of the
  same method.

* class.c (include_modules_at): add a refined method entry for each
  method defined in a module included in a refinement.

* class.c (rb_prepend_module): set an empty table to
  RCLASS_M_TBL(klass) to add refined method entries, because
  refinements should have priority over prepended modules.

* proc.c (mnew): use rb_method_entry_with_refinements() to get
  a refined method.

* vm.c (rb_thread_mark): mark cfp->klass for iclasses created by
  copy_refinement_iclass().

* vm.c (Init_VM), cont.c (fiber_init): initialize th->cfp->klass.

* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
  the test because it should pass successfully.

* test/ruby/test_refinement.rb (test_redefine_refined_method): new
  test for the case a refined method is redefined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06 13:08:41 +00:00
nobu fcbd6db87d proc.c: magic number
* proc.c (rb_method_call): name a magic number.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-03 10:22:15 +00:00
shugo 9e44974874 * revert r37993 to avoid SEGV in tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 02:11:59 +00:00
shugo 421314cf4e * vm_method.c (rb_method_entry_make): add a method entry with
VM_METHOD_TYPE_REFINED to the class refined by the refinement if
  the target module is a refinement.  When a method entry with
  VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
  the same name is searched in refinements.  If such a method is
  found, the method is invoked.  Otherwise, the original method in
  the refined class (rb_method_definition_t::body.orig_def) is
  invoked.  This change is made to simplify the normal method lookup
  and to improve the performance of normal method calls.

* vm_method.c (EXPR1, search_method, rb_method_entry),
  vm_eval.c (rb_call0, rb_search_method_entry): do not use
  refinements for method lookup.

* vm_insnhelper.c (vm_call_method): search methods in refinements if
  ci->me is VM_METHOD_TYPE_REFINED.  If the method is called by
  super (i.e., ci->call == vm_call_super_method), skip the same
  method entry as the current method to avoid infinite call of the
  same method.

* class.c (include_modules_at): add a refined method entry for each
  method defined in a module included in a refinement.

* class.c (rb_prepend_module): set an empty table to
  RCLASS_M_TBL(klass) to add refined method entries, because
  refinements should have priority over prepended modules.

* proc.c (mnew): use rb_method_entry_with_refinements() to get
  a refined method.

* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
  the test because it should pass successfully.

* test/ruby/test_refinement.rb (test_redefine_refined_method): new
  test for the case a refined method is redefined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 12:50:10 +00:00
ko1 585ac7f1a2 * include/ruby/debug.h: add rb_debug_inspector_* APIs.
* vm_backtrace.c: ditto.
* common.mk: add dpendency from vm_backtrace.o to
  include/ruby/debug.h.
* proc.c (rb_binding_new_with_cfp): constify.
* vm.c (rb_vm_get_ruby_level_next_cfp): consitify.
* vm_core.h, vm_trace.c: move decls.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 07:05:27 +00:00
ko1 49ed2a756b * proc.c: remove Proc#== and Proc#eql?.
Proc objects compared with thier object ids.
* test/ruby/test_proc.rb: remove related test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 08:00:53 +00:00
ktsj 049ace5888 * vm.c, proc.c: avoid unnecessary `rb_vm_rewrite_ep_in_errinfo'
calls.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-03 09:18:58 +00:00
nobu 499b5a9197 proc.c: main.define_method
* proc.c (top_define_method): new method, main.define_method.
  [ruby-core:45715] [Feature #6609]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-01 23:24:33 +00:00
ko1 588b73bca2 * class.c (rb_define_frameless_method): rename from
rb_define_method_fast(). Defined method with this C API
  does not make a method frame. It is bit lightweight than
  ordinal C functions. Now only 0 or 1 argc are permitted.
* method.h (VM_METHOD_TYPE_CFUNC_FRAMELESS): rename macro name
  from VM_METHOD_TYPE_CFUNC_FAST.
* vm_insnhelper.c, vm_method.c: rename related functions.
* proc.c (rb_method_entry_arity): catch up above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-18 05:22:13 +00:00
ko1 90a6dce041 * method.h: introduce new method type VM_METHOD_TYPE_CFUNC_FAST.
This method is similar to VM_METHOD_TYPE_CFUNC methods, but
  called cfunc without building new frame (does not push new control
  frame). If error is occured in cfunc, the backtrace only shows
  caller frame and upper.
  This kind of methods can be added by rb_define_method_fast().
  This feature is similar to specialized instructions (opt_plus, etc),
  but more flexible (but a bit slower).
* class.c (rb_define_method_fast): added.
  Maybe it will be renamed soon.
* vm_insnhelper.c (vm_call_method): support method type
  VM_METHOD_TYPE_CFUNC_FAST.
* proc.c (rb_method_entry_arity): catch up new method type.
* vm_method.c (rb_add_method_cfunc_fast): added.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-15 21:24:08 +00:00
ko1 d28e07d57b * vm_trace.c: support TracePoint. [ruby-trunk - Feature #6895]
* test/ruby/test_settracefunc.rb: add tests for above.
* proc.c (rb_binding_new_with_cfp): add an internal function.
* vm.c (rb_vm_control_frame_id_and_class): add an internal function.
* vm_trace.c: add rb_add_event_hook2() and rb_thread_add_event_hook2().
  Give us the good name for them!



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-22 05:12:31 +00:00
nobu ceece4650a vm_insnhelper.c: iclass as klass in cfp
* vm_insnhelper.c (vm_call_method): follow iclasses as klass in cfp
  but not included modules.  [ruby-core:47241] [Bug #6891]
* vm_insnhelper.c (vm_call_bmethod): pass defined_class to follow
  proper ancestors.  [ruby-core:47241] [Bug #6891]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-20 11:36:34 +00:00
eregon fd7dc23d28 Kernel#inspect: improve consistency and do not call #to_s.
* object.c (rb_obj_inspect): Kernel#inspect: do not call #to_s. A class
  can now benefit from the nice default #inspect even if it defines #to_s.
  Also, there is no more unexpected change in #inspect result.
* NEWS: Add note about the change.
* bignum.c, io.c, numeric.c, object.c, proc.c, vm.c (Init_*):
  Adapt internal structures (by aliasing #inspect to #to_s) so they
  don't rely on the removed behavior (#inspect calling overridden #to_s).
* test/ruby/test_object.rb (test_inspect): add tests for Kernel#inspect.
* lib/pp.rb (class PP): do not call #to_s anymore, as #inspect
  no more does (mame).
* test/test_pp.rb (class PPInspectTest): remove related assertion (mame).
  [ruby-core:43238][Feature #6130]
* test/drb/drbtest.rb (DRbCore#teardown, DRbAry#teardown):
  adapt DRb tests with the new change (shirosaki).
  [ruby-core:47182][Bug #6866]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15 11:50:01 +00:00
naruse 780e7d0951 Revert r36699 and r36700. [Feature #6130]
Revert "Kernel#inspect: improve consistency and do not call #to_s."
Revert "update PP with recent Kernel#inspect change. Patch by Yusuke Endoh."

r36699 cause test-all failure on test/drb/test_drb.rb and
test/drb/test_drbssl.rb. Run test-all before commit.

Moreover its ChangeLog formst is wrong: see CommitterHowto
https://bugs.ruby-lang.org/projects/ruby/wiki/CommitterHowto#ChangeLog

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15 01:09:10 +00:00
eregon 795c29dcda Kernel#inspect: improve consistency and do not call #to_s.
A class can now benefit from the nice default #inspect even if it
defines #to_s. Also, there is no more unexpected change in #inspect
result. Internal structures have been adapted so they don't rely
on the removed behavior (#inspect calling overridden #to_s).

* object.c (rb_obj_inspect): Kernel#inspect: do not call #to_s.
* test/ruby/test_object.rb (test_inspect): add tests for Kernel#inspect.
* bignum.c, io.c, numeric.c, object.c, proc.c, vm.c (Init_*):
  alias #inspect to #to_s where it was expected.
  [ruby-core:43238][Feature #6130]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-14 10:20:44 +00:00
drbrain 292a319608 * proc.c (method_clone): Added documentation. Patch by Robin Dupret.
Fixes #152 on github.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-07 20:51:48 +00:00
shugo 319088e9c7 * class.c, insns.def, method.h, proc.c, vm.c, vm_core.h, vm_eval.c,
vm_insnhelper.c, vm_insnhelper.h, vm_method.c: add klass to
  rb_control_frame_t to implement super correctly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02 11:08:44 +00:00
naruse 85dc1ab23b Add tests for r36415.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-17 18:08:40 +00:00
naruse c2bcae864e * proc.c (rb_proc_arity): return normal value (not -n-1) if it is not
a labmda, or it is a labmda and no arg_opts. [Bug #5694]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-17 07:47:52 +00:00
marcandre 43395d53c9 Revert of r36411, as does not distinguish proc from lambda
* proc.c (rb_proc_arity): Fix Proc#arity in case of optional arguments
  [bug #5694] [rubyspec:b8b259] [rubyspec:184c8100f]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-16 15:28:34 +00:00
marcandre 466f7f6c81 Revert r33924.
* proc.c (rb_proc_arity): Fix Proc#arity in case of optional arguments
  [bug #5694] [rubyspec:b8b259] [rubyspec:184c8100f]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-16 15:19:03 +00:00
nobu e6f1e3f49d method transplanting
* proc.c (rb_mod_define_method): allow method transplanting from a
  module to either class or module.  [ruby-core:34267][Feature #4254]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-25 07:57:42 +00:00
ko1 0a71db8a74 * vm_core.h: remove lfp (local frame pointer) and rename
dfp (dynamic frame pointer) to ep (environment pointer).
  This change make VM `normal' (similar to other interpreters).
  Before this commit:
  Each frame has two env pointers lfp and dfp.  lfp points
  local environment which is method/class/toplevel frame.
  lfp[0] is block pointer.
  dfp is block local frame. dfp[0] points previous (parent)
  environment pointer.
  lfp == dfp when frame is method/class/toplevel.
  You can get lfp from dfp by traversing previous environment
  pointers.
  After this commit:
  Each frame has only `ep' to point respective enviornoment.
  If there is parent environment, then ep[0] points parent
  envioenment (as dfp).  If there are no more environment,
  then ep[0] points block pointer (as lfp).  We call such ep
  as `LEP' (local EP).  We add some macros to get LEP and to
  detect LEP or not.
  In short, we replace dfp and lfp with ep and LEP.
  rb_block_t and rb_binding_t member `lfp' and `dfp' are removed
  and member `ep' is added.
  rename rb_thread_t's member `local_lfp' and `local_svar' to
  `root_lep' and `root_svar'.
  (VM_EP_PREV_EP(ep)): get previous environment pointer.  This macro
  assume that ep is not LEP.
  (VM_EP_BLOCK_PTR(ep)): get block pointer.  This macro assume
  that ep is LEP.
  (VM_EP_LEP_P(ep)): detect ep is LEP or not.
  (VM_ENVVAL_BLOCK_PTR(ptr)): make block pointer.
  (VM_ENVVAL_BLOCK_PTR_P(v)): detect v is block pointer.
  (VM_ENVVAL_PREV_EP_PTR(ptr)): make prev environment pointer.
  (VM_ENVVAL_PREV_EP_PTR_P(v)): detect v is prev env pointer.
* vm.c: apply above changes.
  (VM_EP_LEP(ep)): get LEP.
  (VM_CF_LEP(cfp)): get LEP of cfp->ep.
  (VM_CF_PREV_EP(cfp)): utility function VM_EP_PREV_EP(cfp->ep).
  (VM_CF_BLOCK_PTR(cfp)): utility function VM_EP_BLOCK_PTR(cfp->ep).
* vm.c, vm_eval.c, vm_insnhelper.c, vm_insnhelper.h, insns.def:
  apply above changes.
* cont.c: ditto.
* eval.c, eval_intern.h: ditto.
* proc.c: ditto.
* thread.c: ditto.
* vm_dump.c: ditto.
* vm_exec.h: fix function name (on vm debug mode).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-11 03:14:59 +00:00
ko1 bac9f65f70 * vm_core.h (rb_location_t): fix type and field name.
(1) rename rb_location_t to rb_iseq_location_t.
  (2) rename field names of rb_iseq_location_t to adjust
  RubyVM::Backtrace::Location methods.
  (2-1) filename -> path
  (2-2) filepath -> absolute_path
  (2-3) basename -> base_label
  (2-4) name -> label
  (3) rename filed name rb_iseq_location_t#line_no to
  rb_iseq_location_t#first_lineno to clear purpose of this field.
  (4) The field names rb_binding_t#(filename|line_no) are also renamed
  to rb_binding_t#(path|first_lineno).
* compile.c: apply above changes.
* iseq.c: ditto.
* proc.c: ditto.
* vm*.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 02:49:37 +00:00
nobu b0dd250dc9 use RB_TYPE_P() instead of comparison of TYPE()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-23 07:13:21 +00:00
ko1 8bcf7fc402 * vm_core.h: add a data type rb_location_t to store iseq location
information.
  rb_location_t#filename, filepath, name and line_no was moved from
  rb_iseq_t.  rb_location_t#basename is a new field which is
  similar to `name' field without any decoration.
  `name' field contains some decoration such as `block in foo'.
  `basename' only contains `foo'.
  rb_iseq_t contains memory object of rb_location_t.
* iseq.c: setup rb_location_t for each rb_iseq_t memory objects.
* compile.c, proc.c, vm.c, vm_dump.c, vm_eval.c, vm_insnhelper.c,
  vm_method.c: support about it.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-22 08:31:38 +00:00
drbrain da39d32f60 * encoding.c (rb_enc_codepoint_len): Use UNREACHABLE to avoid "control
reaches end of non-void function" warnings.  [ruby-trunk - Bug #6066]
* re.c (name_to_backref_number):  ditto.
* object.c (rb_Float):  ditto.
* io.c (io_readpartial):  ditto.
* io.c (io_read_nonblock):  ditto.
* pack.c (rb_uv_to_utf8):  ditto.
* proc.c (rb_method_entry_arity):  ditto.
* vm_method.c (rb_f_notimplement):  ditto.
* struct.c (rb_struct_aset_id):  ditto.
* class.c (rb_scan_args):  ditto.
* process.c (rlimit_resource_type):  ditto.
* process.c (rlimit_resource_value):  ditto.
* process.c (p_uid_switch):  ditto.
* process.c (p_gid_switch):  ditto.
* ext/digest/digest.c (rb_digest_instance_update):  ditto.
* ext/digest/digest.c (rb_digest_instance_finish):  ditto.
* ext/digest/digest.c (rb_digest_instance_reset):  ditto.
* ext/digest/digest.c (rb_digest_instance_block_length):  ditto.
* ext/bigdecimal/bigdecimal.c (BigDecimalCmp):  ditto.
* ext/dl/handle.c (rb_dlhandle_close):  ditto.
* ext/tk/tcltklib.c (pending_exception_check0):  ditto.
* ext/tk/tcltklib.c (pending_exception_check1):  ditto.
* ext/tk/tcltklib.c (ip_cancel_eval_core):  ditto.
* ext/tk/tcltklib.c (lib_get_reltype_name):  ditto.
* ext/tk/tcltklib.c (create_dummy_encoding_for_tk_core):  ditto.
* ext/tk/tkutil/tkutil.c (tk_hash_kv):  ditto.
* ext/openssl/ossl_ssl.c (ossl_ssl_session_reused):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_key_dsa_verify_asn1):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_at_infinit):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_on_curve):  ditto.
* ext/fiddle/conversions.c (generic_to_value):  ditto.
* ext/socket/raddrinfo.c (rsock_io_socket_addrinfo):  ditto.
* ext/socket/socket.c (sock_s_getnameinfo):  ditto.
* ext/ripper/eventids2.c (ripper_token2eventid):  ditto.
* cont.c (return_fiber):  ditto.
* dmydln.c (dln_load):  ditto.
* vm_insnhelper.c (vm_search_normal_superclass):  ditto.
* bignum.c (big_fdiv):  ditto.
* marshal.c (r_symlink):  ditto.
* marshal.c (r_symbol):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-13 23:45:37 +00:00
marcandre 7316302483 * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* array.c: Use rb_check_arity / rb_error_arity

* class.c: ditto

* enumerator.c: ditto

* eval.c: ditto

* file.c: ditto

* hash.c: ditto

* numeric.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* re.c: ditto

* signal.c: ditto

* string.c: ditto

* struct.c: ditto

* transcode.c: ditto

* vm_eval.c: ditto

* vm_insnhelper.c: ditto & implementation of rb_error_arity

* test/ruby/test_arity.rb: tests for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 21:10:34 +00:00
nobu 2e733be0b2 * proc.c (rb_hash_proc): get wrapped pointer properly. [Bug #6048]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-21 07:08:21 +00:00
marcandre f12c14d3ef * proc.c (method_hash, proc_hash): Fix {Unbound}Method#hash
[Bug #6048]. Isolate hash computation for proc

* internal.h: Declaration for above

* vm_method.c (rb_method_definition_hash): Computation for
  hash part of a method definition

* method.h: Declaration for above

* test/ruby/test_method.rb: Test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-21 00:13:44 +00:00
nobu 8af67e3072 * proc.c (proc_call): get rid of optimazation-out by clang.
* proc.c (rb_proc_call, rb_proc_call_with_block): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-24 03:38:56 +00:00
nobu b526738c3b * bignum.c (big_rshift), compile.c (validate_label,
iseq_build_from_ary_exception), cont.c (cont_capture), dir.c
  (dir_open_dir), gc.c (objspace_each_objects), io.c (pipe_open)
  (rb_io_advise), parse.y (parser_compile_string)
  (rb_parser_compile_file), proc.c (binding_free), process.c
  (rb_proc_exec_n, rb_seteuid_core, proc_setegid, rb_setegid_core)
  (p_uid_exchange, p_gid_exchange), regparse.c (strdup_with_null),
  signal.c (sig_dfl), vm.c (rb_iseq_eval, rb_iseq_eval_main),
  vm_insnhelper.c (vm_expandarray): suppress
  unused-but-set-variable warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 09:57:00 +00:00
naruse 0b1651753c Revert r33921.
Revert "* proc.c (rb_proc_arity): Fix Proc#arity in case of optional arguments"
Because following two reason:
* Proc#arity's return value with optional arguments is not clear.
  The optional argument for proc/lambda is Ruby 1.9 feature.
  In 1.9, proc(a, b=1){} can receive 1 or more arguments.
  But lambda(a, b=1){} can receive only 1 or two arguments.
  r33921 breaks lambda's arity.
  The spec arround optional arguments of proc/lambda needs more
  discussion.

* No tests.
  Add tests to test-all.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-01 22:14:45 +00:00
marcandre c6dec37649 * proc.c (rb_proc_arity): Fix Proc#arity in case of optional arguments
[bug #5694] [rubyspec:b8b259]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-01 11:46:31 +00:00
drbrain 983476fbab * proc.c (proc_call): Update documentation to match argument handling
of proc/Proc.new/lambda/->()


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-03 23:16:11 +00:00
drbrain b7ea625bd6 * proc.c (proc_call): Fix documentation of Proc#call vs Proc#===.
[Ruby 1.9 - Bug #5349]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-03 22:59:45 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
ktsj a09e7139a3 * proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
[Bug #5234] [ruby-core:39125]
  This code will be removed after changing throw mechanism (see r33064).

* vm.c (rb_vm_rewrite_dfp_in_errinfo): new function.

* vm.c (vm_make_env_each): changed accordingly.

* vm_core.h: ditto.

* bootstraptest/test_flow.rb: add tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-27 09:59:48 +00:00
ko1 7049d9c80d * iseq.h, iseq.c, compile.c: Change the line number data structure
to solve an issue reported at [ruby-dev:44413] [Ruby 1.9 - Bug #5217].
  Before this fix, each instruction has an information including
  line number (iseq::iseq_insn_info_table).  Instead of this data
  structure, recording only line number changing places
  (iseq::iseq_line_info_table).
  The order of entries in iseq_line_info_table is ascending order of
  iseq_line_info_table_entry::position.  You can get a line number
  by an iseq and a program counter with this data structure.
  This fix reduces memory consumption of iseq (bytecode).
  On my measurement, a rails application consumes 21.8MB for
  iseq with this fix on the 32bit CPU.  Without this fix, it
  consumes 24.7MB for iseq [ruby-dev:44415].
* proc.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.
* vm.c (rb_vm_get_sourceline): change to use rb_iseq_line_no().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-24 06:31:15 +00:00
nobu 8603c5934a * eval_error.c (rb_print_undef_str): new function to raise
NameError for undefined method.
* load.c (rb_mod_autoload_p), object.c (rb_mod_const_get),
  variable.c (rb_f_untrace_var, set_const_visibility), vm_method.c
  (rb_mod_{remove,undef,alias}_method, set_method_visibility):
  remove inadvertent symbol creation.  based on the first patch by
  Jeremy Evans at [ruby-core:38447].  [Feature #5089]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26 16:05:35 +00:00
nobu 3fbc65d47f * parse.y (rb_check_id): make the given name a symbol or a string.
based on the second patch by Jeremy Evans at [ruby-core:38447]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26 16:05:27 +00:00
mame da5b7f9229 * proc.c: pre-allocate the unlinked_method_entry_list_entry struct to
avoid memory allocation during GC.  based on a patch from Eric Wong.
  [ruby-core:38498]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-25 15:17:56 +00:00
mame 9a27239558 * proc.c (struct METHOD), gc.c (gc_marks), vm_method.c
(rb_gc_mark_unlinked_live_method_entries): fix SEGV bug.
  rb_method_entry_t was free'd even when the method is still on the
  stack if it is BMETHOD (i.e., Method#call).  This is because
  rb_method_entry_t is embedded in struct METHOD.  This commit
  separates them and marks the live method entries.
  See [ruby-core:38449] in detail.  fix [Bug #5047] [ruby-core:38171]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-25 14:29:28 +00:00
nobu 4dc1a21809 * error.c (rb_name_error_str): new function to raise NameError
with the name string but not ID.
* object.c, proc.c, variable.c: more removal of inadvertent symbol
  creation.  [Feature #5079]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-23 15:05:03 +00:00
akr 5ed8c08aa0 * eval.c, hash.c, load.c, proc.c, range.c, thread.c, time.c: don't
declare internal functions.

* internal.h, vm_core.h: declare internal functions.

* array.c: include internal.h.

* common.mk: update dependency for array.o.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 08:26:19 +00:00
akr 7da3ea811e * method.h, internal.h iseq.h: declare internal functions.
* compile.c, eval.c, iseq.c, object.c, parse.y, proc.c, process.c,
  thread.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c: don't
  declare internal functions.

  Note that rb_method_entry_eq() is defined in vm_method.c but
  there was a declaration in proc.c with different const-ness.
  Now it is declared in method.h with same const-ness to the
  definition.

* object.c (rb_mod_module_exec): don't declare functions declared in
  include/ruby/intern.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 03:49:33 +00:00
akr afd7e4668f * internal.h: declare more internal functions.
* iseq.h (rb_method_get_iseq): declared.

* compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c,
  ruby.c, time.c, util.c, vm.c: don't declare internal functions.

* eval.c, parse.y, thread_pthread.c: non-existing function declarations
  removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 01:54:57 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
marcandre 7bb29d4b32 * proc.c: Rdoc formatting, clarification & example fix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-27 13:55:43 +00:00
nobu 52f5f410e4 * internal.h: add for internal use only.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-18 13:41:54 +00:00
matz 1df42597d1 cancel subversion backfire. sorry
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 08:44:45 +00:00
matz eb807d42ec * gc.c (rb_gc_set_params): allow GC parameter configuration by
environment variables.  based on a patch from funny-falcon at
  https://gist.github.com/856296, but honors safe level.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 08:39:39 +00:00