* object.c (rb_obj_dig): raise TypeError if an element does not
have #dig method. [ruby-core:71798] [Bug #11762]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
instead of raising Encoding::CompatibilityError. [Feature #11801]
* string.c (rb_str_escape): added to dump given string like
rb_str_inspect without quotes and always dump in US-ASCII
like rb_str_dump.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
nil/true/false are special literals just like floats, integers,
literal strings, and symbols. Optimize when statements with
them by using a jump table, too.
target 0: a (ruby 2.3.0dev (2015-12-08 trunk 52928) [x86_64-linux]) at "/home/ew/rrrr/b/ruby"
target 1: b (ruby 2.3.0dev (2015-12-08 master 52928) [x86_64-linux]) at "/home/ew/ruby/b/ruby"
benchmark results:
minimum results in each 5 measurements.
Execution time (sec)
name a b
loop_whileloop2 0.102 0.103
vm2_case_lit* 1.657 0.549
Speedup ratio: compare with the result of `a' (greater is better)
name b
loop_whileloop2 0.988
vm2_case_lit* 3.017
* benchmark/bm_vm2_case_lit.rb: new benchmark
* compile.c (case_when_optimizable_literal): add nil/true/false
* insns.def (opt_case_dispatch): ditto
* vm.c (vm_redefinition_check_flag): ditto
* vm.c (vm_init_redefined_flag): ditto
* vm_core.h: ditto
* object.c (InitVM_Object): define === explicitly for nil/true/false
* test/ruby/test_case.rb (test_deoptimize_nil): new test
* test/ruby/test_optimization.rb (test_opt_case_dispatch): update
(test_eqq): new test
[ruby-core:71923] [Feature #11769]
Original patch by Aaron Patterson <tenderlove@ruby-lang.org>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* encoding.c (enc_m_loader): defer finding encoding object not to
be infected by marshal source. [ruby-core:71793] [Bug #11760]
* marshal.c (r_object0): enable compatible loader on USERDEF
class. the loader function is called with the class itself,
instead of an allocated object, and the loaded data.
* marshal.c (compat_allocator_table): intialize
compat_allocator_tbl on demand.
* object.c (rb_undefined_alloc): extract from rb_obj_alloc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_eval.c (rb_check_funcall_default): split from
rb_check_funcall to return the given fallback value.
* object.c (rb_obj_dig): use rb_check_funcall_default so that tail
call optimization will be possible. [Feature #11643]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (RUBY_DTRACE_CREATE_HOOK): macro to call hook at
object creation.
* vm.c (rb_source_location, rb_source_loc): retrieve source path
and line number at once.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (name_err_mesg_to_str): quote the name if unprintable.
* object.c (check_setter_id): use rb_check_id to convert names.
* variable.c (uninitialized_constant): use NameError::message to
keep the receiver of uninitialized constant. [Feature #10881]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* variable.c (rb_const_get_0): warn deprecated constant reference.
* variable.c (rb_mod_deprecate_constant): mark constants to be
warned as deprecated. [Feature #11398]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (rb_obj_hash): move in order to share with rb_any_hash.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* object.c (convert_type): conversion without "to_" prefix is not
implicit. fix up r51039.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_method.c (rb_attr): remove redundant check. attribute names
given in ruby level should be checked before calling this
function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
struct method_table_wrapper was introduced to avoid duplicate marking
for method tables.
For example, `module M1; def foo; end; end` make one method table
(mtbl) contains a method `foo`. M1 (T_MODULE) points mtbl.
Classes C1 and C2 includes M1, then two T_ICLASS objects are created
and they points mtbl too. In this case, three objects (one T_MODULE
and two T_ICLASS objects) points same mtbl. On marking phase, these
three objects mark same mtbl. To avoid such duplication, struct
method_table_wrapper was introduced.
However, created two T_ICLASS objects have same or shorter lifetime
than M1 (T_MODULE) object. So that we only need to mark mtbl from M1,
not from T_ICLASS objects. This patch tries marking only from M1.
Note that one `Module#prepend` call creates two T_ICLASS objects.
One for refering to a prepending Module object, same as
`Module#include`. We don't nedd to care this T_ICLASS.
One for moving original mtbl from a prepending class. We need to
mark such mtbl from this T_ICLASS object. To mark the mtbl,
we need to use `RCLASS_ORIGIN(klass)` on marking from a prepended
class `klass`.
* class.c: ditto.
* eval.c (rb_using_refinement): ditto.
* gc.c: ditto.
* include/ruby/ruby.h: define m_tbl directly. The definition of
struct RClass should be moved to (srcdir)/internal.h.
* method.h: remove decl of rb_free_m_tbl_wrapper().
* object.c: use RCLASS_M_TBL() directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use rb_funcallv() for no arguments call instead of variadic
rb_funcall().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* object.c: [DOC] Revise documentation by Marcus Stollsteimer at
[ruby-core:66368]. [Bug #10526]
* #inspect: be more specific about generated string, remove
obsolete example.
* #nil?: use code examples instead of different call-seq's.
* #tap: clarify what is yielded.
* Integer(): be more specific about to_int and to_i, remove
reference to Ruby 1.8.
* Array(): fix error.
* Class: fix variable name style and indentation in example.
* improve consistency, fix typos and formatting.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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
* object.c (check_setter_id): show the original argument instead
of nil on TypeError.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/ruby/test_module.rb (test_inspect_segfault):
Test case and bug report by Thomas Stratmann.
[ruby-core:65214] [Bug #10282]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
* object.c (rb_obj_itself): new method Object#itsef. based on the
patch by Rafael França in [ruby-core:64156].
[EXPERIMENTAL] this method may be renamed due to compatibilities.
[ruby-core:44704] [Feature #6373]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
* 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
to avoid an exception on Class.new.freeze.clone.to_s.
Reported by Andrew Grimm. [ruby-core:41858] [Bug #5828]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* object.c (init_copy): no longer copy tables of classes/modules,
since r45874 rb_mod_init_copy() does it instead.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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
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
constify a parameter (VALUE *).
I believe this incompatibility doesn't break any code.
However, if you have trouble, please tell us.
* eval.c, object.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e