aboutsummaryrefslogtreecommitdiffstats
path: root/marshal.c
Commit message (Collapse)AuthorAgeFilesLines
* marshal.c: revert r57631 partiallynobu2017-02-151-4/+4
| | | | | | | | | | * 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
* marshal.c: use hidden objects to allow recyclingnormal2017-02-151-6/+6
| | | | | | | | | | | | | | 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
* ruby.h: RB_GC_GUARD stronger than gcc7nobu2017-02-131-2/+2
| | | | | | | * 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
* Prevent GC by volatile [Bug #13150]naruse2017-01-231-2/+2
| | | | | | | | 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
* marshal.c: fix infinite recursionnobu2016-11-241-1/+15
| | | | | | | | * 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
* marshal.c: negative limitnobu2016-11-241-3/+5
| | | | | | | * 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
* remove SIGN_EXTEND_CHAR macronobu2016-03-231-9/+1
| | | | | | | | * 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
* * marshal.c (r_object0): raise ArgumentError when linking to undefineddrbrain2016-03-161-0/+5
| | | | | | | object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * marshal.c (r_object0): Fix Marshal crash for corrupt extended object.drbrain2016-03-141-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * marshal.c (r_object0): honor Marshal.load post procnaruse2016-01-211-1/+1
| | | | | | | 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
* marshal.c: remove NULL checks for *_memsizenormal2015-12-091-2/+2
| | | | | | | | | | 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
* marshal.c: skip internal namesnobu2015-12-081-9/+2
| | | | | | | * 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
* encoding.c: defer finding encodingnobu2015-12-021-2/+15
| | | | | | | | | | | | | * 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
* marshal.c: lookup and removenobu2015-12-021-3/+2
| | | | | | | * 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
* marshal.c: reduce arity checksnobu2015-09-251-11/+23
| | | | | | | | | | * 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
* marshal.c: reentrant checksnobu2015-09-251-33/+24
| | | | | | | | * 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
* marshal.c: use STATIC_ASSERTnobu2015-09-251-1/+1
| | | | | | * 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
* encindex.h: ENCINDEXnobu2015-09-151-0/+1
| | | | | | * 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
* * id_table.h: introduce ID key table.ko12015-08-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | [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
* variable.c: avoid compatibility table with generic ivarsnormal2015-05-301-18/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* marshal.c: class name encodingnobu2015-04-161-3/+4
| | | | | | | | * 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
* marshal.c: class name encodingnobu2015-04-161-3/+4
| | | | | | | | * 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
* marshal.c: class name encodingnobu2015-04-161-3/+4
| | | | | | | * 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
* marshal.c: class name encodingnobu2015-04-161-2/+2
| | | | | | | * 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
* marshal.c: class name encodingnobu2015-04-161-2/+2
| | | | | | | * 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
* marshal.c: register symbol strings firstnobu2015-03-221-12/+19
| | | | | | | | | | * 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
* marshal.c: indetity tablesnobu2015-01-231-4/+4
| | | | | | | | | * 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
* marshal.c: append at oncenobu2014-12-261-5/+2
| | | | | | | * 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
* use 0 for reservednobu2014-12-011-2/+2
| | | | | | | 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
* marshal.c: literal method namesnobu2014-11-241-17/+32
| | | | | | | * 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
* * internal.h: Gather declarations in non-header files.akr2014-11-181-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-3/+1
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: rename rb_str_dynamic_internnobu2014-10-141-2/+2
| | | | | | | | * 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
* marshal.c: lazy compat_tbl allocationnormal2014-10-011-9/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* ruby.h: warn untyped Datanobu2014-09-281-2/+2
| | | | | | | | | | | * 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
* ruby.h: deprecate plain Datanobu2014-09-271-0/+2
| | | | | | | * 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
* marshal.c: fix symlink indexnobu2014-07-291-1/+2
| | | | | | | * 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
* marshal.c: fix instance variable load odrdernobu2014-07-281-1/+2
| | | | | | | | * marshal.c (r_symreal): fix instance variable load odrder, its name must be read before its value. the order of function call arguments is not stable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbols instead of IDsnobu2014-07-281-44/+44
| | | | | | | | | | | | | | | | | * encoding.c (rb_enc_get_index): deal with symbols instead of IDs to get rid of inadvertent pin-downs. * enum.c (chunk_ii): ditto. * enumerator.c (append_method): ditto. * iseq.c (iseq_load): ditto. * marshal.c (w_symbol, r_symlink, r_symreal, r_symbol): ditto. * signal.c (trap_handler): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (struct RBignum): Use size_t for len.akr2014-04-191-4/+10
| | | | | | | | | | | | | | | | * include/ruby/intern.h (rb_big_new): Use size_t instead of long to specify the size of bignum. (rb_big_resize): Ditto. * bignum.c: Follow above changes. * rational.c: Follow above changes. * marshal.c: Follow above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (SIZEOF_BDIGIT): Renamed from SIZEOF_BDIGITS.akr2014-04-131-4/+4
| | | | | | | | | | | | * internal.h: Ditto. * marshal.c: Ditto. * rational.c: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* marshal.c: remove hack for old gccnobu2014-04-121-2/+6
| | | | | | | * marshal.c (r_object0): remove hack for old gcc, no gcc 2.x any more. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* marshal.c: undumpable hidden objectsnobu2014-03-261-0/+5
| | | | | | | * marshal.c (w_object): internal objects are not dumpable. [ruby-core:61677] [Bug #9674] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* marshal.c: do not recycle wrapper objectsnobu2014-02-171-4/+4
| | | | | | | | * marshal.c (marshal_dump, marshal_load): do not recycle wrapper objects, to prevent from segfault with continuation. [ruby-dev:47970] [Bug #9523] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* marshal.c: use rb_gc_force_recycle for GC-safetynormal2014-02-161-8/+8
| | | | | | | | | Putting rb_gc_force_recycle at the end of the function has a nice side-effect of keeping wrapper visible to GC until the moment of recycle, preventing GC from prematurely killing live objects. volatile is a common source of compiler bugs/differences, avoid it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Rename macro names: RBIGNUM_FOO to BIGNUM_FOO.akr2014-02-151-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (BIGNUM_EMBED_LEN_NUMBITS): Renamed from RBIGNUM_EMBED_LEN_NUMBITS. (BIGNUM_EMBED_LEN_MAX): Renamed from RBIGNUM_EMBED_LEN_MAX. (BIGNUM_SIGN_BIT): Renamed from RBIGNUM_SIGN_BIT. (BIGNUM_SIGN): Renamed from RBIGNUM_SIGN. (BIGNUM_SET_SIGN): Renamed from RBIGNUM_SET_SIGN. (BIGNUM_POSITIVE_P): Renamed from RBIGNUM_POSITIVE_P. (BIGNUM_NEGATIVE_P): Renamed from RBIGNUM_NEGATIVE_P. (BIGNUM_EMBED_FLAG): Renamed from RBIGNUM_EMBED_FLAG. (BIGNUM_EMBED_LEN_MASK): Renamed from RBIGNUM_EMBED_LEN_MASK. (BIGNUM_EMBED_LEN_SHIFT): Renamed from RBIGNUM_EMBED_LEN_SHIFT. (BIGNUM_LEN): Renamed from RBIGNUM_LEN. (RBIGNUM_DIGITS): Renamed from RBIGNUM_DIGITS. (BIGNUM_LENINT): Renamed from RBIGNUM_LENINT. * bignum.c: Follow the above change. * gc.c: Ditto. * marshal.c: Ditto. * math.c: Ditto. * numeric.c: Ditto. * random.c: Ditto. * rational.c: Ditto. * sprintf.c: Ditto. * ext/-test-/bignum/bigzero.c: Ditto. * ext/-test-/bignum/intpack.c: Ditto. * ext/bigdecimal/bigdecimal.c: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * marshal.c: fix typo by @xta [fix GH-533] [ci skip]hsbt2014-02-131-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* marshal.c: Numerics are not taintednobu2014-02-081-2/+2
| | | | | | | | * include/ruby/ruby.h (OBJ_TAINTABLE, OBJ_TAINT, OBJ_INFECT), marshal.c (r_entry0): all Numerics never be tainted now. [ruby-core:57346] [Bug #8945] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c: hide associated objectsnobu2014-02-051-1/+1
| | | | | | | | | | | * marshal.c (to_be_skipped_id): ignore anonymous attributes. * pack.c (Init_pack): use anonymous ID so that associated objects do not appear in the packed result. * parse.y (rb_make_internal_id): return an anonymous ID for internal use. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* marshal.c: refine special instance variablesnobu2014-02-051-48/+76
| | | | | | | | | | | | | * marshal.c (w_obj_each, obj_count_ivars): count instance variables accurately. * marshal.c (encoding_name, w_encoding): separate getting encoding values and writing them. * marshal.c (w_symbol, w_ivar, w_objivar, w_object): refine special instance variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e