aboutsummaryrefslogtreecommitdiffstats
path: root/marshal.c
diff options
context:
space:
mode:
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/marshal.c b/marshal.c
index a0f9d76edb..129ea701c8 100644
--- a/marshal.c
+++ b/marshal.c
@@ -643,14 +643,23 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
if (rb_respond_to(obj, s_mdump)) {
volatile VALUE v;
+ int hasiv2 = 0;
st_add_direct(arg->data, obj, arg->data->num_entries);
v = rb_funcall(obj, s_mdump, 0, 0);
check_dump_arg(arg, s_mdump);
+ if (!hasiv && (hasiv2 = rb_ivar_count(obj) > 0)) {
+ w_byte(TYPE_IVAR, arg);
+ }
w_class(TYPE_USRMARSHAL, obj, arg, FALSE);
w_object(v, arg, limit);
- if (hasiv) w_ivar(obj, 0, &c_arg);
+ if (hasiv) {
+ w_ivar(obj, ivtbl, &c_arg);
+ }
+ else if (hasiv2) {
+ w_objivar(obj, &c_arg);
+ }
return;
}
if (rb_respond_to(obj, s_dump)) {