summaryrefslogtreecommitdiff
path: root/marshal.c
Commit message (Collapse)AuthorAgeFilesLines
* marshal.c Marshal.load accepts a freeze: true option.Jean Boussier2021-10-051-30/+24
| | | | | | | | Fixes [Feature #18148] When set, all the loaded objects are returned as frozen. If a proc is provided, it is called with the objects already frozen.
* Using NIL_P macro instead of `== Qnil`S.H2021-10-031-1/+1
|
* Restore Hash#compare_by_identity mode [Bug #18171]Nobuyoshi Nakada2021-10-021-3/+25
|
* marshal.c: don't call the proc with partially initialized objects. (#4866)Jean byroot Boussier2021-09-301-33/+42
| | | | | For cyclic objects, it requires to keep a st_table of the partially initialized objects.
* Add symname_equal_lit for comparison with a string literalNobuyoshi Nakada2021-09-231-7/+9
|
* Prohibit invalid encoding symbols [Bug #18184]Nobuyoshi Nakada2021-09-231-1/+7
|
* Check instance variable count overflowNobuyoshi Nakada2021-09-231-7/+7
|
* Extract ruby2_keywords predicate and setterNobuyoshi Nakada2021-09-231-3/+15
|
* Turned to_be_skipped_id to an inline functionNobuyoshi Nakada2021-09-231-1/+8
|
* Check the encoding of `ruby2_keywords_flag` [Bug #18184]Nobuyoshi Nakada2021-09-231-0/+1
|
* Check the entire name as `ruby2_keywords_flag` [Bug #18184]Nobuyoshi Nakada2021-09-221-1/+1
|
* Marshal.load: do not call the proc until strings have their encodingJean Boussier2021-09-151-1/+6
| | | | Ref: https://bugs.ruby-lang.org/issues/18141
* Remove unneeded declarationsS.H2021-03-201-2/+0
|
* Don't redefine #rb_intern over and over againStefan Stüben2020-10-211-3/+0
|
* Removed useless castsNobuyoshi Nakada2020-09-051-6/+5
|
* RARRAY_AREF: convert into an inline function卜部昌平2020-08-151-0/+1
| | | | | | RARRAY_AREF has been a macro for reasons. We might not be able to change that for public APIs, but why not relax the situation internally to make it an inline function.
* r_object0: do not goto into a branch卜部昌平2020-06-291-2/+4
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* Ensure origins for all included, prepended, and refined modulesJeremy Evans2020-06-031-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes various issues when a module is included in or prepended to a module or class, and then refined, or refined and then included or prepended to a module or class. Implement by renaming ensure_origin to rb_ensure_origin, making it non-static, and calling it when refining a module. Fix Module#initialize_copy to handle origins correctly. Previously, Module#initialize_copy did not handle origins correctly. For example, this code: ```ruby module B; end class A def b; 2 end prepend B end a = A.dup.new class A def b; 1 end end p a.b ``` Printed 1 instead of 2. This is because the super chain for a.singleton_class was: ``` a.singleton_class A.dup B(iclass) B(iclass origin) A(origin) # not A.dup(origin) ``` The B iclasses would not be modified, so the includer entry would be still be set to A and not A.dup. This modifies things so that if the class/module has an origin, all iclasses between the class/module and the origin are duplicated and have the correct includer entry set, and the correct origin is created. This requires other changes to make sure all tests still pass: * rb_undef_methods_from doesn't automatically handle classes with origins, so pass it the origin for Comparable when undefing methods in Complex. This fixed a failure in the Complex tests. * When adding a method, the method cache was not cleared correctly if klass has an origin. Clear the method cache for the klass before switching to the origin of klass. This fixed failures in the autoload tests related to overridding require, without breaking the optimization tests. Also clear the method cache for both the module and origin when removing a method. * Module#include? is fixed to skip origin iclasses. * Refinements are fixed to use the origin class of the module that has an origin. * RCLASS_REFINED_BY_ANY is removed as it was only used in a single place and is no longer needed. * Marshal#dump is fixed to skip iclass origins. * rb_method_entry_make is fixed to handled overridden optimized methods for modules that have origins. Fixes [Bug #16852]
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-1/+1
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-1/+1
| | | | This shall fix compile errors.
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-1/+1
| | | Split ruby.h
* marshal.c: Support dump and load of a Hash with the ruby2_keywords flagYusuke Endoh2020-01-171-7/+45
| | | | | | | | | | | | It is useful for a program that dumps and load arguments (like drb). In future, they should deal with both positional arguments and keyword ones explicitly, but until ruby2_keywords is deprecated, it is good to support the flag in marshal. The implementation is similar to String's encoding; it is dumped as a hidden instance variable. [Feature #16501]
* Get rid of use of magic number 'E'Nobuyoshi Nakada2020-01-111-4/+10
|
* decouple internal.h headers卜部昌平2019-12-261-7/+18
| | | | | | | | | | | | | | | | | | Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies).
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-22/+1
| | | | | | This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
* drop-in type check for rb_define_module_function卜部昌平2019-08-291-2/+2
| | | | | | We can check the function pointer passed to rb_define_module_function like how we do so in rb_define_method. The difference is that this changeset reveales lots of atiry mismatches.
* rb_hash_foreach now free from ANYARGS卜部昌平2019-08-271-1/+2
| | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit adds function prototypes for rb_hash_foreach / st_foreach_safe. Also fixes some prototype mismatches.
* st_foreach now free from ANYARGS卜部昌平2019-08-271-1/+1
| | | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from st_foreach. I strongly believe that this commit should have had come with b0af0592fdd9e9d4e4b863fde006d67ccefeac21, which added extra parameter to st_foreach callbacks.
* Warn instance variable `E`Nobuyoshi Nakada2019-08-101-1/+7
| | | | It is not dumped, as it is a short alias for `:encoding`.
* * expand tabs.git2019-08-101-1/+1
|
* Share caches for short encoding ivar name.Nobuyoshi Nakada2019-08-101-2/+5
|
* * expand tabs.git2019-07-311-1/+1
|
* Use 1 byte hint for ar_table [Feature #15602]Koichi Sasada2019-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On ar_table, Do not keep a full-length hash value (FLHV, 8 bytes) but keep a 1 byte hint from a FLHV (lowest byte of FLHV). An ar_table only contains at least 8 entries, so hints consumes 8 bytes at most. We can store hints in RHash::ar_hint. On 32bit CPU, we use 4 entries ar_table. The advantages: * We don't need to keep FLHV so ar_table only consumes 16 bytes (VALUEs of key and value) * 8 entries = 128 bytes. * We don't need to scan ar_table, but only need to check hints in many cases. Especially we don't need to access ar_table if there is no match entries (in many cases). It will increase memory cache locality. The disadvantages: * This technique can increase `#eql?` time because hints can conflicts (in theory, it conflicts once in 256 times). It can introduce incompatibility if there is a object x where x.eql? returns true even if hash values are different. I believe we don't need to care such irregular case. * We need to re-calculate FLHV if we need to switch from ar_table to st_table (e.g. exceeds 8 entries). It also can introduce incompatibility, on mutating key objects. I believe we don't need to care such irregular case too. Add new debug counters to measure the performance: * artable_hint_hit - hint is matched and eql?#=>true * artable_hint_miss - hint is not matched but eql?#=>false * artable_hint_notfound - lookup counts
* * expand tabs.git2019-07-141-3/+3
|
* Add /* fall through */ commentsYusuke Endoh2019-07-141-3/+4
| | | | to suppress some Coverity Scan warnings
* * expand tabs.git2019-07-011-1/+1
|
* marshal.c: check instance variable countNobuyoshi Nakada2019-07-011-4/+10
| | | | | * marshal.c (w_ivar_each): ensure that no instance variable was removed while dumping other instance variables. [Bug #15968]
* Hoisted out w_ivar_eachNobuyoshi Nakada2019-07-011-6/+10
|
* marshal.c: check instance variable countNobuyoshi Nakada2019-07-011-3/+17
| | | | | * marshal.c (w_obj_each): ensure that no instance variable was added while dumping other instance variables. [Bug #15968]
* Marshal distant past/futureNobuyoshi Nakada2019-06-191-8/+32
| | | | [Feature #15160]
* Revert "marshal.c: new functions for extensions"Nobuyoshi Nakada2019-06-041-0/+2
| | | | This reverts a commit miss, 24a96a0228ccf355826644a9daad69e11b67b53b.
* marshal.c: new functions for extensionsNobuyoshi Nakada2019-06-041-2/+0
| | | | | | | | * marshal.c (rb_marshal_dump_limited): new function for extension libraries to dump object with limited nest level. * marshal.c (rb_marshal_load_with_proc): new function for extension libraries to load object with hook proc.
* avoid division by zeroshyouhei2018-11-161-2/+2
| | | | | | | | | | | | | | * cvt(): use signbit() instead of 1/d < 0 * w_float(): ditto * ruby_float_step_size(): unit==0 check shall be prior to divisions * arith_seq_float_step_size(): ditto * rb_big_divide(): same as r65642 * fix_divide(): ditto * rb_big_fdiv_double(): ditto * fix_fdiv_double(): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* suppress integer overflow warningsshyouhei2018-11-151-2/+3
| | | | | | | | | * util.c: annotate as NO_SANITIZE * bignum.c: avoid (size_t)-- * marshal.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces, expand tabs.svn2018-10-301-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* support theap for T_HASH. [Feature #14989]ko12018-10-301-1/+1
| | | | | | | | | | | | | | | | | * hash.c, internal.h: support theap for small Hash. Introduce RHASH_ARRAY (li_table) besides st_table and small Hash (<=8 entries) are managed by an array data structure. This array data can be managed by theap. If st_table is needed, then converting array data to st_table data. For st_table using code, we prepare "stlike" APIs which accepts hash value and are very similar to st_ APIs. This work is based on the GSoC achievement by tacinight <tacingiht@gmail.com> and refined by ko1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* move GCC version check from marshal.c to configure.acshyouhei2018-09-271-4/+0
| | | | | | | I think it should be done in configure git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* check enc_capable.ko12018-06-281-20/+30
| | | | | | | | | | | | | | | | | | | | | | | * encoding.c (rb_enc_capable): make it extern to check enc_capable. enc_index can be set to limited types such as T_STRING, T_REGEX and so on. This function check an object is this kind of types. * include/ruby/encoding.h: ditto. * encoding.c (enc_set_index): check a given object is enc_capable. * include/ruby/encoding.h (PUREFUNC): * marshal.c (encoding_name): check `rb_enc_capable` first. * marshal.c (r_ivar): ditto. If it is not enc_capable, it should be malformed data. * spec/ruby/optional/capi/encoding_spec.rb: remove tests depending on the wrong feature: all objects can set enc_index. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add missing/nan.cshyouhei2018-01-201-6/+1
| | | | | | | | | instead of scattering #ifdef HAVE_NANF here and there define our own nan() unless defined elsewhere. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* INFINITY is float. That of double is HUGE_VAL.shyouhei2018-01-191-3/+8
| | | | | | | | | | It seems HUGE_VAL is already used. Why not eliminate INTINITY. NAN is also float. That of double is called nan(). This is also fixed. Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e