|
30 | 30 | #include "ruby/io.h"
|
31 | 31 | #include "vm_callinfo.h"
|
32 | 32 | #include "vm_core.h"
|
| 33 | +#include "vm_sync.h" |
33 | 34 |
|
34 | 35 | RUBY_EXTERN const char ruby_hexdigits[];
|
35 | 36 |
|
@@ -776,15 +777,21 @@ static VALUE
|
776 | 777 | objspace_dump(VALUE os, VALUE obj, VALUE output)
|
777 | 778 | {
|
778 | 779 | struct dump_config dc = {0,};
|
779 |
| - if (!RB_SPECIAL_CONST_P(obj)) { |
780 |
| - dc.cur_page_slot_size = rb_gc_obj_slot_size(obj); |
781 |
| - } |
| 780 | + VALUE result = Qnil; |
| 781 | + RB_VM_LOCKING() { |
| 782 | + rb_vm_barrier(); |
| 783 | + |
| 784 | + if (!RB_SPECIAL_CONST_P(obj)) { |
| 785 | + dc.cur_page_slot_size = rb_gc_obj_slot_size(obj); |
| 786 | + } |
782 | 787 |
|
783 |
| - dump_output(&dc, output, Qnil, Qnil, Qnil); |
| 788 | + dump_output(&dc, output, Qnil, Qnil, Qnil); |
784 | 789 |
|
785 |
| - dump_object(obj, &dc); |
| 790 | + dump_object(obj, &dc); |
786 | 791 |
|
787 |
| - return dump_result(&dc); |
| 792 | + result = dump_result(&dc); |
| 793 | + } |
| 794 | + return result; |
788 | 795 | }
|
789 | 796 |
|
790 | 797 | static void
|
@@ -840,35 +847,47 @@ static VALUE
|
840 | 847 | objspace_dump_all(VALUE os, VALUE output, VALUE full, VALUE since, VALUE shapes)
|
841 | 848 | {
|
842 | 849 | struct dump_config dc = {0,};
|
843 |
| - dump_output(&dc, output, full, since, shapes); |
| 850 | + VALUE result = Qnil; |
| 851 | + RB_VM_LOCKING() { |
| 852 | + rb_vm_barrier(); |
844 | 853 |
|
845 |
| - if (!dc.partial_dump || dc.since == 0) { |
846 |
| - /* dump roots */ |
847 |
| - rb_objspace_reachable_objects_from_root(root_obj_i, &dc); |
848 |
| - if (dc.roots) dump_append(&dc, "]}\n"); |
849 |
| - } |
| 854 | + dump_output(&dc, output, full, since, shapes); |
850 | 855 |
|
851 |
| - if (RTEST(shapes)) { |
852 |
| - rb_shape_each_shape_id(shape_id_i, &dc); |
853 |
| - } |
| 856 | + if (!dc.partial_dump || dc.since == 0) { |
| 857 | + /* dump roots */ |
| 858 | + rb_objspace_reachable_objects_from_root(root_obj_i, &dc); |
| 859 | + if (dc.roots) dump_append(&dc, "]}\n"); |
| 860 | + } |
| 861 | + |
| 862 | + if (RTEST(shapes)) { |
| 863 | + rb_shape_each_shape_id(shape_id_i, &dc); |
| 864 | + } |
854 | 865 |
|
855 |
| - /* dump all objects */ |
856 |
| - rb_objspace_each_objects(heap_i, &dc); |
| 866 | + /* dump all objects */ |
| 867 | + rb_objspace_each_objects(heap_i, &dc); |
857 | 868 |
|
858 |
| - return dump_result(&dc); |
| 869 | + result = dump_result(&dc); |
| 870 | + } |
| 871 | + return result; |
859 | 872 | }
|
860 | 873 |
|
861 | 874 | /* :nodoc: */
|
862 | 875 | static VALUE
|
863 | 876 | objspace_dump_shapes(VALUE os, VALUE output, VALUE shapes)
|
864 | 877 | {
|
865 | 878 | struct dump_config dc = {0,};
|
866 |
| - dump_output(&dc, output, Qfalse, Qnil, shapes); |
| 879 | + VALUE result = Qnil; |
| 880 | + RB_VM_LOCKING() { |
| 881 | + rb_vm_barrier(); |
| 882 | + |
| 883 | + dump_output(&dc, output, Qfalse, Qnil, shapes); |
867 | 884 |
|
868 |
| - if (RTEST(shapes)) { |
869 |
| - rb_shape_each_shape_id(shape_id_i, &dc); |
| 885 | + if (RTEST(shapes)) { |
| 886 | + rb_shape_each_shape_id(shape_id_i, &dc); |
| 887 | + } |
| 888 | + result = dump_result(&dc); |
870 | 889 | }
|
871 |
| - return dump_result(&dc); |
| 890 | + return result; |
872 | 891 | }
|
873 | 892 |
|
874 | 893 | void
|
|
0 commit comments