summaryrefslogtreecommitdiff
path: root/object.c
AgeCommit message (Collapse)Author
2012-11-30* revert r37993 to avoid SEGV in tests.shugo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29* vm_method.c (rb_method_entry_make): add a method entry withshugo
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-16object.c: suppress warningnobu
* object.c (rb_obj_alloc): suppress unused variable warning. * tool/gen_dummy_probes.rb: define dtrace disabling macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-16adjust indentnobu
* object.c (rb_obj_alloc): adjust indent. * vm.c (vm_collect_usage_{insn,operand,register}): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12* probes.d: add DTrace probe declarations. [ruby-core:27448]tenderlove
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe. * compile.c (rb_insns_name): allowing DTrace probes to access instruction sequence name. * Makefile.in: translate probes.d file to appropriate header file. * common.mk: declare dependencies on the DTrace header. * configure.in: add a test for existence of DTrace. * eval.c (setup_exception): add a probe for when an exception is raised. * gc.c: Add DTrace probes for mark begin and end, and sweep begin and end. * hash.c (empty_hash_alloc): Add a probe for hash allocation. * insns.def: Add probes for function entry and return. * internal.h: function declaration for compile.c change. * load.c (rb_f_load): add probes for `load` entry and exit, require entry and exit, and wrapping search_required for load path search. * object.c (rb_obj_alloc): added a probe for general object creation. * parse.y (yycompile0): added a probe around parse and compile phase. * string.c (empty_str_alloc, str_new): DTrace probes for string allocation. * test/dtrace/*: tests for DTrace probes. * vm.c (vm_invoke_proc): add probes for function return on exception raise, hash create, and instruction sequence execution. * vm_core.h: add probe declarations for function entry and exit. * vm_dump.c: add probes header file. * vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on function entry and return. * vm_exec.c: expose instruction number to instruction name function. * vm_insnshelper.c: add function entry and exit probes for cfunc methods. * vm_insnhelper.h: vm usage information is always collected, so uncomment the functions. 12 19:14:50 2012 Akinori MUSHA <knu@iDaemons.org> * configure.in (isinf, isnan): isinf() and isnan() are macros on DragonFly which cannot be found by AC_REPLACE_FUNCS(). This workaround enforces the fact that they exist on DragonFly. 12 15:59:38 2012 Shugo Maeda <shugo@ruby-lang.org> * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo), vm_insnhelper.c (vm_search_method): revert r37616 because it's too slow. [ruby-dev:46477] * test/ruby/test_refinement.rb (test_inline_method_cache): skip the test until the bug is fixed efficiently. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-07object.c: inadvertent symbolnobu
* object.c (rb_mod_const_get): avoid inadvertent symbol creation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* object.c (rb_mod_const_get): Fix constant missing exception classtenderlove
and message to maintain backwards compatibility. Constant search should start at Object when constant starts with '::' * test/ruby/test_module.rb: test for fixes git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-02* object.c (rb_mod_to_s): Module#{to_s,inspect}, when invoked onshugo
a refinement, returns a string in the format #<refinement:C@M>, where C is a refined class and M is a module at which the refinemet is defined. * eval.c (rb_mod_refine): store information on a refinement for the above change. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27* object.c (rb_mod_const_get): make sure the constant name istenderlove
converted to a string before searching. [ruby-core:48405] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-26* object.c (rb_mod_const_get): const_get accepts qualified constanttenderlove
strings. e.g. Object.const_get("Foo::Bar::Baz") [ruby-core:41404] * test/ruby/test_module.rb: tests for new behavior git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20* include/ruby/ruby.h: add C APIs.nari
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-09-08internal.h: allocator function in rb_classext_tnobu
* 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-08-17object.c: preserve encodingsnobu
* object.c (rb_any_to_s, rb_obj_inspect): preserve encodings of class name and instance variable names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-16object.c: forbid uninitialized classnobu
* object.c (rb_class_initialize): forbid inheriting uninitialized class. another class tree not based on BasicObject cannot exist. [ruby-core:47148][Bug #6863] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15Kernel#inspect: improve consistency and do not call #to_s.eregon
* object.c (rb_obj_inspect): Kernel#inspect: do not call #to_s. A class can now benefit from the nice default #inspect even if it defines #to_s. Also, there is no more unexpected change in #inspect result. * NEWS: Add note about the change. * bignum.c, io.c, numeric.c, object.c, proc.c, vm.c (Init_*): Adapt internal structures (by aliasing #inspect to #to_s) so they don't rely on the removed behavior (#inspect calling overridden #to_s). * test/ruby/test_object.rb (test_inspect): add tests for Kernel#inspect. * lib/pp.rb (class PP): do not call #to_s anymore, as #inspect no more does (mame). * test/test_pp.rb (class PPInspectTest): remove related assertion (mame). [ruby-core:43238][Feature #6130] * test/drb/drbtest.rb (DRbCore#teardown, DRbAry#teardown): adapt DRb tests with the new change (shirosaki). [ruby-core:47182][Bug #6866] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15Revert r36699 and r36700. [Feature #6130]naruse
Revert "Kernel#inspect: improve consistency and do not call #to_s." Revert "update PP with recent Kernel#inspect change. Patch by Yusuke Endoh." r36699 cause test-all failure on test/drb/test_drb.rb and test/drb/test_drbssl.rb. Run test-all before commit. Moreover its ChangeLog formst is wrong: see CommitterHowto https://bugs.ruby-lang.org/projects/ruby/wiki/CommitterHowto#ChangeLog git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-14Kernel#inspect: improve consistency and do not call #to_s.eregon
A class can now benefit from the nice default #inspect even if it defines #to_s. Also, there is no more unexpected change in #inspect result. Internal structures have been adapted so they don't rely on the removed behavior (#inspect calling overridden #to_s). * object.c (rb_obj_inspect): Kernel#inspect: do not call #to_s. * test/ruby/test_object.rb (test_inspect): add tests for Kernel#inspect. * bignum.c, io.c, numeric.c, object.c, proc.c, vm.c (Init_*): alias #inspect to #to_s where it was expected. [ruby-core:43238][Feature #6130] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02* eval.c (rb_mod_using): new method Module#using. [experimental]shugo
* 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-07-19* variable.c (rb_mod_class_variables): return inherited variablesshugo
except when the optional argument is set to false. [ruby-dev:44034] [Bug #4971] * variable.c (rb_mod_constants): fix typo in documentation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-02* object.c (Init_Object): Added RDoc location pointers fordrbrain
Kernel#methods, Kernel#protected_methods, Kernel#private_methods and Kernel#public_methods. [Bug #6666] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27Module#prependnobu
* 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-19* object.c: Fix typo in rdocmarcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05obj_init_copynobu
* object.c (rb_obj_init_copy): should check if trusted too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-01class_or_module_requirednobu
* object.c (class_or_module_required): extract check for class or module. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-31* object.c (Init_Object): Restored Kernel documentation based ondrbrain
Pickaxe book documentation. Patch by Zachary Scott. [ruby-trunk - Feature #6521] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-31* object.c (rb_equal): Let Object be a link in #=== documentation.drbrain
Patch by Zachary Scott. [ruby-trunk - Feature #6518] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-07* object.c (Init_Object): Added reference to variable.c wheredrbrain
public_constant and private_constant documentation lives. [#6381] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-24* hash.c, object.c, struct.c, lib/ostruct.rb: add to_h methods.nobu
[Feature #6276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-18Revert r35339-35343 because of no tests.naruse
* hash.c: Alias ENV.to_h to ENV.to_hash [ref #6276] * lib/ostruct.rb: Add OpenStruct#to_h [Feature #6276] * struct.c: Add Struct#to_h [Feature #6276] * object.c: Add NilClass#to_h [Feature #6276] * hash.c: Add Hash#to_h [Feature #6276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-16* object.c: Add NilClass#to_h [Feature #6276]marcandre
[ref #5008] [rubyspec:dc5ecddbd608] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-13* encoding.c (rb_enc_codepoint_len): Use UNREACHABLE to avoid "controldrbrain
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-03-30* hash.c, marshal.c, object.c, variable.c: fix callback argument typesnobu
of iterators. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-16 * object.c: Fix indentation of Class#inherited example.drbrain
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-23* object.c (rb_obj_eql): Improve equality documentation by adding andrbrain
example of equal? vs == and recommending eql? be aliased to == when overridden. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-23* object.c (rb_obj_hash): Added note that the hash value is notdrbrain
deterministic on Marc-Andre's suggestion. Expanded description of the purpose of the hash method. [Bug #6068] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-24* object.c (rb_Hash): fix mixed declaration and code.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-24* object.c (rb_Hash): trivial optimization.nobu
* test/ruby/test_object.rb (TestObject#test_convert_hash): fix arguments order. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-24* object.c (rb_Hash): add Kernel#Hash conversion method likematz
Array() or Float(). a patch from Run Paint Run Run. Fix #3131 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-15* object.c (rb_inspect): raise the result is not compatible withnaruse
the default external encoding. [ruby-core:42095] [Bug #5848] If the default external encoding is ASCII compatible, the encoding of inspected result must be compatible with it. If the default external encoding is ASCII incomapatible, the result must be ASCII only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-11* object.c: Added examples for Object#is_a? and Object#instance_of?ayumin
patcheed from Manoj Kumar. [Bug #5880] [ruby-core:42057] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-07Fix typo of rdoc of Object#inspect.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-07* gc.c: use Bitmap Marking algorithm to avoid copy-on-write ofnari
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-06* object.c (rb_inspect): raises Encoding::CompatibilityError if thenaruse
result is incompatible with the default external encoding. [ruby-core:41931] [Bug #5848] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-11* object.c (rb_check_to_int): new function to convert a VALUE tonobu
an Integer if possible, but returns nil instead of raising an exception otherwise. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-10* object.c (Init_Object): Add reference to BasicObject, briefdrbrain
explanation of constant lookup. Based on patch by Alvaro Pereyra Rabanal. [Ruby 1.9 - Bug #5426] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29* use RB_TYPE_P which is optimized for constant types, instead ofnobu
comparison with TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-18* object.c (rb_obj_clone): singleton class should be attachednobu
singleton object to. a patch by Satoshi Shiba <shiba AT rvm.jp> at [ruby-dev:44460]. [Bug #5274] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-27 * object.c: Add usage documentation for BasicObject. Based on patchdrbrain
by Thomas Sawyer. [Ruby 1.9 - Bug #5067] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26* eval_error.c (rb_print_undef_str): new function to raisenobu
NameError for undefined method. * load.c (rb_mod_autoload_p), object.c (rb_mod_const_get), variable.c (rb_f_untrace_var, set_const_visibility), vm_method.c (rb_mod_{remove,undef,alias}_method, set_method_visibility): remove inadvertent symbol creation. based on the first patch by Jeremy Evans at [ruby-core:38447]. [Feature #5089] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26* parse.y (rb_check_id): make the given name a symbol or a string.nobu
based on the second patch by Jeremy Evans at [ruby-core:38447] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e