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

351 Коммитов

Автор SHA1 Сообщение Дата
nobu 72f60a2ff1 class.c: optimization just one key
* class.c (keyword_error): use only element itself for
  optimization in the case the key has just one element.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 07:17:21 +00:00
tmm1 8f77cfb308 gc.c: promote long-lived NODE_CREF objects to oldgen
* include/ruby/ruby.h: add RGENGC_WB_PROTECTED_NODE_CREF setting
  In a large app, this reduces the size of
  remembered_shady_object_count by 80%. [Bug #9225] [ruby-core:58947]
* gc.c (rb_node_newnode): add FL_WB_PROTECTED flag to NODE_CREF
* class.c (rewrite_cref_stack): insert OBJ_WRITE for NODE_CREF
* iseq.c (set_relation): ditto
* iseq.c (rb_iseq_clone): ditto
* vm_eval.c (rb_yield_refine_block): ditto
* vm_insnhelper.c (vm_cref_push): ditto
* vm_insnhelper.h (COPY_CREF): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 02:28:04 +00:00
nobu 100fe2e659 class.c: fix uninitialized value
* class.c (rb_get_kwargs): fix returning uninitialized value when no
  optional keywords.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 01:32:07 +00:00
nobu 113008a7ae class.c: move kwarg functions
* class.c (rb_extract_keywords, rb_get_kwargs): move from
  vm_insnhelper.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 10:33:42 +00:00
tmm1 084b602d9a * include/ruby/ruby.h (struct RClass): Add wrapper struct around
RClass->m_tbl with serial. This prevents double marking method
  tables, since many classes/modules can share the same method table.
  This improves minor mark time in a large application by 30%.
* internal.h (struct method_table_wrapper): Define new
  wrapper struct with additional serial.
* internal.h (RCLASS_M_TBL_INIT): New macro for initializing method
  table wrapper and st_table.
* method.h (void rb_sweep_method_entry): Rename rb_free_m_table to
  rb_free_m_tbl for consistentcy
* .gdbinit (define rb_method_entry): Update rb_method_entry gdb helper
  for new method table structure.
* class.c: Use RCLASS_M_TBL_WRAPPER and
  RCLASS_M_TBL_INIT macros.
* class.c (rb_include_class_new): Share WRAPPER between module and
  iclass, so serial can prevent double marking.
* eval.c (rb_prepend_module): ditto.
* eval.c (rb_using_refinement): ditto.
* gc.c: Mark and free new wrapper struct.
* gc.c (obj_memsize_of): Count size of additional wrapper struct.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 08:11:07 +00:00
nobu c683096c90 vm_insnhelper.c: keyword hash functions
* vm_insnhelper.c (rb_extract_keywords, rb_check_keyword_opthash):
  extract from vm_callee_setup_keyword_arg.

* class.c (rb_scan_args): check if keys of keyword hash are symbols.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-30 12:22:17 +00:00
charliesome 8b0771b014 * class.c: unify names of vm state version counters to 'serial'.
This includes renaming 'vm_state_version_t' to 'rb_serial_t',
  'method_state' to 'method_serial', 'seq' to 'class_serial',
  'vmstat' to 'constant_serial', etc.

* insns.def: ditto
* internal.h: ditto
* vm.c: ditto
* vm_core.h: ditto
* vm_insnhelper.c: ditto
* vm_insnhelper.h: ditto
* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 03:34:49 +00:00
charliesome 7fafa8f376 * insns.def, vm.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: split
ruby_vm_global_state_version into two separate counters - one for the
  global method state and one for the global constant state. This means
  changes to constants do not affect method caches, and changes to
  methods do not affect constant caches. In particular, this means
  inclusions of modules containing constants no longer globally
  invalidate the method cache.

* class.c, eval.c, include/ruby/intern.h, insns.def, vm.c, vm_method.c:
  rename rb_clear_cache_by_class to rb_clear_method_cache_by_class

* class.c, include/ruby/intern.h, variable.c, vm_method.c: add
  rb_clear_constant_cache

* compile.c, vm_core.h, vm_insnhelper.c: rename vmstat field in
  rb_call_info_struct to method_state

* vm_method.c: rename vmstat field in struct cache_entry to method_state

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 00:52:38 +00:00
ko1 52c1331763 * class.c, variable.c, gc.c (rb_class_tbl): removed.
* vm.c, vm_core.h (rb_vm_add_root_module): added to register as a
  defined root module or class.
  This guard helps mark miss from defined classes/modules they are
  only refered from C's global variables in C-exts.
  Basically, it is extension's bug.
  Register to hash object VM has.
  Marking a hash objects allows generational GC supports.
* gc.c (RGENGC_PRINT_TICK): disable (revert).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 18:27:18 +00:00
ko1 9d70a17541 revert r43259 because it is possible to mark miss classes defined in C-exts. Thanks charliesome.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 18:03:43 +00:00
ko1 7aecb95637 * class.c, variable.c, gc.c (rb_class_tbl): removed.
rb_class_tbl is no longer used.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 17:33:44 +00:00
charliesome f088828106 * class.c (class_alloc): remove mc_tbl
* gc.c (obj_free): ditto

* internal.h (struct rb_classext_struct): ditto

* method.h (rb_method_entry): remove ent param

* vm_method.c: restore the global method cache. Per class cache tables
  turned out to be far too slow.

  [ruby-core:57289] [Bug #8930]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-24 05:02:13 +00:00
nobu 67129c8383 class.c: exclude refined methods
* class.c (method_entry_i): should exclude refined methods from
  instance method list.  [ruby-core:57080] [Bug #8881]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-10 03:39:31 +00:00
nobu bbbc8b57eb class.c: remove recursion
* class.c (rewrite_cref_stack): remove recursion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-05 15:05:20 +00:00
nobu eeb39e0152 vm.c: prototype
* vm.c (rb_next_class_sequence): use ANSI style definition and
  prorotype declaration, instead of old-K&R style.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 07:18:24 +00:00
charliesome 2f522b9cc6 * class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
  vm_method.c: Implement class hierarchy method cache invalidation.

  [ruby-core:55053] [Feature #8426] [GH-387]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 05:25:06 +00:00
ko1 9af743fe0e * class.c (rb_prepend_module): make T_ICLASS object shady because
this T_ICLASS object seems to share method table with other class
  objects. It was causes WB miss.
  TODO: need to know the data structure.
* test/ruby/test_module.rb: add a test for WB miss.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-12 06:19:15 +00:00
ko1 982fee4fcc * include/ruby/ruby.h, gc.c: rename macros and functions:
OBJ_WB_GIVEUP() -> OBJ_WB_UNPROTECT(),
  rb_obj_wb_giveup() -> rb_obj_wb_unprotect(),
  rb_gc_giveup_promoted_writebarrier() ->
  rb_gc_writebarrier_unprotect_promoted(),
* class.c, eval.c, hash.c: use OBJ_WB_UNPROTECT().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 21:54:10 +00:00
ko1 7da562e740 * class.c (rb_include_class_new), eval.c (rb_using_refinement):
make classes/modules (who share method table) shady.
  If module `a' and `b' shares method table m_tbl and new method
  with iseq is added, then write barrier is applied only `a' or `b'.
  To avoid this issue, shade such classes/modules.
* vm_method.c (rb_method_entry_make): add write barriers.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 20:48:35 +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
ko1 87a120fbdc * class.c, include/ruby/ruby.h: add write barriers for T_CLASS,
T_MODULE, T_ICLASS.
* constant.h: constify rb_const_entry_t::value and file to detect
  assignment.
* variable.c, internal.h (rb_st_insert_id_and_value, rb_st_copy):
  added. update table with write barrier.
* method.h: constify some variables to detect assignment.
* object.c (init_copy): add WBs.
* variable.c: ditto.
* vm_method.c (rb_add_method): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-14 09:23:54 +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
charliesome b512e61ca0 * class.c (include_modules_at): invalidate method cache if included
module contains constants

* test/ruby/test_module.rb: add test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 10:48:33 +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
nobu 609c7420d7 class.c: rb_singleton_class_get
* class.c (rb_singleton_class_get): get the singleton class if exists,
  or nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 05:50:38 +00:00
nobu 111c791c37 class.c: adjust indent
* class.c (singleton_class_of): adjust indent.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 05:49:47 +00:00
nobu e8bdef657a class.c: include modules only
* class.c (rb_mod_included_modules): should not include non-modules.
  [ruby-core:53158] [Bug #8025]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-08 16:05:50 +00:00
nobu 3fd0000c0c class.c: exclude original module
* class.c (rb_mod_included_modules): should not include the original
  module itself.  [ruby-core:53158] [Bug #8025]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-08 13:47:11 +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 6500760bd3 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24 04:51:05 +00:00
zzak 0b4214ad9b * class.c: Example of Object#methods by @windwiny [Fixes GH-293]
* ruby.c: Document return values of Kernel #sub, #gsub, and #chop


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24 04:47:31 +00:00
nobu c5fe7eb6f6 class.c: suppress wrong warning
* class.c (HAVE_METACLASS_P): should check FL_SINGLTON flag before get
  instance variable to get rid of wrong warning about __attached__.
  [ruby-core:53839] [Bug #8188]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-30 21:27:27 +00:00
nobu 99126a4c88 class.c: from the origin class
* class.c (rb_obj_singleton_methods): collect methods from the origin
  class.  [ruby-core:53207] [Bug #8044]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-13 06:13:08 +00:00
marcandre dfde34cb3c * class.c (rb_mod_ancestors): Include singleton_class in ancestors list
[Feature #8035]

* test/ruby/test_module.rb (class): test for above

* test/ruby/marshaltestlib.rb (module): adapt test

* NEWS: list change

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-07 17:54:49 +00:00
nobu f113ab552c class.c: check redefinition
* class.c (rb_prepend_module): check redefinition of built-in opimized
  methods.  [ruby-dev:47124] [Bug #7983]
* vm.c (rb_vm_check_redefinition_by_prepend): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05 12:36:45 +00:00
nobu 632ab19c4d class.c: cyclic prepend
* class.c (include_modules_at): detect cyclic prepend with original
  method table.  [ruby-core:52205] [Bug #7841]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-14 02:08:31 +00:00
nobu ad6f06aed8 object.c: singleton class clone
* object.c (rb_obj_clone): attach clone to its singleton class during
  cloning singleton class so that singleton_method_added will be called
  on it.  based on the patch by shiba (satoshi shiba)[Bug #5283] in
  [ruby-dev:44477].  [Bug #5283]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 02:37:47 +00:00
charliesome a70bb8889b * class.c (rewrite_cref_stack, clone_method): rewrite a method's cref
stack when cloning into a new class to allow lexical const lookup to
  work as expected [ruby-core:47834] [Bug #7107]
* test/ruby/test_class.rb (class TestClass): related test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-17 09:49:00 +00:00
nobu 3738ebe15a * object.c (Init_Object): no needs to override with same method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13 14:32:40 +00:00
charliesome c01f06089f * object.c (Init_Object): use rb_mod_init_copy for Class#initialize_copy
* class.c (rb_class_init_copy): rename to class_init_copy_check, performs type
	  checks on arguments to prevent reinitialization of initialized class
	  [ruby-core:50869] [Bug #7557]
	* class.c (rb_mod_init_copy): use class_init_copy_check if receiver is T_CLASS
	* test/ruby/test_class.rb (class TestClass): related test


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13 14:11:01 +00:00
shugo 75bed271f0 * class.c (rb_prepend_module): move refined methods from the origin
of a class to the class, because refinements should have priority
  over prepended modules.

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-12 09:35:50 +00:00
shugo 7ef16d224a * fix the behavior when a module is included into a refinement.
This change is a little tricky, so it might be better to prohibit
  module inclusion to refinements.

* include/ruby/ruby.h (RMODULE_INCLUDED_INTO_REFINEMENT): new flag
  to represent that a module (iclass) is included into a refinement.

* class.c (include_modules_at): set RMODULE_INCLUDED_INTO_REFINEMENT
  if klass is a refinement.

* eval.c (rb_mod_refine): set the superclass of a refinement to the
  refined class for super.

* eval.c (rb_using_refinement): skip the above superclass (the
  refined class) when creating iclasses for refinements.  Otherwise,
  `using Refinement1; using Refinement2' creates iclasses:
  <Refinement2> -> <RefinedClass> -> <Refinement1> -> RefinedClass,
  where <Module> is an iclass for Module, so RefinedClass is
  searched before Refinement1.  The correct iclasses should be
  <Refinement2> -> <Refinement1> -> RefinedClass.

* vm_insnhelper.c (vm_search_normal_superclass): if klass is an
  iclass for a refinement, use the refinement's superclass instead
  of the iclass's superclass.  Otherwise, multiple refinements are
  searched by super.  For example, if a refinement Refinement2
  includes a module M (i.e., Refinement2 -> <M> -> RefinedClass,
  and if refinements iclasses are <Refinement2> -> <M>' ->
  <Refinement1> -> RefinedClass, then super in <Refinement2> should
  use Refinement2's superclass <M> instead of <Refinement2>'s
  superclass <M>'.

* vm_insnhelper.c (vm_search_super_method): do not raise a
  NotImplementError if current_defind_class is a module included
  into a refinement.  Because of the change of
  vm_search_normal_superclass(), the receiver might not be an
  instance of the module('s iclass).

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-10 16:05:45 +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
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 f3e5f2cd75 * bignum.c (bignew_1): Bignum instances are frozen.
Feature #3222
* include/ruby/ruby.h: Fixnum instances are also frozen.
* class.c (singleton_class_of): check Bignum before
  singleton cheking.
* test/ruby/test_bignum.rb: add a test.
* test/ruby/test_fixnum.rb: ditto.
* test/ruby/marshaltestlib.rb, test/ruby/test_eval.rb,
  test/ruby/test_object.rb: catch up above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28 00:03:20 +00:00
ko1 180c744b3b * numeric.c (rb_float_new_in_heap), include/ruby/ruby.h:
make all Float objects frozen.
  [ruby-dev:46081] [ruby-trunk - Feature #6936]
  Most part of patch by NARUSE, Yui  <naruse@ruby-lang.org>.
* class.c (singleton_class_of): raise TypeError when
  trying to define a singleton method on Float objects.
* vm.c (vm_define_method): ditto.
* test/ruby/marshaltestlib.rb: catch up above changes.
* test/ruby/test_class.rb: ditto.
* test/test_pp.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27 02:10:53 +00:00
ko1 9dc3a7d7a5 * include/ruby/ruby.h, class.c: remove (revert)
`rb_add_method_cfunc_frameless()' API.
  This API is not mature to become an offical API.
  For example, we can not use this API with
  `rb_define_private_method()'.
* method.h, vm_method.c (rb_add_method_cfunc_frameless): removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-25 06:03:53 +00:00
nari c3a46d6aca * include/ruby/ruby.h: add C APIs.
VALUE rb_newobj_of(VALUE klass, VALUE flags)
  #define NEWOBJ_OF(obj,type,klass,flags)
  These allow to change a allocation strategy depending on klass
  or flags.

* gc.c: ditto

* array.c: use new C API.
* bignum.c: ditto
* class.c: ditto
* complex.c: ditto
* ext/socket/ancdata.c: ditto
* ext/socket/option.c: ditto
* hash.c: ditto
* io.c: ditto
* marshal.c: ditto
* numeric.c: ditto
* object.c: ditto
* random.c: ditto
* range.c: ditto
* rational.c: ditto
* re.c: ditto
* string.c: ditto
* struct.c: ditto
  [Feature #7177][Feature #7047]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20 06:57:51 +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
nobu 5fbfc21b67 internal.h: allocator function in rb_classext_t
* internal.h (struct rb_classext_struct): move allocator function into
  rb_classext_t from ordinary method table.  [ruby-dev:46121]
  [Feature #6993]
* object.c (rb_obj_alloc): call allocator function directly.
* vm_method.c (rb_define_alloc_func, rb_undef_alloc_func)
  (rb_get_alloc_func): use allocator function in rb_classext_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-08 09:52:26 +00:00
usa 6a80947a4b * class.c (singleton_class_of): flonum can't have singleton class.
* vm.c (vm_define_method): flonum can't have singleton method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23 11:36:42 +00:00
nobu 28827e61d1 method in instance_eval
* class.c (rb_special_singleton_class_of): utility function.
* vm_eval.c (eval_under): special deal for class variable scope with
  instance_eval.
* vm_eval.c (rb_obj_instance_eval, rb_obj_instance_exec): allow method
  definition in instance_eval of special constants.  [ruby-core:28324]
  [Bug #2788]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-06 15:31:13 +00:00
shugo 9537e8ffe5 * internal.h, class.c, eval.c, insns.def: find the appropriate
receiver for super called in instance_eval.  If such a receiver is
  not found, raise NoMethodError. [ruby-dev:39772] [Bug #2402]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-06 07:00:19 +00:00
shugo 19ddfc2483 * eval.c (rb_mod_using): new method Module#using. [experimental]
* eval.c (rb_mod_refine): new method Module#refine. [experimental]

* eval.c (f_using): new method Kernel#using. [experimental]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02 11:34:19 +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
nobu b283d01987 class.c: fix duplication of prepended module
* class.c (include_class_new): fix duplication of prepended module.
  since m_tbl of prepended module is always zero, copy from its
  copy iclass of original.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-31 15:33:23 +00:00
nobu edb1fc4eb2 prepend: fix mixing with include
* class.c (rb_include_module): include modules after the origin.
* class.c (include_modules_at): skip prepended modules.
* class.c (rb_prepend_module): now basic.klass in ICLASS refers the
  old original class/module.  [ruby-dev:45868][Bug #6662]
* class.c (rb_mod_ancestors): ditto.
* vm_method.c (search_method): search method entry from the origin
  iclass.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-02 08:06:37 +00:00
nagachika 912df4b615 * class.c (class_instance_method_list): consider prepended Class/Module
when recur != 0. [ruby-dev:45863] [Bug #6660]

* test/ruby/test_module.rb (test_prepend_instance_methods_false): add
  a test for it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-28 00:39:52 +00:00
nobu 3f3225905b prepend: fix ancestors order
* class.c (rb_mod_ancestors): fix ancestors order.
  [ruby-core:45919][Bug #6658] [ruby-dev:45861][Bug #6659]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 21:12:46 +00:00
nobu d4269d7b7c fix null m_tbl
* class.c (rb_obj_singleton_methods): m_tbl in prepended class/module
  is NULL.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 13:40:34 +00:00
nobu cf3a8f09b8 ancestor modules
* class.c (rb_prepend_module): ancestors of prepending module also
  should be included.  [ruby-core:45914][Bug #6654]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 12:31:17 +00:00
nobu 48c04ad0d8 fix null m_tbl
* class.c (class_instance_method_list): m_tbl in prepended
  class/module is NULL.  [ruby-core:45915][Bug #6655]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 12:01:39 +00:00
nobu 8ddbbb3324 Module#prepend
* class.c (rb_prepend_module): prepend module into another module.
* eval.c (rb_mod_prepend): new method Module#prepend.  [Feature #1102]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 07:48:50 +00:00
nobu ffa20cf154 use rb_check_hash_type
* class.c (rb_scan_args): use rb_check_hash_type.
* process.c (rb_exec_getargs): ditto.
* sprintf.c (get_hash): ditto.
* string.c (rb_str_sub_bang, str_gsub): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-26 07:46:24 +00:00
nobu 82a408fb9d Revert r31873 Module#mix
* class.c (rb_mix_module): revert Module#mix.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-25 08:49:32 +00:00
drbrain 1d4e7d9232 * class.c (rb_mod_init_copy): Clear the cached inspect string of a
dup'd anonymous module or class.  [ruby-trunk - Bug #6454]
* test/ruby/test_module.rb (class TestModule):  ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-22 20:15:28 +00:00
nobu 57fb219905 * reduce UNREACHABLE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-15 00:06:13 +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
nari 50675fdba1 * gc.c: use Bitmap Marking algorithm to avoid copy-on-write of
memory pages. See [ruby-dev:45085] [Feature #5839]
  [ruby-core:41916].

* include/ruby/ruby.h : FL_MARK rename to FL_RESERVED1.

* node.h : ditto.

* debug.c : ditto.

* object.c (rb_obj_clone): FL_MARK move to a bitmap.

* class.c (rb_singleton_class_clone): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-07 14:02:23 +00:00
nobu 8baffe6ef6 * class.c (rb_obj_methods), compile.c (iseq_compile_each),
iseq.c(iseq_load, rb_iseq_parameters), pack.c (pack_pack),
  regcomp.c (is_not_included, update_string_node_case_fold),
  transcode.c (rb_econv_open0, make_replacement),
  vm_eval.c (raise_method_missing): remove unused variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 09:50:12 +00:00
naruse 6e56d645f0 * lib/delegate.rb (Delegator#methods): Kernel#methods receives
zero or one argument. [ruby-core:37118] [Bug #4882]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-04 03:05:03 +00:00
nobu 92a05ea2cf * class.c (class_alloc): allocate extra memory after containing
object setup to get rid of rare-but-potential memory leak.
* gc.c (gc_mark_children): skip marking extended members if ptr is
  NULL.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-04 12:10:09 +00:00
naruse 0688c81a89 Revert r33397 because it cause segv.
"* class.c (class_alloc): allocate extra memory after containing"

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-04 09:44:08 +00:00
nobu bf8168cf33 * class.c (class_alloc): allocate extra memory after containing
object setup to get rid of rare-but-potential memory leak.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-04 06:04:46 +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
matz 8fca66d7eb * class.c (Init_class_hierarchy): should name BasicObject
explicitly.

* variable.c (rb_const_defined_0): should not check for
  superclasses as const_get.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30 18:34:09 +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
nobu 83ef8ee73e clone_const_i
* class.c (clone_const_i, class_instance_method_list): get rid of
  type-punning function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-04 03:49:50 +00:00
nobu 40930b7144 * class.c (check_mix_method_i, do_mix_method_i): not mix methods
renamed as nil.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-04 02:30:59 +00:00
nobu 604fe33b44 * class.c (rb_mix_module): implement Module#mix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 16:16:06 +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
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
nagachika c8e5ba0e84 * class.c (clone_method): add GC guard to prevent intermediate
variable from GC. [Bug #4321] [ruby-dev:43107]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-26 13:59:20 +00:00
nobu 1a3f4dbafa * class.c (make_metaclass): fix probable typo. builtin type flag
cannot be used with FL_TEST.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-05 08:56:42 +00:00
akr 5c6b43d91e * class.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-04 02:18:42 +00:00
usa 6223582f2a * class.c (clone_const): need to return value. fix r29602.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-27 03:06:27 +00:00
mame a115768161 * class.c, constant.h, gc.c, method.h, object.c, variable.c,
vm_insnhelper.c: use struct rb_constant_entry_t as entry of
  RCLASS_CONST_TBL.  RCLASS_CONST_TBL has contained VALUE of constant
  directly.  Now instead rb_const_entry_t is contained in
  RCLASS_CONST_TBL,  rb_const_entry_t is managed by malloc, and
  have not only the value itself but also visibility flag.
  This is another preparation for private constant (see
  [ruby-dev:39685][ruby-core:32698]).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-26 17:27:32 +00:00
mame 2285a8d813 * class.c, gc.c, object.c, variable.c, vm_insnhelper.c,
include/ruby/ruby.h: separate RCLASS_CONST_TBL from RCLASS_IV_TBL.
  RCLASS_IV_TBL has contained not only instance variable table but
  also constant table.  Now the two table are separated to
  RCLASS_CONST_TBL and RCLASS_IV_TBL.  This is a preparation for
  private constant (see [ruby-dev:39685][ruby-core:32698]).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-26 17:27:21 +00:00
nobu 137d82569f * class.c (rb_define_{class,module}_id_under): register to be
marked, which probably are defined and used internally.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-17 01:40:22 +00:00
nobu 7735e63593 * array.c (rb_ary_and, rb_ary_or), class.c (rb_mod_init_copy),
gc.c (undefine_final), time.c (time_mload): get rid of
  type-punning casts.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-13 22:22:18 +00:00
nobu cea3919ae6 * configure.in (RUBY_CHECK_PRINTF_PREFIX): check for printf format
specifier if possible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 15:03:51 +00:00
knu 82abe79b9f * class.c (rb_scan_args): Add support for optional keyword
argument hash.

* README.EXT, README.EXT.ja: Update documentation accordingly.

* dir.c (dir_initialize): Make use of the new rb_scan_args()
  feature.

* io.c (rb_io_s_popen, rb_scan_open_args, rb_io_initialize)
  (rb_io_s_pipe, open_key_args, io_s_foreach, io_s_readlines)
  (rb_io_s_read, rb_io_set_encoding): Ditto.

* transcode.c (str_transcode, econv_args)
  (econv_primitive_convert): Ditto.

* ext/zlib/zlib.c (rb_gzreader_initialize): Ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-10 07:51:58 +00:00
akr a35c3cf341 * class.c (rb_include_module): don't clear the method cache if the
included module has no method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-01 00:46:18 +00:00
naruse 7175a9073e * class.c, compile.c, dir.c, file.c, iseq.c, parse.y, random.c:
clean unused-value warnings.

* cont.c, process.c, vm_exec.h: clean cast warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-27 07:13:43 +00:00
mame 9b94dabe77 * class.c (rb_mod_init_copy): when class is dup'ed, a metaclass of the
class should be attached to the dup'ed class, not the original
  class.  [ruby-core:30843] [Bug #3461]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-27 17:47:21 +00:00
marcandre 52ebd4b7f4 * class.c: rdoc fix [ruby-core:30449]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-22 04:52:03 +00:00
mame d35f8ea885 * object.c: Object#public_methods, private_methods, etc. returns
method ids that belong to the class or the singleton class(es) of
  the object.  [ruby-dev:41613]

* class.c: on the other hand, Module#public_instance_methods, etc.
  returns method ids that belong to the module itself (even if the
  module is singleton, it does not return method ids of super
  class(es); see [ruby-core:28837]).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-06-17 16:58:25 +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
nari ca64478089 * gc.c : use simple lazy sweep algorithm for response performance
gain. See [ruby-dev:41067].

* object.c: FL_MARK of some objects by lazy sweep is copied when
  RVALUE is cloned. These objects are not marked in the mark phase.
  So delete FL_MARK.

* class.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-28 11:13:42 +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
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
shyouhei d894e1d930 instance_methods should not special-case singleton classes, fixes #2993
Signed-off-by: URABE, Shyouhei <shyouhei@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-29 05:59:46 +00:00
shugo b09eabd430 * class.c (rb_class_init_copy): raise a TypeError if the argument is
BasicObject.  [ruby-core:27060]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-06 15:26:34 +00:00
marcandre fb2941a4ec * object.c (rb_class_initialize): Make sure BasicObject doesn't get initialized twice [ruby-core:27577]
* class.c (rb_class_init_copy): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-13 02:57:48 +00:00
nobu b4da253400 * class.c (rb_define_class): raise TypeError same as class
statement.  [ruby-core:27504]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-09 19:54:38 +00:00
mame 4a761c3209 * class.c (rb_mod_init_copy): fix memory leak of Class#dup.
[ruby-dev:39687]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-14 12:56:16 +00:00
akr b9e0294eda fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 17:46:28 +00:00
matz 5d6440c748 * class.c (rb_class_new): move class check to rb_check_inheritable().
* class.c (rb_check_inheritable): should not allow subclass of
  class Class.  [ruby-core:26225]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-23 23:37:14 +00:00
usa 359d932332 * class.c (rb_obj_basic_to_s_p): typo. Please become familiar with
the ANSI style. 



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-22 12:12:24 +00:00
matz 7eac66b9c6 * object.c (rb_obj_inspect): print instance variables only when
Object#to_s is not overridden.  [ruby-core:24425]

* class.c (rb_obj_basic_to_s_p): new function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-21 20:17:27 +00:00
yugui 9b062c9685 * class.c (make_singleton_class): variable name changed.
removed an unnecessary conditional.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-31 07:21:54 +00:00
yugui e056ac59a7 * class.c: refactored singleton class related matters.
Handles eigenclasses and plain classes transparently.

  (make_metaclass): renamed from make_metametaclass.
  (METACLASS_OF): new utility macro
  (META_CLASS_OF_CLASS_CLASS): ditto.
  (ENSURE_EIGENCLASS): ditto.
  (make_singleton_class): extracted from rb_singleton_class.
  (boot_defclass): moved from object.c
  (Init_class_hierarchy): extracted from Init_Object.
  (rb_make_metaclass): refactored.
  (singleton_class_of): extracted from rb_singleton_class.
  (rb_singleton_class): refactored.
  (rb_define_singleton_method): it needs a metaclass only
  but not its metametaclass.

* object.c: booting class hierarchy was moved to class.c
  for keeping dependency between compilation units least.
  (Init_Object): extracting the booting into
  Init_class_hierarchy.
  (boot_defclass): moved to class.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-31 05:55:57 +00:00
yugui ebabbc6cb9 Doxygen comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-29 13:39:44 +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
naruse 054770068a * class.c (rb_define_module_id_under): fix the name.
* class.c (rb_define_module_under): fix for prevvious changes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-12 06:54:45 +00:00
nobu 31f4a82942 * class.c (rb_define_class_id_under, rb_define_module_id_under):
new functions to define a nested class/module with non-ascii
  name.

* struct.c (make_struct): use name with encoding.

* struct.c (inspect_struct): ditto.  [ruby-core:24849]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-12 06:32:21 +00:00
nobu e07cb859cc * suppressed shorten-64-to-32 warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 08:05:32 +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
yugui 2d42e704f4 Doxy-comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-29 16:39:28 +00:00
matz 4d4bd7ab95 * class.c (clone_method): add cast to remove warning from
rb_gc_write_barrier().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-19 05:00:19 +00:00
matz 7d1f48b5c3 * struct.c (struct_ivar_get): new function to avoid repeated
rb_intern() calls.

* struct.c (rb_struct_iv_get): use struct_ivar_get()

* struct.c (num_members): ditto.

* struct.c (rb_struct_s_members): ditto.

* class.c (rb_singleton_class): cache symbol to reduce calls to
  rb_intern().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-19 04:58:36 +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 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
nobu ffbaa25b62 * class.c: fixed indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-13 05:55:13 +00:00
knu 400ded9338 * class.c (rb_scan_args): Allow specifying the number of trailing
mandatory arguments right after the number of optional arguments
  only if the number of leading mandatory arguments is not omitted.

* ext/socket/tcpserver.c (tcp_svr_init): Make use of it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-24 15:41:39 +00:00
knu ca292099a6 * class.c (rb_scan_args): Revamp rb_scan_args() to compute the
number of required and optional arguments precisely to prepare
  for a more informative error message.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-24 15:15:25 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
knu f5ca95ee10 * class.c (rb_scan_args), README.EXT, README.EXT.ja: Add support
for specifying the number of the trailing mandatory arguments.
  Update the documents accordingly. [ruby-dev:37995]




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-16 08:04:56 +00:00
yugui 3a5c0bbcb5 * test/ruby/test_metaclass.rb: new test case for metaclass hierarchy.
* class.c (make_metametaclass): new function. extracted from
  rb_make_metaclass.

* class.c (rb_make_metaclass): uses make_metametaclass when called for a
  metaclass.

* class.c (rb_singleton_class): creates a meta^(n+2)-class in
  addition to a meta^(n+1)-class when called for a meta^(n)-class.
  This is because the returned meta^(n+1) class must acts as an instance of 
  Class, metaclass of Class, ..., meta^(n+1)-class of Class,
  Module, metaclass of Module, ..., meta^(n+1)-class of Module,
  Object, metaclass of Object, ..., meta^(n+2)-class of Object,
  BasicObject, metaclass of BasicObject, ..., meta^(n+2)-class of
  and BasicObject even when Class, Module, Object or BasicObject has
  not have its meta^(i)-class yet.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-15 06:23:43 +00:00
matz 06151d4a99 * class.c (rb_class_instance_methods): rdoc fixed. [ruby-core:19458]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-23 08:30:52 +00:00
yugui 7a86a81dcc * class.c (rb_make_metaclass): [BUG] Fixed a bus error
on the case for metaclass of a class which includes a
  module.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-25 11:31:02 +00:00
yugui 788001a9c8 * class.c (rb_make_metaclass): Made class of class of class
from Class into its own eigenclass. Now meta^(n)-class
  hierarchy regresses infinitely, again.
  (This feature was decided on developer-meeting-20080922.)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-25 09:46:59 +00:00
ko1 2e311f6bd5 * include/ruby/node.h, node.h: move node.h from include path.
This change stop to install node.h beacuase of saving ABI
  (node.h will be changed. Extensions should not depends on
  this file).
* blockinlining.c, class.c, compile.c, debug.h, enum.c,
  gc.c, iseq.c, parse.y, ruby.c, signal.c, variable.c,
  vm.c, vm_core.h, vm_dump.c: ditto.
* ext/ripper/depend: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 19:52:31 +00:00
ko1 68a533c611 * class.c, vm_core.h: move decl of rb_iseq_clone() to class.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 08:10:20 +00:00
ko1 7f7834abf7 * include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
  move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
  from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
  vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
  rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
  iseq structure.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 07:49:45 +00:00
ko1 204929af9d * include/ruby/signal.h: removed.
* common.mk, class.c, eval.c, eval_intern.h, file.c, gc.c, hash.c,
  io.c, process.c, signal.c: vm_core.h: ditto.
  Some unused external global variables are also removed.
  (rb_prohibit_interrupt, rb_trap_immediate, rb_trap_pending,
  rb_thread_critical)
* ext/openssl/ossl_ssl.c, ext/openssl/ossl_x509store.c,
  ext/readline/readline.c, ext/socket/depend,
  ext/socket/socket.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 08:00:05 +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
matz e956f28724 * class.c (clone_method): should copy cbase in cref as well.
[ruby-dev:35116]

* iseq.c (iseq_mark): mark original iseq object.

* iseq.c (iseq_free): do not free internal data if they have
  original iseq to belong.

* iseq.c (rb_iseq_clone): a new function to clone iseq value.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-11 08:13:42 +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
akr 861219ce4a fix doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-09 01:04:46 +00:00
matz 39787ea14d * numeric.c (fix_to_s): avoid rb_scan_args() when no argument
given. 
* bignum.c (rb_big_to_s): ditto.
* enum.c (enum_first): ditto.
* eval_jump.c (rb_f_catch): ditto.
* io.c (rb_obj_display): ditto.
* class.c (rb_obj_singleton_methods): ditto.
* object.c (rb_class_initialize): ditto.
* random.c (rb_f_srand): ditto.
* range.c (range_step): ditto.
* re.c (rb_reg_s_last_match): ditto.
* string.c (rb_str_to_i): ditto.
* string.c (rb_str_each_line): ditto.
* string.c (rb_str_chomp_bang): ditto.
* string.c (rb_str_sum): ditto.

* string.c (str_modifiable): declare inline.
* string.c (str_independent): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-05 05:22:17 +00:00
akr 6cdef2dc7e * $Date$ keyword removed to avoid inclusion of locale dependent
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 15:49:38 +00:00
matz 9bcbd08b0b * include/ruby/node.h (NOEX_LOCAL): remove unused local visibility.
* class.c (ins_methods_push): ditto.

* class.c (rb_class_local_methods): method removed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-11 13:20:14 +00:00
akr 5c0e68c39c * include/ruby/intern.h: export rb_ivar_foreach.
* include/ruby/ruby.h: modify struct RObject and RClass for optimizing
  T_OBJECT space.  [ruby-dev:31853]
  (ROBJECT_LEN, ROBJECT_PTR)
  (RCLASS_IV_TBL, RCLASS_M_TBL, RCLASS_SUPER, RCLASS_IV_INDEX_TBL)
  (RMODULE_IV_TBL, RMODULE_M_TBL, RMODULE_SUPER): abstract accessor
  defined.

* variable.c: support the modified RObject and RClass.

* object.c: ditto.

* class.c: ditto.

* gc.c: ditto.

* marshal.c: ditto.

* eval_method.ci: use the abstract accessor.

* insns.def: ditto.

* proc.c: ditto.

* struct.c: ditto.

* eval.c: ditto.

* error.c: ditto.

* vm.c: ditto.

* insnhelper.ci: ditto.

* ext/digest/digest.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-28 06:21:46 +00:00