summaryrefslogtreecommitdiff
path: root/marshal.c
AgeCommit message (Collapse)Author
2018-10-30* remove trailing spaces, expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30support theap for T_HASH. [Feature #14989]ko1
* 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
2018-09-27move GCC version check from marshal.c to configure.acshyouhei
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
2018-06-28check enc_capable.ko1
* 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
2018-01-20add missing/nan.cshyouhei
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
2018-01-19INFINITY is float. That of double is HUGE_VAL.shyouhei
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
2018-01-18long_toobig marked as NORETURNshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18marshal.c: initialize keywordsnobu
* marshal.c (r_object0): initialize `keywords` and removed `keyword_init` flag, to get rid of maybe-uninitialized warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-17include ruby/ruby.h before ruby.io.hnaruse
It breaks AIX build: https://rubyci.org/logs/rubyci.s3.amazonaws.com/aix71_ppc/ruby-trunk/log/20180117T113303Z.log.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09Include ruby/{io,encoding}.h before internal.hkazu
because of r61712 and r61713 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05marshal.c: allow marshalling keyword_init structk0kubun
struct.c: define rb_struct_s_keyword_init to shared with marshal.c internal.h: add the declaration to be used by marshal.c test/ruby/test_marshal.rb: add test for Bug#14314 [Feature #14314] [ruby-core:84629] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-04hide internal data objectsnobu
* marshal.c (compat_allocator_table): hide the wrapper object of compat_allocator_tbl. * process.c (rb_execarg_new): hide wrapper objects of struct rb_execarg. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-01use rb_hash_new_with_size()glass
* hash.c: use rb_hash_new_with_size(). * marshal.c: ditto * struct.c: ditto * vm_args.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-15marshal.c: revert r57631 partiallynobu
* marshal.c (rb_marshal_dump_limited): do not free dump_arg, which may be dereferenced in check_dump_arg due to continuation, and get rid of dangling pointers. * marshal.c (rb_marshal_load_with_proc): ditto for load_arg. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-15marshal.c: use hidden objects to allow recyclingnormal
Hidden objects (klass == 0) are not visible to Ruby code invoked from other threads or signal handlers, so they can never be accessed from other contexts. This makes it safe to call rb_gc_force_recycle on the object slot after releasing malloc memory. * marshal.c (rb_marshal_dump_limited): hide dump_arg and recycle when done (rb_marshal_load_with_proc): hide load_arg and recycle when done [ruby-core:79518] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-13ruby.h: RB_GC_GUARD stronger than gcc7nobu
* include/ruby/ruby.h (RB_GC_GUARD): prevent guarded pointer from optimization by using as an input to inline asm. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-23Prevent GC by volatile [Bug #13150]naruse
test/ruby/test_marshal.rb test_context_switch (load) and test_gc (dump) are failed on FreeBSD 10.3 and gcc7 (FreeBSD Ports Collection) 7.0.0 20170115 (experimental); RB_GC_GUARD looks not worked well. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-24marshal.c: fix infinite recursionnobu
* marshal.c (check_userdump_arg): marshal_dump should not return an instance of the same class, otherwise it causes infinite recursion. [ruby-core:78289] [Bug #12974] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-24marshal.c: negative limitnobu
* marshal.c (w_object): should not decrement negative limit which means unlimited. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-23remove SIGN_EXTEND_CHAR macronobu
* marshal.c (r_long): cast to `signed char`, which is used already, instead of SIGN_EXTEND_CHAR. * parse.y: SIGN_EXTEND_CHAR is no longer used. [Fix GH-1302] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-16* marshal.c (r_object0): raise ArgumentError when linking to undefineddrbrain
object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-14* marshal.c (r_object0): Fix Marshal crash for corrupt extended object.drbrain
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-21* marshal.c (r_object0): honor Marshal.load post procnaruse
value for TYPE_LINK. by Hiroshi Nakamura <nahi@ruby-lang.org> https://github.com/ruby/ruby/pull/1204 fix GH-1204 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09marshal.c: remove NULL checks for *_memsizenormal
This follows r52986, NULL checks in rb_data_type_t.function.dsize callbacks are unnecessary. * marshal.c (memsize_dump_arg): remove NULL check (memsize_load_arg): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08marshal.c: skip internal namesnobu
* marshal.c (w_objivar): skip internal instance variables in T_OBJECT too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52940 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-12-02marshal.c: lookup and removenobu
* marshal.c (r_fixup_compat): delete compatible object with lookup. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-25marshal.c: reduce arity checksnobu
* marshal.c (rb_marshal_dump_limited): get rid of redundant arity check to dump object with limited nest level. * marshal.c (rb_marshal_load_with_proc): get rid of redundant arity check to load object with hook proc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-25marshal.c: reentrant checksnobu
* marshal.c (dump_funcall, dump_check_funcall, load_funcall): function calls with reentrant check. always show names corresponding to the called methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-25marshal.c: use STATIC_ASSERTnobu
* marshal.c (MARSHAL_INFECTION): check size by STATIC_ASSERT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-15encindex.h: ENCINDEXnobu
* encindex.h: separate encoding index constants from internal.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-12* id_table.h: introduce ID key table.ko1
[Feature #11420] This table only manage ID->VALUE table to reduce overhead of st. Some functions prefixed rb_id_table_* are provided. * id_table.c: implement rb_id_table_*. There are several algorithms to implement it. Now, there are roughly 4 types: * st * array * hash (implemented by Yura Sokolov) * mix of array and hash The macro ID_TABLE_IMPL can choose implementation. You can see detailes about them at the head of id_table.c. At the default, I choose 34 (mix of list and hash). This is not final decision. Please report your suitable parameters or your data structure. * symbol.c: introduce rb_id_serial_t and rb_id_to_serial() to represent ID by serial number. * internal.h: use id_table for method tables. * class.c, gc.c, marshal.c, vm.c, vm_method.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30variable.c: avoid compatibility table with generic ivarsnormal
This recovers and improves performance of Marshal.dump/load on Time objects compared to when we implemented generic ivars entirely using st_table. This also recovers some performance on other generic ivar objects, but does not bring bring Marshal.dump/load performance up to previous speeds. benchmark results: minimum results in each 10 measurements. Execution time (sec) name trunk geniv after marshal_dump_flo 0.343 0.334 0.335 marshal_dump_load_geniv 0.487 0.527 0.495 marshal_dump_load_time 1.262 1.401 1.257 Speedup ratio: compare with the result of `trunk' (greater is better) name geniv after marshal_dump_flo 1.026 1.023 marshal_dump_load_geniv 0.925 0.985 marshal_dump_load_time 0.901 1.004 * include/ruby/intern.h (rb_generic_ivar_table): deprecate * internal.h (rb_attr_delete): declare * marshal.c (has_ivars): use rb_ivar_foreach (w_ivar): ditto (w_object): update for new interface * time.c (time_mload): use rb_attr_delete * variable.c (generic_ivar_delete): implement (rb_ivar_delete): ditto (rb_attr_delete): ditto [ruby-core:69323] [Feature #11170] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-16marshal.c: class name encodingnobu
* marshal.c (r_object0): preserve the encoding of the class name in an error message, in the case of USRMARSHAL without marshal_load method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-16marshal.c: class name encodingnobu
* marshal.c (r_object0): preserve the encoding of the class name in an error message, in the case of USERDEF without _load singleton method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-16marshal.c: class name encodingnobu
* marshal.c (r_object0): preserve the encoding of the class name in an error message, in the case of no _load_data method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-16marshal.c: class name encodingnobu
* marshal.c (w_object): preserve the encoding of the class name in an error message, in the case of no _dump_data method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-16marshal.c: class name encodingnobu
* marshal.c (w_object): preserve the encoding of the class name in an error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-22marshal.c: register symbol strings firstnobu
* marshal.c (r_symreal): register symbol names as strings first so that r_symlink always returns valid names. [ruby-core:68587] [Bug #10991] * marshal.c (r_ivar, r_object0): now need to intern symbol names. * marshal.c (r_object0): compare with symbol names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-23marshal.c: indetity tablesnobu
* 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
2014-12-26marshal.c: append at oncenobu
* marshal.c (w_long): append at once by w_nbyte() instead of appending byte by byte. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01use 0 for reservednobu
use 0 for rb_data_type_t::reserved instead of NULL, since its type may be changed in the future and possibly not a pointer type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-24marshal.c: literal method namesnobu
* marshal.c (check_dump_arg, check_load_arg): use literal method names, instead of converting from ID every time. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18* internal.h: Gather declarations in non-header files.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15* internal.h: Include ruby.h and ruby/encoding.h to beakr
includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-14symbol.c: rename rb_str_dynamic_internnobu
* 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-01marshal.c: lazy compat_tbl allocationnormal
In some common cases, compat_tbl is unused in dump_arg/load_arg, so avoid malloc/free costs for the unused table. ruby -e 'h = {a: :b}; 600000.times { Marshal.load(Marshal.dump(h)) }' before: real 0m2.458s user 0m2.450s sys 0m0.006s after: real 0m2.122s user 0m2.110s sys 0m0.011s * marshal.c (w_class): check dump_arg->compat_tbl before lookup (w_object): lazy init ->compat_tbl before insert (obj_alloc_by_class): ditto (clear_dump_arg): free only non-NULL ->compat_tbl (clear_load_arg): ditto for ->compat_tbl (marshal_dump): ->compat_tbl defaults to zero (marshal_load): ditto for ->compat_tbl (r_entry0): check l->compat_tbl before lookup (r_fixup_compat): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-28ruby.h: warn untyped Datanobu
* include/ruby/ruby.h (rb_data_object_alloc_warning): warn Data_Wrap_Struct and Data_Make_Struct only if RUBY_UNTYPED_DATA_WARNING is set to 1. * include/ruby/ruby.h (rb_data_object_get_warning): ditto for Data_Get_Struct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-27ruby.h: deprecate plain Datanobu
* include/ruby/ruby.h (rb_data_object_alloc_deprecated): deprecate Data_Make_Struct and Data_Wrap_Struct. [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-29marshal.c: fix symlink indexnobu
* marshal.c (w_symbol): fix symlink index. register the given symbols, not its name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e