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

496 Коммитов

Автор SHA1 Сообщение Дата
nobu a2229db3e8 * vm_method.c (Init_eval_method): copy basic methods to Exception.
[ruby-core:40287][Bug #5473]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-12 03:44:40 +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
knu 23473d1f9f * vm_method.c (rb_method_boundp):
obj.respond_to?(:a_protected_method) should return false because
  calling a protected method may cause NoMethodError if called
  from outside the class inheritance tree.  Kernel#respond_to? is
  mostly used to test if it is safe to call a method, so the false
  positive should be avoided. [ruby-dev:40461] [ruby-dev:41739]
  [ruby-dev:41837]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-13 14:02:26 +00:00
mame 4a1cfe70dc * variable.c (set_const_visibility): print a warning when no argument
is passwd to Module#private_constant.  [ruby-list:48558]

* vm_method.c (set_method_visibility): ditto for
  Module#private_class_method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-03 11:52:14 +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
ko1 beb26e1b49 * vm_insnhelper.h, vm_insnhelper.c, vm.c, vm_method.c, insns.def:
Manage a redefinition of special methods for each classes.
  A patch from Joel Gouly <joel.gouly@gmail.com>.  Thanks!



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-24 22:02:03 +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 34fcd4406a * vm_method.c (rb_gc_mark_unlinked_live_method_entries): remove unused
variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26 16:17:24 +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 298349d03b * vm_method.c (obj_respond_to): fix the respond_to_missing? override
case.  based on the patch by Jeremy Evans at [ruby-core:38417].
  [Feature #5072]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26 16:05:30 +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 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 34918aa832 * object.c (rb_mod_{const,cvar}_defined, rb_obj_ivar_defined):
avoid inadvertent symbol creation in reflection methods.  based
  on a patch by Jeremy Evans at [ruby-core:38367].  [Feature #5072]
* vm_method.c (rb_mod_method_defined)
  (rb_mod_{public,private,protected}_method_defined)
  (obj_respond_to): ditto.
* parse.y (rb_check_id): new function returns already interned ID
  or 0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-22 12:06:42 +00:00
nobu 256eae162c * vm_method.c (obj_respond_to): fix missing argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-22 09:33:41 +00:00
matz ba5d78581a * vm_method.c (rb_add_method): should not call method_added hook
for undef operation. [Bug #5015]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-12 08:15:47 +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
ko1 038ef3f05c * vm_core.h, vm_insnhelper.h: move decl. of
ruby_vm_global_state_version and related macros
  from vm_core.h to vm_insnhelper.h.
* vm.c (vm_clear_all_cache): added.  This function is called
  when ruby_vm_global_state_version overflows.
  TODO: vm_clear_all_inline_method_cache() is only place holder.
  We need to implement it ASAP.
* vm_method.c (vm_clear_global_method_cache): added.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 11:25:44 +00:00
ko1 8c09664a94 * vm_method.c (rb_clear_cache*): update only vm state version.
* vm_method.c (rb_method_entry_get_without_cache, rb_method_entry):
  Fill method cache entry with vm state version, and
  check current vm state version for method (cache) look up.
  This modification speed-up invaridating of global method cache table.
  [Ruby 1.9 - Feature #3905] [ruby-core:36908]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-12 08:53:15 +00:00
kosaki e4ba4b79b6 * vm_method.c (rb_clear_cache_by_class): Revert r29673. It made
a segmentation fault regression. [Bug #4289][ruby-core:34554].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-29 01:29:22 +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
naruse 18f4f08885 * class.c: fix camelCase to snake_case in documentation code examples.
patched by Andrew Grimm. fixes Bug #4469

* marshal.c: ditto.

* proc.c: ditto.

* sample/biorhythm.rb: ditto.

* vm_eval.c: ditto.

* vm_method.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-05 20:25:08 +00:00
akr 8dc0eb6c4b * vm_method.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-14 14:26:27 +00:00
akr d295957957 * vm_method.c (rb_clear_cache_by_class): just return if the class has
no method.  reported by Eric Wong.  [ruby-core:32689]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-02 22:37:08 +00:00
nobu 23e8deaf0d * array.c, gc.c, hash.c, object.c, string.c, struct.c,
transcode.c, variable.c, vm.c, vm_insnhelper.c, vm_method.c:
  replace calls to rb_error_frozen() with rb_check_frozen().  a
  patch from Run Paint Run Run at [ruby-core:32014]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-24 08:14:05 +00:00
nobu 671b498070 Commit miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-19 03:25:29 +00:00
nobu 12cbb58819 * test/ruby/test_sprintf.rb: fix ML ref. [ruby-core:32848]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-19 03:22:03 +00:00
nobu d410639a6d * compile.c (iseq_build_body), error.c (set_syserr, get_syserr),
(syserr_initialize), gc.c (define_final, rb_gc_copy_finalizer),
  (run_final), hash.c (rb_hash_aref, rb_hash_lookup2),
  (rb_hash_fetch_m, rb_hash_clear, rb_hash_aset, eql_i),
  iseq.c (iseq_load, iseq_data_to_ary), marshal.c (r_symlink),
  thread.c (rb_thread_local_aref),
  variable.c (generic_ivar_remove, ivar_get, rb_const_get_0),
  (rb_cvar_get), vm.c (rb_vm_check_redefinition_opt_method),
  vm_insnhelper.c (vm_get_ev_const), vm_method.c (remove_method),
  ext/iconv/iconv.c (map_charset): use st_data_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 14:47:23 +00:00
naruse ad717fa7e6 * vm_method.c (rb_method_boundp): revert r28543, r28564.
They may be merged in Ruby 2.0. [ruby-core:31217]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-21 05:00:53 +00:00
knu 42f4a548f0 * vm_method.c (rb_method_boundp): respond_to?(:protected_method,
true) should return true.  Pointed out by Marc-Andre Lafortune.
  [ruby-dev:41837]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-07 04:06:32 +00:00
knu 78a78b45d6 * vm_method.c (rb_method_boundp): Return false for protected
methods when called from Kernel#respond_to?. [ruby-dev:40461]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-05 07:11:44 +00:00
nobu 45f6fbf339 * removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-29 18:51:39 +00:00
marcandre 7729de4d91 * array.c: Documentation: change => in call-seq to ->.
Harmonize "#=>" in examples. [ruby-core:30206]

* bignum.c: ditto

* class.c: ditto

* compar.c: ditto

* cont.c: ditto

* dir.c: ditto

* encoding.c: ditto

* enum.c: ditto

* enumerator.c: ditto

* error.c: ditto

* eval.c: ditto

* file.c: ditto

* gc.c: ditto

* io.c: ditto

* load.c: ditto

* marshal.c: ditto

* math.c: ditto

* numeric.c: ditto

* object.c: ditto

* pack.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* range.c: ditto

* re.c: ditto

* ruby.c: ditto

* signal.c: ditto

* sprintf.c: ditto

* string.c: ditto

* struct.c: ditto

* thread.c: ditto

* time.c: ditto

* transcode.c: ditto

* variable.c: ditto

* vm_eval.c: ditto

* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:07:33 +00:00
nobu fbe5ce6ca7 * eval_intern.h (rb_vm_get_sourceline): add prototype.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-11 00:57:09 +00:00
ko1 833cade2dc * vm_method.c (rb_unlink_method_entry, rb_sweep_method_entry):
added.  Unlinked method entries are collected to
  vm->unlinked_method_entry_list.  On the GC timing, mark all method
  entries which are on all living threads.  Only non-marked method
  entries are collected.  This hack prevents releasing living method
  entry.
  [Performance Consideration] Since this Method Entry GC (MEGC)
  doesn't occuer frequently, MEGC will not be a performance bottleneck.
  However, to traverse living method entries, every control frame push
  needs to clear cfp->me field.  This will be a performance issue
  (because pushing control frame is occurred frequently).
  Bug #2777 [ruby-dev:40457]
* cont.c (fiber_init): init cfp->me.
* gc.c (garbage_collect): kick rb_sweep_method_entry().
* method.h (rb_method_entry_t): add a mark field.
* vm.c (invoke_block_from_c): set passed me.
* vm.c (rb_thread_mark): mark cfp->me.
* vm_core.h (rb_thread_t): add a field passed_me.
* vm_core.h (rb_vm_t): add a field unlinked_method_entry_list.
* vm_insnhelper.c (vm_push_frame): clear cfp->me at all times.
* vm_insnhelper.c (vm_call_bmethod): pass me.
* bootstraptest/test_method.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-05 17:51:21 +00:00
ko1 b4d7d616d9 * method.h, vm_method.c: rename some internal functions related to
rb_method_entry_t.
  rb_add_method_me()        -> rb_method_entry_set().
  rb_get_method_entry()     -> rb_method_entry_without_cache().
  rb_gc_mark_method_entry() -> rb_mark_method_entry().
* class.c, proc.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-04 20:25:09 +00:00
mame 3728ec6ea3 * vm_method.c (rb_add_method_def): decrement alias count of
rb_method_definition_t to prevent memory leak.  see
  [ruby-dev:41021].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-20 15:15:44 +00:00
naruse 61e5cf84ff * vm_method.c (rb_add_method_def): workarond fix for redefinition
of methods. This is because cfp->me uses the rb_method_entry
  which is freed by redefinition of remove_method. Note that
  reusing may cause another problem when the usage is changed.
  [ruby-core:27320] [ruby-core:29464]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-18 17:59:56 +00:00
wanabe 7d73136d06 * vm_method.c (rb_add_method): clear attr.location before rb_ary_new3.
a patch from Masaya TARUI in [Bug #3108]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-09 22:38:46 +00:00
nobu e3888976d0 * vm_method.c (rb_add_method): prototype of rb_vm_get_sourceline.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-24 06:08:47 +00:00
wanabe c46f71399a * proc.c (rb_method_location): return attr's location if it is setup.
[Feature #2084]

* NEWS: follow above.

* vm_method.c (rb_add_method): save attr's location.

* gc.c (mark_method_entry): mark attr's location.

* method.h (rb_method_definition_t): add member to save attr's location.

* vm_eval.c (vm_call0): follow above.

* vm_insnhelper.c (vm_call_method): ditto.

* vm_method.c (rb_method_definition_eq): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-22 11:44:01 +00:00
shyouhei 0d3de66006 * common.mk (compile.$(OBJEXT)): dependencies lacking.
* vm_method.c (rb_add_method_cfunc): invalid initializer for C89

	* compile.c (iseq_insns_unification): int might be smaller than int*


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-20 07:12:16 +00:00
mame 479a3c4c8b * vm_method.c (rb_alias): skip ZSUPER method when searching body of
source method.  [ruby-dev:39760]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-08 14:10:58 +00:00
nobu 4d786d21e3 * removed spaces just before tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-26 05:25:08 +00:00
shugo 63c3b2d283 * vm_method.c (rb_undef): should raise TypeError if klass is nil.
1.instance_eval { undef to_s } causes SEGV before this fix.
* test/ruby/test_undef.rb: new tests for undef.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-18 01:13:54 +00:00
shugo 86d46b5459 * vm_method.c (rb_alias): should raise TypeError if klass is nil.
1.instance_eval { alias to_string to_s } causes SEGV before this
  fix.
* test/ruby/test_alias.rb (test_special_const_alias): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-17 14:53:32 +00:00
matz eccb700286 * vm_method.c (basic_obj_respond_to): call #respond_to_missing?
always with two arguments.  [ruby-core:26090]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-17 05:34:51 +00:00
matz 4631523baf * vm_method.c (rb_method_boundp): should exclude NOEX_RESPONDS.
based on the patch from Nikolai Lugovoi.  [ruby-core:25949]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-09 14:52:02 +00:00
matz e3fc29a71b * vm_method.c (basic_obj_respond_to): should not call
#respond_to_missing? for not implemented methods.
  [ruby-core:25909]

* vm_method.c (rb_method_boundp): returns exceptional value 2 for
  not-implemented methods when called from #respond_to? (specifies
  by new contant NOEX_RESPONDS).

* method.h (enum): new constant NOEX_RESPONDS added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-04 17:05:59 +00:00
nobu 9603cd2f62 * vm_method.c (rb_add_method_def): no redefinition warning on
undef.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-03 12:19:19 +00:00
nobu a71d47a380 * vm_method.c (rb_add_method_def): show the location where
overwritten method was defined.  [ruby-dev:39400]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-30 04:15:46 +00:00
nobu 16969412b3 * vm_method.c (rb_method_definition_eq): non-null definition is
not equal to null definition.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-29 04:49:00 +00:00
nobu 1fe57a4b5d * vm_method.c (rb_add_method_def): nothing to do if old method had
same definition.  [ruby-dev:39397]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-29 04:37:52 +00:00
nobu 5e4d04c36e * vm_method.c (rb_method_entry_eq): fixed a message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-29 04:33:17 +00:00
matz 102918a3ee git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e 2009-09-28 03:09:16 +00:00
nobu 6bf6f3d4c4 * vm_method.c (rb_method_entry_eq): suppressed a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-27 00:17:48 +00:00
matz 3ca245a54c * vm_method.c (rb_method_entry_eq): method defined from same
block/proc should be equal.  [ruby-core:25755] [ruby-core:24791]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-26 14:59:09 +00:00
nobu 8be423f51d * vm_method.c (check_definition): fixed typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-25 03:36:26 +00:00
nobu 44f7a34031 * vm_method.c (obj_respond_to_missing): added rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-25 03:33:26 +00:00
nobu 2c549ad5d3 * vm_method.c (rb_mod_method_defined): should return true or false.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-25 02:56:52 +00:00
nobu bc7123e434 * vm_method.c (rb_mod_method_defined): should return true or false.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-25 02:51:36 +00:00
matz 945f4df6a8 * vm_method.c (basic_obj_respond_to): new function to fundamental
behavior for #respond_to?

* vm_method.c (basic_obj_respond_to): calls #respond_to_missing
  method if overridden, to check responsiveness of methods
  implemented by #method_missing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-23 08:46:44 +00:00
nobu fe1ce93f52 * compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
  vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
  tool/instruction.rb: fixed types.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-21 20:58:26 +00:00
nobu 63b231cea0 * vm_method.c (rb_add_method_def): no warning for inherited
method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-13 00:34:11 +00:00
nobu 97c3bad478 * vm_method.c (CALL_METHOD_HOOK): refined with macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-12 15:46:42 +00:00
nobu a5971a1282 * vm_method.c (remove_method): typo fixed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-12 15:31:43 +00:00
nobu 2fcdd7e080 * vm_method.c (rb_remove_method_id): no definition body is
undefined.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-12 15:27:59 +00:00
nobu efa4ed8cce * vm_method.c (rb_alias): hooks are called from rb_add_method_def.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-12 15:21:03 +00:00
nobu d7feab06cc * vm_method.c (rb_add_method, rb_add_method_me): call method added
hook after definition.  [ruby-core:25536]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-12 15:03:02 +00:00
nobu fcf88c1b8d * method.h (rb_method_definition_t): split from rb_method_entry_t
to deal aliases.  [ruby-dev:39165]

* proc.c (struct METHOD): contains rb_method_entry_t copy.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-28 02:45:41 +00:00
nobu 84255e0485 * vm_method.c (rb_remove_method_id): exported.
* numeric.c (num_sadded): fix for non-ascii method name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-27 09:31:11 +00:00
nobu efb9097352 * vm_method.c (rb_method_entry_eq): deals with optimized method
properly.  [ruby-core:24789]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-06 06:44:10 +00:00
shyouhei 506a9821ce * method.h : Commas at end of enum list not allowed as of C89
* vm_method.c (rb_add_method): avoid C++ comment

	* vm_insnhelper.c (vm_call_cfunc): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-22 13:27:26 +00:00
nobu 33fc55acef * vm_method.c (me_opts): fixed optimized method aliasing.
[ruby-dev:38824]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-19 02:00:27 +00:00
ko1 b5dd85f049 * vm_method.c (rb_alias): fix a case which try non-existing method alias.
* test/ruby/test_alias.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-16 08:44:23 +00:00
ko1 d4628c0bcd * vm_method.c: separate clearing cache entry code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-15 23:59:15 +00:00
ko1 c330876d7c * method.h, vm_core.h: add rb_method_entry_t. Remove nodes around
method management.  This change affect some VM control stack structure.
* vm.c, vm_insnhelper.c, vm_method.c, vm_eval.c: ditto.  and make some
  refactoring.
* insns.def, class.c, eval.c, proc.c, vm_dump.c : ditto.
* vm_core.h, compile.c (iseq_specialized_instruction): remove
  VM_CALL_SEND_BIT.  use another optimization tech for Kernel#send.
* node.h: remove unused node types.
* ext/objspace/objspace.c (count_nodes): ditto.
* gc.c: add mark/free functions for method entry.
* include/ruby/intern.h: remove decl of
  rb_define_notimplement_method_id().  nobody can use it
  because noex is not opend.
* iseq.c (iseq_mark): fix to check ic_method is available.
* iseq.c (rb_iseq_disasm): fix to use rb_method_get_iseq().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-15 14:59:41 +00:00
nobu fd4d1dde2f * vm_method.c (rb_add_method, remove_method, rb_undef): fixed
minor grammatical errors in warnings.  a patch from Run Paint
  Run Run at [ruby-core:24141].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-04 23:14:43 +00:00
nobu ba0ac946e9 * vm_method.c (Init_eval_method): registers notimplement_body as a
mark-object.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-04 23:12:04 +00:00
matz 9553911f29 * vm_method.c (rb_attr): should preserve encoding info.
[ruby-dev:38498]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-19 15:07:45 +00:00
nari 57b83a5191 * gc.c: add longlife garbage collection. [ruby-dev:38423]
(NORMAL_HEAPS_USED): new macro.
  (LONGLIFE_ALLOCATE_HEAPS_MIN): ditto.
  (add_longlife_heaps_slot): new function.
  (rb_newobj_from_longlife_heap): ditto.
  (rb_newobj_longlife): ditto.
  (rb_node_newnode_longlife): ditto.
  (rb_gc_write_barrier): ditto.
  (remembered_set_recycle): ditto.
  (rb_gc_mark_remembered_set): ditto.
  (clear_mark_longlife_heaps): ditto.
  (gc_sweep_for_longlife): ditto.
  (assign_heap_slot): new argumnent to longlife heaps slot.
  (add_freelist): ditto.
  (gc_sweep): avoid lonlife heap slot. set longlife_collection
   flag at add heap.
  (rb_gc_force_recycle): avoid mark object and remembered_set
   object.
  (garbage_collect): add longlife collection.
  (rb_gc_start): invoke longlife collection.
  (gc_profile_record_get): for longlife collction profile.
  (gc_profile_result): ditto.

* include/ruby/intern.h (rb_gc_write_barrier): declared.

* include/ruby/ruby.h (FL_REMEMBERED_SET): renamed from FL_RESERVED.

* debug.c (FL_REMEMBERED_SET): ditto.

* insns.def (setinlinecache): insert write barrier.

* vm_insnhelper.c (vm_method_search): ditto.

* set_relation (set_relation): use longlife object.

* vm.c (vm_define_method): ditto.

* vm_core.h (NEW_INLINE_CACHE_ENTRY): ditto.

* vm_method.c (rb_add_method): ditto.

* class.c (rb_add_method): ditto.

* node.h (NEW_NODE_LONGLIFE): new macro.
  (rb_node_newnode_longlife): declared.
					    


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-13 14:08:26 +00:00
akr a69b87e80e update rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-21 18:41:07 +00:00
akr 8e8ae2a9c5 * node.h (rb_notimplement_body_p): declared.
* vm_method.c (Init_eval_method): suppress a warning.

* io.c (rb_io_fsync): use rb_f_notimplement if not implemented.
  (rb_io_close_on_exec_p): ditto.
  (rb_io_set_close_on_exec): ditto.
  (rb_io_fcntl): ditto.
  (rb_f_syscall): ditto.

* dir.c (dir_tell): ditto.
  (dir_seek): ditto.
  (dir_s_chroot): ditto.

* process.c (proc_getpgrp): ditto.
  (proc_setpgrp): ditto.
  (proc_getpgid): ditto.
  (proc_setpgid): ditto.
  (proc_setsid): ditto.
  (proc_getpriority): ditto.
  (proc_setpriority): ditto.
  (proc_getrlimit): ditto.
  (proc_setrlimit): ditto.
  (p_sys_setuid): ditto.
  (p_sys_setruid): ditto.
  (p_sys_seteuid): ditto.
  (p_sys_setreuid): ditto.
  (p_sys_setresuid): ditto.
  (p_sys_setgid): ditto.
  (p_sys_setrgid): ditto.
  (p_sys_setegid): ditto.
  (p_sys_setregid): ditto.
  (p_sys_setreuid): ditto.
  (p_sys_setresgid): ditto.
  (p_sys_issetugid): ditto.
  (proc_getgroups): ditto.
  (proc_setgroups): ditto.
  (proc_initgroups): ditto.
  (proc_daemon): ditto.
  (rb_proc_times): ditto.

* file.c (rb_file_s_lchown): ditto.
  (rb_file_s_link): ditto.
  (rb_file_s_symlink): ditto.
  (rb_file_s_readlink): ditto.
  (rb_file_s_truncate): ditto.
  (rb_file_truncate): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-16 16:58:06 +00:00
akr 8b27d153d2 * class.c (rb_define_method_id): use rb_define_notimplement_method_id
if rb_f_notimplement is given.
  (rb_define_protected_method): ditto.
  (rb_define_private_method): ditto.
  (rb_define_method): use rb_define_method_id.

* include/ruby/intern.h (rb_f_notimplement): declared.
  (rb_define_notimplement_method_id): declared.

* proc.c (method_inspect): show not-implemented.

* vm_method.c (notimplement_body): new variable.
  (rb_notimplement_body_p): new function.
  (rb_method_boundp): return false if not implemented.
  (rb_f_notimplement): new function.
  (rb_define_notimplement_method_id): new function.

* process.c (rb_f_fork): use rb_f_notimplement if not implemented.

* file.c (rb_file_s_lchmod): use rb_f_notimplement if not implemented.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-16 14:17:14 +00:00
ko1 b30b998966 * vm_insnhelper.c (vm_call_method, vm_call_cfunc): use original id instead of
calling id when NODE_CFUNC or NODE_BMETHOD.
  fixes Bug #632 [ruby-core:19282].
* vm_eval.c (vm_call0, vm_call_super): ditto.
* vm_method.c (rb_add_method, rb_alias): store original id
  in nd_file field of NODE_METHOD.
* test/stringio/test_stringio.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-27 03:57:21 +00:00
nobu d5b7e69032 * vm_eval.c (vm_call_super): uses method_missing().
* vm_eval.c (method_missing): get rid of too large alloca.

* vm_eval.c (rb_call0, method_missing): uses idMethodMissing.

* vm_method.c (rb_add_method, remove_method, rb_undef): uses
  id__send__.

* vm_method.c (Init_eval_method): removed IDs which are defined as
  immediate values.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-15 05:15:26 +00:00
knu f259918c81 * vm_method.c (rb_obj_respond_to): Remove a duplicated rdoc
comment and fix a markup error.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-04 02:39:55 +00:00
nobu 4c88510849 * vm_method.c (rb_mod_modfunc): method undefined in included module
may not have nd_body.  [ruby-core:18738]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-05 14:07:06 +00:00
ko1 8cd252ac6f * common.mk: clean up
- remove blockinlining.$(OBJEXT) to built
  - make ENCODING_H_INCLDUES variable (include/ruby/encoding.h)
  - make VM_CORE_H_INCLUDES variable (vm_core.h)
  - simplify rules.
  - make depends rule to output depend status using gcc -MM.
* include/ruby/mvm.h, include/ruby/vm.h: rename mvm.h to vm.h.
* include/ruby.h: ditto.
* load.c: add inclusion explicitly.
* enumerator.c, object.c, parse.y, thread.c, vm_dump.c:
  remove useless inclusion.
* eval_intern.h: cleanup inclusion.
* vm_core.h: rb_thread_t should be defined in this file.
* vm_evalbody.c, vm_exec.c: rename vm_evalbody.c to vm_exec.c.
* vm.h, vm_exec.h: rename vm.h to vm_exec.h.
* insnhelper.h, vm_insnhelper.h: rename insnhelper.h to vm_insnhelper.h.
* vm.c, vm_insnhelper.c, vm_insnhelper.h:
  - rename vm_eval() to vm_exec_core().
  - rename vm_eval_body() to vm_exec().
  - cleanup include order.
* vm_method.c: fix comment.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 00:20:28 +00:00
matz cf6334e1cb * vm_method.c (rb_method_node): fail earlier if no method found.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-28 12:08:19 +00:00
nobu 5f9c188d97 * include/ruby/ruby.h (rb_intern_const): tiny optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16 00:20:31 +00:00
shugo f433d710d0 * object.c (rb_obj_untrusted): new method Object#untrusted?.
(rb_obj_untrust): new method Object#untrust.
  (rb_obj_trust): new method Object#trust.
* array.c, debug.c, time.c, include/ruby/ruby.h, re.c, variable.c,
  string.c, io.c, dir.c, vm_method.c, struct.c, class.c, hash.c,
  ruby.c, marshal.c: fixes for Object#untrusted?.
* test/ruby/test_module.rb, test/ruby/test_array.rb,
  test/ruby/test_object.rb, test/ruby/test_string.rb,
  test/ruby/test_marshal.rb, test/ruby/test_hash.rb: added tests for
  Object#untrusted?.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 07:25:05 +00:00
nobu a58e3d763b * array.c (rb_ary_sort_bang): respect overridden <=> for String and
Fixnum.  [ruby-core:17708]

* include/ruby/node.h (NOEX_BASIC): basic definition method flag.

* include/ruby/intern.h, vm_method.c (rb_method_basic_definition_p):
  new function to check if the method is not redefined after the
  initialization.

* vm_method.c (rb_obj_respond_to): use rb_method_basic_definition_p.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-04 18:29:55 +00:00
nobu 5a647a3f5f * include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.
* *.c: no cache in init functions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 09:25:32 +00:00
nobu 075530a685 * suppress warnings with -Wwrite-string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 09:28:20 +00:00
ko1 59c061235f * eval_method.c: renamed from vm_method.c. "vm_method.c" is included
by "vm.c".
* vm_eval.c: added.  Some codes are moved from "eval.c"
* common.mk: fix for above changes.
* compile.c: make a vm_eval(0)
* eval.c, eval_error.c, eval_intern.h, eval_jump.c, proc.c, vm.c,
  id.c, id.h, vm_core.h, vm_dump.c, vm_evalbody.c, vm_insnhelper.c,
  blockinlining.c: fix for above changes.  and do some refactoring.
  this changes improve rb_yield() performance.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-24 17:50:17 +00:00