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

372 Коммитов

Автор SHA1 Сообщение Дата
nobu b4974e71dc util.c: hexdigit
* util.c (hexdigit): extract identical constants.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-13 07:07:39 +00:00
nobu 18db8cea6a error.c: rb_sys_enc_warning
* error.c (rb_sys_enc_warning): new function to show warning and
  error message with the encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-06 08:37:24 +00:00
nobu e567f351c2 marshal.c: indetity tables
* marshal.c (w_object, marshal_dump): use indetity tables for
  arbitrary VALUE keys, because of performance of FLONUM.
  [Bug #10761]
* marshal.c (obj_alloc_by_klass, marshal_load): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-23 11:01:02 +00:00
nobu 059ea6e4d8 hash.c: move Hash specific functions
* hash.c (rb_ident_hash): move compare_by_identity specific
  function from st.c.

* hash.c (rb_ident_hash_new): ditto from thread.c.

* st.c (st_numhash): remove ruby's Hash specific implementation.

* thread.c (recursive_list_access): use rb_ident_hash_new().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-23 02:36:50 +00:00
nobu 0fb2cd458b class.c: add callback argument
* class.c (rb_class_foreach_subclass): add argument for callback
  function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-19 14:09:20 +00:00
ko1 9c6eaad723 * hash.c (rb_hash_delete): return Qnil if there are no corresponding
entry. [Bug #10623]
* hash.c (rb_hash_delete_entry): try delete and return Qundef if there
  are no corresponding entry.
* internal.h: add rb_hash_delete_entry()'s declaration.
* symbol.c: use rb_hash_delete_entry().
* thread.c: use rb_hash_delete_entry().
* ext/-test-/hash/delete.c: use rb_hash_delete_entry().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-24 02:53:37 +00:00
nobu aacc35e144 encoding.c: load by rb_require_internal
* encoding.c (load_encoding): use rb_require_internal instead of
  calling rb_require_safe with protection.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-03 08:13:26 +00:00
nobu c262acb4e0 ruby.h: export keyword argument functions
* include/ruby/ruby.h (rb_get_kwargs, rb_extract_keywords): export
  keyword argument functions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-26 13:28:15 +00:00
normal 83f0e9d6f1 trivial packing of rb_execarg, load_file_arg, args_info
* internal.h (struct rb_execarg): 160 => 144 bytes on x86-64
* ruby.c (struct load_file_arg): 48 => 40 bytes on x86-64
* vm_args.c (struct args_info): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-23 01:49:57 +00:00
nobu 8eb0c810b2 get rid of inadvertent ID creation
* object.c (rb_mod_const_get, rb_mod_const_defined): ditto.
* variable.c (rb_const_missing, rb_mod_const_missing): call
  const_missing without new ID to get rid of inadvertent ID
  creation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-21 16:11:55 +00:00
akr fdc41af774 * internal.h (ruby_init_setproctitle): Declare here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-19 15:57:31 +00:00
akr a494ed4113 Add comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-19 03:55:45 +00:00
akr 2b9191e557 * internal.h: Gather declarations in non-header files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 15:13:05 +00:00
akr 714fd78f67 * debug.c (SET_WHEN): Don't declare debug variables here.
ruby_initial_gc_stress_ptr is changed int* to VALUE* at r41406.

* internal.h (ruby_initial_gc_stress_ptr): Declared.
  (ruby_enable_coredump): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 14:58:03 +00:00
nobu 4e48b64280 symbol.c: symbol type predicate functions
* symbol.h (is_{local,global,instance,attrset,const,class,junk}_sym):
  fix ID type names.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-17 18:20:22 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
ko1 5d5c95f28e * gc.c (gc_stat_internal): add compatible layer.
From Ruby 2.2, keys of GC.stat are changed [Feature #9924].
  To provide compatible layer, GC.stat add a default_proc
  (if default_proc of given Hash object is not set).
  At first use of this compatible layer of interpreter process,
  show a warning message like that:
  program: GC.stat[:total_allocated_object]
  warning message: "warning: GC.stat keys were changed from Ruby
  2.1. In this case,  you refer to obsolete `total_allocated_object'
  (new key is `total_allocated_objects').
  Please check <https://bugs.ruby-lang.org/issues/9924>
  for more information."
  Pleaes correct my English message :)
* hash.c (rb_hash_set_default_proc): export (in internal).
* internal.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-14 07:29:33 +00:00
nobu d21daa2b91 internal.h: define
* internal.h (STATIC_ASSERT): fix missing preprocessor directive.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13 03:44:54 +00:00
nobu 54af8757b3 internal.h: STATIC_ASSERT
* st.c: include "internal.h" for STATIC_ASSERT.

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



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 18:02:55 +00:00
nobu 5617e31771 symbol.c: rename rb_str_dynamic_intern
* iseq.c, marshal.c, string.c: use rb_str_intern instead of
  rb_str_dynamic_intern.
* symbol.c (rb_str_intern): rename rb_str_dynamic_intern.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-14 07:23:01 +00:00
nobu 795b8b474c internal.h: optimize rb_ary_new_from_args
* internal.h (rb_ary_new_from_args): optimization by expanding
  arguments in caller to get rid of va_list if possible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-09 07:53:54 +00:00
nobu 0ca714fa1a symbol.h: move struct RSymbol
* symbol.h (struct RSymbol): move from internal.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-06 13:36:45 +00:00
nobu 24b03b32e4 readline.c: use rb_setup_fake_str
* ext/readline/readline.c (readline_s_delete_text): initialize a
  fake string by rb_setup_fake_str().

* internal.h (rb_setup_fake_str): allow extensions to call.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-12 13:11:13 +00:00
ko1 c653db51b0 * gc.c (rb_gc_mark_values): added.
This function is similar to rb_gc_mark_locations(), but not
  conservertive.
* internal.h: ditto.
* vm.c (env_mark): use rb_gc_mark_values() because env values should
  be Ruby VALUEs.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-11 10:34:09 +00:00
ko1 123eeb1c1a * gc.c: add incremental GC algorithm. [Feature #10137]
Please refer this ticket for details.
  This change also introduces the following changes.
  * Remove RGENGC_AGE2_PROMOTION and introduce object age (0 to 3).
    Age can be count with FL_PROMOTE0 and FL_PROMOTE1 flags in
    RBasic::flags (2 bit). Age == 3 objects become old objects.
  * WB_PROTECTED flag in RBasic to WB_UNPROTECTED bitmap.
  * LONG_LIVED bitmap to represent living objects while minor GCs
    It specifies (1) Old objects and (2) remembered shady objects.
  * Introduce rb_objspace_t::marked_objects which counts marked
    objects in current marking phase. marking count is needed to
    introduce incremental marking.
  * rename mark related function and sweep related function to
    gc_(marks|sweep)_(start|finish|step|rest|continue).
  * rename rgengc_report() to gc_report().
  * Add obj_info() function to get cstr of object details.
  * Add MEASURE_LINE() macro to measure execution time of specific line.
  * and many small fixes.
* include/ruby/ruby.h: add flag USE_RINCGC.
  Now USE_RINCGC can be set only with USE_RGENGC.
* include/ruby/ruby.h: introduce FL_PROMOTED0 and add FL_PROMOTED1
  to count object age.
* include/ruby/ruby.h: rewrite write barriers for incremental marking.
* debug.c: catch up flag name changes.
* internal.h: add rb_gc_writebarrier_remember() instead of
  rb_gc_writebarrier_remember_promoted().
* array.c (ary_memcpy0): use rb_gc_writebarrier_remember().
* array.c (rb_ary_modify): ditto.
* hash.c (rb_hash_keys): ditto.
* hash.c (rb_hash_values): ditto.
* object.c (init_copy): use rb_copy_wb_protected_attribute() because
  FL_WB_PROTECTED is moved from RBasic::flags.
* test/objspace/test_objspace.rb: catch up ObjectSpace.dump() changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-08 04:11:00 +00:00
nobu b6c425aadd internal.h: WARN_UNUSED_RESULT
* internal.h (WARN_UNUSED_RESULT): warn unused result by gcc 3.4
  or later.

* symbol.c: declare some functions with WARN_UNUSED_RESULT.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-30 13:29:45 +00:00
normal a1e95636ac string.c: move frozen_strings table to rb_vm_t
Cleanup in case MVM development proceeds.

* string.c: remove static frozen_strings
* string.c (Init_frozen_strings): new function
* string.c (rb_fstring): remove check for frozen strings,
  use per-VM table
* string.c (rb_str_free): use per-VM table
* string.c (Init_String): use per-VM table
* vm_core.h (rb_vm_t): add frozen_strings table
* internal.h (Init_frozen_strings): new function prototype
* eval.c (ruby_setup): call Init_frozen_strings
  [Feature #10182]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-29 06:30:03 +00:00
nobu 3636e08858 string.c: rb_setup_fake_str
* string.c (rb_setup_fake_str): setup fake string from C pointer,
  length, and encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-16 03:36:47 +00:00
ko1 b5e89e44f1 * array.c (rb_ary_tmp_new): added.
This function creates internal use only array (which is completely
  hided by ObjectSpace.each_object) with filling nil.
  Otherwise, it can be incldues strange VALUEs.
* internal.h: added.
* node.h: use rb_ary_tmp_new_fill() for MEMO.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-15 10:32:58 +00:00
nobu d0987afc74 make symbol conversion functions public
* include/ruby/encoding.h (rb_check_symbol_cstr): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-03 01:55:10 +00:00
nobu 6016da7dab symbol.h: move macros
* symbol.h (RSYMBOL): move macros for Symbol from internal.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-31 09:58:01 +00:00
nobu 6db9db48ad string.c: rb_to_symbol
* string.c (rb_to_symbol): new function to convert an object to a
  symbol.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-30 12:36:31 +00:00
ko1 96815f1ebe * symbol.c: remove rb_gc_mark_symbols().
fstrings refered by static symbols and pinned dynamic symbols
  are registerd by rb_gc_register_mark_object().
  frstring refered by dynamic symbols (not pinned symbols)
  are refered from global_symbols.dsymbol_fstr_hash (Hash object).
  Note that fstrings refered from dynamic symbols must live loger
  than symbol objects themselves because rb_gc_free_dsymbol() uses
  fstring to remove from symbol tables.
  This is why we can not mark fstrings from dynamic symbols.
  This technique reduces root objects for GC marking.
* gc.c (gc_mark_roots): ditto.
* internal.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-09 16:19:13 +00:00
ko1 76a929a7fc * parse.y: change Symbol <-> ID relationship to avoid
exposing IDs from collectable symbols.
  [Bug #10014]
  Now, rb_check_id() returns 0 if corresponding symbol is
  pinned dynamic symbol.
  There is remaining intern_cstr_without_pindown(), it can return
  IDs from collectable symbols. We must be careful to use it
  (only used in parse.y).  I think it should be removed if
  it does not have impact for performance.
* parse.y:
  add:
  * STATIC_SYM2ID()
  * STATIC_ID2SYM()
  rename:
  * rb_pin_dynamic_symbol() -> dsymbol_pindown()
* internal.h:
  remove:
  * rb_check_id_without_pindown()
  * rb_sym2id_without_pindown()
  add:
  * rb_check_symbol()
  * rb_check_symbol_cstr()
* load.c: use rb_check_id() or rb_check_id_cstr().
* object.c: ditto.
* struct.c: ditto.
* thread.c: ditto.
* vm_method.c: ditto.
* string.c (sym_find): use only rb_check_symbol().
* sprintf.c (rb_str_format): use rb_check_symbol_cstr().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-09 06:14:41 +00:00
ko1 2c551e4715 * parse.y: need to use updated (re-created) symbols.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-07 03:42:42 +00:00
nobu 58bd5facb2 string.c: rb_fstring_new
* string.c (rb_fstring_new): create fstring from pointer and
  length.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-30 14:59:44 +00:00
shyouhei 8250aa2df0 * include/ruby/ruby.h (struct RHash): no longer. [Feature #9889]
* include/ruby/ruby.h (RHASH): ditto.

	* include/ruby/ruby.h (RHASH_ITER_LEV): deprecated.  Will be deleted later.

	* include/ruby/ruby.h (RHASH_IFNONE): ditto.

	* internal.h (struct RHash): moved here.

	* internal.h (RHASH): ditto.

	* hash.c (rb_hash_iter_lev): do not use this.

	* hash.c (rb_hash_ifnone): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23 07:26:03 +00:00
shyouhei 62bfc4f24e * include/ruby/ruby.h (struct RComplex): no longer. [Feature #9888]
* include/ruby/ruby.h (RCOMPLEX): ditto.

	* include/ruby/ruby.h (RCOMPLEX_SET_REAL): deprecated.  Will be deleted later.

	* include/ruby/ruby.h (RCOMPLEX_SET_IMAG): ditto.

	* internal.h (struct RFloat): moved here.

	* internal.h (RCOMPLEX): ditto.

	* complex.c (rb_complex_set_real): do not use this.

	* complex.c (rb_complex_set_imag): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23 04:41:27 +00:00
shyouhei 6adcf6a898 * include/ruby/ruby.h (struct RFloat): no longer. [Feature #9863]
* include/ruby/ruby.h (RFLOAT): ditto.

	* internal.h (struct RFloat): moved here.

	* internal.h (RFLOAT): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23 04:12:19 +00:00
nobu cf3890205f object.c: rb_obj_copy_ivar
* object.c (rb_obj_copy_ivar): extract function to copy instance
  variables only for T_OBJECT from init_copy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23 02:33:15 +00:00
nobu e99ee55abc constify parameters
* include/ruby/intern.h: constify `argv` parameters.

* include/ruby/ruby.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18 06:16:39 +00:00
nobu f2980e3e20 encoding.h: constify rb_encoding
* include/ruby/encoding.h: constify `rb_encoding` itself, not only
  arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-02 20:23:47 +00:00
nobu 046831094b constify rb_encoding and OnigEncoding
* include/ruby/encoding.h: constify `rb_encoding` arguments.
* include/ruby/oniguruma.h: constify `OnigEncoding` arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-01 22:06:11 +00:00
normal fae18c95be remove empty rb_gc_mark_parser function
* parse.y (rb_gc_mark_parser): remove, empty since r8758
* internal.h: ditto, not usable from extensions since 2.0.0
* gc.c (gc_mark_roots): remove checkpoint for parser

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-29 19:49:22 +00:00
normal 205e690646 include/ruby/ruby.h: hide Symbol internals
This is too new to be a compatibility problem.

* include/ruby/ruby.h: Hide Symbol internals.
  (struct RSymbol): moved to internal.h
  (RSYMBOL): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-28 20:08:56 +00:00
nobu 923b43fb9c internal.h: remove duplicate declaration
* internal.h (rb_vm_bugreport): remove declaration duplicate to
  `vm_core.h`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-24 14:04:40 +00:00
akr e56d2c385a * include/ruby/ruby.h: Hide Rational internal.
(RRational): Moved to internal.h
  (RRATIONAL): Ditto.
  (RRATIONAL_SET_NUM): Moved to rational.c.
  (RRATIONAL_SET_DEN): Ditto.

* rational.c (rb_rational_num): New function.
  (rb_rational_den): Ditto.

* include/ruby/intern.h (rb_rational_num): Declared.
  (rb_rational_den): Ditto.

*  ext/bigdecimal/bigdecimal.c: Follow the above change.

* ext/date/date_core.c: Ditto.

  [ruby-core:60665] [Feature #9513]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-17 16:37:41 +00:00
nobu 5bec2d8ccd hash.c: make rb_hash_keys extern
* hash.c (rb_hash_keys): make an internal public function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 04:26:53 +00:00
tadf a210f7c225 * math.c (rb_math_sqrt): omitted exporting an unused function,
anyway.
	* internal.h: follows the above change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-05 08:28:56 +00:00
nobu 40c6eaf6d8 vm.c: Init_vm_objects
* vm.c (Init_vm_objects): initialize VM internal objects, after
  heap initialized.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-04 13:04:37 +00:00
akr 95de2b0012 * internal.h (struct RBignum): Use size_t for len.
* include/ruby/intern.h (rb_big_new): Use size_t instead of long to
  specify the size of bignum.
  (rb_big_resize): Ditto.

* bignum.c: Follow above changes.

* rational.c: Follow above changes.

* marshal.c: Follow above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-19 01:11:04 +00:00
nobu c2a7a091cc object.c: rb_class_search_ancestor
* object.c (rb_class_search_ancestor): return ancestor class or
  iclass if inherited.

* object.c (rb_obj_is_kind_of, rb_class_inherited_p): share
  function to search the ancestor.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-14 07:59:42 +00:00
akr 9aa67e267b * bignum.c (SIZEOF_BDIGIT): Renamed from SIZEOF_BDIGITS.
* internal.h: Ditto.

* marshal.c: Ditto.

* rational.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-13 03:48:17 +00:00
nobu 2f3b28c682 string.c: clear env self in symbol proc
* string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear
  caller's self which is useless, so that it can get collected.
  [Fixes GH-592]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-12 13:11:11 +00:00
nobu fd8f3cb987 parse.y: rb_id_attrget
* parse.y (rb_id_attrget): new function to convert setter ID to
  getter ID.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-28 12:36:26 +00:00
nobu 5752b61d86 string.c: search by rb_str_index
* re.c (match_regexp): set regexp for MatchData from string.
* re.c (rb_backref_set_string): create MatchData from string and
  set backref.
* string.c (rb_pat_search, rb_str_sub, rb_str_sub_bang, str_gsub),
  (scan_once, rb_str_scan, rb_str_partition): use rb_str_index
  instead of rb_reg_search() when pattern is a String.  based on
  the patch by Sam Rawlins <sam.rawlins@gmail.com> [Fixes GH-579]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-27 09:58:12 +00:00
nari b9ea135950 * internal.h (USE_SYMBOL_GC): enable Symbol GC by default (USE_SYMBOL_GC == 1).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 05:39:22 +00:00
nari 90b7073842 * parse.y: support Symbol GC. [ruby-trunk Feature #9634]
See this ticket about Symbol GC.

* include/ruby/ruby.h:
  Declare few functions.
  * rb_sym2id: almost same as old SYM2ID but support dynamic symbols.
  * rb_id2sym: almost same as old ID2SYM but support dynamic symbols.
  * rb_sym2str: almost same as `rb_id2str(SYM2ID(sym))` but not
    pin down a dynamic symbol.
  Declare a new struct.
  * struct RSymbol: represents a dynamic symbol as object in
    Ruby's heaps.
  Add few macros.
  * STATIC_SYM_P: check a static symbol.
  * DYNAMIC_SYM_P: check a dynamic symbol.
  * RSYMBOL: cast to RSymbol

* gc.c: declare RSymbol. support T_SYMBOL.

* internal.h: Declare few functions.
  * rb_gc_free_dsymbol: free up a dynamic symbol. GC call this
    function at a sweep phase.
  * rb_str_dynamic_intern: convert a string to a dynamic symbol.
  * rb_check_id_without_pindown: not pinning function.
  * rb_sym2id_without_pindown: ditto.
  * rb_check_id_cstr_without_pindown: ditto.

* string.c (Init_String): String#intern and String#to_sym use
  rb_str_dynamic_intern.

* template/id.h.tmpl: use LSB of ID as a flag for determining a
  static symbol, so we shift left other ruby_id_types.

* string.c: use rb_sym2str instead `rb_id2str(SYM2ID(sym))` to
  avoid pinning.

* load.c: use xx_without_pindown function at creating temporary ID
  to avoid pinning.

* object.c: ditto.

* sprintf.c: ditto.

* struct.c: ditto.

* thread.c: ditto.

* variable.c: ditto.

* vm_method.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 04:57:47 +00:00
nobu df0034f890 * internal.h (rb_reg_search0): not a public API.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25 23:52:18 +00:00
charliesome a77206582e Stop allocating backref strings within gsub's search loop
* internal.h: add prototype for rb_reg_search0

* re.c: rename rb_reg_search to rb_reg_search0, add set_backref_str
  argument to allow callers to indicate that they don't require the
  backref string to be allocated

* string.c: don't allocate backref str if replacement string is provided

Closes GH-578. [Bug #9676] [ruby-core:61682]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25 23:46:05 +00:00
nobu d64ba37ad0 process.c: constify
* process.c (rb_execarg_new, rb_execarg_init): constify argv.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-17 08:21:47 +00:00
akr 841bf2b208 * internal.h: Move BDIGIT and related definitions from
include/ruby/defines.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-17 11:01:12 +00:00
akr 3c99764bcd * internal.h: Rename macro names: RBIGNUM_FOO to BIGNUM_FOO.
(BIGNUM_EMBED_LEN_NUMBITS): Renamed from RBIGNUM_EMBED_LEN_NUMBITS.
  (BIGNUM_EMBED_LEN_MAX): Renamed from RBIGNUM_EMBED_LEN_MAX.
  (BIGNUM_SIGN_BIT): Renamed from RBIGNUM_SIGN_BIT.
  (BIGNUM_SIGN): Renamed from RBIGNUM_SIGN.
  (BIGNUM_SET_SIGN): Renamed from RBIGNUM_SET_SIGN.
  (BIGNUM_POSITIVE_P): Renamed from RBIGNUM_POSITIVE_P.
  (BIGNUM_NEGATIVE_P): Renamed from RBIGNUM_NEGATIVE_P.
  (BIGNUM_EMBED_FLAG): Renamed from RBIGNUM_EMBED_FLAG.
  (BIGNUM_EMBED_LEN_MASK): Renamed from RBIGNUM_EMBED_LEN_MASK.
  (BIGNUM_EMBED_LEN_SHIFT): Renamed from RBIGNUM_EMBED_LEN_SHIFT.
  (BIGNUM_LEN): Renamed from RBIGNUM_LEN.
  (RBIGNUM_DIGITS): Renamed from RBIGNUM_DIGITS.
  (BIGNUM_LENINT): Renamed from RBIGNUM_LENINT.

* bignum.c: Follow the above change.

* gc.c: Ditto.

* marshal.c: Ditto.

* math.c: Ditto.

* numeric.c: Ditto.

* random.c: Ditto.

* rational.c: Ditto.

* sprintf.c: Ditto.

* ext/-test-/bignum/bigzero.c: Ditto.

* ext/-test-/bignum/intpack.c: Ditto.

* ext/bigdecimal/bigdecimal.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-15 21:17:34 +00:00
akr ab9bc151e8 * include/ruby/ruby.h,
internal.h,
  ext/-test-/bignum/bigzero.c: Hide a Bignum definition.
  [ruby-core:42891] [Feature #6083]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-14 15:29:10 +00:00
nobu b2b5a5db09 pack.c: hide associated objects
* marshal.c (to_be_skipped_id): ignore anonymous attributes.
* pack.c (Init_pack): use anonymous ID so that associated objects
  do not appear in the packed result.
* parse.y (rb_make_internal_id): return an anonymous ID for
  internal use.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05 11:56:35 +00:00
ko1 1ccaa4756a * internal.h, vm_core.h: move LIKELY/UNLIKELY/UNINITIALIZED_VAR()
macros from vm_core.h to internal.h.
* string.c: remove dependency to "vm_core.h".
* common.mk: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05 04:58:00 +00:00
ko1 38cd45a3cd * internal.h: remove macros STR_NOCAPA and STR_NOCAPA_P().
* string.c (rb_str_resize): remove `STR_SET_NOEMBED(str)' because
  str_make_independent_expand() set NOEMBED flag.
* string.c (rb_str_resize): remove `STR_NOCAPA_P(str)' check because
  `str' is independent (not shared).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05 04:21:30 +00:00
ko1 c77a745aab * string.c: remvoe STR_ASSOC related code.
By r44804, string objects can not have STR_ASSOC flag.
* internal.h: ditto.
* ext/objspace/objspace_dump.c (dump_object): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-04 07:12:49 +00:00
ko1 c2e72fb343 * vm.c (rb_vm_pop_cfunc_frame): added. It cares c_return event.
The patch base by drkaes (Stefan Kaes).
  [Bug #9321]
* variable.c (rb_mod_const_missing): use rb_vm_pop_cfunc_frame()
  instead of rb_frame_pop().
* vm_eval.c (raise_method_missing): ditto.
* vm_eval.c (rb_iterate): ditto.
* internal.h (rb_vm_pop_cfunc_frame): add decl.
* test/ruby/test_settracefunc.rb: add tests.
  provided by drkaes (Stefan Kaes).
* vm.c, eval.c, include/ruby/intern.h (rb_frame_pop):
  move definition of rb_frame_pop() and deprecate it.
  It doesn't care about `return' events.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-09 10:12:59 +00:00
glass 2c11bda8b9 * hash.c (rb_hash_keys): make rb_hash_keys() static.
it is no longer used from array.c since r43969.
  the patch is from normalperson (Eric Wong).
  [ruby-core:59449] [Feature #9336]

* internal.h: remove definition of rb_hash_keys().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-01 15:19:23 +00:00
ko1 c702005a7b * include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
  proc.c, process.c, re.c, string.c, variable.c, vm.c,
  vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
  vm_method.c: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 08:07:47 +00:00
tmm1 3409690957 ruby.h: swap iv_index_tbl and super for struct RClass
* include/ruby/ruby.h (struct RClass): add super, remove iv_index_tbl.
  since RCLASS_SUPER() is commonly used inside while loops, we move it
  back inside struct RClass to improve cache hits. this provides a
  small improvement (1%) in hotspots like rb_obj_is_kind_of()
* internal.h (struct rb_classext_struct): remove super, add
  iv_index_table
* internal.h (RCLASS_SUPER): update for new location
* internal.h (RCLASS_SET_SUPER): ditto
* internal.h (RCLASS_IV_INDEX_TBL): ditto
* object.c (rb_class_get_superclass): ditto
* include/ruby/backward/classext.h (RCLASS_SUPER): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 05:10:07 +00:00
ngoto 42ae24a6e8 * internal.h (ruby_sized_xrealloc2): fix typo introduced in r44117, which cause compile error on Solaris.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13 15:44:13 +00:00
ko1 0aed7c6874 * error.c: add Exception#backtrace_locations.
Now, there are no setter and independent from Exception#backtrace.
  [Feature #8960]
* eval.c (setup_exception): set backtrace locations for `bt_location'
  special attribute.
* vm_backtrace.c (rb_backtrace_to_location_ary): added.
* internal.h: ditto.
* test/ruby/test_backtrace.rb: add a test for
  Exception#backtrace_locations.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13 04:31:06 +00:00
nobu bcdad3299b gc.c: ruby_sized_xrealloc2
* gc.c (ruby_sized_xrealloc2): reallocate from old size.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 07:16:06 +00:00
tmm1 7170baa878 objspace_dump.c: include object's gc flags in dump
* ext/objspace/objspace_dump.c (dump_object): include fstring flag on
  strings. include gc flags (old, remembered, wb_protected) on all objects.
* ext/objspace/objspace_dump.c (Init_objspace_dump): initialize lazy
  IDs before first use.
* gc.c (rb_obj_gc_flags): new function to retrieve object flags
* internal.h (RB_OBJ_GC_FLAGS_MAX): maximum flags allowed for one obj
* test/objspace/test_objspace.rb (test_dump_flags): test for above
* test/objspace/test_objspace.rb (test_trace_object_allocations):
  resolve name before dump (for rb_class_path_cached)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 02:26:09 +00:00
charliesome c039c70815 * internal.h (RCLASS_SERIAL): Add RCLASS_SERIAL as a convenience
accessor for RCLASS_EXT(klass)->class_serial.

* class.c, vm_insnhelper.c, vm_method.c: Use RCLASS_SERIAL

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-09 11:00:23 +00:00
tmm1 599dbf65a5 vm.c: fix compile issue on 32bit freebsd
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 23:07:43 +00:00
nobu b9cafaf524 vm_insnhelper.c: rb_get_kwargs
* vm_insnhelper.c (rb_get_kwargs): get keyword argument values from an
  option hash, not only checking keys.
* dir.c (dir_initialize): use rb_get_kwargs.
* gc.c (gc_start_internal): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 08:10:47 +00:00
tmm1 53e0d4666c gc.c: Load GC tuning settings earlier during boot.
* gc.c (ruby_gc_set_params): Accept safe_level argument so GC tuning
  settings can be applied before rb_safe_level() is available.
* internal.h (rb_gc_set_params): ditto.
* ruby.c (process_options): Apply GC tuning early during boot process
  so boot-time allocations can benefit. This also benefits any code
  loaded in via `ruby -r`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 00:19:13 +00:00
nobu b7c6db94ae gc.c: use malloc_size
* configure.in: check malloc_size() available on BSD.
* gc.c: use malloc_size() with malloc/malloc.h on BSD.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 14:48:20 +00:00
nobu c7159e81fc vm_eval.c: rb_catch_protect
* vm_eval.c (rb_catch_protect): new function similar to
  rb_catch_obj(), but protect from all global jumps like as
  rb_load_protect(), rb_protect(), etc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 12:53:18 +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
nobu 58553ca184 ruby/ruby.h, enum.c, vm_eval.c: constify argv
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): constify argv.
* enum.c (rb_enum_values_pack): ditto.
* vm_eval.c (rb_block_call, rb_check_block_call): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 08:02:51 +00:00
nobu f0e73fc986 ruby/ruby.h: rb_block_call_func_t
* include/ruby/ruby.h (rb_block_call_func_t): strict check for
  rb_block_call_func* if RB_BLOCK_CALL_FUNC_STRICT is set.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 07:55:11 +00:00
ko1 2bfd722d80 * internal.h: do not use ruby_sized_xrealloc() and ruby_sized_xfree()
if HAVE_MALLOC_USABLE_SIZE (or _WIN32) is defined.
  We don't need these function if malloc_usable_size() is available.
* gc.c: catch up this change.
* gc.c: define HAVE_MALLOC_USABLE_SIZE on _WIN32.
* array.c (ary_resize_capa): do not use ruby_sized_xfree() with
  local variable to avoid "unused local variable" warning.
  This change only has few impact.
* string.c (rb_str_resize): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-25 01:13:31 +00:00
glass b25a6494cc * internal.h: use __builtin_bswap16() if possible.
* configure.in: check existence of __builtin_bswap16().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-24 16:03:22 +00:00
nari f29e925701 * include/ruby/intern.h, internal.h: Expose rb_gc_count().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22 08:16:55 +00:00
nari 9d2f54b3e9 * include/ruby/intern.h (rb_gc_set_params): Deprecate
rb_gc_set_params because it's only used in ruby internal.

* internal.h (ruby_gc_set_params): Declare rb_gc_set_params's
  alias function.

* gc.c: ditto.

* ruby.c: use ruby_gc_set_params.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22 07:26:55 +00:00
ko1 a6ca9f9fce * vm.c (ruby_vm_destruct): do not use ruby_xfree() after freeing
objspace.
* gc.c (ruby_mimfree): added. It is similar to ruby_mimmalloc().
* internal.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22 01:38:08 +00:00
ko1 301223df95 * gc.c (rb_gc_resurrect): added.
rb_fstring() used rb_gc_mark() to avoid freeing used string.
  However, rb_gc_mark() set mark bit *and* pushes mark_stack.
  rb_gc_resurrect() does only set mark bit if it is before sweeping.
* string.c (rb_fstring): use rb_gc_resurrect.
* internal.h: add decl.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-19 09:48:47 +00:00
tarui 28a1c4f33e * cont.c : Introdule ensure rollback mechanism. Please see below.
* internal.h (ruby_register_rollback_func_for_ensure): catch up above change.
	  Add rollback mechanism API.

	* vm_core.h (typedef struct rb_vm_struct): catch up above change.
	  Introdule ensure-rollback relation table.

	* vm_core.h (typedef struct rb_thread_struct): catch up above change.
	  Introdule ensure stack.

	* eval.c (rb_ensure): catch up above change.
	  Introdule ensure stack.

	* hash.c : New function for rollback ensure, and register it to
	  ensure-rollback relation table. [ruby-dev:47803] [Bug #9105]

	Ensure Rollback Mechanism:
	A rollback's function is a function to rollback a state before ensure's
	function execution.
	When the jump of callcc is across the scope of rb_ensure,
	ensure's functions and rollback's functions are executed appropriately
	for keeping consistency.

	Current API is unstable, and only internal use.

	ruby_register_rollback_func_for_ensure(ensure_func,rollback_func)
	This API create relation ensure's function to rollback's function.
	By registered rollback's function, it is executed When jumpping into
	corresponding rb_ensure scope.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-15 17:15:31 +00:00
tmm1 8f3934261a * internal.h: move common string/hash flags to include file.
* ext/objspace/objspace_dump.c: remove flags shared above.
* hash.c: ditto.
* string.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-11 09:39:13 +00:00
nari 5e73aa6e24 Revert "* internal.h: prototype declarations of gc.c collect up."
These declarations should be exported.

This reverts commit 3c9f88c2ce138f2714c36cd25dc9b50ec93861e7.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 11:51:32 +00:00
nari f0b087220c * internal.h: prototype declarations of gc.c collect up.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 10:43:07 +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
nobu 8a79f9cd8c From 33f55b1eac7f044feb59a29da4a5a82bee3f419e Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@ruby-lang.org>
Date: Fri, 8 Nov 2013 17:40:10 -0500
Subject: [PATCH 2/2] internal.h: prototype declarations

* internal.h (rb_vm_backtrace_object, rb_gc_count): make prototype
  declarations, not old-K&R style.
---
 internal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/internal.h b/internal.h
index 20a813c..4cea0a8 100644
--- a/internal.h
+++ b/internal.h
@@ -747,7 +747,7 @@ void rb_backtrace_print_as_bugreport(void);
 int rb_backtrace_p(VALUE obj);
 VALUE rb_backtrace_to_str_ary(VALUE obj);
 void rb_backtrace_print_to(VALUE output);
-VALUE rb_vm_backtrace_object();
+VALUE rb_vm_backtrace_object(void);
 
 RUBY_SYMBOL_EXPORT_BEGIN
 const char *rb_objspace_data_type_name(VALUE obj);
@@ -818,7 +818,7 @@ int rb_st_insert_id_and_value(VALUE obj, st_table *tbl, ID key, VALUE value);
 st_table *rb_st_copy(VALUE obj, struct st_table *orig_tbl);
 
 /* gc.c */
-size_t rb_gc_count();
+size_t rb_gc_count(void);
 size_t rb_obj_memsize_of(VALUE);
 
 RUBY_SYMBOL_EXPORT_END
-- 
1.8.4.2



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-08 22:42:25 +00:00
ko1 d1674ef67b * gc.c: add support to estimate increase of oldspace memory usage.
This is another approach to solve an issue discussed at r43530.
  This feature is diabled as default.
  This feature measures an increment of memory consuption by oldgen
  objects. It measures memory consumption for each objects when
  the object is promoted. However, measurement of memory consumption
  is not accurate now. So that this measurement is `estimation'.
  To implement this feature, move memsize_of() function from
  ext/objspace/objspace.c and expose rb_obj_memsize_of().
  Some memsize() functions for T_DATA (T_TYPEDDATA) have problem to
  measure memory size, so that we ignores T_DATA objects now.
  For example, some functions skip NULL check for pointer.
  The macro RGENGC_ESTIMATE_OLDSPACE enables/disables this feature,
  and turned off as default.
  We need to compare 3gen GC and this feature carefully.
  (it is possible to enable both feature)
  We need a help to compare them.
* internal.h: expose rb_obj_memsize_of().
* ext/objspace/objspace.c: use rb_obj_memsize_of() function.
* cont.c (fiber_memsize): fix to check NULL.
* variable.c (autoload_memsize): ditto.
* vm.c (vm_memsize): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-05 04:51:01 +00:00