summaryrefslogtreecommitdiff
path: root/object.c
AgeCommit message (Collapse)Author
2017-01-23object.c: no TypeError at Symbolnobu
* object.c (special_object_p): uninterned Symbol also should not raise a TypeError but return itself instead, as well as interned Symbols. [ruby-core:79216] [Bug #13145] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-02object.c: rb_class_allocnobu
* object.c (rb_obj_alloc): add pathological check of klass for extension libraries which do not check given arguments properly. [ruby-core:78934] [Bug #13093] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-02object.c: rb_class_s_newnobu
* object.c (rb_class_new_instance): add pathological check of klass for extension libraries which do not check given arguments properly. [ruby-core:78934] [Bug #13093] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-29object.c: no TypeError at special constnobu
* object.c (special_object_p): no longer raise a TypeError for Integer and Float, and return itself instead. [Feature#12979] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-29object.c: no TypeError at special const clonenobu
* object.c (rb_obj_clone2): no longer raise a TypeError for special constants, and return itself instead. however, if freeze option is false, raise an ArgumentError. [Feature#12979] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-27object.c: no TypeError at special const dupnobu
* object.c (rb_obj_dup): no longer raise a TypeError for special constants, and return itself instead. [Feature#12979] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-27object.c: fixable float to fixnumnobu
* object.c (rb_convert_to_integer): convert a fixable float to a fixnum directly without the convesion method, as well as bignum case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-27object.c: use converted stringnobu
* object.c (rb_convert_to_integer): should not drop the converted string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26[DOC] replace Fixnum with Integer [ci skip]nobu
* numeric.c: [DOC] update document for Integer class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-14* object.c: Improve documentation for Integer conversion.hsbt
[ruby-core:71661][Bug #11736][ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-07* basictest/test.rb: Adjust spaces in class declarationshsbt
with inheritance. [fix GH-1227] Patch by @adrfer * lib/irb/*: ditto. * lib/prime.rb: ditto. * lib/shell/builtin-command.rb: ditto. * object.c: ditto. * sample/*.rb: ditto. * test/-ext-/method/test_arity.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-09object.c: update rdocnobu
* object.c (InitVM_Object): update rdoc of NIL/TRUE/FALSE, and use rb_deprecate_constant. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08replace fixnum by integer in documents.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-24object.c: fix {Module,Class}.new rdoc [ci skip]nobu
* object.c (rb_mod_initialize, rb_class_initialize): [DOC] these methods do not invoke module_eval/class_eval, just eval the given block under the new module/class but sharing the context with the surrounding scope like those methods. [ruby-core:77023] [Bug #12696] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-14* object.c (InitVM_Object): Update referenced document path.kou
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-07deprecate TRUE,FALSE,NILnobu
* object.c (InitVM_Object): deprecate toplevel constants TRUE, FALSE, and NIL. [Feature #12574] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-03object.c: restrict freeze optionnobu
* object.c (rb_obj_clone2): restrict freeze option to true other than false which only has the effect. [Feature #12300] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-03object.c: suppress warningnobu
* object.c (rb_obj_clone2): remove set but not used variable to suppress unused-but-set-variable warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-01Object#clone with freeze: false [Feature #12300]shyouhei
* object.c (rb_obj_clone2): Allow Object#clone to take freeze: false keyword argument to not freeze the clone. [ruby-core:75017][Feature #12300] * test/ruby/test_object.rb (TestObject): test for it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-28Fix typo [ci skip]nobu
* object.c (rb_mod_eqq): [DOC] Fix typo in RDoc. [Fix GH-1393] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-17Use Integer instead of Fixnum and Bignum.akr
* object.c, numeric.c, enum.c, ext/-test-/bignum/mul.c, lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rexml/xpath_parser.rb, lib/rubygems/specification.rb, lib/uri/generic.rb, bootstraptest/test_eval.rb, basictest/test.rb, test/-ext-/bignum/test_big2str.rb, test/-ext-/bignum/test_div.rb, test/-ext-/bignum/test_mul.rb, test/-ext-/bignum/test_str2big.rb, test/csv/test_data_converters.rb, test/date/test_date.rb, test/json/test_json_generate.rb, test/minitest/test_minitest_mock.rb, test/openssl/test_cipher.rb, test/rexml/test_jaxen.rb, test/ruby/test_array.rb, test/ruby/test_basicinstructions.rb, test/ruby/test_bignum.rb, test/ruby/test_case.rb, test/ruby/test_class.rb, test/ruby/test_complex.rb, test/ruby/test_enum.rb, test/ruby/test_eval.rb, test/ruby/test_iseq.rb, test/ruby/test_literal.rb, test/ruby/test_math.rb, test/ruby/test_module.rb, test/ruby/test_numeric.rb, test/ruby/test_range.rb, test/ruby/test_rational.rb, test/ruby/test_refinement.rb, test/ruby/test_rubyvm.rb, test/ruby/test_struct.rb, test/ruby/test_variable.rb, test/rubygems/test_gem_specification.rb, test/thread/test_queue.rb: Use Integer instead of Fixnum and Bignum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-22* variable.c: use uint32_t instead of long to avoid confusion aboutnaruse
the type of ivtbl->numiv. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-19object.c: fix error messagenobu
* object.c (rb_mod_const_get): make error message at uninterned string consistent with symbols. [ruby-dev:49498] [Bug #12089] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-12resolve class name earlier and more consistentlynormal
This further avoids class name resolution issues which came about due to relying on hash table ordering before r53376. Pre-caching the class name when it is never used raises memory use, but the overall gain from moving away from st still gives us a small gain. Reverting r53376 and this patch and testing with "valgrind -v ./ruby -rrdoc -eexit" on x86 (32-bit) shows: before: in use at exit: 1,662,239 bytes in 25,286 blocks total heap usage: 49,514 allocs, 24,228 frees, 6,005,561 bytes allocated after, with this change: in use at exit: 1,646,529 bytes in 24,572 blocks total heap usage: 48,891 allocs, 24,319 frees, 6,003,921 bytes allocated * class.c (Init_class_hierarchy): resolve name for rb_cObject ASAP * object.c (rb_mod_const_set): move name resolution to rb_const_set * variable.c (rb_const_set): do class resolution here [ruby-core:72807] [Bug #11977] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-30object.c: fix prepend cmpnobu
* object.c (rb_class_inherited_p): search the corresponding ancestor to prepended module from prepending class itself. [ruby-core:72493] [Bug #11878] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-29use id_table for constant tablesnormal
valgrind 3.9.0 on x86-64 reports a minor reduction in memory usage when loading only RubyGems and RDoc by running: ruby -rrdoc -eexit before: HEAP SUMMARY: in use at exit: 2,913,448 bytes in 27,394 blocks total heap usage: 48,362 allocs, 20,968 frees, 9,034,621 bytes alloc after: HEAP SUMMARY: in use at exit: 2,880,056 bytes in 26,712 blocks total heap usage: 47,791 allocs, 21,079 frees, 9,046,507 bytes alloc * class.c (struct clone_const_arg): adjust for id_table (clone_const): ditto (clone_const_i): ditto (rb_mod_init_copy): ditto (rb_singleton_class_clone_and_attach): ditto (rb_include_class_new): ditto (include_modules_at): ditto * constant.h (rb_free_const_table): ditto * gc.c (free_const_entry_i): ditto (rb_free_const_table): ditto (obj_memsize_of): ditto (mark_const_entry_i): ditto (mark_const_tbl): ditto * internal.h (struct rb_classext_struct): ditto * object.c (rb_mod_const_set): resolve class name on assignment * variable.c (const_update): replace with const_tbl_update (const_tbl_update): new function (fc_i): adjust for id_table (find_class_path): ditto (autoload_const_set): st_update => const_tbl_update (rb_const_remove): adjust for id_table (sv_i): ditto (rb_local_constants_i): ditto (rb_local_constants): ditto (rb_mod_const_at): ditto (rb_mod_const_set): ditto (rb_const_lookup): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-13* object.c (rb_inspect): check the default internal encoding asshugo
String#inspect do. [ruby-dev:49415] [Bug #11787] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-12object.c: raise TypeErrornobu
* 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
2015-12-10* object.c (rb_inspect): dump inspected result with rb_str_escape()naruse
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
2015-12-08compile optimized case dispatch for nil/true/falsenormal
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
2015-12-02encoding.c: defer finding encodingnobu
* 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
2015-11-16struct.c: dignobu
* object.c (rb_obj_dig): dig in nested structs too. * struct.c (rb_struct_dig): new method Struct#dig. [Feature #11688] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-12Module#<=> is not suitable for Comparable.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-09vm_eval.c: rb_check_funcall_defaultnobu
* 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
2015-11-09dignobu
* array.c (rb_ary_dig): new method Array#dig. * hash.c (rb_hash_dig): new method Hash#dig. * object.c (rb_obj_dig): dig in nested arrays/hashes. [Feature #11643] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29RUBY_DTRACE_CREATE_HOOKnobu
* 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
2015-10-28NameError#receiver of uninitialized constantnobu
* 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
2015-08-13object.c: rb_num_to_dblnobu
* object.c (rb_num_to_dbl): move from num2dbl_with_to_f in math.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-07* object.c: [DOC] Improve grammar for Module#===zzak
Patch by @SkyBirdSoar in documenting-ruby/ruby#52: https://github.com/documenting-ruby/ruby/pull/52 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-30variable.c: Module#deprecate_constantnobu
* 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
2015-07-29hash.c: move rb_obj_hashnobu
* 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
2015-07-02object.c: fix up r51039nobu
* 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
2015-06-26object.c: common prefix of converter methodsnobu
* object.c (convert_type): check common prefix of converter method names first. shrink conv_method_names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24vm_method.c: remove redundant checknobu
* 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
2015-06-20* object.c (rb_obj_taint): [DOC] $SAFE=3 is obsolete.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-17* include/ruby/ruby.h: $SAFE=3 is now obsolete.hsbt
* ext/socket/init.c, ext/socket/socket.c, ext/socket/tcpsocket.c ext/socket/udpsocket.c, gc.c, object.c, re.c, safe.c: removed code for $SAFE=3 * bootstraptest/test_method.rb, test/erb/test_erb.rb, test/ruby/test_dir.rb test/ruby/test_file.rb, test/ruby/test_method.rb, test/ruby/test_regexp.rb test/ruby/test_thread.rb: remove tests for $SAFE=3 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18* object.c (rb_obj_clone): do not touch age (FL_PROMOTED[01]) becauseko1
rb_obj_alloc() can return old object in debug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-05* internal.h: remove struct method_table_wrapper.ko1
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
2015-02-16use rb_funcallvnobu
* 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
2014-12-09object.c: [DOC] Revise documentationnobu
* 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